Programming Clojure, 2nd Edition – The virtues of concurrency and functional style – #bookreview #in #programming

Programming Clojure, 2nd Edition
Stuart Halloway and Aaron Bedra
(Pragmatic Bookshelf,
paperback, list price $35.00)

Clojure is yet another computer programming language with an odd name and many followers.

For example, Dr. Venkat Subramaniam, an award-winning author and founder of Agile Developer, Inc., has called Clojure “a beautiful, elegant, and very powerful language on the JVM [Java Virtual Machine].”

A lot has happened to Clojure (pronounced like “closure”) since the first edition of this book was published in 2009. Clojure has been updated several times and gained some enhancements, a lot of new followers, and many libraries.

Programming Clojure, 2nd Edition has been rewritten and reorganized to cover these new features, concepts and developments.

“Clojure is a powerful, general-purpose programming language,” the authors note. But this is not a book for raw beginners, even though its first chapter does start at the traditional “Hello, world” level. It is intended for “experienced programmers looking for power and elegance.” You should have some experience with C#, Java, Python, or Ruby before tackling Clojure.

“Clojure is built on top of the Java Virtual Machine, and it is fast,” Halloway and Bedra emphasize. “This book will be of interest of Java programmers who want the expressiveness of a dynamic language without compromising on performance.”

They add: “If you program in Lisp, use a functional language such as Haskell, or write explicitly concurrent programs, you will enjoy Clojure.”

Indeed, Clojure’s creator, Rick Hickey, emphasizes the language’s value as an alternative to the “complexity” introduced in object-oriented programming. “Object-oriented programming seems easy,” he states, “but the programs it yields can often be complex webs of interconnected mutable objects.”

He continues: “Functional programming offers an alternative. By emphasizing pure functions that take and return immutable values, it makes side effects the exception rather than the norm. Clojure is designed to make functional programming approachable and practical for commercial software developers.”

Clojure also makes concurrent programming easier. “Many languages build a concurrency model around locking, which is difficult to use correctly,” the authors point out. “Clojure provides several alternatives to locking: software transactional memory, agents, atoms, and dynamic variables.”

The 268-page book is well-organized and well written, and it offers numerous practical code examples. The book also has been reviewed for technical accuracy by a panel of Clojure practitioners.

Clojure code, incidentally, tends to be short (but you do need an editor that can “at least indent code correctly and can match parentheses”).

In one of the book’s comparison examples, the function produced by a 14-line sample of Java code is duplicated in Clojure with just two lines. So development in Clojure potentially can be fast.

Si Dunn

About these ads

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