guides icon indicating copy to clipboard operation
guides copied to clipboard

Cover debugging of Clojure code...

Open robermann opened this issue 12 years ago • 8 comments

...depending on the used IDE / tool.

robermann avatar Oct 18 '12 22:10 robermann

With a section about how to interpret Clojure stack traces. ;)

freeeve avatar Oct 18 '12 22:10 freeeve

Yes you are correct :) Also a list of common errors, with a brief explanation of the most probable causes, would help.

robermann avatar Oct 18 '12 22:10 robermann

There are a few exceptions mentioned in the interop guide. There will be more but within reason.

michaelklishin avatar Oct 19 '12 02:10 michaelklishin

A debug section should consider:

  • A) Strict debugging tools, as (swank.core/break) or integrated IDE 's debuggers (perhaps the Eclipse's CCW plugin).
  • B) Debugging and inspecting techniques in a broader sense, that could help in understanding how a chunk of code works. I provide my preferred examples of what I'm meaning:
    • B.1) Let's consider a function:
(func1 
 (func2 123) 
 (func3))

If I want to inspect what func2 and func3 return values look like, I can rewrite the whole form using let and do without change the final returned value and in the while checking the intermediate ones:

(let [p1 (func2 123)
      p2 (func3)]
          (do
              (println p1)
              (println p2)
              (func1 p1 p2)))
  • B.2) If I want to temporarily force an evaluated value I can comment the original form and replace it with a value of the same expected type:
(func1 
 #_(func2 123)  ; #_ comments the whole form
  1000          ; forced value, which replaces the commented form
 (func3))

In my opinion these sort of hints could help newbies in their coding activities.

robermann avatar Oct 20 '12 18:10 robermann

What helped us a lot in debugging is:

  • nrepl on long-running processes and web applications (a lot!)
  • swapping / wrapping functions during runtime
  • heap dumps / thread dumps / object observing in VisualVm

If there's any interest, I could help out with these.

ifesdjeen avatar Nov 14 '12 08:11 ifesdjeen

could this be done for emacs? I might consider using it(emacs)

ghost avatar Jan 30 '13 03:01 ghost

Things that have helped me:

xcthulhu avatar Apr 08 '14 13:04 xcthulhu

I'm am resurrecting this site at https://clojure-doc.github.io so feel free to recreate this issue at https://github.com/clojure-doc/clojure-doc.github.io/issues or submit a PR https://github.com/clojure-doc/clojure-doc.github.io/pulls

seancorfield avatar Nov 14 '21 21:11 seancorfield