Introducing Clojure
Introducing Clojure For Java Programmers |
---|
Convenor: Ben Evans |
Participants:
|
Summary:
Language FeaturesIf we could write a new language what would we take from the existing languages we already know
<sidebar> Rafi from Twitter - Scale out - presentation at oscon -- go watch They hired ppl to work on ruby gc and got nowhere and now hire full time Java GC dev. </sidebar> AST is the syntax that we start with when compiling something. Therefore the transformation language should be as close to the AST This is akin to XSLT being written in XML Shipping clojure
Thread SafetyClojure defs work with bindings - are always local to a thread. So if I change the binding, the other thread won't see it. The fundamental data type here is a clojure.lang.Var - think of it as a Clojure scalar skin over a Java data value. STMS shared transaction memory system: Many threads can share state. This uses a clojure.lang.Ref (as one level of indirection over the value). One thread alters a reference and tries to commit It will either succeed or roll back and fail. For this reason, the Clojure memory transactions cannot contain code with side-effects (although this can't be enforced by the runtime at present). If side-effects are present, they can occur an undetermined number of times. For async thread comms Clojure has agents (ala Erlang/Scala) Simplicitycode sample JAVA fn1().fn2().fn3(); helloworld(); CLOSURE (fn3 (fn2 (fn2))) (helloworld) The closure first example shows how the method execution will happen, which isn't as clear from the Java one. pointer datatype called var clojure.lang.Var Var points to an Object
TODO: Add Ben's slide's to this page as they went in more detail! |
Recommendations:
(as above) |