Navigate Select ESC Close

`const` was a mistake

2024-05-19 Science & Technology
159.0k
5.1k
1.3k
Theo - t3․gg
Theo - t3․gg
539.0k subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

Finally sharing my thoughts on the Const vs Let debate. Ugh. Original rant (unlisted for now) https://youtu.be/LAd3zMw7_9c SOURCES https://www.epicweb.dev/talks/let-me-be https://twitter.com/cramforce/status/1786608749354082455 https://github.com/TodePond/DreamBerd/tree/main?tab=readme-ov-file https://www.joshwcomeau.com/javascript/the-const-deception/ Check out my Twitch, Twitter, Discord more at https://t3.gg S/O Ph4se0n3 for the awesome edit 🙏

Top Comments (10)

@inwerpsel 2024-05-19

Ah, the good old let-leaning vs constervative

1.1k 15 replies
@SandraWantsCoke 2024-05-20

ES2026 will come with `const const` to indicate that it is truly immutable and we will also get a quadruple equal sign ==== to indicate that the thing is truly truly equal.

272 16 replies
@-parrrate 2024-05-19

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.

36
@akinaguda 2024-05-19

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.

1.6k 57 replies
@iancarlson3421 2024-05-20

"Defaulting to `const` actually makes 'let` mean something" (paraphrasing of course)

101 4 replies
@HamdiRizal 2024-05-20

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.

75 5 replies
@georgemunyoro 2024-05-19

2:22 Theo just casually calling an audience member a chatter lol

14
@tharunbalaji5131 2024-05-19

const is not to protect us from mutation, it is to protect us from javaScript

608 7 replies
@Mothuzad 2024-05-19

I have literally never seen an argument about whether to use const vs let. If anybody has a meeting to waste your time about that, their real purpose was to fill time, and they'd have still created a nonsense meeting about something else pointless.

12
@tinrab 2024-05-19

Most variables are immutable. I like the way this is expressed in Rust, `let`, `let mut`, and `const`/`static`. By default you write `let`, and upgrade to mutable if needed. In TS, I write `const` by default in 90% of cases, because a variable usually holds a result of something.

13

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot