Andi Smith

Scaring Off Beginners

There has already been far too much conversation about whether semicolons are appropriate to use at the end of lines in JavaScript. Serious problems could have been solved in the time JavaScript experts have spent arguing about this. And if the experts can't make a decision on something as simple as semicolons, what chance do beginners have of understanding JavaScript at all?

Web development is already full of so many variations of ways of doing the same thing, and this is part of what makes our job so much fun - but if you are someone who's still learning about web development these arguments just makes matters even more confusing.

Often I find myself in a situation where I need to write code for a prototype or proof of concert which will be handed over to another developer. When I write the code I have no idea who that developer is or what their skill level will be.

So my aim has to be to write readable, reusable, consistent code that could be understood by any level of JavaScript developer. Even if they have a fairly basic understanding of JavaScript, they should be able to figure out what is going on. And that includes using semi colons at the end of every line. If you have already written code that is going to take some time to understand, adding further complexity by removing semi-colons from the end of lines isn't going to help.

And there's an incentive for me to write readable, understandable code. If I write poorly structured, bad code then I have to spend much longer handing over my code; sitting with the developer; explaining how it works and coming back to answer questions. And I want to work on the next exciting thing. By following an approach that everyone can understand, I'm saving myself time and pain later on.

When you are writing JavaScript, try to stick to best practices and style guidelines such as Rick Waldron's Idiomatic style guide or Google's JavaScript style guide, and worry about optimising your code at build time using minification.

Should JavaScript developers know about automatic semi-colon insertion? Sure, it's good to have an understanding about how it works.. Is it the most important thing for beginners to learn right now? No. Let's help the newbies by producing code that can be used and understood by all.

And if you are a beginner, then Codecademy is a great place to start learning; and Javascipt: The Good Parts and Eloquent JavaScript should be the top of your reading list.