Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Taste of Clojure

A Taste of Clojure

Clojure is a new and upcoming programming language that is a Lisp running on JVM.

In this talk, we explore the basic of programming in Clojure.

Abhinav Sarkar

November 04, 2010
Tweet

More Decks by Abhinav Sarkar

Other Decks in Programming

Transcript

  1. About Me  Working in Java/JEE professionally for last 2

    years at FICO  Programming Hobbyist  Learned JavaScript, C, Perl, Java, PHP, Python, JavaScript, Java (in that order)  Currently dabbling with Functional Programming languages: Haskell, Scala and Clojure  Some personal projects on Google Code and Github 2 DevCamp2010
  2. Clojure  Clojure is a dynamic programming language that targets

    the Java Virtual Machine.  Clojure is a dialect of Lisp.  Clojure is a compiled language.  Clojure is predominantly a functional programming language.  Clojure 1.2 was released two weeks ago 3 DevCamp2010
  3. Twitter Feelings DevCamp2010 4  Shows how people on Twitter

    are feeling, in real-time.  Written in Clojure + Swing  120 line (core logic) + 200 lines (Swing UI)  Written in 10 hours (specifically for purpose of demo at DevCamp2010)  Uses Apache HttpClient and JFreeChart
  4. Twitter Feelings: How it works DevCamp2010 5 Twitter released their

    Real-time Streaming API to public a month ago  Access the Twitter sample tweet stream  Find the feeling related adjectives in each tweet's status text and lookup their type (Positive, Neutral, Negative) against a list of adjectives  Keep the count of the adjective types in a sliding window of tweets  Show the statistics on the UI in pretty charts
  5. Clojure DevCamp2010 7  Leiningen – the Clojure build tool

     Uses Maven for dependency management and Ant for build  Project build file written in Clojure itself
  6. Clojure DevCamp2010 12  -> and ->>: macros  Macros

     allow the compiler to be extended by user code  used to define syntactic constructs which would require primitives or built-in support in other languages  possible because in Lisp “code is data”
  7. Clojure DevCamp2010 20  Concurrency primitives  future  atom

     agent  ref  var  Easy thread-less concurrency
  8. Clojure: Libraries DevCamp2010 23  Clojure Core API  clojure.core

     clojure.inspector  clojure.java.browse  clojure.java.io  clojure.java.javadoc  clojure.java.shell  clojure.main  clojure.pprint  clojure.repl  clojure.set  clojure.stacktrace  clojure.template  clojure.test  clojure.walk  clojure.xml  clojure.zip
  9. Clojure: Libraries DevCamp2010 24  Clojure Contrib API  accumulators

     base64  classpath  combinatorics  command-line  complex-numbers  condition  dataflow  duck-streams  error-kit  except  gen-html-docs  generic  Graph  http  jar  java-utils  jmx  json  logging  macros  math  miglayout  mock  monads  pprint  probabilities  profile  reflect  repl-utils  seq  sql  string  swing-utils  test-is  trace  types
  10. Clojure: Libraries DevCamp2010 25  Many third-party libraries  Enlive

     fnparse  ClojureCheck  ClojureQL  Composure  Ring  Lancet  Cloak  Incanter  Conjure http://clojure.org/libraries#Clojure%20Libraries-3rd-party%20Clojure%20Libraries
  11. Clojure DevCamp2010 27  Packaging  As JAR  AOT:

    Ahead Of Time compilation  gen-class and gen-interface
  12. DevCamp2010 29 Learn more about Clojure at http://clojure.org Check out

    the code at http://github.com/abhin4v/clj_twitter_feelings See the slides at http://tinyurl.com/a-taste-of-clojure Find me at [email protected] @abhin4v