Hacker News new | ask | show | jobs
by tieTYT 4756 days ago
Yeah I'm using CCW right now. I like it, but it's annoying that the repl doesn't start with (doc) or (source). I read an article from Stuart Sierra where you can add your own user.clj to the classpath and put code in it to load those up on start, but I haven't tested if CCW's repl will use this correctly. Assuming it does, tips like this are essential and should be in the book IMO.

Your last paragraph is good advice, but IMO I code like that in general. Consider this code:

(-> x doSomething1 doSomething2 doSomething3)

This was tested as I went, but after the fact, I had to change x. Now any part of the whole series of steps could be broken. This is where I spend 15 minutes trying to understand what the error message means. shrug Maybe this is just what's expected when you're new to clojure.

2 comments

The best advice I can give there is, learn how to read a stacktrace. I won't lie, they're messy, but they do contain the information you need to figure out that sort of problem.

For example, all Clojure function calls have the same sort of appearance in the stacktrace, which you'll learn to recognize. You'll be able to pick out "doSomething2" in the trace, which will then help you narrow in on the problem. Recurse through the stack trace using this technique until you find the specific form which is the problem.

Just added a "reading stacktraces" idea to the book: https://github.com/clojure-cookbook/clojure-cookbook/issues/...

Yeah, I tend to put a `pprint` at various points in the pipeline. (One which returns the form unchanged.)

I use print statements with virtually any programming language, basically using binary search to locate where my assumptions are violated.