Live data from Hacker News

Of parser-fetishists and semi-colons

christianheilmann.com

1–10 of 125 posts

Re: Of parser-fetishists and semi-colons

#2
This whole debate seems like two folks stuck in their way blowing a whole thing out of proportion.

How about Bootstrap adds the damn semi-colon and JSLint accepts that for the most part the lack of a semi-colon is working and "valid" JS add allows for the edge case. Now everyone gets to go home happy.

Re: Of parser-fetishists and semi-colons

#3
I think the argument that we shouldn't rely on the parser for certain language features is a bit silly (including interpreting end-of-statements). The language is precisely what the parser says it is, and nothing more or less. JSMin is free to not do what the parser does of course, but that won't be Javascript.

Re: Of parser-fetishists and semi-colons

#4
The author is right on the money. I've always written code as specified - just because it felt 'right' - but I could never pin down my arguments - the author captures my thoughts beautifully.

Particularly his points about reading other people's code & extending functionality - there are very few use-cases where it makes sense to omit semi-colons, end-tags, etc - and if you aren't sure - yours isn't one of those use-cases.

Re: Of parser-fetishists and semi-colons

#5
I suspect, that to understand the logic behind semicolon exclusion, you should program at least a little in the languages, that do not require it.

At least for me, mental switch between semicolon and no semicolon is hard for some reason, if it happens a lot during the day :)

Re: Of parser-fetishists and semi-colons

#6
I think this whole semicolon story is a natural step of a language becoming more wide-spread. The more people spend time appropriating the language, the more they'll want to push the envelope, exploit the quirks and get the best out of the language's syntax.

It's a natural cycle. C programmers went through the very same phase at some point and to this day different coding styles persist.

It's only when those choices cause incompatibilities that friction emerges, but we should see it as a natural step towards a more unified grasp of what Javascript means for people who program with it. That the general tone of the conversation is antagonistic is just a symptom of the fact that people care about their opinions and their choices, which by all means should be seen as a very healthy questioning on the part of the community. Just my 2 cents.

TL;DR: Sure the image conveyed is bad, but the reasons why such a debate emerges are natural and are part of the evolution of a language, it'll get better.

Re: Of parser-fetishists and semi-colons

#7

    Now, this could be easily solved – by adding the friggin semicolon.
What this furore misses is that the original issue (JSMin failing to minify bootstrap-dropdown.js) was already fixed when the bug was raised [1]. Fixed without adding semicolons. Everyone should be happy with that. Developers of bootstrap got to stick to their "no semicolons" schtick, and the person with the original problem got it fixed. Everyone seems to forget this salient point when they rush in to this debate.

For reference, I sometimes use semicolons in my javascript, sometimes I don't. It depends on context and whether it makes the code more readable. It's not an issue I care enough about to get involved in a holy war, one only marginally more relevant than tabs vs spaces.

[1] https://github.com/twitter/bootstrap/issues/3057#issuecommen...

Re: Of parser-fetishists and semi-colons

#8

Now, this could be easily solved – by adding the friggin semicolon. What this furore misses is that the original issue (JSMin failing to minify bootstrap-dropdown.js) was already fixed when the bug was raised [1]. Fixed without adding semicolons. Everyone should be happy with that. Developers of bootstrap got to stick to their "no semicolons" schtick, and the person with the original problem got it fixed. Everyone se…

That isn't really the original issue at all, Crockford's comment is just what brought it to a boilover. The lack of semi-colons has been brought up in issue after issue on the bootstrap project. Each time it's been rejected for the same arguably poor reasoning.

Christian's post is completely spot on here. Javascript was designed to be tolerant of errors and inconsistencies as much as it could. That fact however, shouldn't be used as an excuse for advocating inconsistent coding. Not that I'm saying semi-colons are the epitome of consistent coding (I prefer Ruby myself) but that Javascript was not designed with significant whitespace in mind, rather it just has a tolerance for inconsistent and arguably erroneous syntax.

The argument here is that we shouldn't let Javascript's tolerance excuse laxness on our parts. We should know better.

Re: Of parser-fetishists and semi-colons

#10

Now, this could be easily solved – by adding the friggin semicolon. What this furore misses is that the original issue (JSMin failing to minify bootstrap-dropdown.js) was already fixed when the bug was raised [1]. Fixed without adding semicolons. Everyone should be happy with that. Developers of bootstrap got to stick to their "no semicolons" schtick, and the person with the original problem got it fixed. Everyone se…

[deleted]
Post reply on HN