End tags, semi-colons and maintainable code

In Of parser-fetishists and semi-colons, Chris Heilmann brings up the importance of code maintainability, something that I feel is overlooked a bit too often.

The main issue Chris talks about is omitting semi-colons at the end of JavaScript statements, the subject of a current JavaScript drama. Doing so is valid syntax in many cases, and browsers parse and execute the code fine. However, it does not improve code readability for humans, who are often as important to target as the browsers that run the code.

Another language where some people make code harder to read by omitting characters is HTML (I wrote a bit about that a while ago in HTML5 syntax guidelines). You can omit the end tags of some elements, the start and end tags of some, quotation marks around attributes, etc. It is valid HTML and browsers will parse it, but again, it will not make the code easier for fellow developers to understand and maintain.

There are more examples in Christian’s post, so do read it. And remember this:

Writing clean and readable code makes you a nice person to the people who take code over from you.

Relying on browsers to magically insert missing code is not developer-friendly.

Posted on April 17, 2012 in Coding, HTML 5, JavaScript

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.