Ask HN: Why do we still build the web in XML?

7 points by mikercampbell ↗ HN
I know that JSX and HTML aren't XML, but they practically are. Yes, there are template engines, and markdown, but they both transpile to HTML, and because of that they're forced or at least limited by it's basic "isms" of structure. Or have I not been using the right ones??

Sorry, I'm tired of closing <div> tags.

12 comments

[ 2.7 ms ] story [ 45.2 ms ] thread
So, what would you suggest as an alternative?

XML fell out of SGML - trust me, you don't want to go there. So did HTML.

Also too: the IDEs I use always form closed tags. No effort needed.

If you're worried that HTML is too verbose and therefore inefficient, that's not really an issue since it's going to be compressed in transit anyways. So then the question is, assuming that the compressed representation has the maximum information density, "what format should the decompressed web page be in". I think HTML is a pretty logical format to view the structure of the page.

There are definitely plugins for auto-closing your HTML tags that will make your life easier, though.

Java Applet, wasn't that deprecated in '17?
I don't remember the exact date, but yeah, something like that. That answer was meant at least a little tongue in cheek, so I didn't look too hard at those little details. :-)

All of that said, you can still get Java in the browser working today, albeit not applets per-se, using JNLP / JWS. It takes some effort considering JWS was removed from the base JDK a while back, but there is an open source effort to keep it alive.

https://openwebstart.com/

Sorry, I'm tired of closing <div> tags.

Avoid this feeling of mental toil by using a text editor which does this for you.

I am tired of my editor closing my <div> tag when I wanted it to cover 3 other tags, and now I have to move the </div> it generated elsewhere.
A better question is why Javascript is still being used:

https://www.destroyallsoftware.com/talks/wat

https://youtu.be/D5xh0ZIEUOE

Can't we just get WASM browser APIs and then do the web in whatever programming language we want?

I hope not. And if WASM does get access to browser APIs, I hope it will be behind some sort of user-visible confirmation, to discourage causal use.

Modern web is not always user friendly, and many users benefit from ad blocking, data extraction, per-site fixeups and so on. The limited and flaky Javascript helps a lot - we can block the 3rd party script, and the pages will continue displaying without the ads; any data fetching is via browser's http engine and in most cases using JSON or XML format; and the sites are expected to support a wide range of browser features so they are often compatible with much older/newer browsers.

Now imagine web using "compiled language" model (or if you are old enough, remember ActiveX or Flash-as-entire-website): you get that immutable blob of binary code and there is very little you can do. Reverse-engineering it is non-trivial, takes a lot of time and any patches you produce may break with the next release. A trivial change like making input box a big bigger is a major effort.

(one may say: "but wait! WASM will only replace Javascript, the HTML/DOM will still stay around, so it would not be that bad!". You are too optimistic, I bet there right now, there are people who want to do it all in WASM and only need canvas from web browser.)

cough Flutter CanvasKit renderer cough
The question is, why are you writing <div> tags? Between the wide variety of semantic elements now in HTML, and the ability to create your own via custom elements, the number of times you actually need to use divs—especially "div tag soup" that we unfortunately see all too often out in the wild—has dropped to nearly nil.

Viva la semantic and expressive HTML code!

HTML over the wire, but feel free to use YAML.

JSX may have solidified the XML markup style in the developer's toolbox though. Especially with server side rendering too.