News for hackers. Stuff that matters.
Re:Writing CSS Algorithms by pault on Wednesday February 20, 2019 @01:26AM (#19206033)
Algorithm? I see a design process but using the word algorithm to describe a CSS layout is a bit baffling to me. It's like creating a library of json snippets and calling it a json algorithm.
Re:Writing CSS Algorithms by tobr on Wednesday February 20, 2019 @01:39AM (#19206081)
Should have seen it coming after “object oriented CSS”, “functional CSS” and “immutable CSS”, none of which has anything to do with OOP or FP.

What’s next? CSS data structures?

Re:Writing CSS Algorithms by ivanhoe on Wednesday February 20, 2019 @06:31AM (#19207124)
While these are really just boilerplate snippets for some common layouts, you can easily have an actual algorithm for CSS, too. For instance complex recipes/tricks for selecting just some of the nodes using different combinations of n-th child and sibling selectors are definitely algorithms, offering very generalized list of steps to follow to implement the logic on any number of elements.
Re:Writing CSS Algorithms by pault on Wednesday February 20, 2019 @09:26AM (#19208000)
I guess I can concede that. If you can compose an algorithm using a flow-based visual programming language I suppose you can consider a series of selectors an algorithm for applying styles, but by that logic every selector is an algorithm.
Re:Writing CSS Algorithms by ivanhoe on Wednesday February 20, 2019 @01:30PM (#19210555)
For me algorithm is simply an explanation/strategy of a list of steps needed to implement some logic and/or solve some problem. IMO it can even be a paper with IKEA instructions how to assemble a desk. Might not seem so, but if you'd tried to program a robot to do it, you'd probably call those steps the desk building algorithm. However I wouldn't call every css selector an algorithm on its own, just like print() function is not an algorithm - but if we have a routine to print say only odd numbers, that is definitely the (very simple) algorithm. Equally if you come up with a recipe how to combine css selectors into a series of rules to select e.g. N particular elements in an arbitrary list of DOM nodes, in my mind it's the full-blown algorithm too. Just my $.02 of course...
Re:Writing CSS Algorithms by dahart on Wednesday February 20, 2019 @10:38AM (#19208668)
I’d agree using the word ‘algorithm’ feels a little misleading from the point of view of a programmer. But just to defend the glass half full point of view: it does feel reasonable to call the design processes in the article “recipes”, and once something is a “recipe”, “algorithm” feels more synonymous. Maybe the way to look at this article is that “algorithm” refers to what the person is doing, not to what the CSS is doing.
Re:Writing CSS Algorithms by tobr on Wednesday February 20, 2019 @11:18AM (#19209072)
That’s not really what the article is saying, as far as I can tell. It describes the process for writing a CSS algorithm, not an algorithm for writing CSS. So in this use, the algorithm is something the CSS is doing, not the person.

I think the issue is that an algorithm is typically an unambiguously defined, imperative solution to a problem. It involves step by step instructions that happen in a certain order. Even though you can argue that these CSS patterns are clearly defined solutions to specific problems, the fact that there are no steps involved, no procedure, nothing imperative, makes it odd to call it an algorithm. There are other established words to use, like pattern, utility, hack.

There’s added confusion since CSS obviously involves actual algorithms, like how the engine calculates selector matching, specificity, layout, filters, etc.

Re:Writing CSS Algorithms by dahart on Wednesday February 20, 2019 @12:28PM (#19209771)
I hear you and I think you're making a reasonable point, but just for fun, I'll double down on the devil's advocate defense.

I still think it's fair to include the person's activity in the broader idea of what constitutes an "algorithm" here, and I believe the article's language does support my interpretation.

First, the author explicitly acknowledges that "algorithm" is being somewhat misused compared to it's conventional programmer usage, and gives a bunch of reasons why she thinks it's still "useful" to co-opt this word. Some of the point behind this article is precisely to explain and defend her use of the world "algorithm" in this context. Language is fluid, and that's okay & sometimes fun & useful & interesting, right?

Also, there are steps listed in the article, such as defining boxes for layout, then naming them, then listing changes, then determining dependencies. That counts as step-by-step instructions, I think.

The author also said: "A CSS algorithm is well-defined declaration or set of declarations that produces a specific styling output." and "Phrased another way, a CSS algorithm is a very intentional and well thought-out utility pattern."

That's pretty explicitly including the design & thinking in the "algorithm" as I read it, don't you agree?

> an algorithm is typically an unambiguously defined, imperative solution to a problem

The English definition of an algorithm is closer to "a process or set of rules to be followed", and that's basically the extent of it. We programmers can use the word to mean more specific things if we want, but can't claim that the word always means the same thing to others as it does in our expert domain, or even that it always means the same thing in our domain.

I'd have to disagree with the qualification of "imperative", math algorithms and functional algorithms are widely accepted as algorithms by programmers. Unambiguous is always desirable, but can't be the definition. The words "process" and "rules" imply minimal ambiguity.

Re:Writing CSS Algorithms by tobr on Wednesday February 20, 2019 @02:37PM (#19211224)
I have to admit, you're doing a pretty good job of playing the devil's advocate. I absolutely agree that any word can be used in creative and novel ways and to express new ideas, I just find this example to be much more confusing than useful. :)

FWIW, I've been trying to find examples of things conventionally called algorithms, but which are not in essence imperative (in the sense that there are multiple operations that must happen in a certain order - "procedural" is perhaps a more precise word than "imperative"), but I can't really find anything, so I would like to insist that it's one of the defining characteristics of an algorithm.

Re:Writing CSS Algorithms by dahart on Wednesday February 20, 2019 @03:13PM (#19211526)
Thanks, and I agree with you too, css algorithms can be confusing for most of us and useful for some at the same time. ;) I’ll concede to order and dependency in an algorithm being important, you’re right, it doesn’t feel right to exclude.
Re:Writing CSS Algorithms by parthdesai on Wednesday February 20, 2019 @10:54AM (#19208841)
Yeah, i personally thought this post would be about actually designing algorithms that determine where the HTML elements are rendered on the screen.
Re:Writing CSS Algorithms by midgetjones on Wednesday February 20, 2019 @04:32AM (#19206757)
A heuristic maybe?
Re:Writing CSS Algorithms by ArrayList on Wednesday February 20, 2019 @08:09AM (#19207510)
"Styleless"