You’re coding it wrong

Written by:
by Lucie Sadler
Date Posted:
22 January 2018
New Tech

It seems like there’s always beef in the JavaScript community (think tabs v spaces). The group that advise on ECMAScript (TC39) have just suggested that semicolons can be omitted in certain situations; and some people have lost their minds.

Flouting rules
A lot of developers use semicolons to separate JavaScript statements from one another, but it’s not gospel. So should devs end statements and declarations with semicolons, or rely on Automatic Semicolon Insertion (ASI)?

It’s possible to flout the punctuation requirement by using ASI. As most devs will agree, every extra character could mean making an error in the script. So by getting rid of semicolons, are we not just causing more problems?

JavaScript developers could ignore the guidelines and ASI would add the missing semicolons. ASI isn’t going anywhere, but users should probably try to rely less on ASI because there are situations where it isn’t always going to be correct.

Several developers seem pretty miffed by the news. Are the group insinuating that they’re in the wrong for using JavaScript in a certain way? It’s been common practice for years anyway, so why change something that works? To semicolon or not to semicolon, that’s the question.

One JavaScript style to rule them all 
The JavaScript Standard Style project set out to create “one JavaScript style to rule them all”. Most of the debate on this revolves around the humble semicolon. They say get rid.  Supporters say it provides some structure and stability to the language, whereas the anti group say that they’re cluttered and unnecessary.

It seems to be a controversial topic, especially amongst devs who program in many different languages that use semicolons (Java, PHP). It would be more difficult to remember to leave out the semicolon, especially if you’re coding in multiple languages at the same time. As the language develops over time, other problems could arise by relying on ASI too…

No votes yet.
Please wait...

Leave a Reply

Be the First to Comment!

Notify of

Hyve are 100% carbon neutral. We use carbon offsetting to balance out the release of carbon dioxide from our offices and infrastructure.