Posted on Fri 09 August 2013

The war on curly braces and angle brackets

Once upon a time if I wanted to put together a website I'd open a couple of PHP files, embed some HTML and CSS, perhaps some JavaScript too if the spec called for it and call it a day. Having four programming languages and scripts in each file made for poor maintainability and ultimately this was an architecture I moved away from.

A few years back I started working with Python. I liked how it enforced indentation to delimit program blocks. A lot of PHP projects I'd worked on had little in the way of tabs used to explains hierarchy. In Python, the code might not run properly or at all if tabbing wasn't adhered to. By removing the need for curly braces and using tabbing to describe hierarchy, the readability of code was greatly enhanced in my opinion.

A few months back I started to look at replacing HTML with a tab-based alternative. I found with JADE I could see hierarchy a lot clearer and it made the code a lot shorter. I could get more code onto one screen and get a sense of what was going on as a whole a lot better. Good Bye angle brackets.

After the readability improvements I found with JADE, I started to look at what's left. Enter: SASS. It was tab-indented, hierarchal and supported mixins. I could group complex lists of properties into normalised, generic blocks and include them as single properties with parameters throughout my code. And with inheritance I could target specific nodes in the DOM hierarchy as a first port of call instead of creating a load of global property changes or polluting the global namespace with generic, non-specific classes. CSS was finally becoming very specific without the need for a lot of syntax. Good Bye curly braces.

But I did save the best for last, CoffeeScript. The syntactical sugar of this preprocessor meant that one line of CoffeeScript could equal 13 lines of properly-formatted JavaScript and would often include more checks than I would have otherwise known to include. Some of my JavaScript files that were ~50 lines of code were suddenly five or six lines and some that were 600 lines came down to 400.

Bringing all of these together, I now feel the syntax of each language I'm using resemble one another much closer and demand less context switching when being revisited.

If you like what you've read above and you're interested in working on a test-driven codebase which uses Python on the backend and JADE, SASS and CoffeeScript on the frontend, please do get in touch. We're always looking for engineers who care about their code.

Signup for our low-traffic newsletter:

Powered by MailChimp

© Giulio Fidente. Built using Pelican. You can fork the theme on github. .