5 ms·
Ask HN: why do people seem to hate ; that much?
This question has bugged me since the first line of Javascript. Seriously, what is wrong with ; (semicolon)? It is small and enabling. Why do new languages (including functional ones like Scala) keep advertise if their lack of requirement?
- yashchandra 14y agoI actually love the semicolon when coding whichever language/script allows me to do.I do not mind it at all.
- AznHisoka 14y agoI love it when it's optional like in Ruby. If I accidentally put it in, it's cool.
- magice 14y agoThe thing is, if the semicolon is optional, you can't write more complex expression. For example, if you want to sum a bunch of numbers, you can't have the plus signs at the beginning of the lines anymore.
- Sarkar 14y agoI know what you mean - same in JS. It was a little unnerving for me to write code in JS without semi colons after every line. It gets to the point where sometimes I'll chat on facebook and after finishing a thought I'll type ';' at the end of a sentence. Weird, I know.
- marssaxman 14y agoThe semicolon signifies C syntax, and C syntax signifies arcane, low-level danger. Designing a syntax without semicolons is a way to show that a language is not trying to play in the same space as C.
- debacle 14y agoThe semicolon is used by Perl, PHP, JavaScript, Java, and C#. None of those are what I would consider 'low-level' languages. You can write arcane code in any language.
- factorialboy 14y agoThe strongest argument against the semi-colon is readability. #confession Out of habit, I still use it in most of my code.
- brudgers 14y ago"They [semicolons] are transvestite hermaphrodites representing absolutely nothing. All they do is show you've been to college." --- Kurt Vonnegut.
- dannytatom 14y agoI don't get it, can someone explain what this is supposed to mean?
- rprospero 14y agoVonnegut was speaking with regards to the English language. He was arguing that semi-colon in written sentences serve no function beyond pretension.
- TheIrishman 14y agoThere are two reasons for avoiding semis in JS, and similar languages, to wit: 1) Code clarity. Semis do not aid legibility. All they add is sad little bits of fluff that get in the way of your eyes reading the code 2) Symbol overloading. Some us (Yes I am one) do NOT like symbols being overloaded. I esp. hate the way both semi and comma are overloaded in C, Java, etc. The result is that inside of a for definition (that is the bit in brackets after the word 'for') semis and commas almost reverse their meanings. I just find that so retarded. So, in JS I never use semis EXCEPT where they are required. Note, that by doing this when you do come across a semi in my code, you DO notice it. Again, improves code clarity. Cheers TheIrishman