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.
- Previous post: The HTML5 placeholder attribute is not a substitute for the label element
- Next post: Automatic line breaks in narrow columns with CSS 3 hyphens and word-wrap
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.
Subscribe / follow
Sponsors
Authentic Jobs
- Front-end Developer and UI/UX Designer at DrivingSales, LLC (Salt Lake City, UT, Ut, US)
- Web Application Developer (Ruby on Rails) at Archon Systems Inc (Toronto, ON, Canada, CA)
- Full-Stack Developer at Svensk Lånemarknad (Stockholm, Sweden, SE)
- Front-End Engineer at Piqora (San Mateo, CA, Ca, US)
DreamHost web hosting
Use the promo code 456BEREASTREET3 to save USD 20 when you sign up for DreamHost

