56 ms·
Is it just me, or is Javascript (and more generally, all front end technology) more susceptible to these trivial holy wars? While I agree that const/let is a u
by cloakandswagger 10y ago
Is it just me, or is Javascript (and more generally, all front end technology) more susceptible to these trivial holy wars?
While I agree that const/let is a useful convention for communicating mutability, it isn't nearly a big enough deal to warrant the attention it receives from the community.
It's not just const/let; I rarely make a front end PR that isn't bike-shedded to death over subjective styling choices, single quotes vs double quotes, etc. It often feels like conforming to flavor-of-the-week, subjective decrees from frontend trendsetters is more important than the substantive work that your code is doing.
- abritinthebay 10y ago> Is it just me, or is Javascript (and more generally, all front end technology) more susceptible to these trivial holy wars? - Tabs vs spaces. - Vi vs Emacs - Weak vs strong typing - where to place {} in block statements - where to put commas No, programming in general is susceptible to these trivial holy wars.
- nothrabannosir 10y agoWeak vs strong typing is hardly "trivial"... it's the very foundation of a language. Not trying to derail the convo or take sides, but one of these is not like the others ;)
- nitroll 10y agoHardly anyone argues weak vs. strong types, the battle is primarily between dynamic vs static typing.
- gotofritz 10y agoVi vs Emancs? Weak vs strong typing?? tabs vs spaces??? where did you get those?? The ONLY holy war in JS is the semi-colon one
- lmkg 10y agoThat's what OP is saying: programming has plenty of holy wars that predate JavaScript.
- gotofritz 10y agoYou are right, I misread his comment
- deleted 10y ago[deleted]
- abritinthebay 10y agoClearly you have never encountered the strange "comma first" brigade.
- gotofritz 10y agoAu contraire, for a while I was one of them. But I think we were seen as too weird to even bother with a holy war
- ieatkittens 10y agoThough I don't see why this is a holy war in the first place. Clearly, no-semicolon is the only way to go. :^)
- gotofritz 10y ago[loads machine gun...]
- h1d 10y agoWe have a little more than vi and emacs these days as competition not two sided wars.
- abritinthebay 10y agoSublime vs Atom if you prefer. The point still stands
- Can_Not 10y agoAtom is clearly better until you want to open a file larger than 64 bytes.
- betenoire 10y agoconst vs let is an "immutable by default" vs "mutable by default" type of difference. it's not just a style difference, it can help you write stateless code if you assume immutability. but yeah.
- BinaryIdiot 10y ago> const vs let is an "immutable by default" vs "mutable by default" type of difference Sorta. I mean you're right but at the same time if you're using const for an object or array then it doesn't really matter without `object.freeze()` because it's not immutable only the reference is and I don't think most JavaScript developers understand that (at least not most of the ones I've run into).
- gotofritz 10y agoNote that Object.freeze only works for shallow objects
- deleted 10y ago[deleted]
- z3t4 10y agoNative objects in JavaScript are already immutable as in you can not change them, only create new objects. Const will not make your object immutable! Try this: const foo = {bar: 1} foo.bar = 2; It will only avoid having the pointer re-pointed to another object. It's better to just try avoiding global variables, and use a naming convention like uppercase and/or underscore for constants and global variables. Const is probably only meant for constants like the name suggests. I think something like this is pretty safe from reassigning: { let foo = 1 ... } ... If you want more control over your properties, you can use the ES5 feature "defineproperty" where you can set writeable: false
- fryan 10y agoconst foo = {bar: 1} The only thing const about it is the reference `foo` cannot be reassigned: foo = something_else; // error Unlike `const` in C++, `const` in javascript in not very useful in my opinion. `let` is shorter and more readable.
- AngeloR 10y ago> Is it just me, or is Javascript (and more generally, all front end technology) more susceptible to these trivial holy wars? What constitutes holy wars are often the most accessible[1] [1] https://en.wikipedia.org/wiki/Law_of_triviality https://en.wikipedia.org/wiki/Law_of_triviality
- PravlageTiem 10y agoThe arguments are so bitter because the stakes are so low.
- mnarayan01 10y agoPresumably each project/organization/etc. has its own style guidelines (or at least unwritten conventions). If you're not following them, then it's not a surprise people are calling you on it. If, on the other hand, they don't exist then it would be weirder.
- jeremy_wiebe 10y agoThe fact that a const can't be changed is great but in my mind the bigger thing is what the code communicates. Using const vs let tells future devs who work on the code that the value was meant to remain unchanged. If they need to change it, that's a signal that maybe there's more to it than they currently understand. I agree that pull requests that mass change from let to const are largely a waste of time, but usage of const vs let is a legitimate discussion within your team.