guides
guides copied to clipboard
Cover debugging of Clojure code...
...depending on the used IDE / tool.
With a section about how to interpret Clojure stack traces. ;)
Yes you are correct :) Also a list of common errors, with a brief explanation of the most probable causes, would help.
There are a few exceptions mentioned in the interop guide. There will be more but within reason.
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.
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.
could this be done for emacs? I might consider using it(emacs)
Things that have helped me:
- the
with-redefs
macro for monkey-patching -
lein midje :autotest
-
clj-factory
for generating test data -
io.aviso.exception
for saner exception reporting -
timber
'sspy
logging macro
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