Your SlideShare is downloading. ×
Clojurescript slides
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Clojurescript slides


Published on



Published in: Technology
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Clojure ...
  • 2. Clojure ... rocks
  • 3. Clojure ... rocksJavaScript ...
  • 4. Clojure ... rocksJavaScript ... reaches
  • 5. ClojureScript
  • 6. 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
  • 7. Rationale• Clojure is arguably simpler, more powerful and more robust than JS• JS VMs getting faster• Clojure on JS empowers developers
  • 8. Strategy• Compile (a substantial subset of) Clojure to JS source• Leverage best-of-breed JS approaches• Look beyond the browser
  • 9. Non-Objectives• Complete Clojure• Portable large applications• Browser REPL demos etc• The target is production applications
  • 10. Tactics• ClojureScript in Clojure(Script)• ClojureScript on (Google) Closure
  • 11. ClojureScript in Clojure(Script)• Compiler written in Clojure• Macros written in Clojure• Library written in ClojureScript • No JavaScript source files
  • 12. CinC• Core abstractions are protocols• Data structures are deftypes• Excellent mapping to JS under the hood
  • 13. REPL• Written in Clojure• Hosts embedded Rhino• Compiles to JS on the fly • Rhino evals
  • 14. 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+
  • 15. 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
  • 16. Closure Compiler• Optimizing Compiler • Whitespace only • Within-function • Whole program (advanced mode)• Try it: •
  • 17. Another Minifier, yawn• No!• Closure compiler does symbol replacement • but also expression rewriting, transformation• Dead code elimination • read as: uncalled code elimination
  • 18. Why Whole ProgramOptimization 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
  • 19. 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?
  • 20. 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
  • 21. Whole-programOptimization 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
  • 22. 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
  • 23. Find Out More“The O’Reilly [kloh-zher] book - you know, with the bird on the front”
  • 24. What’s There• Compiler• REPL• Primitives• Arity overloading• Macros
  • 25. What’s There• Seqs, maps, vectors, sets • and much of supporting library• Symbols, keywords• Destructuring• Regex
  • 26. 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
  • 27. What’s There• 2500+ lines of core lib• clojure.string• clojure.set• clojure.walk•
  • 28. What’s There• Reader • Why, given JSON? • Sets, keywords, symbols • Metadata • Great fit when Clojure on the server
  • 29. What’s There• Namespaces • integrated with Google Closure provide/ require• compile-file, build project, including • deps calculation • invocation of Google Closure compiler
  • 30. What’s Not (yet)• Full collection persistence• defrecord• multimethods/hierarchy• Full numerics• Testing• Misc core library
  • 31. What Won’t Be• Thread-related things• eval and runtime compilation• structs, proxy, Java type-stuff• Runtime reification of • Vars, namespaces, protocols etc
  • 32. It’s Alpha!• Bugs• Missing bits• Rough edges• Work to do
  • 33. 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
  • 34. Participating• This is a Clojure/dev project • all with Clojure CAs welcome to participate• Plenty to do • Libraries • Environment • Tooling
  • 35. Face Time• The Conj! • Nov. 10-12 Raleigh, NC • With training: Nov. 7 -12 • • Early registration ends soon• Core Fridays
  • 36. Demo• REPL• Compilation• Web app• CLI app
  • 37. Summary• ClojureScript is • Clojures client story • Clojures mobile story • Clojures CLI scripting story• The power of Clojure • The reach of JavaScript