Hacker News new | ask | show | jobs
by cryptolect 4463 days ago
How big/complex were your functions? Have you seen the style guide? It's easy to write really powerful, nested functions in Clojure, which are damn hard to read the next morning. Taking advantage of thread-first and thread-last macros can really help here. I've finally started to use them heavily. For instance, you could do the following to read a file, parse it from json, and retrieve somekey:

  (:somekey (cheshire/parse-string 
              (slurp "/tmp/somefile.json") true)
Or

  (-> "/tmp/somefile.json" 
      (slurp)
      (cheshire/parse-string true)
      (get :somekey))
In other words, there's much nicer ways to write maintainable, readable code that you can still understand in the morning.

Your "jumping around" comment also makes me wonder how you were laying out your functions? My advice is to go through the libraries of the popular Clojure libraries, you will discover a lot of good practices. It's taken me a few months of Clojure to start writing cleaner, readable code.