Live data from Hacker News

CSS is unnecessary given a layout language

pchiusano.github.io

91–100 of 183 posts

Re: CSS is unnecessary given a layout language

#91
post #72

Earlier quoted context omitted.

1. Someone _has_ come up with the One True Layout System. It's just that most people like to pretend TeX doesn't exist or, when they grok the box-and-glue layout model, try to reinvent it from scratch.

Someone yell at me if I'm wrong, but isn't TeX designed for paged content? That means while TeX might work amazingly for paginated content, single page apps, or really any non-paginated content, is very much a screwdriver where a hammer should be used scenario.

Overall it is, but when the above commenter mentions box-and-glue, they're talking about the building blocks of the line breaking algorithm TeX uses (you can read about it in this paper: http://onlinelibrary.wiley.com/doi/10.1002/spe.4380111102/ab... ). The box-and-glue system is a way of expressing a layout as an optimization problem (in the paper, they talk mostly about determining line breaks within a paragraph, but the idea of minimizing badness can be extended to determining page breaks as well). A bigger concern for me is the performance of laying out any reasonably complex page — the performance we get from rendering a reasonably complex webpage today is generally much better than rendering a reasonably complex LaTeX document.

I've come across a feature request for Firefox where someone proposed to use the Knuth Plass line breaking algorithm just for text layout, but they didn't get very much traction: https://bugzilla.mozilla.org/show_bug.cgi?id=630181

Re: CSS is unnecessary given a layout language

#92

CSS is broken. I've just been watching a colleague learning HTML/CSS for the first time. HTML was easy and she has a very good handle on that, producing some nice HTML5 markup by hand very quickly. CSS has been a nightmare - mostly not because of selectors or values (that comes later), but because of basic layout issues caused by the nasty hacky layout model of CSS - in particular the concepts of floats, block and in…

Indeed CSS is broken. But, if you tried to make that case several years ago during the Great War on Table-based Layout, you'd have been absolutely persecuted. Oh how we wrangled with the utter pain that is CSS layout, only to appease the tableless zealots. I can remember wrestling for hours with simple layouts that just wouldn't cooperate cross-browser. Meanwhile, I could achieve those layouts in mere minutes with ta…

Styling is one thing, but layout tends to be intrinsically tied to the content.

This is an interesting distinction - thanks. As you say there are issues with separating layout and content, because the two can be hard to separate effectively. I think it is worth the effort though, and sometimes pays off (for example reflowing content for a mobile device). An interesting thought though that we should separate style and content, not layout and content.

As to tables, I think there were two issues mixed up in that religious war - the nasty markup of table/tr/rd, sliced images etc polluting every website when it was intended for data, and grid layouts (which it made easier). Unfortunately grid layouts were thrown on to the auto-de-fé along with sliced images and table markup, and then promptly reinvented (with much pain) by entire frameworks designed to make up for the shortcomings of CSS.

There have been very recent attempts to add grids to CSS, and hopefully they'll come to something (see link above from buovjaga) - I do think they're far more intuitive and most importantly impose a sensible structure on people attempting to lay out information.

Re: CSS is unnecessary given a layout language

#93
post #51

Graphical layout is one of the most underestimated challenges in computer science. Programmers instinctively look at the problem and thing "oh, this is logical, I'll just whip up some basic principles and layout primitives and I'll have this solved in no time!" No, you won't. Designing a layout framework is really, really hard. Designing one that is simultaneously expressive enough to handle all of the crazy corner c…

Have you used Qt's layouts? The problem with Android's layout system (if I understand it correctly) is that you specify how things are arranged relative to each other, so you never really know where something is. Added to that you have counter-intuitive behavior from things being calculated at time of addition rather than time of display (can't remember exactly, but I ran into something like that).

Qt is more declarative. I forget the function calls but in pseudocode you can do things like horizLayout.add(Text("abc").setFixedWith(12)); horizLayout.add(Text("XYZ").setExpand().setAlign(kCentered)); horizLayout.add(Text("").setFixedWidth(12)); and you get something like: [abc | XYZ | ] (where [] is the width of the layout, and | separates each element.) I've found it to be pretty intuitive.

Re: CSS is unnecessary given a layout language

#94
Browsers use DOM whether you like it or not. The rendering engines are built on eventing model. CSS is what they understand now. We can think of changing that, but given the history of browsers and HTML standard, I am not very optimistic that such changes can be pushed through easily in a reasonable amount of time.

Re: CSS is unnecessary given a layout language

#95
post #34

I don't think the problem is that CSS is an unnecessary approach to the problem of layout. It is more that it is a poor approach to the problem of layout. A layout language is unnecessary given a bytcode VM a chunk of memory, code, and an output. The balance is in capability, performance, and understanding. I have done a lot of CSS wrangling which has given me plenty of time to consider what 'a better way' could be.…

I fully agree with your distinction of selectors, properties and values - not all parts of CSS are bad. When you say "property values should be the results of expressions in a pure functional language" - which I think is a great idea - do you mean to use them to compute layout as well?

Re: CSS is unnecessary given a layout language

#96
post #51

Graphical layout is one of the most underestimated challenges in computer science. Programmers instinctively look at the problem and thing "oh, this is logical, I'll just whip up some basic principles and layout primitives and I'll have this solved in no time!" No, you won't. Designing a layout framework is really, really hard. Designing one that is simultaneously expressive enough to handle all of the crazy corner c…

I absolutely agree that the main issue is that the system can't be improved by competing concepts. The development model is really important - what started as a private hack became a designed-by-committee mess, and now is starting to become more sane in the age of HTML5, as new useful technologies and APIs are being added. The big issue is CSS (and Javascript is only slowly becoming better), which stems from the designed-by-committee (with bad taste) era - if it was designed today with Google etc. at the table, it probably would be a lot better.

People try to work around that by using pre-compilers like LESS and CoffeeScript, but those cannot fix the underlying issues. If people could design their own CSS engines, the development model would allow for rapid iteration and whatever people like the best would see broad adoption.

Reminds me of the BPF packet filter bytecode - limited, but fast and secure.

Re: CSS is unnecessary given a layout language

#98

CSS is broken. I've just been watching a colleague learning HTML/CSS for the first time. HTML was easy and she has a very good handle on that, producing some nice HTML5 markup by hand very quickly. CSS has been a nightmare - mostly not because of selectors or values (that comes later), but because of basic layout issues caused by the nasty hacky layout model of CSS - in particular the concepts of floats, block and in…

Indeed CSS is broken. But, if you tried to make that case several years ago during the Great War on Table-based Layout, you'd have been absolutely persecuted. Oh how we wrangled with the utter pain that is CSS layout, only to appease the tableless zealots. I can remember wrestling for hours with simple layouts that just wouldn't cooperate cross-browser. Meanwhile, I could achieve those layouts in mere minutes with ta…

I think part of the story was that people wanted to write cross-browser code and that limited your tools to the bits of CSS that IE supported at the time. I doubt any system you could design, even tables, would be considered anything less than broken when a majority of the market was indifferent or actively hostile to it.

Even today I regularly think "I wish I could just use X", then I remember that my current project is targetting IE9+ and that means often I can. It gives me that same warm glow you get when you remove shoes that are too tight or stop banging your head against a brick wall.

Post reply on HN