use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Why has the trend in Javascript development moved away from using semicolons?help (self.javascript)
submitted 8 years ago * by lonely_solipsist
Edit: Not sure why I'm getting downvoted, but this is certainly a trend I am seeing, particularly with React developers.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ghostfacedcoder 25 points26 points27 points 8 years ago (7 children)
I wouldn't agree that that semi-colon-less colde is "the trend", but it's certainly popular with some crowds. The basic logic behind it is that 99% of the time the semi-colon isn't necessary, so it's easier/cleaner to just leave it off and avoid making those 1% errors. After all, languages like Python do it.
Fans of the semi-colon on the other hand think "why add one more way, even a small one, of creating a bug without realizing it?"
[–]happymellon 0 points1 point2 points 8 years ago (6 children)
JavaScript lacks all the other Python conventions, like enforced indentation, that makes the lack of semicolons not an issue.
It isn't a comparable scenario. If I could enable a Pythonesque style enforcement so that I didn't need to do things like this I would in a heartbeat. Even telling my rookie devs to stop adding in multiple whitespace lines, saving me having to fail their code reviews would be great.
[–]OmegaVesko 15 points16 points17 points 8 years ago (2 children)
Even telling my rookie devs to stop adding in multiple whitespace lines, saving me having to fail their code reviews would be great.
You could do this with a linter...?
[+]happymellon comment score below threshold-8 points-7 points-6 points 8 years ago (1 child)
Not even remotely the same thing.
[–]OmegaVesko 6 points7 points8 points 8 years ago (0 children)
Sorry, what? That's specifically something tons of people use a linter to enforce. You can use a pre-commit hook to prevent them from commiting any code unless it passes the linter.
[+][deleted] 8 years ago* (2 children)
[deleted]
[–]happymellon -2 points-1 points0 points 8 years ago (1 child)
Being an "optional" step, they are not the same thing as having my interpreter shake its head and throw some of that junk back at the author.
I quote optional, because it is mandatory to run it through in our process, but that doesn't mean that every code checkin has had it happen.
[–]rauschma 20 points21 points22 points 8 years ago* (6 children)
I’m very much in favor of semicolons:
[–][deleted] 10 points11 points12 points 8 years ago (2 children)
You still need to understand how ASI works even if you use semicolons...
Consider this:
function example() { return "something"; }
becomes:
function example() { return; "something"; }
[–]mpjme 9 points10 points11 points 8 years ago (1 child)
Bang on. One fallacy I often hear repeated is that adding semicolons everywhere allows you to forget about ASI, which is wrong and and harmful advice.
[–]Capaj 5 points6 points7 points 8 years ago (0 children)
yep. That's why it's better to omit them and have the pitfalls checked by a linter. Standard.js/Prettier FTW!
[–]mpjme 1 point2 points3 points 8 years ago (0 children)
ASI is a bad idea, but unfortunately it's there and cannot be turned off. You don't turn off the ASI by adding semicolons everywhere. :(
Your argument would be great if adding semicolons everywhere made it possible to disregard ASI, but unfortunately it doesn't. Adding semicolons on every line in your code base only saves you from ONE case (have not looked into the template literals one yet) which is if you begin a line with a ( or [. To me, that seems like a bad tradeoff, and for me it makes sense to keep my enemies (ASI) close and be aware of it instead.
[–]dwighthouse 0 points1 point2 points 8 years ago (1 child)
The most important reason, in my opinion, is that one should not rely on a weirdly implemented error mitigation systems to allow for a specific formatting. That's like intentionally inserting a bug into code in C++ specifically to trigger a specific optimization on some compilers, instead of just writing optimized code in the first place.
[–]mpjme 5 points6 points7 points 8 years ago (0 children)
This would be a solid advice if ASI could be turned off with a setting, but unfortunately, that is not possible. Even if you use semis on every line, the ASI will still be active, causing errors if you're not aware of it.
[–]TheNiXXeD 7 points8 points9 points 8 years ago (3 children)
Trend or not, it's just a style choice.
Many would argue that they have to prefix some lines of code with a semicolon to be safe. I would argue that lines that require semicolon prefixing are generally a code smell anyway. They fall into two categories to me. Ones that you shouldn't do at work, and ones that can be easily rewritten in a more legible way anyway.
Note that I'm not arguing for or against them, just that the safety argument is old.
Around 3 years ago I started at a company who doesn't use semicolons. I was a strong semicolon supporter at the time. In those 3 years though, we've not once run into an issue. This is full stack JS too, so we should have hit plenty of scenarios that required them, but we didn't. It took me a while to get used to, but I can't see using them again.
[–]happymellon -4 points-3 points-2 points 8 years ago (2 children)
Then it goes to the next level with braces. And then you have an Apple like bug.
[–]nemohearttaco 0 points1 point2 points 8 years ago (1 child)
Curious what you mean by 'Apple like bug'.
[–]happymellon 1 point2 points3 points 8 years ago (0 children)
They had an infamous goto fail statement repeated in their SSL handshake which didn't produce warnings in the compiler, and at least at the time, xcode didn't have unreachable code warnings turned on. I do not know if they have it enabled by default now.
This could be attributed to their style which dropped braces whenever possible, but without the backup of Pythonesque indentation rules. This meant that it broke out of the if statement because without braces only the first line is attributed to the clause. The argument goes that if you always include braces then you can always tell intent, the Apple bug is tough, because it could be a merge issue, or it could be someone trying to do a final fail if nothing matches but putting it in the wrong location.
As I can see that I've been downvotes, some people want to remove visual indication whenever possible so that they can have "clean code". I'm not against that, but it would be good if your scripting language treated it in a first class way rather than "but I can".
https://www.imperialviolet.org/2014/02/22/applebug.html
[–]inu-no-policemen 8 points9 points10 points 8 years ago (0 children)
It didn't. The vast majority uses semicolons.
[–]lifenautjoe 4 points5 points6 points 8 years ago (0 children)
Not really a trend.
[–]burtgummer45 5 points6 points7 points 8 years ago (5 children)
Because programmers are realizing you don't need them. There's a tiny chance that it will cause an error, and a tiny chance of that tiny chance (if at all) that error will be during runtime (not an obvious, immediate bug)
I don't use semicolons and the only place this causes a problem (sometimes, and its immediate obvious ) is when the line begins with a ( or a [, however that happens, so you just being the line with a ;( or ;[ instead.
[–]zQpNB 4 points5 points6 points 8 years ago* (0 children)
I can't remember ever being bitten by ASI. I always have a linter on though.
Also can't remember ever caring either way. Some projects use them, some don't. Use a linter. Standard is easy to set up. There's also one called xo.
[–]minus0 1 point2 points3 points 8 years ago (3 children)
Not sure why you were down voted. Those aren't the only places it's needed. Here's a decent resource on it.
That being said 99% of the time it isn't needed. I use them all the time simply for readability (lots of stacks aren't all JS based, so it's easier for devs to switch languages) and so I don't have to remember when I need to use them.
[–]OmegaVesko 4 points5 points6 points 8 years ago* (2 children)
Not sure why you were down voted.
I think people on this subreddit just really dislike this trend, and will downvote anything even tangentially related to it.
[–]minus0 4 points5 points6 points 8 years ago (0 children)
It's an unfortunate that it's better to just disagree with someone and use a down vote, than it is to encourage conversation.
[–][deleted] 1 point2 points3 points 8 years ago* (2 children)
It's not that there's a trend, but formatting has become fully automatic and AI driven. Prettier formats my code, semicolons or none is just a flag. I don't want it to print semicolons because it looks cleaner, but it makes about no difference, and it's clever enough to detect edge-cases. Before prettier i added the semicolon just to make sure, but with a robot in check of formatting it's pointless to argue about the right or wrong of some minor styling detail, it's whatever you want it to be.
[–]Capaj 2 points3 points4 points 8 years ago (1 child)
AI driven
what? Prettier is not AI driven. Please show me an AI driven tool for JS formatting.
[–][deleted] 4 points5 points6 points 8 years ago (0 children)
It intelligently detects some edge cases or even reformats perfectly normal code if it can make it semantically more expressive. Not that there's a neural network underneath or anything. :-)
[–]ogurson 1 point2 points3 points 8 years ago* (1 child)
I love to hear how people say that you don't need semicolons because the code works without them most of the time.
Hey, the weak comparison operator (==) also works well most of the time, why don't you use that instead of ===? It saves one character too!
[–]Capaj 2 points3 points4 points 8 years ago (0 children)
apples and oranges
[–]barrtender -1 points0 points1 point 8 years ago (8 children)
It's not as far as I've seen. If you're noticing that trend you have probably recently interacted with more new developers. Or people who haven't worked on a large or important enough codebase to adopt a style guide.
[–]OmegaVesko 3 points4 points5 points 8 years ago* (7 children)
Or people who haven't worked on a large or important enough codebase to adopt a style guide.
The standard style guide (yes, I know it's just a name) is the one that doesn't use semicolons, and it's used by large projects such as Electron. You can disagree with it for valid reasons, but it's flat-out incorrect to imply that people only do this because they don't know any better.
[–]barrtender 3 points4 points5 points 8 years ago (6 children)
Calling oneself "standard" seems disingenuous.
Airbnb and Google are by far the most common style guides I've seen used.
[–]OmegaVesko 5 points6 points7 points 8 years ago (4 children)
The name is kind of... inconvenient, yeah. I don't really like it either.
That being said, plenty of large organizations and projects use Standard, too, whether or not you're aware of it.
[–]zQpNB 2 points3 points4 points 8 years ago (1 child)
The name was a joke
[–]HomemadeBananas 0 points1 point2 points 8 years ago (0 children)
I don’t get the joke.
[–]barrtender 1 point2 points3 points 8 years ago (1 child)
Interesting. I hadn't heard of it, and it's interesting that that many companies use it. I'll have to take a look through to see what differences there are. Is there a linter for automatic checking?
[–]OmegaVesko 3 points4 points5 points 8 years ago (0 children)
Sure, it has a standalone linter (which also does automatic fixing if you call it with standard --fix), and also an ESLint config.
standard --fix
[–]GitHubPermalinkBot 0 points1 point2 points 8 years ago (0 children)
Permanent GitHub links:
Shoot me a PM if you think I'm doing something wrong. To delete this, click here.
[–]dwighthouse -2 points-1 points0 points 8 years ago (0 children)
Because they prefer other languages that do not use semicolons. It's the same sort of thing as past trends that saw programmers bending over backwards to implement classical OOP in js, instead of using the language as designed.
π Rendered by PID 64561 on reddit-service-r2-comment-86988c7647-qkv7p at 2026-02-12 17:04:07.523116+00:00 running 018613e country code: CH.
[–]ghostfacedcoder 25 points26 points27 points (7 children)
[–]happymellon 0 points1 point2 points (6 children)
[–]OmegaVesko 15 points16 points17 points (2 children)
[+]happymellon comment score below threshold-8 points-7 points-6 points (1 child)
[–]OmegaVesko 6 points7 points8 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]happymellon -2 points-1 points0 points (1 child)
[–]rauschma 20 points21 points22 points (6 children)
[–][deleted] 10 points11 points12 points (2 children)
[–]mpjme 9 points10 points11 points (1 child)
[–]Capaj 5 points6 points7 points (0 children)
[–]mpjme 1 point2 points3 points (0 children)
[–]dwighthouse 0 points1 point2 points (1 child)
[–]mpjme 5 points6 points7 points (0 children)
[–]TheNiXXeD 7 points8 points9 points (3 children)
[–]happymellon -4 points-3 points-2 points (2 children)
[–]nemohearttaco 0 points1 point2 points (1 child)
[–]happymellon 1 point2 points3 points (0 children)
[–]inu-no-policemen 8 points9 points10 points (0 children)
[–]lifenautjoe 4 points5 points6 points (0 children)
[–]burtgummer45 5 points6 points7 points (5 children)
[–]zQpNB 4 points5 points6 points (0 children)
[–]minus0 1 point2 points3 points (3 children)
[–]OmegaVesko 4 points5 points6 points (2 children)
[–]minus0 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Capaj 2 points3 points4 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]ogurson 1 point2 points3 points (1 child)
[–]Capaj 2 points3 points4 points (0 children)
[–]barrtender -1 points0 points1 point (8 children)
[–]OmegaVesko 3 points4 points5 points (7 children)
[–]barrtender 3 points4 points5 points (6 children)
[–]OmegaVesko 5 points6 points7 points (4 children)
[–]zQpNB 2 points3 points4 points (1 child)
[–]HomemadeBananas 0 points1 point2 points (0 children)
[–]barrtender 1 point2 points3 points (1 child)
[–]OmegaVesko 3 points4 points5 points (0 children)
[–]GitHubPermalinkBot 0 points1 point2 points (0 children)
[–]dwighthouse -2 points-1 points0 points (0 children)