Comment by jraph

6 hours ago

In the linked article:

> you should master the HTML programming¹ language

The footnote reads:

> 1. This is a common debate - but for simplicity sake I'm just calling it this.

It's not really a debate, HTML is a markup language [1], not a programming language: you annotate a document with its structure and its formatting. You are not really programming when you write HTML (the markup is not procedural) (and this is not gatekeeping, there's nothing wrong about this and doesn't make HTML a lesser language).

To avoid the issue completely, you can phrase this as: "you should master HTML" and remove the footnote. Simple, clean, concise, clear. By the way, ML already means "Markup Language", so any "HTML .* language" phrasing can feel a bit off.

[1] https://en.wikipedia.org/wiki/Markup_language

What happens if I simply add an iterator mechanism to HTML (well, I guess we need variables too)? Is it no longer a markup language here (I won't add anything else):

<for i=0; i<1; i++> <html> </html> </for>

Better question, why don't we upgrade XML to do that?

  • That's basically the design of PHP with different syntax. <?for($i=0;$i<1;$i++){?> <html></html> <?}?>

    Nobody uses PHP this way any more though — people treat it like Python or Node and write the entire codebase inside a big <? block

    JSP is similar with different syntax again — nobody uses JSP either

    I think ASP too but I never used that

    • You could have some client side JavaScript handle your for nodes as well. That's how I imagined what OP described actually.

      > Nobody uses PHP this way any more though

      Well… I have bad news.

      I do, for one :-)

      4 replies →

    • If HTML was never able to be the full solution, then I guess if I had to expand on where I'm going, then what the heck are we even doing with this html thing? Either MAKE IT like PHP, ditch it, or do something, anything.

      1 reply →

I dunno, you're being pedantic :) Yes yes, the name clearly ends up "Markup Language" so yeah, with a very strict definition of programming languages, HTML is not one of them.

But if we use a broader definition, basically "a formal language that specifies behavior a machine must execute", then HTML is indeed a programming language.

HTML is not only about annotating documents or formatting, it can do things you expect from a "normal" programming language too, for example, you can do constraints validation:

    <input name="token" required pattern="[A-Z]{3}-\d{4}" title="Must match ABC-1234 (3 uppercase letters, hyphen, 4 digits)" placeholder="ABC-1234">

That's neither annotating, just a "document" or just formatting. Another example is using <details> + <summary> and you have users mutating state that reveals different branches in the page, all just using HTML and nothing else.

In the end, I agree with you, HTML ultimately is a markup language, but it's deceiving, because it does more than just markup.

  • I'm not sure we can call your parent comment pedantic. They're just being correct. Is it pedantic to say that fish is not a fruit? It's just correct to do so.

    If anything, it is the act of stretching the definition of "programming language" so much that it includes HTML as a programming language that we should call pedantic.

  • One threshold is "can you write a program that might not complete?" You can't in SQL, which makes it less of a programming language than, say, FORTRAN.

    If you look at the HTML 5 spec it is clear that it's intended to be a substrate for applications. The HTML 5 spec could be factored into a specification of the DOM, specification of an x-language API for the DOM and a specification for a serialization format as well as bindings of that x-language API to specific languages like Javascript.

    • > If you look at the HTML 5 spec it is clear that it's intended to be a substrate for applications

      That's the saddest thing I've read today.

      (arguably not a terribly sad day)

      2 replies →

  • > I dunno, you're being pedantic :)

    It might be, I'm usually not, but this is all xhtml.club and this footnote are about, might as well be correct :-)

    Constraint validation is still descriptive (what is allowed)

    All details and summary are doing is conveying information on what's a summary and what's the complete story, and it has this hidden / shown behavior.

    In any case, you will probably find something procedural / programming like in HTML, but it's not the core idea of the language, and if you are explaining what HTML is to a newbie, I feel like you should focus to the essential. Then we can discuss the corners between more experienced people.

    In the end, all I'm saying is: you can just avoid issues and just say "HTML" without further qualifying it.

I think that it is a debate, and it depends on the role of HTML in your system.

If all you're doing is using HTML to "annotate a document with its structure and its formatting", then yes, I'll accept that it's not quite programming, but I've not seen this approach of starting with a plain non-html document and marking it up by hand done in probably over two decades. I do still occasionally see it done for marking up blog posts or documentation into markdown and then generating html from it, but even that's a minuscule part of what HTML is used for these days.

Your mileage my vary, but what I and people around me typically do is work on hundreds/thousands of loosely coupled small snippets of HTML used within e.g. React JSX, or Django/Jinja templates or htmx endpoints, in order to dynamically control data and state in a large program. In this sense, while the html itself doesn't have control flow, it is an integral part of control flow in the larger system, and it's extremely likely that I'll break something in the functionality if I carelessly change an element's type or attribute value. In this sense, I'm not putting on a different hat when I'm working on the html, but just working on a different part of the program.

  • > React JSX, or Django/Jinja templates

    Those are not HTML. PHP neither, even when used as a templating language for HTML.

    > htmx endpoints

    Not really familiar with htmx, but I would say this is HTML augmented with some additional mechanisms. I don't know how I would describe this augmented HTML, but I'm not applying my "not programming" statement to htmx (I probably could, but I haven't given enough thoughts to do it).

    > In this sense, I'm not putting on a different hat when I'm working on the html, but just working on a different part of the program.

    I agree with this actually. I wouldn't consider that writing HTML (or CSS) is really a separate activity when I'm building some web app.

  • > In this sense, while the html itself doesn't have control flow, it is an integral part of control flow in the larger system

    That's correct but I don't see what it has got to do with the question of whether HTML is a programming language or not.

    Strings do not have control flow but strings are integral part of larger programs that have control flow. So what? That doesn't make strings any closer to being programming languages.