`const` was a mistake

94,862
0
Published 2024-05-19

All Comments (21)
  • @akinaguda
    Can't we just agree to default to const and use let when we want to re-assign a variable. It's so useful and nice and helps readers and helps even you the developer.
  • @inwerpsel
    Ah, the good old let-leaning vs constervative
  • If you’re in a company that runs a meeting about const vs let quit immediately
  • const is not to protect us from mutation, it is to protect us from javaScript
  • @nilskaspersson
    I can't believe I'm writing this, but does Ryan seriously not understand the difference between constant assignment and immutability? This is the dumbest hill I've ever seen anyone climb. 100% agreed on your convention, this is what I've been doing for years already
  • @ando_rei
    This presentation's argument is just so useless, because it is based on the premise, that writing "const" is intenting to mean "the whole structure is immutable", when it means "the name cannot be bound to another value than the initial one". JS isn't by far the only language with semantics like that. So this is rather a skill issue/(intentional) misinterpretation than an argument. Addendum: Mutability of bindings is different than mutability of their contents –Have fun getting your "export let" or "export function" destroyed by assignments on a star-import! (ESMs export bindings not values and "function"+ has the same semantics as "var" bindings!)
  • @joe-robin
    At this point choosing JavaScript as my main programming language is the only mistake I made.
  • @iancarlson3421
    "Defaulting to `const` actually makes 'let` mean something" (paraphrasing of course)
  • @Luxcium
    i will unsubscribe if this is a serious thing
  • @claasdev
    The conference talk feels like a troll
  • @-parrrate
    to me the meaning of JS's const is that it's always the same object, not that it's immutable. clear and simple. and quite important for dealing with mutability too: if you mutate it in one place, all other places are guaranteed to observe the change.
  • @HamdiRizal
    When I encounter "let" in the code, it stored in some part of my brain. Expecting to find it again later in the code where the value changes. By using "const" for constant value instead of "let". The number of brain energy spent to hold those information are reduced greatly.
  • @insu_na
    In C++ you can absolutely change both the memory that a pointer points to, as well as the address of the pointer. There's a whole can of worms about `const int* someName` vs `int* const someName` vs `const int* const someName` vs `int const* someName` which is pretty annoying to deal with. The older I get, the more I appreciate a really good implementation of const-ness, and in C++ we're closing in on that with constexpr and consteval
  • @revenity7543
    Just imagine const objects, arrays and functions are pointers. It all makes sense if you think it that way.
  • Ah yes, JS devs discussing stupid shit with ridiculous arguments and fallacies
  • @Bozon671_Higgs
    I'm disappointed that clickbait made me spend 30 minutes on this video.
  • @mranthonymills
    Const means you can't rebind the thing. That's really important to know. It doesn't mean the thing is a constant. Once you know that, just use const by default, and use let where necessary, which points out which variables change and which ones don't. This isn't rocket science or something.
  • What I think many people are missing in the imperative world is that FP programmers don't need to freeze objects or protect themselves from mutations. We simply don't do it. If we do it, it's in a tiny and controlled scope. The mental load is just so much lower when you do that. When a FP programmer looks for an immutable data structure, it is not to prevent mutations. They don't do mutations, it is to have an efficient data structure, with structural sharing for example
  • @cmlttnts4906
    One good thing about "const" is that it basically tells you that it's type of "data structure" is constant, so if we do this: const arr = [1,2,3], arr will always be array, even if content changes, if it was "let", you can assigng arr= "123", and it is now a string. Another reason and intention we can provide.
  • @grzeske
    I just clicked this video only to pause it at 0:00 and write the comment that I'm 99,9% sure it's just another theo'ish clickbait title