HTML is not an imperative programming language and that's the best thing about it

bcalou

Bastien Calou

Posted on October 21, 2020

HTML is not an imperative programming language and that's the best thing about it

I love HTML. The more I learn about it, the more I think it is genius work. Above all, I love that it is not a programming language.

Programming languages suck. They fail all the time (I swear, I always write my JavaScript perfectly on the first try, and yet it persists in failing 🤷).

Worse, when they fail, most of the time the whole program fails! I'd just rather stack toothpicks on a windy bridge.

But compare that to the beauty that is HTML:

<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="products.html">Products</a></li>
    <li><a href="about.html">About</a></li>
  </ul>
</nav>
Enter fullscreen mode Exit fullscreen mode

This is beautiful, semantic HTML5. It helps accessibility. It helps legibility. It helps styling. It helps crawlers.

And it doesn't fail.

If an old browser doesn't know about HTML5, it will just treat the nav element as good old div, and it will work.

If a developer or a user with a code editor (e.g. the WordPress back-end) writes nax instead of nav, it will still work.

Let's see another example:

<details>
  <summary>HTML</summary>
  HTML is an acronym for HyperText Markup Language. It was created by Tim Berners-Lee in 1989.
</details>
Enter fullscreen mode Exit fullscreen mode

Not everyone knows about the details element, so here's what it will produce in modern browsers:

I didn't program this behavior (browser's developers did). I described the content of the document and trusted the browser to render it the best it could. And I think that's very, very cool.

And it will work with old browsers too: there won't be any interactivity, but the content will be displayed and that's the most important thing.

Keep calm and stop programming

I don't want to program. I often have to, when HTML is not enough to describe what my website should do. And like many of us, my typical day revolves around front-end JavaScript frameworks, some of which I really like.

But when I think about the user, I know that the worst thing I can do to them is to program.

Everytime I program something myself, I feel like signing a strange document in my head:

I hereby acknowledge that I'm introducing a non-standard behavior into this website, discharging the browser of its responsibility to ensure a reliable experience for every user. I do this fully aware of my partial knowledge of web technologies, of the existence of limits in my implementations, temporal and technical, which cannot be estimated. I realize that what I'm doing will probably break at some point or in some situations. But I have no choice and I promise not to fuck it up.

Alt Text

On the other hand, when I use HTML and web standards, I rely on the shared knowledge of skilled browser's developers and decades of debates aiming to make the web a great platform.

And that's why a deep knowledge of HTML is infinitely valuable: it simply brings quality to the user, which at the end of the day is the only thing of importance.

Resilience

In one of my best reads of the year, Resilient Web Design, Jeremy Keith tells us how we almost lost one of the most powerful aspects of HTML because of XHTML 2.0:

[XHTML 2.0] would also implement XML’s draconian error‐handling model. If there is a single error in an XML document — one unquoted attribute or missing closing slash — then the parser should stop immediately and refuse to render anything.

Thank god we didn't have that.

XHTML 2.0 died on the vine. Its theoretical purity was roundly rejected by the people who actually made websites for a living.

HTML5 won against XHTML 2.0

Source : https://speakerdeck.com/elkraneo/html5

I told you: sane people don't want to program nor anything close to it.

Is HTML hard?

Of course, for HTML to be such a great language, you have to know it. I mean really know it.

Semantics, accessibility, SEO, browser compatibility and default styling, new tags, deprecated tags, specific attributes related to language and time, forms, performance optimization, metadata, media resources...

Even without considering framework-generated "tag soups", there is a huge gap between a good HTML markup and a great one.

It would be a mistake to consider HTML (and CSS) to be the easy part of web development. The problem is that you need to know these languages well to realize that.

JavaScript is hard. Why does everyone know that? Because before you get anything to work, you will deal with countless red errors blocking your entire project. Only after a painful debugging your code will run correctly.

console log all the ways

You can't fail with HTML. You can write tag soup, bad forms and follow none of the good practices, but it won't fail, because of its fundamental resilience.

The first time you write JavaScript, it's a mess. The first time you write HTML, you feel like a web genius.

It's only with time and knowledge that you realize you were not the genius: HTML designers were the geniuses, and they gave you a great tool which will require a lot of practice and patience to get really right.

The permissiveness of HTML gave the opportunity to contribute to the web to a lot of people and probably has to do with how far the vision of Tim Berners-Lee has come. But for professional developers, it comes with the responsibility to not rest on this apparent simplicity, and really master this powerful language.

The identity crisis of web languages

It is important how we call things. It's very frustrating to see the HTML/CSS part of a project devalued so often when you know its critical aspect. It's excruciating hearing front-end developers "not caring about CSS", while displaying pixels on a screen is almost the definition of the job.

Maybe calling HTML a programming language makes it more worthy of attention to some people? It would be naive not to realize the biases in salaries and even the sexism related to this matter. You know, because HTML/CSS is the presentation part, and that's... feminine?

Face Palm

On the other hand, I understand that reading that HTML is a programming language can bother some people, including myself. Not because I think programming languages are better. Because I don't want HTML to be a programming language.

We are just building things

During my courses I often use the term development language. I don't see it used often in english. In french we say "langage de développement" and I think that's beautiful.

With that term, you can reunite HTML, CSS and JS without everybody freaking out. From the Cambridge Dictionnary:

Develop: to invent something or bring something into existence

While it seems the debate about HTML/CSS being programming languages will last until the end of datetimes, the fact that they are used, sometimes alongside JS, to "bring something to existence", does not seem controversial at all.

developers developers developers

We are all developers.

Who cares if you're programming or not? The only thing that matters is the quality of what you're building.

I guess we just have to make non-programming cool again.

💖 💪 🙅 🚩
bcalou
Bastien Calou

Posted on October 21, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related