Recommended Learning Exercise : Simulating A Parking Garage in Clojure

Here is a nice example of creating software that simulates a parking garage. Two different examples. If you are learning Clojure this might be of interest to you.  In the first example, Clojure Refs are used. The problem is to simulate operations on a garage used for parking vehicles – vehicles come into the parking garage, park and then later leave.  They are identified by their license plate number.  This is a nice example for those looking for Clojure examples.

parkgarage1

In the second example, the same parking garage problem from the previous post is solved using  clojure.spec . See more on the clojure.spec rationale and the  guide.  Here is the second example which uses Clojure.spec.

garagespec2

 

 

Recommended Reading : An Archaeology-Inspired Database

Yoav Rubin shows how a change in a common perspective affects the design and archdb2implementation of a well-studied type of software: a database.  In this excellent examination of how a shift in perspective changes everything, Yoav provides us with a rich examination of what we thought we knew but it turns out that perhaps there are better ways to approach databases. “Database systems are designed to store and query data. This is something that all information workers do; however, the systems themselves were designed by computer scientists. As a result, modern database systems are highly influenced by computer scientists’ definition of what data is, and what can be done with it.

For example, most modern databases implement updates by overwriting old data in-place instead of appending the new data and keeping the old. This mechanism, nicknamed “place-oriented programming” by Rich Hickey, saves storage space but makes it impossible to retrieve the entire history of a particular record. This design decision reflects the computer scientist’s perspective that “history” is less important than the price of its storage.”

As Yoav puts it succintly -If you were to instead ask an archaeologist where the old data can be found, the answer would be “hopefully, it’s just buried underneath”.

Leveraging the richness of the Clojure language and 360 lines of code – we have an “archeology-inspired” database. To read the article, select:

archdb

Recommended Quick Read : Clojure By Example & Writing Clojure RESTful Web Services

I’ve been heavily invested in learning and working on Solr deployments and also learning Chef this past few months. More on those technologies is coming shortly.  

It is worth reading a Clojure introduction if you are trying to learn Clojure quickly. Here are two quick and useful reads.

cljbyexam

Also there is a nice stackoverflow question and answer on learning how to write Clojure web services.

RESTwsclj

Recommended Reading : Comparisons of Python and Clojure

Programming languages are tools. Depending on what you are doing the right tool becomes an important choice. When developers move to another programming language – It is worth examining why they moved. In this case from Python to Clojure. In the article he provides a list of why he views the move to Clojure as a good one : immutability, a highly interactive REPL and class loader, better performance, deployment advantages, Java interoperability by virtue that Clojure sits ontop of the JVM, simplicity and wealth of functional programming advantages.

screenshot_429

A follow-on read to this is zach charlop-powers blog entry :

screenshot_430

One more interesting article on this topic that I ran into :

screenshot_431

and the follow-on :

screenshot_432

Recommended : Rich Hickey Introduces Transducers to Clojure

In a blog post, Rich Hickey introduced transducers.  Transducers “are a powerful and composable way to build algorithmic transformations that you can reuse in many contexts”.  It is worth reading this two articles :

rhtransducersand

rhreducersAnd if you want more on Clojure transducers, people are already looking at what this means.

understandtransducers

and here is a write-up of some some examples :

trivialextransducers