News for hackers. Stuff that matters.
Re:Bringing functional to the frontend – Clojure and Clojure... by dustingetz on Thursday January 17, 2013 @03:59PM (#5075169)
the dom is a mutable data structure and the native (fast) dom apis expose mutable interfaces. so dynamic sites (you know, single page html5 apps doing all sorts of client-side dom manipulation) are either going to be slow, or are going to have an imperative core, which is where you need functional programming the most ;(

maybe HTML6 will have native functional dom manipulation and we can rewrite all our favorite javascript libraries to expose functional interfaces. one can dream.

Re:Bringing functional to the frontend – Clojure and Clojure... by vemv on Thursday January 17, 2013 @06:12PM (#5075882)
I'm afraid you're confusing data structures (such as vectors, sets and maps) with the document model object.

Not even in JS the DOM and objects are the same - some properties of the DOM have 'magical behavior' attached.

ClojureScript does not provide any functional interface to the DOM - that would involve a Haskell-like model of programming (monads etc), which Clojure programmers rarely do in practice.

Re:Bringing functional to the frontend – Clojure and Clojure... by dustingetz on Thursday January 17, 2013 @07:08PM (#5076196)
i don't think i'm confusing anything. Clojure programmers love their persistent data structures, and in a browser environment, the most important data structure - the document model object - is not persistent and cannot be made persistent in a performant manner because it is a native api.

there is ongoing research into dom manipulaton in clojurescript - Conrad Barski presented one approach[1] at Conj 2012 where the dom is mirrored in clojurescript data structures, and then 'synced' with the dom - so that way the imperative ickyness is tucked away in the sync method - it remains to be seen if that can be made fast enough until we get a native persistent interface to the dom.

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

Re:Bringing functional to the frontend – Clojure and Clojure... by vemv on Thursday January 17, 2013 @10:29PM (#5076918)
Characterizing side-effects as a series of supposedly functional transformations doesn't sound quite alright to me.

That said I'm curious about such an approach.

Re:Bringing functional to the frontend – Clojure and Clojure... by dustingetz on Wednesday January 23, 2013 @07:00PM (#5106179)
Modeling side effects as transformations on data is what functional programmers do all day. I'm not talking about monads - simple things like inserting keys into a map and manipulating collections does not rely on side effects in functional languages.