Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like consistency. And I am paranoid. When I write JS, I always include semicolons. When I write CS, it is a non-issue.


> 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/ [1]https://github.com/prettier/prettier


Yeah, 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.


It must be said though that CS has its own headscratchers in terms of parsing, if you choose to leave off all optional punctuation.


I agree. With great power comes great responsibility. Just because you can leave out all punctuation with CoffeeScript, it doesn't mean you should.


I consistently don't use semicolons in JS. It's just noise.


Omitting 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.


I 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.


In 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.


I have my VSC set up to automatically format and insert semicolons when I save. Saves a lot of hassle.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: