Clojure/West 2015: Notes from Day Two
Data Science in Clojure
- Soren Macbeth; yieldbot
- yieldbot: similar to how adwords works, but not google and not on search results
- 1 billion pageviews per week: lots of data
- end up using almost all of the big data tools out there
- EXCEPT HADOOP: no more hadoop for them
- lots of machine learning
- always used clojure, never had or used anything else
- why clojure?
- most of the large distributed processing systems run on the jvm
- repl great for data exploration
- no delta between prototyping and production code
- cascalog: was great, enabled them to write hadoop code without hating it the whole time, but still grew to hate hadoop (running hadoop) over time
- december: finally got rid of last hadoop job, now life is great
- replaced with: storm
- marceline: clojure dsl (open-source) on top of the trident java library
- writing trident in clojure much better than using the java examples
- flambo: clojure dsl on top of spark's java api
- renamed, expanded version of climate corp's clj-spark
Pattern Matching in Clojure
- Sean Johnson; path.com
- runs remote engineering team at Path
- history of pattern matching
- SNOBOL: 60s and 70s, pattern matching around strings
- Prolog: 1972; unification at its core
- lots of functional and pattern matching work in the 70s and 80s
- 87: Erlang -> from prolog to telecoms; functional
- 90s: standard ml, haskell...
- clojure?
- prolog: unification does spooky things
- bound match unbound
- unbound match bound
- unbound match unbound
- clojurific ways: core.logic, miniKanren, Learn Prolog Now
- erlang: one way pattern matching: bound match unbound, unbound match bound
- what about us? macros!
- pattern matching all around us
- destructuring is a mini pattern matching language
- multimethods dispatch based on pattern matching
- case: simple pattern matching macro
- but: we have macros, we can use them to create the language that we want
- core.match
- dennis' library defun: macros all the way down: a macro that wraps the core.match macro
- pattern matching macro for defining functions just like erlang
- (defun say-hi
(["Dennis"] "Hi Dennis!")
([:catty] "Morning, Catty!"))
- can also use the :guard syntax from core.match in defining your functions' pattern matching
- not in clojurescript yet...
- but: how well does this work in practice?
- falkland CMS, SEACAT -> incidental use
- POSThere.io -> deliberate use (the sweet spot)
- clj-json-ld, filter-map -> maximal use
- does it hurt? ever?
- limitations
- guards only accept one argument, workaround with tuples
- best practices
- use to eliminate conditionals at the top of a function
- use to eliminate nested conditionals
- handle multiple function inputs (think map that might have different keys in it?)
- recursive function pattern: one def for the start, one def for the work, one def for the finish
- used all over erlang
- not as explicit in idiomatic clojure