Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: why do people seem to hate ; that much?
4 points by magice on May 31, 2012 | hide | past | favorite | 11 comments
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?



There 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


"They [semicolons] are transvestite hermaphrodites representing absolutely nothing. All they do is show you've been to college." --- Kurt Vonnegut.


I don't get it, can someone explain what this is supposed to mean?


Vonnegut was speaking with regards to the English language. He was arguing that semi-colon in written sentences serve no function beyond pretension.


I love it when it's optional like in Ruby. If I accidentally put it in, it's cool.


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


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


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


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


I actually love the semicolon when coding whichever language/script allows me to do.I do not mind it at all.


The strongest argument against the semi-colon is readability.

#confession Out of habit, I still use it in most of my code.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: