nijikokun / the-zen-approach

JavaScript Styleguide, can be applied to other things as well.
MIT License
168 stars 16 forks source link

Semicolons #3

Closed yyx990803 closed 10 years ago

yyx990803 commented 10 years ago

"If it does not affect performance, or does not affect the outcome, it is aesthetic."

However the guide went on to suggest always use semicolons. In my opinion, using or omitting semicolons are both perfectly valid choices, just like spaces vs. tabs. If the latter deserves discussion, then so do semicolons. Understanding ASI is not that hard, and even if you write semicolons everywhere, you still need to understand it because of restricted productions (e.g. newline after return).

nijikokun commented 10 years ago

It can affect outcome, thus, I feel that semicolons should be required.

I do agree on the front that it should have it's own section and with a discussion on the topic so that people may decide for themselves, however, to save time and frustration from many. It is just a lot easier to have them.

Reference for anyone reading this issue and does not know what ASI is.

yyx990803 commented 10 years ago

You didn't provide convincing reasons as to why it should be required. There is only one scenario it causes practical concerns: when a line starts with (, [ or /, which is quite rare and dead simple to deal with: just add ; at beginning. In my over 2 years of semicolon free javascript, this is really the only thing that's different.

The point is, you need to understand ASI regardless of whether you use semicolons or not. Once you actually understand it, whether to use semicolon becomes a largely aesthetic and open choice. The argument of "use semicolons because I don't understand how ASI works" is simply insufficient.

Suggested reading:

nijikokun commented 10 years ago

Well, attacks, and assumptions aside.

I've already stated that I agree there should be a section on semicolons, and educating not only new users, but older users of JavaScript on the subject is better than what my styleguide currently does which is advises that it is easier on the mind to simply use semicolons rather than memorize a subset of rules to which they then can decide whether to use them or not.

Thank you for your references, and insights into your personal journey into the semicolon free world. I'd like to give you congratulations for sticking with it for so long. I guess I am bias as I find semicolons aesthetically pleasing even though I have full understanding of how AST works and gives some sort of ending to the tale that lines give.

In the future you can expect to see a section on semicolons going into detail regarding the rules, and suggestions that I may give.

yyx990803 commented 10 years ago

I posted the last comment before you updated yours, so I didn't see the addition about your willingness to add a section discussing it. I'm glad you are willing to do so, and that is my intention. I don't think any part of my comment can be labeled as "attacks". The argument about "use semicolons because I don't understand how ASI works" was not pointed directly at anyone either, but rather an attitude I don't think a guide like this should be encouraging.

yyx990803 commented 10 years ago

FYI, there are large, successful projects written in semicolon-free style, e.g. Bootstrap & npm.

nijikokun commented 10 years ago

I agree, there are quite a few projects which utilize semicolon-free coding style, however, I think that maybe it is a personal choice rather than something we should force people to do, or shove down their throats just as semicolon usage is (forgive me for doing so in a slighted manner); and at the end of the day, something that when you code with a group of people, you should follow what the groups current standards are regarding this notion.

Not that one isn't free to bring it up, but should it be turned down, just go with the flow rather than forcing ideals of aesthetic.

If you are alone, be yourself.

yyx990803 commented 10 years ago

That's exactly what I was suggesting. I never said I want everyone to drop semicolons. Follow the house rules is always the priority. My only issue was with the blanket "use semicolons" suggestion.

yyx990803 commented 10 years ago

Closing now that we've reached agreement.