Introduction to clojure
Upcoming SlideShare
Loading in...5
×
 

Introduction to clojure

on

  • 294 views

A brief introduction to Clojure language.

A brief introduction to Clojure language.

Statistics

Views

Total Views
294
Views on SlideShare
294
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to clojure Introduction to clojure Presentation Transcript

  • Introduction to Clojure By Abhishek Mahawar BM Tech Talk
  • Not so old History ● Created by Rich Hickey ● First version in 2008 ● Origin of name - Wanted to involve c(c#), l (lisp) and j(java).
  • Clojure is a …. ● LISP dialect targeting the JVM ● Dynamic programming language ● Functional programming language ● Compiled language
  • Clojure is a LISP ● S-expressions (Polish notation) (+ 2 4) ● Homoiconicity code is data, data is code ● Reader Operator/function names Arguments
  • Atomic Data Types ● Arbitrary precision integers 123 ● Doubles 1.23 , BigDecimals 1.23M ● Ratios 22/7 ● Strings “bm” , Characters b ● Symbols bm , Keywords :bm ● Booleans true false, Null - nil
  • Data Structures ● Lists (1 2 3) ● Vectors [1 2 3] ● Maps {:a 1 :b 2} maps are functions of their keys ● Sets #{1 2}
  • Data Structures (contd.) ● Clojure data structures are ○ persistent ■ previous version remains intact when modified ○ immutable ○ support proper equality semantics in their implementation of equals
  • Syntax ● We’ve just seen it !! ● No text based syntax ● Data structures are the code Homoiconicity ● Actually, syntax is in the interpretation of data structures
  • Clojure Evaluation Clojure code Reader characters evaluator/ compiler data structures JVM Output bytecode
  • Expressions ● Everything is an expression ● All data literals represent themselves, except ○ symbols - looks for binding to value ○ lists - an operation form ■ (operation arguments) ■ operation can be special ops, macros or functions
  • Special ops/forms ● Can have non-normal evaluation of arguments ○ (def name value-expr) ○ (if test-expr then-expr else-expr) ■ conditional, evaluates only one of then/else ● fn, let, loop, recur, do, new, ., throw, try, set!, quote, var, monitor-enter, monitor- exit
  • Functions ● First class values ○ (def five 5) ○ (def add-1 (fn[x] (+ x 1))) ○ (add-1 five) = 6 ● Higher order functions (HOF) ● fn special op is used to create functions
  • Lots of other stuff ● Software Transactional Memory ● Macros ● Lazy Sequences ● Metadatas
  • References ● http://clojure.org/ ● http://www.youtube.com/clojuretv ● Clojure Programming by Chas Emerick, Brian Carper and Christophe Grand