News for hackers. Stuff that matters.
Re:Writing HTML with Racket and X-Expressions (2019) by TylerE on Wednesday April 01, 2020 @01:16AM (#22745915)
Not a fan. Given that in a template context the first atom will always be a symbol, all the : is just redundant. I despise visual noise.
Re:Writing HTML with Racket and X-Expressions (2019) by fnordsensei on Wednesday April 01, 2020 @03:10AM (#22746431)
The `:` is not visual noise, it indicates that it is a keyword. Without it, you're indicating that you're writing a symbol. Symbols are evaluated, so keywords is a better choice given that they always are what they say they are, whereas you could define `div` to mean `<p>`, point to a function, or any number of other things.

You could write a macro to use symbol names literally, so that `div` always means `<div>`, but then you'd have a macro where none was needed, and you'd have no obvious way of using symbols in a non-literal/evaluated way.

Fulcro[1] lies little closer to what you're after. The above would be:

  (div 
    (p "I am a component!")
    (p :.someclass
       "I have " (strong "bold")
       (span {:style {:color "red"}} "and red") "text."))
This is since Fulcro defines the element tags as functions, which are called in order, rather than as a data structure that's interpreted (a la Hiccup).

The immediate and obvious benefit of Hiccup over the function hierarchy is that Hiccup can be trivially (and safely) seralized/deserialized.

1: https://github.com/fulcrologic/fulcro

Re:Writing HTML with Racket and X-Expressions (2019) by fulafel on Wednesday April 01, 2020 @01:18AM (#22745927)
The advantage is that you can include normal Clojure expressions in it without any special syntax. Also lets you compose Hiccup data and forms without having two mental models of the data representation. Worthy tradeoffs IMO.