4 ms·
> I'm yet to see a single case of an upside. It's a signal of coolness from inexperienced programmers. That's the value proposition offered by semicolon-free J
by beering 8y ago
> I'm yet to see a single case of an upside.
It's a signal of coolness from inexperienced programmers. That's the value proposition offered by semicolon-free JS.
- ng12 8y agoI disagree, I think people who really care about semicolons in JS are people who just don't write a lot of JS. I can honestly say in the last 5 years of only writing front-end I have never been bit by ASI.
- wayneftw 8y agoThe most popular JS style guide from AirBnB uses semi-colons. Google and Facebook uses semi-colons. I'm pretty sure they collectively write way more JS than you do.The most popular code formatter also defaults to having semi-colons because they know it's the de factor standard in JS. I myself have been writing JS since the late 90s (around the time when XHR was introduced) and it's been my most used language for easily the past 15 years. So, sorry but you couldn't possibly be more wrong. The great majority of the other commenters here disagree with you as well. You got lucky if you have in fact never had an ASI bug as you claim, but in this thread there is at least one link to a famous bug that has been caused by it and mention of others. The fact that you anecdotally gambled and "won" doesn't hold a lot of weight. There is one much less popular style guide which actually made headlines for recommending against semi-colons and they got roundly criticized for it by many, many famous JS programmers including the likes of Dan Abramov from Facebook. The author of this style guide tried to weasel more popularity out of it by calling his guide "Standard" since he knows for a fact that the vast majority of JS coders use a de facto style that includes semi-colons. That's exactly the type of behavior that I expect from young, inexperienced coders who make poor decisions based on vanity. I see it all day long from junior programmers. Luckily for everyone in my company, it's my job to set them straight.
- ng12 8y ago> Luckily for everyone in my company, it's my job to set them straight. I'm sure they love being told they're wrong because they're young and vain. I'm aware styleguides recommend semis but I'm more referring to people who have strong opinions about what is a minor semantic. For my part it's simple: the effort involved using semicolons correctly (and in my experience many devs who like semis use them inconsistently) is significantly greater than the effort to fix/prevent ASI bugs. The only possible caveat to this is if you're using a code-formatter like Prettier to handle semis for you -- but then Prettier will catch and fix ASI bugs for you even if you don't.
- wayneftw 8y ago> I'm sure they love being told they're wrong because they're young and vain. I wouldn't say that, but it is a decision based on vanity and it does tend to come from younger/junior coders in my experience. Making one bad decision based on vanity doesn't make you vain though IMO. It's not personal vanity either, it's "code vanity" so maybe a better word would be: hasty or risky... Anyway, the effort that it takes to setup and use Prettier (which we use) or before that, "eslint --fix", is the least amount of effort of all the options. You're expending more effort to memorize edge-case rules than my teams are if you're not using Prettier and if you are using Prettier but without semis, then you risk running into a bug like the one that broke Twitter Bootstrap due to lack of semis. It's just a bad decision. > I think people who really care about semicolons in JS are people who just don't write a lot of JS... > I'm aware styleguides recommend semis but I'm more referring to people who have strong opinions about what is a minor semantic. It's not just some guides, it's the majority of the most popular style guides and the biggest JS-using companies that write and use those guides, which recommend semis. It's also not a minor semantic. The language requires them and if you make the error of omitting them, the runtime will try and correct your error. Depending on this runtime behavior is the kind of hasty and shallow decision that costs real money. That's why the most popular style guides recommend them and that's why the de fact standard is to use them. Googles style guide requires them company wide. The people who wrote these guides really cared about semicolons, that's why they put it in the rules.
- ng12 8y ago
- cmroanirgo 8y ago> people who really care about semicolons in JS are people who just don't write a lot of JS I started JS in the mid 90's. I still use semi-colons. To me it's like using a period to end a sentence. It's a pause. It defines the end of a statement. I feel that too much emphasis is placed on the desire to remove curlys and semi colons from JS. It's part of the language. There's always coffeescript or those other flavours that will suit you.
- adrianhel 8y agoThe reason why I made the switch was that it really irked me when one line missed a semicolon. No warning, no error and completely valid code. It really triggered my proverbial OCD. That one function out of ten where I made that typo. So I stopped, and it was a major relief. Note that I didn't use a linter at that time. I don't really mind semicolons in languages where they are enforced, but I also don't end statements in Python with semicolons.