Hacker News new | ask | show | jobs
by blowski 861 days ago
> HTML is the native language for describing UI in the browser

In the same way that assembler is the native language for giving instructions to the CPU. In practice, it is of zero importance, because there are powerful abstractions built on top of it, with wonderful benefits once you’re building anything more complicated than one-page documents.

5 comments

That's not the same because the abstraction a mature computer language provides is nearly complete (not totally complete, of course, but the situations where you ought to go digging through machine code or lower are pretty rare).

Outside of games, almost all the frameworks people use don't try to do that -- you are essentially trying to write HTML, but using the syntax of a different language, or each HTML thing in a thing from a different language. (Flutter is the exception -- it really does try to provide a complete abstraction, though it's certainly not without its tradeoffs.)

Abstractions are great, as long as you understand their performance implications. Some are essentially free, some are surprisingly costly if you hold them wrong.

Sadly, there's no way around understanding HTML and CSS when you need to troubleshoot what a high-level framework built for you. (Or maybe there is! Render everything using WebGL, the way Flutter does, and Flash did before it. But it's a different kettle of fish.)

That is what's called a leaky abstraction.

Think, how often do you write a javascript code and think to yourself to debug it by understanding the underlying assembler code. I'd guess it's nil.

But abstractions to html leaks a lot.

Leaky abstractions are never good as now you have to think about your cool framework and the underlying library.

Open the browsers dev tools and you see HTML. Read MDN and you see HTML. Constantly translating back and forth between that and another language isn't worth it.
Though if there was a better language to describe the UI which is as performant, widely supported and documented as HTML, I can easily see people using it. Maybe someone will start that project today based on my comment, and a decade later browsers will integrate it natively because it's such a success and everyone is using it :).
It's quite important for accessibility.
I've found that web accessibility often calls for nice templates and abstraction, not less, because you often need to do some dynamic rewriting.

For example, in a world where components are embedded into different places on a website and where users might submit rich text content, you have to rewrite their headers (h1...h6) to fit with accessibility guidelines.

problem is, the most important "abstractions" for describing the UI are not built "on top of" HTML, but along side it (CSS and to a limited degree JS). the relationship between contemporary "frameworks" and HTML is not like that of C and assembler or even Rust and assembler. It is more like that of a driver of a vehicle that has each of a gasoline, electric and steam powered motor, and must constantly pick which one to use for a given situation (sometimes two and occasionally all three).