Semico what?

2016-12-21

Recently, at my workplace, a colleague felt a rustle up his jimmies due to our lack of semicolon usage in our NodeJs repos. The number of projects without semicolons were in the tens and there really wasn’t a good way to introduce semicolons in them even had the team agreed to do so. But that got me thinking.

Do we really need semi-colons?

Why have them or not have them? What are the arguments for and against the issue? What do people argue with when they want to defend their position? So I started doing some light research.

And yes, this was light research. I don’t care enough about the issues to have spent more than an hour on it. Do your own research if you care so much.

Stuff I Read

I read some stuff while researching this but these are the ones that I think you should start with. You should do your own research as well: don’t take my word for it. Branch out from these links and find your own perspective on the matter. If you write a more comprehensive post on the issue, hit me up coz I’d like to read that.

This is What People Seem to be Saying (heavily paraphrased)

Semico-yes:

  • Not using it introduces weird bugs.
  • My linter says so.
  • Douglas Crockford says so.
  • It’s what I’ve always done.
  • It’s the standard!

Semico-no:

  • It leads to less code.
  • It reminds me of Ruby,Python,Brainfuck.
  • Isaac Schlueter says so.
  • It’s what I’ve always done.

Right.

My Unsolicited Thoughts on the Matter

  • Using or not using semicolons in a language shouldn’t be because you miss using them/not using them in a different language.
  • With the way things are today, our interpreters and engines being smarter than ever, a lot of things come down to a matter of preference, semicolon being one of them.
  • That said certain things make sense about having semi-colons:
    • They explicitly terminate a statement. Anything that’s explicit requires less of your mind-power to grok. You don’t have to check the next line to see if a function call was terminated or chained.
    • -crickets chirping-

Final Thoughts

I like semicolons for their explicitness. But at the end of the day, either style works. I use semi-colons in my personal code and don’t in my professional. And I don’t find it that hard to switch between the styles (especially since I offload any checking to my linters). So, use what you want, and if you can’t because of whatever reasons, don’t make a big deal out of it. It matters very little.

Notes:


More posts like this

My ES Lint and Why

2018-09-21 | #coding-style #eslint #nodejs

I recently updated my company’s main NodeJS repository to include formatting via prettier-eslint and linting via eslint. My colleague asked me to explain my choice of rules since it’s tedious to go through each and every rule and figure out why it was chosen and I thought it was worth getting a blog post out of it, so here we go. This is the eslint config I plan to use:

Continue reading 


Template Literals, All the Way!

2017-02-23 | #coding-style #javascript #nodejs

Today, while at work, I had to turn a single-quoted string into a template literal because mid-way through the string I realized I had to put in an apostrophe. This has happened often enough that I want to stop thinking in this dual single-quoted/template-literal mode and just go template-literal all the time. Now before I say anything more I’d like to clarify that I’m working with NodeJS almost all the time with full feature support for template strings and no issues with things like minification.

Continue reading 