From: "Amy K. Farrell" <a...@aracnet.com>
Date: Mon, 21 Apr 2008 21:41:24 -0700
Local: Tues, Apr 22 2008 12:41 am
Subject: Meeting notes -- Clojure, a concurrent Lisp on the JVM
I thought I'd make an attempt at contributing something to the group
by taking notes last week. Here's my attempt at capturing some of the content of the presentation and discussion. At least the "upcoming events" are accurate, as they were easy to verify online! - Amy ======================================== Portland Functional Programming Study Group, 2008-04-14 The meeting started off with some informal chat and reminders of Innotech at the Convention Center (now past) ======================================== Topic: "A Modest Introduction to Clojure" Patrick gave us an introduction to Clojure in a live-demo Background from the abstract for this talk: Abstract: Clojure is a Lisp dialect that runs on the Java Virtual Speaker: Patrick Logan started programming in Common Lisp in 1984 Your notetaker last used Scheme 20+ years ago for a class, and can What makes Clojure a LISP? * Uses s-expressions as its syntax Some quirks and features of Clojure: * no car! "first" Mostly functional, moreso even than Scheme. Lists, vectors, hashes are (let [a 10 b 5] (def ccc 4) (* a b)) (def box (var x)) Boxes are mutable (thread-local or shared across threads). Some quirks: map syntax, treatment of nil: (= (cons 1 ()) (cons 1 nil)) ... it's unclear whether this is by design, or a bug. Recursion: running on JVM, the language is not as recursive as you (defn fact [n] (if (== n 1) 1 (* n (fact (-n 1 ))))) (fact 3) Anonymous function of 3 args: (#(* 2 %1 %2 %3) 20 30 40) (Adam Jones interjected that the bootstrapping code for defn is Metadata - readtable ^# -- next form is the metadata; it will be (def vec #^{:a 2 :b 6} [1 2 3]) Other special syntax: recur, loop (defn fact [n] recur -> back to loop with new binding. Use must be tail-recursive. (defn fact Can freely access classes in Java: (import '(java.swing.... Concurrency: vars are thread-local boxes to store mutable values. A ref is like a var, but can be seen across threads: (def r (ref 3)) (ref-set r 5) (dosync (ref-set r 5)) commute -- if you know you are applying a commutative operation =============== BREAK =============== Adam Jones shared some of his experiences working with Java and * importing classes Clojure supports implementing interfaces from Java with a proxy (proxy [Class and Interfaces] [Superclass constructor args] There are limitations to this; Adam doesn't generally use it and The Clojure developer is moving quickly. Code is changing frequently Appeal of Clojure: Adam was looking for a LISP on the JVM. It's much Top-level definitions *are* redefinable. It's more immutable by Patrick noted that transaction conflicts are only handled at the box Trying to move mutable state and things that need speed into Java. Any time you eval you get a generic Java object. This can lead to All the Clojure datatypes implement the Iterable interface, so Java ======================================== You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||