Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am very interested in the s-expression stylesheet format. I think it would be preferable for me at least to CSS, especially the code for alternating rows; I imagine that people write programs in this language might have well done away with the need for CSS preprocessors that we have today. This also makes me ask a question - why are there no Lisp-like CSS preprocessors?

I am reminded of the proposal to markup webpages with s-expressions rather than XML, though there are packages available (actually just macros) in CL that let you write websites this awy.



Be careful what you wish for. The fact that CSS can be so easily declaratively analyzed is the reason why it can be made reasonably fast at all. CSS has some key restrictions—for instance, that attributes always inherit top-down and never bottom-up—that makes it amenable to parallelism (which is no longer a theoretical concern, as parallel CSS implementations are starting to ship). Adding a full programming language would have the potential to make styling much slower than it already is.


> as parallel CSS implementations are

Is someone else outside mozilla ready to ship a parallel CSS engine any time soon ?


Not that I'm aware of.


You might want to check out Garden [0], a meta-css library for clojure(script).

[0] https://github.com/noprompt/garden


Just think: were HTML replaced with SXML, JavaScript with Common Lisp & CSS with something like LASS, we might have pages which look like this:

    (html
     (head
      (style (let ((bg #x0088ee)
                   (fg #x00ee88))
               (body (background bg)
                     (foreground fg))
               (body.inverted (foreground fg)
                              (background bg))))
      (script (defun invert ()
                (with-slots (class-list)
                    (get-element-by-tag document 'body)
                  (setf class-list
                        (if (find 'inverted class-list)
                            (remove 'inverted class-list)
                          (cons 'inverted class-list)))))))
     (body
      (button (@ (on-click (invert))) "Click me")
      (p "This is some text.")))

I contend that this is a massive improvement.


There is also LASS[1] for Common Lisp. You use it either as a library for generating CSS, or as a standalone preprocessor.

[1]: https://github.com/Shinmera/LASS




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: