No const! How NOT To Give A JavaScript Talk

preview_player
Показать описание
Let's talk a look at Ryan Florence's Epic Web Dev talk "Let Me Be" where he wants to convince us to use a lot more "let" in our JavaScript and a lot less const. Does he do a job convincing us? Are you convinced? And if you are do you think you could defend that position to your coworkers? And what can we learn for our own presentations? Let's find out!

00:00 Introduction
00:49 A Whole Mess Of Tweets
03:00 The AirBnB Anecdote
04:03 Language Is Hard
05:00 Finally Some Code
07:05 ChatGPT FTW
08:20 Const Hurts Your Mouth
09:00 What Have We Learned
Рекомендации по теме
Комментарии
Автор

I can see Ryan's point that using `const` by itself doesn't matter. However, `const` shines because using it by default makes `let` stick out like a sore thumb. It's an extremely valuable visual hint that "this is doing something unusual, pay more attention to it". If you use `let` everywhere, you lose that "here be dragons" helper.

traviswatson
Автор

Coming previously from the world of C++, const is perfectly fine to me.
When declaring primitive type values as const, then they are constants. End of story.
When declaring a value of a complex type to be const, then I understand it as "the reference to the content in memory for this object is const", that is "the room number is const, the contents of the room itself are not".
Again, no problem with that either.

EduardKaresli
Автор

I like how fluently and, seemingly, without any effort you keep yourself from calling that talk a total bullshit under the blue moon, which it definitely is. Respect :)

abcq
Автор

ChatGPT also spelled "their" wrong in its response... I think we can all take that accident to its logical conclusion.

GrumpyGrebo
Автор

I don’t see the problem with const = array[]. It’s a pointer to an array, that pointer never changes.

DMC
Автор

I'm in the const camp as well. And I like using linting rules which push for const if no reassignment happens. This way, seeing a let is an indicator for me that there is reassignment to watch out for. As of arrays/objects defined via const: We all know that const doesn't prevent their content to change. But at least they will remain the same type. It's the same with TypeScript in general: You don't get 100% type safety, but you get at least some level of security. His argument would render TS irrelevant because you can't be sure if there is any any in the code, so "just stick with JS"

VeitLehmann
Автор

In JavaScript, using const indicates that the variable will not be reassigned, meaning you're always working with the same object. This is incredibly helpful as it eliminates the need to scan the entire source file or function to check if the object has been reassigned. Remember, you can declare an object with const in a function, mutate it, and return it—the function is still pure because the function isn't mutating data outside the scope of the function. Additionally, mutating an object can be faster than attempting to destructure it into an entirely new object with new memory allocations.

coadyx
Автор

I've quit a new job (one i just joined) because we hired a new guy that removed consts everywhere and removed native map for lodash map.

I asked for a justification in his PR and he yelled and screamed to the head. I gave my reasons in the PR and I don't think he thought he needed to.

I realized this isn't a place I wanted to work.

robertluong
Автор

at 8:08, i have never seen chatgpt spell their as thier before.

gerkim
Автор

I am convinced that the talk was a meme 🤣

dominuskelvin
Автор

Always use const unless you need your variable to actually vary

ecoded
Автор

Reminds me of the time a coworker said we should always nest ternaries and cited a Medium article to back it up.

bumbletastic
Автор

Brilliant! That’s exactly how everyone should consume information critically. Not just in tech but with regard to everything.

murtadha
Автор

Using ChatGPT, that constantly makes up shit as a source of truth for your argument is just yikes. Imagine if that became the standard for all coding practices we rely on. "The AI told me to do it this way!"

lordstorm
Автор

The ChatGPT response on the slide has a typo. `thier` instead of `their` GPT doesn't make spelling mistakes like this. He made it up.

echobucket
Автор

The misspelling in the "ChatGPT response", LOL.

falven
Автор

This is how reaction content should be. Well done sir.

bmind
Автор

JavaScript community just running out of stuff to do conf talks about at this point

zyzlol
Автор

When Ryan says that AirBnB is not using their own lint rules, I don't think it's necessarily an appeal to authority fallacy. It could be in response to another appeal to authority - that you SHOULD use airbnb lint rules because they created it.

cb
Автор

Ryan is an awesome developer, it's needless to say it. Honestly, that talk sounded like "we need 5 min of anything to fulfill a slot in the conference". To make it more useful he could've mentioned how the typescript's `` const... as const` fixes the single case where const is misleading (not useless) he presented. In general, IMO, const makes code much easier to read.

jpavel
join shbcf.ru