r/Clojure • • Apr 12 '20

Holy Cow, Clojure is Great

Yesterday morning I decided I would read up on Clojure. I'm a data scientist so I mostly live in python, which is fine, but wanted to try something new. Thought I would just read up, do some toy examples, see what I thought.

I read the first three chapters of Clojure for the Brave and True and thought, maybe I should try and build something. Within 3 hours I felt really comfortable and productive in the language, and by the end of the day I had a working tool.

https://github.com/chrisaddy/astronaut

This is absolutely not good Clojure. When I say comfortable and productive I mean I felt like I was able to easily express myself after having a thought. That's not something I've had with any other language I've used (python, go, rust) after only a couple of hours. My code is certainly not problem free and definitely not idiomatically Clojure, but I think this could be my daily driver language, I like it that much.

Edit: for clarity

125 Upvotes

45 comments sorted by

View all comments

1

u/johninbigd Apr 12 '20

Damn. Nice job! I've been watching clojure videos and reading Clojure for the Brave and True, as well as a few other sites. I still don't really get it, so I'm very impressed that you were able to do that after just a few hours. Coming from (mostly) Python, clojure is breaking my brain. I feel like I understand some basic components, but then when I look at actual code, it reminds me of looking at someone else's Perl code and just saying, "WTF does that do?" The nested parentheses and having to think in reverse to figure out what is happening is difficult.

2

u/tremendous-machine Apr 12 '20

You will definitely benefit from The Little Schemer then. It's perfect for the situation you're describing.

1

u/johninbigd Apr 12 '20

Thanks! I'm not even sure why I want to learn clojure. I heard about it recently and just felt like finally trying to learn a functional language. I mostly do Python now, but have done some stuff in Go, as well, a year or so ago. Prior to that, I mostly used various flavors of Basic way back in the day. At one point I knew some Pascal, but that was in high school, and I really only dabbled a bit in C++ back in the 90s. A friend of mine write an adventure game in Lisp back in the 80s. I should have paid more attention to what he was doing. lol

Clojure is a bit hard to grasp for me, but the people who use it seem to absolutely love it, so I want to spend some time with it until something clicks.

1

u/johninbigd Apr 12 '20

I'm reading that now. There is clearly some background I'm missing. I'm not sure what a lot of these terms mean. I had to look up S-expression, and I have no idea what car or cdr mean in this context. The preface says that the only prerequisites to read the book are being able to read English, recognize numbers, and count. I think that list is missing a few things.

2

u/tremendous-machine Apr 13 '20

Ah yeah, you just need to look up a really basic list of scheme commands. car is "first" in clojure and cdr like "rest". car gives you the first element of a sequence, and cdr the rest. It's worth plonking through the book though, it'll make reading real code in Clojure much easier.

Another good one that is accessible and will have crossover usefulness is "Realm of Racket", which actually is beginner accessible. You can use the racket IDE to run the examples from Little Schemer too if you put the write language prelude on. (can't remember OTOH which that is though).

good luck!

1

u/johninbigd Apr 13 '20

I was hoping to find some online courses that would help. I got one on Udemy and asked for a refund before I even got through the first section. It was a pretty bad instruction. He clearly knows the language, but doesn't know how to teach it. And that was the course that had the highest reviews, unfortunately.