Hacker News new | ask | show | jobs
by heyts 3520 days ago
I'm very interested in learning Clojure. Would you care to share more of your experience learning the language in terms of learning curve, useful libraries or just general tips. I'm sure that would benefit the community at large.
2 comments

I approached learning Clojure the way I approach learning everything else. I survey the resources available, then pick the two best books. Ideally, I want them to come at it from different perspectives. e.g. one may place an emphasis on doing stuff with Clojure while another may be more about functional programming.

At the time, they were:

https://www.amazon.com/Clojure-Programming-Chas-Emerick-eboo...

https://www.amazon.com/Joy-Clojure-Michael-Fogus/dp/16172914...

I then wrote a data processing app in Clojure; consuming financial data and finding patterns in it.

My suggestions are: 1) If this is your first time learning a functionally-oriented language, clear your mind from any kind of assumptions picked up from other languages.

2) Get a handle on the core tenets of functional programming: immutability, purity, composition, and functions as objects. If you know Javascript, then a lot of this stuff may already be familiar to you. JS is underrated in that department imo.

3) To me, writing programs with Clojure is akin to playing with Lego. You write your base functions, then higher-level functions which use those base functions, and so on. Functions all the way down.

4) Write something with it; it'll force you to decompose your program and think functionally.

Clojure is a simple, opinionated language. I don't think you'll have a hard time picking it up at all. The hard part will be to think in a manner amenable to it.

These days, I think Clojurescript has overtaken Clojure in terms of traction, so if you're into webdev, then CJS would be a natural next step.

> You write your base functions, then higher-level functions which use those base functions, and so on. Functions all the way down.

I'm hoping to follow a similar trajectory to you, but with Elixir instead of closure. At the moment though, I tend to do things the other way around: write the top level functions and then fill out the base functions.

So I'd start a module with

def whatever(something), do: something |> function1 |> function2 |> function3

Then I'll write function1, 2, and 3 and whatever helper functions they need. And so on until it works. Maybe doing it your way is a better approach: helps you think it through first.

(although I'm aware some would say that tests should come before everything else anyway)

It is useful and necessary to use both directions at times. You can't always presuppose the relevant details. But do be ready to factor away functions at a moments notice
"some would say that tests should come before everything else anyway"

Which some others consider a cargo-cult practice if done mandatorily for it's own sake.

Good luck on your studies!

Where did you get this financial data for your first project? Is it a public feed / API? This sounds like exactly the sort of thing that I would like to start playing and eventually working with. I had been assuming that this type of data would only be available to the kind of entities that have a compliance officer, but I would love to have that assumption proven wrong.
I would recommend Clojure for the Brave and True - [0]

I have done some 40% of this book and so far I have thoroughly enjoyed reading and learning. Plus, the book is free to read online.

[0] - http://www.braveclojure.com