Live data from Hacker News

Faster, Better DOM manipulation with Dommy and ClojureScript

blog.getprismatic.com

1–10 of 51 posts

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#4
post #2

Author here. Happy to answer any questions/concerns.

Did the speedup of script execution have other costs? One would imagine that using Clojurescript would incur some other costs somewhere. This feels like a free lunch somehow.

ClojureScript generates a little more ephemeral garbage than native JavaScript and the Clojure data structures are slower, but in reality, the bottlenecks tend to be things which cross the DOM barrier and macros can make those bits much more efficiently. So it's not a free lunch, but it's very very cheap and tasty.

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#5
post #2

Author here. Happy to answer any questions/concerns.

does Dommy provide a pure API on top of the DOM? (e.g., lens based) I don't immediately understand how one would make that performant given that the DOM is a mutable data structure.

edit: WebFUI[1] is one clojurescript project trying to provide a pure interface for dom manipulation; there are others.

[1] https://github.com/drcode/webfui

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#6
post #2

Author here. Happy to answer any questions/concerns.

does Dommy provide a pure API on top of the DOM? (e.g., lens based) I don't immediately understand how one would make that performant given that the DOM is a mutable data structure. edit: WebFUI[1] is one clojurescript project trying to provide a pure interface for dom manipulation; there are others. [1] https://github.com/drcode/webfui

No. We're not trying to do something pure on top of the DOM. That isn't feasible for performant manipulation. Being functional is about more than just immutability.

We use standard manipulation.

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#7
ClojureScript is so different from JavaScript that it makes sense write a more native DOM library for it. As someone with a lisp background, it's very cool to see a high-profile company like Prismatic using it.

However, macros for javascript are being worked on. sweet.js is coming along really well, and just needs to continue ironing out bugs and maturing. http://sweetjs.org/ I believe that it could have a profound effect on JavaScript, such as parsing selector string at expand time.

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#8

ClojureScript is so different from JavaScript that it makes sense write a more native DOM library for it. As someone with a lisp background, it's very cool to see a high-profile company like Prismatic using it. However, macros for javascript are being worked on. sweet.js is coming along really well, and just needs to continue ironing out bugs and maturing. http://sweetjs.org/ I believe that it could have a profound e…

Other languages can totally have macros, but unless you have homoiconicity, which lisp languages do, macros aren't easy to use or support. In ClojureScript, macros are built into the language.

Re: Faster, Better DOM manipulation with Dommy and ClojureScript

#10
This is super impressive. I'm going to use this for my frontend work now. On a side note, what's the idiomatic structure, or "design pattern" for cljs front end code? I would assume something based on MVC, with models comprising of atoms with watches, Views consisting of hiccup templates and controllers gluing dom events to models and views. Am I close?
Post reply on HN