HTML Is Your Friend

Web apps are complex. It takes at least three different languages to put together a working web app: javascript, CSS and HTML. Usually you can get by with a tiny amount of javascript assuming you aren’t using nodejs on the server. Which means that you’re using something else on the server like ruby or python. Which brings a fourth language into the mix.

So if you aren’t going to use vue or react or angular or marko you’re going to be generating your HTML on the server and you’re going to do one of two things.

Template Engine

This is the thing that looks like <%= this %> or like {{this}} and it adds yet another language to the mix that kind of looks like html with placeholders in it, they even have special syntax for if-else and for loops. Template engines seem like a good idea until you realize you’re writing yet another language in addition to your server language.

String Concatenation

This is you resisting the siren song of the template engine and instead just mashing strings together. "<body>" + "hello world" + "</body>" You rebel.

Or instead of any of that you can use the clojure way.


Honestly, is separating html and css files separation of concerns or separation of technologies? The best way to simplify your life as a solo developer or a small team is to have small functions that emit html (or a representation of html). That’s what hiccup gives you, let’s take a look at a some sample hiccup functions along with tachyons and turbolinks

This is amazing

This is just the tip of the iceberg, and the best part about this solution is that you never have to actually write any css other than to change colors, but tachyons is a whole other post. This is 78 lines of insanely re-usable functions that emit a better representation of html than html is. There are no angle brackets or an equal sign in sight!