Live data from Hacker News

CSS is unnecessary given a layout language

pchiusano.github.io

111–120 of 183 posts

Re: CSS is unnecessary given a layout language

#111
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 see where you are getting into... But not pure, please, but reactive. One creates events on HTML and Javascript (there are a few by default), CSS filters, maps, and uses them.

Re: CSS is unnecessary given a layout language

#112
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?

When I posted that comment My view was that layout would still be primarily driven by higher level style properties, but after I posted I though about it some more and I realized if done properly you could probably the css value language could theoretically do it all. If it were to generate values for the complete layout, bypassing the higher level layer, effectively telling the display engine that everything was absolutely positioned and in the right place already.

I don't think I would advocate for that to be the standard way to implement layout, but it should be at least possible.

Similarly I think the system should be capable of specifying a table where each cell has a background colour corresponding to its position in a Mandelbrot set. I don't think people should be doing that normally either, but I certainly think it should be something that is capable.

Re: CSS is unnecessary given a layout language

#116

In Servo we've been able to get a lot of parallelism out of the basic building blocks of CSS. Any replacement would have to have a good story here. "Just write your layout in JS" is not good enough and would be a large performance regression.

Constraints based system is the way to go. And yes, it should be native replacement for CSS- a DOM property called constraints instead of style. Unfortunately, JS has to be used for now. [1] As for parallelism, we still have web workers for the solving of constraints computations.

http://gridstylesheets.org [1]

Re: CSS is unnecessary given a layout language

#117
post #21

I'm not really sure I understand what the point of this message is. The point of separation between CSS and HTML is not that "designers" are idiots. Nor is it that developers are poor designers. The idea is strictly to keep the data separate from any other concern. This is broken all of the time by all sorts of grid based elements and such. But the idea does seem decent, if a touch naive. That is, to Spolsky's credit…

The thing is HTML is not layout free if you use it as intended.

For instance different layouts are defined for table, span or div tags. The same goes for presentation, where h1/h2/h3, input or select tags have a default presentation. You can override most of these defaults (some are still pretty hard to override), but it's still baked in; would your CSS be ignored or not loaded for any reason and you're back on the defaults.

Cleanly separating data and presentation into HTML and CSS only works if you ignore all the semantic tags and use div everywhere. I personally gave up a long time ago on semantic html, that's not the opinion I hear the most.

Either way, I think most people see HTML as base layer with data, presentation and baked in behaviors, and CSS and JS as a enhanced layer on top of that.

Re: CSS is unnecessary given a layout language

#118
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 see where you are getting into... But not pure, please, but reactive. One creates events on HTML and Javascript (there are a few by default), CSS filters, maps, and uses them.

The part of the system I was talking about would be a static component beneath the level of scripting and events. At that level the document can be considered a static snapshot of the state. The evaluation of each of the property values would be single expressions that could draw upon the state as input and produce style properties as a result. There should be no lifetime of the execution beyond that single evaluation. As an implementation detail, this would be extremely amenable to parralelism and memoization. to make things perform well.

Even though you have things like :hover and transitions in a document that can dramatically change what you see onscreen, the Document itself is unchanging. Think of it as a many-dimentional thing. Nothing changes when you hover over an element, but your rendered viewpoint is now drawing the space in which :hover is true.

Scripts are things that can potentially change the Document itself.

Events are things that happen related to the viewpoint renderer. it would be entirely possible to define something at a lower level to indicate that an event is capable of occurring via the styling mechanism, but what actually happens would be up to the viewpoint renderer.

Consider the case of an event occurring on the end of a transition. The triggering mechanism is the viewpoint finishing the transition, and it is up to the engine driving the viewpoint to trigger the event.

The styling behaviour would merely indicate that a transition would be requested on certain elements.

Re: CSS is unnecessary given a layout language

#119

Earlier quoted context omitted.

> That is, to Spolsky's credit, the point of HTML being completely layout free is supposed to be the compelling feature. Except that it isn't. If you want to do anything entirely non-trivial, you have to annotate your HTML with classes and ids, and then hook into this using a complicated declarative language. But, at this point, there is no abstraction gain from ... over floating_figure(...) Functions are fine abstra…

> But, at this point, there is no abstraction gain from > ... > over floating_figure(...) There is no abstraction gain, because you are using a presentational class name. It should not be "floating_figure", "big_red_text" or anything of the kind. What it could probably be is "feynman_diagram" or something simmilar describing what's so special about this particular element, not the looks or placement of it. And then i…

The idea of semantic class names is reasonable, but even that ends up needing to be ridiculously contrived with things like "feynman-diagram-wrapper."

Re: CSS is unnecessary given a layout language

#120

I actually like CSS as it is now, and it's getting better ( cough , flexbox). Am I the only one who finds CSS incredibly hard to master, though? I've been writing CSS for years and I still feel like a newbie sometimes, and feel like I'm just tinkering with random attributes until it looks right.

I don't mean to be rude[0], but what do you find so difficult about it? The box model makes a lot of sense, and once you understand that you're most of the way there. I still Google for less-common syntax (e.g. adding a strikethrough style to text) from time to time, but most of it is internalized by now[1]. Code School[2] was great when I was first ramping up as a developer. I do also have a great memory[4] for tiny…

> my wife constantly complains about how I can remember "all those coding things" but can't recall what she asked me to do This happens to me all the time. I thought about maybe writing an app that records all the time and then will play you back the last 30 seconds when you press a button.

Probably too resource intensive to be usable though.

Post reply on HN