4 ms·
It's almost like it doesn't matter unless it's consistent ;)
by 0xCMP 10y ago
It's almost like it doesn't matter unless it's consistent ;)
- draw_down 10y agoWell, I agree with that and all. But why type (and more importantly, look at) a bunch of semicolons if you don't have to, ya know?
- betenoire 10y agoBecause they signal a complete thought. Like a period.
- mikerybka 10y agoSo kinda like lines.
- betenoire 10y agoKinda. But not. Statements have little to do with lines, and they span lines very often. Variable declarations, especially objects and arrays. Many times for method calls too with many arguments. Kinda.
- iLoch 10y agoBecause it's impossible to complete a thought without a period Seems like a silly conclusion
- betenoire 10y agoObviously it's a preference. But you proved my point to me, your "sentences" look sloppy and incomplete. I try not to write like that, why would I code like that?
- RyanCavanaugh 10y agoIts a good question readers of the English language can also infer punctuation where needed it's not considered good style to make readers infer this there can be some oddness if you are not used to putting punctuation where it belongs naturally garden path sentences can result and some tools can detect ambiguity automatically but why learn some custom rules for that when its straightforward to consistently put periods at the end of sentences
- robertbenjamin 10y agoDamn, this is clever! Except that 'punctuation' in JavaScript comes in the form of a line break, and adding a semicolon is like adding two periods to the end of every sentence just in case someone missed the first one.
- draw_down 10y agoOh, don't be silly. I'm not talking about prose.
- RyanCavanaugh 10y agoExcept for all the times it isn't, which you still have to remember or have enforced by a tool.
- wolfgang42 10y agoConsider, however, the style commonly used on chats such as IRC This sort of writing generally leaves off periods on the ends of sentences sometimes, it even leaves off the capitalization at the beginning, as well and yet it manages to be entirely readable and generally unambiguous This is remarkably similar to js's automatic semicolon insertion: if the sentence makes more sense with a period at the end of the line then the reader usually inserts one automatically, without thinking about it
- codedokode 10y agoBecause JS syntax is copied from Java that uses semicolons. Omitting semicolons makes code more ambigious and one has to remember where they can and where they cannot break a line. JS is not a language like Ruby or Python. If someone doesn't like typing semicolons why don't they set up their editor so that it would insert them automatically?
- 0xCMP 10y agoYour previous comment read like you now were okay with semi-colons, but I realized now that it's you like no semi-colons. But, in my opinion, the reason you'd be okay with looking at it if you didn't have to is if you wanted to! JS will add the semicolons. If you're using Babel and the rest you most likely are not going to run into all the weird things to do with semi-colons as long as you follow K&R C style for control statements. But if you want it to, go ahead. What matters, in the end, is consistency to make it look pretty. The more it looks like a single very smart person wrote it the better.