|
|
|
|
|
by bshimmin
4488 days ago
|
|
> Is it a rhetorical question were I to ask which of the two versions, Om + Clojurescript vs vanilla JavaScript, looks more pleasant? Well, the JavaScript is harder to read because of the colour choices and the fact that at least in part it looks to have been compiled from CoffeeScript (or something else). Conversely, the ClojureScript is probably quite hard to read if you don't know what "peek", "reify", or "did-mount" mean. |
|
* reify is the creation of an anonymous type instance, implementing 1..n protocols (not entirely dissimilar to an anonymous class in java). This could also have been done with a deftype (no difference in efficiency, but Om's creator seems to prefer reify):
* peek's a bit more complex because it requires knowledge of interesting features (?) of Clojure collections: all clojure collections are immutable, and often built with conj(oin). conj "adds an item to a collection", but where it does so depends on the collection (and its efficiency profile): (conj '(1 2 3) 0) -> '(0 1 2 3) but (conj [1 2 3] 0) -> [1 2 3 0] (lists can be efficiently extended from the head, vectors from the tail). `peek` essentially returns the last conj'd item, so on lists it's equivalent to `first`, on vectors it's equivalent to `last` (but faster)[0] http://facebook.github.io/react/docs/component-specs.html#mo...
[1] https://github.com/swannodette/om/wiki/Documentation#wiki-id...