Hacker News new | ask | show | jobs
by diego_sandoval 1105 days ago
> The same could be said about plain HTML/CSS though.

Genuine question: How much of the complexity of working with HTML/CSS is unnecessary and how much is inherent to the problem they solve? Is it as bad as with Javascript?

I would say that we, for the most part, have a very clear idea of how we could (theoretically) replace Javascript with something much better.

I don't know of alternative layout languages, so I don't know how good CSS is in comparison. And what could we replace HTML with? My general appreciation, from my ignorance, is that they are not that bad.

4 comments

TeX solves the core problem of responsive layout using just a small handful of primitives. No one seems to have noticed that FlexBox is mostly a copy of the TeX boxes and glue model.
I believe the complexity often stems from historical development as well. There are often multiple ways to achieve the same thing or workarounds for specific browser. Either you have HTML tags to format something or you can do it with CSS. CSS is difficult, because there are obtuse rules. The order of CSS-rules is relevant as well as the specificity (which is hell in my opinion).

You can write an extremely clean and awesome HTML/CSS document. But you very rarely find that kind on the web.

I think we neglected being more careful here because browsers became more and more forgiving. So they often render as intended, but not really like it is stated in the often invalid document. That made browser insanely complex as well. No new browser will ever be successful if it would be parsing strictly. More than half of all websites would probably stop working correctly.

I believe you could replace both HTML/CSS with something much more clear and as capable. But on the other hand we should be glad that we have standards like this and perhaps we shouldn't let perfect be the enemy of good.

Perhaps JS doesn't qualify as good, but on the other hand I think its success speaks for itself. It even grew beyond the browser and some electron apps are extremely well received (apart perhaps by your system memory). Despite that, it is a scripting language and it should mostly be used as that. Since every browser comes with a parser, it is a quite mighty tool to have.

Python is a similar contender. It is the ultimate choice for certain domains and I don't see that changing any time soon, even if python isn't perfect itself.

Seriously, every time people complain about CSS and HTML I think about how much work it is to support all the localisation and layout stuff they do. Managing massively different sized screens as elegantly as them is hard and yeah, it's still not that elegant or easy, but I haven't used anything better that didn't sacrifice something for it.
Every time I have to build a UI in canvas, I yearn for all the conveniences CSS and the DOM provide. Do people even realise how much trouble it is to make text wrap within a given space?
It is, but yet thousands of videogames have been doing this for decades...
The UI of many games break if you scale the text though, if it offers such a feature (e.g. text won't fit in boxes). This is also the case on the web at times, but much less often.
And most games will use an engine like Unity or Unreal so they don't have to re-invent the wheel. HTML and CSS may not be perfect, but they've been battle tested for a good 30 years and have had improvements added. No need to re-invent that wheel.
Absolutely, I totally agree. Layout development has gotten a lot better with Flexbox, Grid, and the new Container Queries.
> How much of the complexity of working with HTML/CSS is unnecessary

Talk to Google.

They are the ones aggressively increasing the API surface of the Web (driven largely by commercial reasons e.g. ChromeOS) often without much thought to the security, privacy and performance implications.