4 ms·
Clojure is different from any other language I have ever used, and as I learned Clojure I had to struggle with the various programming habits that my mind has a
by lkrubner 14y ago
Clojure is different from any other language I have ever used, and as I learned Clojure I had to struggle with the various programming habits that my mind has acquired over the last 14 years. Here were some of the main struggles:
1.) how do I live without a loop that lets me iterate some counters? The first Clojure (sort of) looping structure that I understood was (reduce), so for awhile I jumping through hoops to use (reduce) every time I wanted to go into a loop.
2.) how do I realize lazy sequences? I got myself badly stuck with some of the libraries, for instance Enlive, when I saved the nodes as a string and then later re-imported them to my code, at which point they were lazy sequences and I was wondering, how do I get this back to being Enlive nodes? Took me awhile.
3.) when do I divide code into a new file/namespace. In a language like Java the rule is something like "one class = one file" (I could qualify that, etc...). Clojure doesn't impose obvious dividing points on your code, and I think it takes a while to figure out what the right dividing points are (and I still wonder about what the best practice is, for instance: is it acceptable for code in one namespace to rely upon, and modify, an atom in a different namespace?)
Learning Clojure has been a fantastic educational experience for me. It is my favorite language and my favorite development eco-system. And I am lucky enough to be able to use at my job, so I get to work with it full time now, for which I am very grateful. (Previously I was getting a lot of corporate gigs where they needed PHP programmers who knew the Symfony framework -- I found those jobs very tedious, and, more to the point, after a few years I felt like I was not learning anything new).
- mark_l_watson 14y agoStick with it! I think that you will find Clojure + Compojure + Noir + Hiccup, etc. will be a refreshing break from PHP. I was mostly using Ruby with Rails or Sinatra for a long time, and the switch to Clojure has been really good. Caveat: I have been actively using Lisp since 1982, and even so it took me a little while to switch over from Common Lisp. Keep at it, and I think Clojure will expand the way you think about programming.