← Back to search

#abstractions

Commentary

Clojure Abstractions

I’m proud to admit that I’m bitten by the Rich Hickey bug. As many in reddit convey, I strarted watching a video or two during my commute to work and a lot of things made so much sense that I decided to give Clojure a try. Of course, I’m not at the level where I want to run my fingers in Rich’s Bob Ross like hair. :P

What are my first impressions? There are many positives already about Clojure. I’m not a Lisp aficionado and have always despised the need for many many parentheses in a program. But Clojure, although it has a healthy dose of parentheses is different from Lisps in many regards. It’s much more simpler and consistent that Common Lisp, I’ve heard.

But the striking feature of Clojure for me so far is Programming to Abstractions. Most OO programs and C programs do not program for abstractions but to implementations. Java took a different spin on it by introducing interfaces that lets one focus on programming to conform to certain interfaces. That gave us the extremely rich and elaborate Collections library of Java. Clojure takes it to the next level since it creates intermediary structures of a certain type (say seq) and completely relies on abstractions.

Python programmers have a different name for this. I believe it originated from the Ruby world - Duck Typing. Duck Typing dictates that if something can quack, it’s a duck. Of course, IRL this is a blatant lie. I can quack too but I’m not a duck. A car has a steering wheel but it’s not a cruise boat or vice versa. While this appears to be an issue, it’s not that big a deal in an environment that strongly promotes writing small composable libraries.