You Really Should Know A Bit Of Clojure – Ben Orenstein

Home / Functional Programming / You Really Should Know A Bit Of Clojure – Ben Orenstein

Ben Orenstein has been knee deep in object oriented programming for years, dealing with it’s limitations, yet more recently has been enjoying the benefits of functional programming with Clojure. Here, he talks about why everyone should know a bit of Clojure and the benefits it brings to his Ruby code.

Orenstein runs through immutable data structures (go to 3:55) and how they prevent a class of bugs in Ruby where an object is passed into a method and is somewhere along the line passed to something that mutated it, a bug which can easily take a day to track down.

I’m finding that the code I am writing is really nice, it’s nice in Clojure and it’s also affecting my Ruby in a positive way, I am now thinking about – how little can I get away with mutating and when I mutate can I control it in the most extreme way possible to the biggest extent I can?

He goes on to demonstrate running functions on values in boxes to change values using swap showing how immutable data stays the same (go to 12:10) saying that using this in functional programming can improve skills in OOP and how he has now stopped writing things in Ruby that mutates things as much as possible.

The end of the talk goes through Clojure’s macro system (go to 18:50) which allows the compiler to be extended by user code, using a wall as an analogy to accessible parts of the language against Ruby and because Clojure compiles into JVM byte code all the features that Clojure offers are able to be compiled down into JavaScript and run in the browser (go to 23:30).

Related Posts