clojure: what just happened? · • pure functions + immutable data ... • dominant hosts (jvm,...
TRANSCRIPT
![Page 1: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/1.jpg)
Clojure:What Just Happened?
Rich Hickey
![Page 2: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/2.jpg)
Clojure is Becoming Popular
• Popular*
• Functional
• Lisp
• Not terribly novel
![Page 3: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/3.jpg)
How Popular?• 8000+ member mailing list
82,000+ messages
• 700+ on IRC
• #2 (behind Scala) non-Java JVM server lang
• Many companies use in production
Startups to Fortune 50
• > Dozen books, several 2nd editions
• 3 Clojure conferences per year
![Page 4: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/4.jpg)
Github New Repos 2013 (thus far)
Rank Lang New repos
15 Scala 6918
16 Go 6884
17 Prolog 5829
18 Clojure 4904
19 Haskell 4681
20 Lua 4048
![Page 5: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/5.jpg)
Context• JVM
• PHP, Python, Perl, Ruby
broke C-lineage stranglehold
demonstrated dynamic lang agility
• Paul Graham’s essays
• Crushing complexity of stateful OO
• JSON, XML
![Page 6: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/6.jpg)
Right Place, Right Time?
• In fall 2007 when announced, no one had heard of me nor Clojure
• 18,000 hits the first day
![Page 7: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/7.jpg)
Survey 2012 - GrowthStopped
1%
< 1 year43%
1 year18%
2 years18%
3 years14%
4+years6%
1,372 respondents
http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/
![Page 8: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/8.jpg)
From Where?
Java
Ruby
Python
C#
Erlang/Scala/Haskell
Other
0 10 20 30 40
![Page 9: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/9.jpg)
Why?
![Page 10: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/10.jpg)
Practical
• Target - use it wherever you could use Java
both reach and performance
• Tool, for professional programmers
hobbyists welcome
• General purpose programming
![Page 11: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/11.jpg)
Small
• A basic Lisp evaluation model
• No continuations, condition systems etc
![Page 12: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/12.jpg)
Simple
• Few, orthogonal axes
• Functions, data, state model, evaluation model, macros etc
![Page 13: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/13.jpg)
FP Benefits, Distilled• Pure functions + immutable data
• Made practical and idiomatic
• Efficient persistent data structures the default
• Functional core library
• No mutable local variables
• Clearly separate state constructs
![Page 14: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/14.jpg)
Opinionated
• Fewer choices
• Set of decisions made and encoded
• Everything works together
![Page 15: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/15.jpg)
Eschews Types for Information
• Simple data - lists, vectors, maps, sets
• Associative collections in lieu of objects
• First-class names (keywords)
![Page 16: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/16.jpg)
Minimal Type-Specific Code
• just generic map-manipulation code
• therefore, much less code
• more reuse
• better interop and libs
• facilitates systems building
• less compiler help
![Page 17: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/17.jpg)
Runtime Polymorphic
• People coming from OO understand and expect this
• Abstractions for everything (even invocation)
• Polymorphism constructs are ‘open’
![Page 18: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/18.jpg)
Concurrency?
• Not so much
• Part of initial story
• Has to be there
• but rarely needed
![Page 19: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/19.jpg)
Hosted
• Dominant hosts (JVM, JS)
• Great interop
• Libraries out of the gate
• No migration pain
• Easy to sneak in
“just another library”
![Page 20: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/20.jpg)
Lisp
• Still has appeal
• Small core, rest is libs
• Runtime redef, code loading, macros
• Code-as-data, read/print, REPL
• but enhancements matter
fp, collections, syntax, abstractions
![Page 21: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/21.jpg)
Permissive
• “Consenting adults” language
• Support the right thing
• vs disallow the wrong
![Page 22: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/22.jpg)
Support and Evangelism
• 3 years x 10 hours/day
Mailing list and IRC
• Lots of talks and travel
![Page 23: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/23.jpg)
Stability
• All programs from first book (2009) still work
• Always a high priority
![Page 24: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/24.jpg)
The Blub Paradox?
• People don’t know what they are missing?
• They know what they are getting
• Simpler and more robust programs
• High productivity
• Resulting systems work, perform well, and are flexible
• Clojure is an effective tool
![Page 25: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/25.jpg)
Biggest Wins
Functional
REPL
Platform/JVM
Immutability
Productivity
Macros
Concurrency
0 22.5 45 67.5 90
![Page 26: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/26.jpg)
Gateway Drug?
Scala
Haskell
Python
Common Lisp
Ruby
Java
Scheme
Erlang
0 10 20 30 40
If Clojure disappeared, then what?
“too depressing to contemplate”
![Page 27: Clojure: What Just Happened? · • Pure functions + immutable data ... • Dominant hosts (JVM, JS) ... Immutability Productivity Macros Concurrency 0 22.5 45 67.5 90. Gateway Drug?](https://reader033.vdocuments.mx/reader033/viewer/2022043006/5f8efec4104d3f44e5247b90/html5/thumbnails/27.jpg)
Thanks!