Isn't that true in most common languages? Python and Ruby and Java and Go (panics) will all spit out the stacktrace?
This is about compile-time errors, not runtime errors.
Re:Why is Jepsen written in Clojure?
by scotty79 on Wednesday December 06, 2023 @04:19PM
(#38549604)
Clojure spits out Java stack trace if you make syntax error. It's equivalent of Python barfing segfault when you put tab in the wrong place.
This doesn't happen with the normal REPL (or invoking with clj -X) after a couple of first examples that came to mind:
user=> (defn foo [[a b] (+ a b))
Syntax error reading source at (REPL:14:26).
Unmatched delimiter: )
user=> (defn foo [a b] a/b)
Syntax error compiling at (REPL:1:1).
No such namespace: a
user=>
It will give you a stack trace of the compiler when asked following a syntax error though, with a disclaimer not to confuse it with your own code: user=> (pst)
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "NO_SOURCE_PATH"}
clojure.lang.Compiler.analyze (Compiler.java:6808)
clojure.lang.Compiler.analyze (Compiler.java:6745)
[...]
Possibly you were using tooling that always tried to present the stack trace without discerning between kinds of evaluation errors?That does look considerably better than what I used to see.
Tbh I think they've actually gotten worse in recent years. This thing where the compiler spits out a stacktrace to /tmp and makes you go and cat it? Absolutely awful.
And the move to spec, ugh, UGH. I have wasted so much of my life looking at spec errors for (e.g.) namespace declarations and being completely unable to tell what was wrong. I don't know how to fix this, unfortunately.
For those who don't know, Clojure's error messages... aren't. They take the form of a stack trace from the compiler's internals, and that whole stack trace just gets barfed out onto the terminal. There's an exception message but it sometimes just isn't that helpful.
I know there was an effort a while back to improve the situation, but last I saw (2019) I believe things were only marginally improved. It's a shame because other than that it's really quite a fantastic language.