7. Why ClojureScript?
• JavaScript is the only programming
technology in key environments
• e.g. the browser
• has the greatest reach in mobile
• but is not very robust
• While demand for sophisticated
applications increases
8. Rationale
• Clojure is arguably simpler, more powerful
and more robust than JS
• JS VMs getting faster
• Clojure on JS empowers developers
9. Strategy
• Compile (a substantial subset of) Clojure to
JS source
• Leverage best-of-breed JS approaches
• Look beyond the browser
12. ClojureScript in
Clojure(Script)
• Compiler written in Clojure
• Macros written in Clojure
• Library written in ClojureScript
• No JavaScript source files
13. CinC
• Core abstractions are protocols
• Data structures are deftypes
• Excellent mapping to JS under the hood
14. REPL
• Written in Clojure
• Hosts embedded Rhino
• Compiles to JS on the fly
• Rhino evals
15. Google Closure
• Production Code
• Closure Compiler
• virtually all of Google’s JS goes through this
• Closure Library
• Used by Google Gmail, Maps, Docs, Sites,
Books, Reader, Calendar, Photos, Google+
16. Why Give Google
Closure Away?
• Be cool
• Make friends
• See if it sticks
• Not using it anymore
• Sucker community into maintaining
• They want the web to win as an application
platform
18. Another Minifier, yawn
• No!
• Closure compiler does symbol replacement
• but also expression rewriting,
transformation
• Dead code elimination
• read as: uncalled code elimination
19. Why Whole Program
Optimization Matters
• Libraries
• Large libraries
• Many libraries
• Sum of many minified libs is large again
• What % of each lib do you use in one app?
• Diminishing returns from delayed loading
and modularity efforts
20. Making it work
• Convention, and lots of it
• Welcome to Javascript!
• Trickiness abounds - string access to
properties, exporting, side-effects
• Google’s conventions not widely followed
• What if we had a Javascript-emitting
language that always emitted advanced-
mode compatible code?
21. Closure Library
• Huge!
• UI, events, DOM, communications, testing,
algorithms and data structures...
• Packaging and dependency resolution
• Yet, not
• Symbiotic with Closure compiler
• Your app will include only the code it uses
• require lib != use all of it
22. Whole-program
Optimization for the Win
• Google has decided this is the key to
delivering
• rich applications
• over thin wires
• to memory constrained devices
• Given away sophisticated tools for making
that work
23. ClojureScript on
(Google) Closure
• Emits advanced-mode compatible code
• encapsulates conventions
• Participates in dependency system
• maps Clojure namespaces to Google’s
optimizable format
• Profit! - whole-program optimization and
large library support
24. Find Out More
“The O’Reilly [kloh-zher] book -
you know, with the bird on the
front”
26. What’s There
• Seqs, maps, vectors, sets
• and much of supporting library
• Symbols, keywords
• Destructuring
• Regex
27. What’s There
• deftypes
• core datatypes
• protocols
• all abstractions
• extend-type, extend-protocol
• can extend primitives e.g. string, nil, default
• Both defined in terms of primitives
28. What’s There
• 2500+ lines of core lib
• clojure.string
• clojure.set
• clojure.walk
• clojure.zip
29. What’s There
• Reader
• Why, given JSON?
• Sets, keywords, symbols
• Metadata
• Great fit when Clojure on the server
30. What’s There
• Namespaces
• integrated with Google Closure provide/
require
• compile-file, build project, including
• deps calculation
• invocation of Google Closure compiler
31. What’s Not (yet)
• Full collection persistence
• defrecord
• multimethods/hierarchy
• Full numerics
• Testing
• Misc core library
32. What Won’t Be
• Thread-related things
• eval and runtime compilation
• structs, proxy, Java type-stuff
• Runtime reification of
• Vars, namespaces, protocols etc
34. Who Did This?
• Clojure/core and friends:
Aaron Bedra, Alan Dipert, Alex Redington
Bobby Calderwood, Brenton Ashworth
Chris Houser, Devin Walters, Eric Thorsen
Frank Failla, Michael Fogus, Jess Martin
Luke VanderHart, Chris Redinger, Jonathan Claggett
Stuart Halloway, Stuart Sierra, Tom Hickey
35. Participating
• This is a Clojure/dev project
• all with Clojure CAs welcome to participate
• Plenty to do
• Libraries
• Environment
• Tooling
36. Face Time
• The Conj!
• Nov. 10-12 Raleigh, NC
• With training: Nov. 7 -12
• http://clojure-conj.org/
• Early registration ends soon
• Core Fridays
38. Summary
• ClojureScript is
• Clojure's client story
• Clojure's mobile story
• Clojure's CLI scripting story
• The power of Clojure
• The reach of JavaScript