Hacker News new | ask | show | jobs
by gmiller123456 3061 days ago
I wonder if I'm alone in the opinion that whatever method is used to create a complex layout, the method needs to be Turing Complete. I can understand the appeal of being able to create some tags and not having to worry about what happens after that, but you really only end up with a good design if you're just trying to do something simple. We often see people so devoted to the idea of CSS they end up with something incredibly complicated that could have been done in just a handful of lines of code.

edit: Fixed spelling of "Touring"

2 comments

I disagree. It is possible to generate a wide variety of layouts using this and other purely declarative approaches. If producing a layout requires the use of "Turing-complete" semantics, then JavaScript is available for the purpose. I would argue if your layout becomes that complex you might consider simplifying.

There is a long-standing trend of adding scripting into declarative environments to allow greater capability. More often than not this becomes yet another avenue for exploitation by bad actors. As an industry we should learn from our mistakes and resist the use of executable code into static documents.

I'd agree with you if web pages were "static documents", but they aren't and never were. They've always had to adjust to different screen sizes, and quickly became interactive applications, and now have to adjust to radically different pixel densities.
And all of that works just fine with CSS. CSS has problems, but more to do with scoping or lack of a grid-based layout system (until now).

When I see devs saying "Just do it all in Javascript" I have to assume they aren't actually that familiar with CSS. First off Javascript simply manipulates CSS properties anyway when it comes to styling, and writing a system that completely ignores CSS and renders its own way is far more complex without any clear benefit.

I think you misunderstood my response, in what you were replying to I was just pointing out web pages are not static documents. I in no way intend to suggest that JavaScript can solve all of the problems with CSS, and also don't agree that the grid system will help much. IMHO the biggest thing missing from the CSS/HTML/JavaScript system is the ability to determine how much space is required to display certain text or elements, vs how much space is available to display them, and the ability to make decisions based on that (recursively) on how other elements are displayed.
Yeah. And then you actually want to create a layout that can display images properly, and you’re screwed.

There’s a reason all the “powerful CSS layouts” are all poor re-iterations of printed pages. Once you want actual layout, you end up carefully positioning everything with Javascript.

And by actual layout I mean things like Sencha (easily half of which still cannot be implemented in CSS without)

It's "Turing complete", named after the mathematician and computer scientist Alan Turing.

https://en.wikipedia.org/wiki/Alan_Turing