3 ms·
I wouldn't mind throwing HTML, CSS, and JS away and replacing it with a single language, perhaps something more functional. I'm imagining writing all my websit
by Zelphyr 6y ago
I wouldn't mind throwing HTML, CSS, and JS away and replacing it with a single language, perhaps something more functional. I'm imagining writing all my websites and web apps in something like Clojure:
(html
(head
(title "My Website")
(style
(heading {:weight bold :size 24}))
(body
(heading {:level 1 :title "Welcome To My Website!"})
(nav
(item {:title "Home" :link "/home"})
(item {:title "About" :link "/about"})))
(script
(doseq [item nav]
(if (= current-page (:link item)) (highlight item)))))
Note: Untested code and there's probably better ways of doing it in actual Clojure.
- deergomoo 6y agoYou should check out Elm[0] if you haven’t already. It’s also worth noting that things like JSX and Vue templates are just syntactic sugar over render functions that look very similar to the example you gave (albeit less terse). John Sundell also has a Swift DSL[1] for generating HTML in a similar fashion, though Swift on the server is still very niche. Obviously these all still ultimately produce HTML, but they do offer some nice accordances for the developer. [0]: https://guide.elm-lang.org/ https://guide.elm-lang.org/ [1]: https://github.com/JohnSundell/Plot https://github.com/JohnSundell/Plot