End of Erlang; start of Clojure

Although i didn’t do much Erlang, Alberto did! :) Looking at this blog post allows me to appreciate Erlang through Alberto’s eyes: Erlang Day Three

Seriously impressive concurrency and fault tolerance. It’s just a simple example, but it shows us something that cannot be killed no matter what you try to do to it. You can easily see how this scales up to huge fault-tolerant telecommunications systems.

Thank you to Alberto for leading the group discussion today, that was great.

Now over to Clojure

And so we start Week 6! Clojure is a version of Lisp that runs on the Java Virtual Machine. So we have lists (obviously!), functions, dynamic typing, immutable state … ahh, well, no. As we now know, for concurrency it is best to write functions without side effects. However, Clojure includes a few tricks to help us out with mutable variables, such as transactional memory and encapsulated access via agents. I’m a little disappointed actually, i was growing rather fond of immutability.

Installing Clojure

I think i probably installed more than was necessary. I’m on Mac OS X with homebrew. I suggest you simply try:

brew install leiningen

Leiningen is a simple build tool that makes it easier to work with Clojure.

Having done that you can start a new project like so:

lein new day1

It sets up an environment for you to use and a few .clj files to get you started (including one to help you write tests!)

Now in the day1 directory you can do:

lein repl

It downloads a couple more files and starts up Java with the Clojure libraries, putting you into a Clojure console.

If that doesn’t work for you, i also did:

brew install clojure
brew install repl

But i think leiningen was all i really needed.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s