4 ms·
I like consistency. And I am paranoid. When I write JS, I always include semicolons. When I write CS, it is a non-issue.
by ralmidani 9y ago
I like consistency. And I am paranoid. When I write JS, I always include semicolons. When I write CS, it is a non-issue.
- akvadrako 9y agoI consistently don't use semicolons in JS. It's just noise.
- jdmichal 9y agoOmitting semicolons breaks the "delete a line in isolation" rule, unless you begin the line with a semicolon instead. Which is even noiser than just having them at the end of the line, where they are unconsciously glossed over by anyone who's ever worked in a language with C-derived syntax.
- RussianCow 9y agoI hear this a lot, but in ~4 years writing JavaScript without semicolons, I've had to do this maybe two or three times. I just don't feel like starting a line with [ or ( is very common, to the point that it's a complete non-issue to me.
- tga 9y agoIn the majority of cases you can't "delete a line in isolation", because it's part of a program. You have to look around and understand what the impact of deleting that line will be -- and modify nearby lines as necessary.
- pramodliv1 9y ago> And I am paranoid You should write tests when building a project in a dynamically typed language to alleviate some paranoia anyway. As long as you have decent test coverage and use a decent linter/formatter such as StandardJS[0] or prettier[1], you'll be fine. [0]https://standardjs.com/ https://standardjs.com/ [1]https://github.com/prettier/prettier https://github.com/prettier/prettier
- sli 9y agoYeah, if your linter/build tool can't handle Javascript that doesn't have semicolons, it should be considered fundamentally broken and/or incomplete. So the question to me becomes, if the build tool doesn't correctly parse the JS that's lacking semicolons, should you really trust that build tool with the rest of your code? You already know at that point that it doesn't handle your otherwise-valid semicolonless JS correctly.
- vanderZwan 9y agoI have my VSC set up to automatically format and insert semicolons when I save. Saves a lot of hassle.
- acjohnson55 9y agoIt must be said though that CS has its own headscratchers in terms of parsing, if you choose to leave off all optional punctuation.
- ralmidani 9y agoI agree. With great power comes great responsibility. Just because you can leave out all punctuation with CoffeeScript, it doesn't mean you should.