r/Clojure • u/alexdmiller • Mar 19 '18
State of Clojure 2018 Results
http://blog.cognitect.com/blog/2017/1/31/clojure-2018-results8
u/mingp Mar 19 '18
We often see the seemingly contradictory dual complaints of companies that need more people and developers that have a hard time finding positions.
How much of this is a disconnect in salary expectations between companies and candidates? Anecdotally, when I was looking for a job 2 years ago, the small number of Clojure positions I encountered were typically advertising salary ranges 25-30% below their Python / Java / MainstreamLang competitors.
14
Mar 19 '18
To me it's not surprising at all to see that both employers and employees have a hard time finding each other, given that not many companies are willing to hire remotely.
0
u/joequin Mar 20 '18 edited Mar 20 '18
From what I've seen in job postings, the companies that have ckojure openings require very strong abilities in high level math. That could explain the disconnect. There's a lot of good software engineers that want to work in ckojure, but the jobs for clojure require mathematicians who can program.
5
u/alexdmiller Mar 20 '18
This does not match what I have seen in any Clojure job posting. Can you point to an example?
1
u/joequin Mar 20 '18
I haven't looked in a few months. It might have something to do with me living near NYC. The only clojure jobs I see are for financial firms.
2
u/jjttjj Mar 20 '18
Have you ever checked out the clojure NYC meetups? https://www.meetup.com/Clojure-NYC/ There's actually one tonight. There are always multiple companies practically begging to hire clojure programmers and none of them have seemed to involve much math that I recall.
0
Mar 19 '18
[deleted]
3
u/mingp Mar 20 '18
Perhaps, but why? I would guess there's 2 major factors at play here.
Certain, primarily mainstream, technologies are associated with certain low-paying clusters in the market. For example, PHP with low-end web agencies and Java with offshoring / onshoring shops, etc. (Not to suggest that there's anything wrong with those technologies or their users, but that there are certain types of companies skewing their stats.)
Non-mainstream technologies are mostly adopted by self-motivated enthusiasts. Companies are willing to pay these individuals on the basis of their motivation, not necessarily their choice of language.
31
u/seantempesta Mar 20 '18
The results are largely similar to prior years, although the question format changed a little making it hard to directly compare every detail. The top result is clearly error messages though - while spec has started us down a road, that is still a work in progress which will continue this year. Many people have been using the Expound library for taking spec error output and making the data easier to read.
Could it be that Clojure 2.0 might finally address these issues? Clearly Cognitect has ignored this complaint for years now, probably because it's not sexy (or groundbreaking) to improve the developer experience. But wouldn't it be great if new users didn't give up the first time they made a typo and got a 10 page java stack trace with little to no useful information?
I know Clojure isn't a democracy, but please please please consider this milestone opportunity to grow the community.
4
Mar 20 '18
Clojure do not need to break existing code, I am still waiting for good specs library. Unfortunately https://github.com/clojure/core.specs.alpha has no that much activity so far (this could solve most of the issues with errors).
9
Mar 20 '18
I've been working with Clojure since 2012, and every stack trace I have ever seen has shown me directly where the problem is.
I am familiar and comfortable with Java though, that may help.
10
u/antiquechrono Mar 20 '18
every stack trace I have ever seen has shown me directly where the problem is
Here's something ripped off Stackoverflow.
(let [myname (read-line)] ((println (str "hello " myname))))The error is obvious that they added an extra set of parens, however not so obvious to the beginner. Even more head scratching for the beginner is that this works and then crashes.
NullPointerException user/eval1440 (form-init8012896866062367401.clj:2) user/eval1440 (form-init8012896866062367401.clj:1) clojure.lang.Compiler.eval (Compiler.java:6927) clojure.lang.Compiler.eval (Compiler.java:6890) clojure.core/eval (core.clj:3105) clojure.core/eval (core.clj:3101) clojure.main/repl/read-eval-print--7408/fn--7411 (main.clj:240) clojure.main/repl/read-eval-print--7408 (main.clj:240) clojure.main/repl/fn--7417 (main.clj:258) clojure.main/repl (main.clj:258) clojure.main/repl (main.clj:174) clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--648 (interruptible_eval.clj:87)The stack trace doesn't help here, and it seems like beginners run into quite a few of these simple but stupid situations and give up. Why is the compiler not smart enough to tell you that you tried to call the output of println (nil) as a function.
-1
Mar 20 '18
The stack trace does help, it tells you precisely the issue with that sexp in the very first line - NullPointerException.
The compiler can't help in that case because it's a runtime issue, I guess spec could help in some way - I have to admit I haven't adopted it yet.
A broad solution to error messages is not simple, to me it's not even clear that a problem exists.
Mostly I would encourage someone who gives up when seeing that stack trace above, they have value and reading them can become second nature in short time.
8
u/joinr Mar 21 '18
That message is opaque. I've experienced worse. Now let's play go hunt the nil (note there's no function invocation to trace to the offending line of source code, good luck). This really sucks when a typo jacks up loading a file, and you're left branch and bounding dependent namespace loads to see which one entered the null hole.
People praise elm, but I wish we had something closer to common lisps system. Badass, informative, and helps you explore what went wrong up and down the stack, starting from a point of failure. Restarts are cool, but not necessary
1
Mar 21 '18
All I can say is I've never really encountered the problem you are describing, and while I accept those who are motivated by improving error messages are very motivated, personally I don't believe it's an issue.
I suspect any attempt to alter the general output of an error from the full context of a stack trace (when hosted on the JVM) to some interpretation of one is possibly going to be unpopular, unless it's something minor like omitting intermediary lines.
7
u/joinr Mar 21 '18
You are fortunate, or maybe in the tail of the distribution. I don't question your experience, but perhaps your sampling is not large enough, or otherwise naturally biased to preclude these kinds of problems.
As i said elsewhere, it doesn't have to be a manichean solution. There can be better errors without losing the context of a stack trace. Maybe, like mutation, exhaustive stack traces should be available, but not the default.
6
Mar 21 '18
[removed] — view removed comment
1
Mar 21 '18
Don't tell me this is super helpful.
I can tell from the first line of the stack trace and a glance at your code what the problem is. Stack traces are unavoidable on the JVM, Clojure is a dynamic hosted language, and your example is a runtime issue.
I've no doubt some people find stack traces frustrating, but this isn't the striking example that proves the point that something is wrong that must be fixed.
8
u/joinr Mar 22 '18 edited Mar 22 '18
I don't buy the "this is a runtime issue, qed" line... Other languages do varying degrees of a better job in detecting this case (both in compile-time analysis and run-time reporting) than Clojure. Outside of Common Lisp, the bar is actually pretty low IMO.
Python is a bit less helpful, and the usage is not idiomatic:
>def showexcuse(excuse): print(excuse + " is no excuse for poor errors!") >showexcuse("runtime").__call__() runtime is no excuse for poor errors! Traceback (most recent call last): File "python", line 1, in <module> AttributeError: 'NoneType' object has no attribute '__call__'BiwaScheme (at least tells you that you're trying to use something that's not a function as a function, still relatively opaque):
BiwaScheme Interpreter version 0.6.4 Copyright (C) 2007-2014 Yutaka HARA and the BiwaScheme team >(define (show-excuse excuse) (print (string-append excuse " is no excuse for poor error messages!"))) >((show-excuse "runtime")) runtime is no excuse for poor error messages! Error: #<undef> is not a function [print]Racket does somewhat better, telling us that it expects a procedure, not necessarily:
Welcome to Racket v6.12. > (define (show-excuses excuse) (print (string-append excuse " is no excuse for poor error messages!"))) > (show-excuses "runtime") "runtime is no excuse for poor error messages!" > (let ((f (show-excuses "runtime"))) (f)) "runtime is no excuse for poor error messages!"; application: not a procedure; ; expected a procedure that can be applied to arguments ; given: #<void> ; [,bt for context]and we can get more context (not terribly useful in "this" case)
> ,bt ; application: not a procedure; ; expected a procedure that can be applied to arguments ; given: #<void> ; arguments...: [none]Common Lisp (SBCL) handles this way more gracefully, despite being a "runtime" error. The analyzer is able to provide compile-time warnings when you eval the form, and the run-time error is not opaque, plus it dumps you into the conditional restart/debugger system automatically:
CL-USER>(defun str (x &rest xs) (format nil "~{~a~}" (cons x xs))) STR CL-USER> (defun show-excuse (excuse) ((print (str excuse " is no excuse for poor errors!")))) ; in: DEFUN SHOW-EXCUSE ; ((PRINT (STR EXCUSE " is no excuse for poor errors!"))) ; ; caught ERROR: ; illegal function call ; (SB-INT:NAMED-LAMBDA SHOW-EXCUSE ; (EXCUSE) ; (BLOCK SHOW-EXCUSE ((PRINT (STR EXCUSE " is no excuse for poor errors!"))))) ; ; caught STYLE-WARNING: ; The variable EXCUSE is defined but never used. ; ; compilation unit finished ; caught 1 ERROR condition ; caught 1 STYLE-WARNING condition SHOW-EXCUSE CL-USER> (show-excuse "runtime") Execution of a form compiled with errors. Form: ((PRINT (STR EXCUSE " is no excuse for poor errors!"))) Compile-time error: illegal function call [Condition of type SB-INT:COMPILED-PROGRAM-ERROR] Restarts: 0: [RETRY] Retry SLIME REPL evaluation request. 1: [*ABORT] Return to SLIME's top level. 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1005380033}>) Backtrace: 0: (SHOW-EXCUSE #<unused argument>) 1: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SHOW-EXCUSE "runtime") #<NULL-LEXENV>) 2: (EVAL (SHOW-EXCUSE "runtime")) --more--As u/halgari points out, there's the possibility for trading off things like performance and error sanity. CL lets you do that via various declare statements, to tell the compiler how to optimize and what to strip out (like debugging information, possibly other helpful information and instrumentation, for the sake of performance). Clojure could ideally be more like Common Lisp in this regard (if for no other reason than to shut up the smug lisp weenies who screech about java stack traces :) ) I also like Racket's additional context prompt. Bottom line: things can be better, particularly in the trivial case where nil is used as a function...
1
Mar 22 '18
I think basically you're describing Spec right?
You ask why the compiler can't help you, the answer is it's a runtime error and Clojure itself is dynamic.
I haven't adopted Spec much myself, but I presume you could spec-up all these functions and have additional safety / error messaging support?
5
u/joinr Mar 22 '18 edited Mar 22 '18
I didn't ask why, I [tried to show] that the compiler can help you, via analysis and by automatically adding (optional) sane runtime checks and forensics.
Clojure is "dynamic" but it's compiled, just like Common Lisp. If we're in interpreted-land we'd be in more trouble, but we're not. As evidenced by Common Lisp, the compiler can and does help, and provides things like Style Warnings and Errors prior to any runtime execution, without sacrificing "dynamic."
Spec (unless used for checking macros and core forms during compile-time) is typically a way to establish run-time contracts. For the macro forms that are now spec'd in clojure, we get compile-time checks (such as ns declarations and defn and other things), which is an example of a compiler preventing runtime errors. This is actually pretty cool, since despite clojure's dynamicity, its use of macros gives you a hook into the compiler, therefore specs can be used inside macros to get some forms of compile-time verification using the same type of contract mechanism you'd use at runtime. For instance, passing a non-vector as function args for a function declaration is a compile-time error. We don't wait until runtime to blow up...
The solution in CL elegantly combines a good code analyzer/compiler and optional runtime instrumentation, i.e. making things smart enough to detect said conditions prior to execution (where possible, which is apparently entirely doable in CL for this case). Layering on runtime checks provides the means for additional useful error conditions and reporting - which for CL results in IMO best-of-class contextual information for the REPL interactive development (maybe the SmallTalk folks would disagree). Bear in mind the compilers like SBCL and CCL have decades of effort put into them, many during the "Golden Age" of Common Lisp by some literal geniuses....approaching that level of badass would be a challenge, but it's at least an example to look up to.
There's also lot of fine-grained, yet relatively high-level control via optional run-time instrumentation via things like optimize where one can specify targets like safety or speed, and levels of optimization to perform on a per-function basis. One could envision a similar functionality for variably invasive instrumentation (via spec or even something stupid like nil-checks on the first element of forms prior to evaluation....) to provide additional context. Right now, it's generally considered bad-practice to instrument all functions and leave the contracts on during runtime; rather you instrument your functions and turn on specs during testing (ideally including generative tests via spec's exercise fn), but leave them "off" during production for performance reasons.
Spec is part of the solution (it is for some core macros already), if - again - errors can be clean and proximate expositions of what went wrong and possibly why. They sometimes are, but as others have pointed out (indicated by the creation of libraries like expound), specs results are not always trivial to parse either.
1
Mar 22 '18
I didn't ask why
Excuse me, I mistook you for the OP who specifically asked:
Why is the compiler not smart enough to tell you that you tried to call the output of println (nil) as a function.
I took that as strictly a question of compile time analysis, though to be fair the OP could have just been asking "why doesn't the computer do better".
I'm aware we could instrument everything at runtime, but that's a different question with different trade-offs. Your runtime examples from other languages are interesting, I wonder if this is a particular special case though (executing a nil fn) in the plethora of possible runtime errors.
→ More replies (0)2
u/halgari Mar 22 '18
A bit of a correction: these stack traces are unavoidable if you want un-compromised performance. As a friend pointed out to me recently, the Clojure community has a bit of an unhealthy obsession with performance. Could we sacrifice a bit of performance for sane errors?
These things are possible, if it was a priority.
1
Mar 22 '18
I meant unavoidable only in that they occur on the JVM, and Clojure is hosted on the JVM. I don't understand the point about performance, you mean that Clojure choosing to interpret stack traces would come at a cost?
0
Mar 22 '18
[deleted]
1
u/joinr Mar 22 '18
That's pretty cool. I hadn't learned of that feature; seems like it would be a useful tool, except where you don't maintain backwards compatibility with earlier JVMs (which Clojure tries to do).
I think the source snippet is key though (thing being eval'd, where it's called, where it came from), and it's likely we could find a way to do that without any additional platform-specific stuff. Since we're in FP land, tracing the point of failure and seeing its inputs is "usually" sufficient to start back-tracking to cause since we don't typically have side-effecting action-at-a-distance.
Much of these problems are mitigated by tooling (I use Cider, you use Cursive), but not entirely, and perhaps not to the utility of folks learning.
1
Mar 22 '18
[removed] — view removed comment
2
u/joinr Mar 22 '18 edited Mar 22 '18
[updated, moved code examples to gist]
Sure. I was merely mimicking the original low-hanging example of trying to invoke nil as a function (common if typos include extra parens).
With file-compilation we get more info. Here's one file (multiple files like building packages vis CommonLisp's asdf or multiple calls to compile-file would produce additional data...)
Given the source demo.lisp
With, at least in the Portacle CL environment (souped up emacs) you get highlighted errors matching another buffer with compiler errors (juxtaposed as if in the margins) with hyperlinks to source file lines matching the error, and the original source file now has red error lines for related forms.
If we add in the actual invocation of ((show-excuses "runtime")) at the end of the source, then compile and load again, we can look at the extended backtrace (elided by default). This has a bunch of slime/swank stuff (kinda like nrepl and repl stuff) but you see the form that failed, the file definition, and you get all the stuff mentioned previously. Lots of approachable context. In this case, since we're compiling a file, we only have the option to restart by aborting, typically though, CL lets you go in and do some invasive debugging, including examining frames in the backtrace, changing values, etc.
Execution of a form compiled with errors. Form: ((SHOW-EXCUSE "runtime")) Compile-time error: illegal function call [Condition of type SB-INT:COMPILED-PROGRAM-ERROR] Restarts: 0: [*ABORT] Return to SLIME's top level. 1: [ABORT] abort thread (#<THREAD "worker" RUNNING {10054D7A43}>) Backtrace: 0: ((SB-C::TOP-LEVEL-FORM ((SHOW-EXCUSE "runtime"))) #<unavailable lambda list>) [toplevel] 1: (SB-FASL::LOAD-FASL-GROUP #S(SB-FASL::FASL-INPUT :STREAM #<SB-SYS:FD-STREAM for "file c:\\Users\\joinr\\portacle\\demo.fasl" {10054DA1F3}> :TABLE #(154 #<PACKAGE "SB-IMPL"> SB-IMPL::%DEFPACKAGE "ERR-DEM.. 2: (SB-FASL::LOAD-AS-FASL #<SB-SYS:FD-STREAM for "file c:\\Users\\joinr\\portacle\\demo.fasl" {10054DA1F3}> NIL NIL) 3: ((FLET SB-FASL::LOAD-STREAM :IN LOAD) #<SB-SYS:FD-STREAM for "file c:\\Users\\joinr\\portacle\\demo.fasl" {10054DA1F3}> T) 4: (LOAD #P"c:/Users/joinr/portacle/demo.fasl" :VERBOSE NIL :PRINT NIL :IF-DOES-NOT-EXIST T :EXTERNAL-FORMAT :DEFAULT) 5: (SWANK:LOAD-FILE "c:/Users/joinr/portacle/demo.fasl") 6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:LOAD-FILE "c:/Users/joinr/portacle/demo.fasl") #<NULL-LEXENV>) 7: (EVAL (SWANK:LOAD-FILE "c:/Users/joinr/portacle/demo.fasl")) 8: (SWANK:EVAL-FOR-EMACS (SWANK:LOAD-FILE "c:/Users/joinr/portacle/demo.fasl") ":err-demo" 196) 9: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD)) 10: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {1006FE5E6B}>) 11: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "c:/Users/joinr/portacle/all/emacsd/elpa/slime-20170203.1728/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::SP.. 12: (SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {1006FE5E6B}>) 13: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD)) 14: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #1=#<SWANK/GRAY::SLIME-INPUT-STREAM {100526C933}>) (*STANDARD-OUTPUT* . #2=#<SWANK/GRAY::SLIME-OUTPUT-STREAM {100535D733}>) (*TRACE-OUTPUT* . #2#) (*ERR.. 15: ((FLET #:FORM-FUN-3864 :IN SWANK::SPAWN-WORKER-THREAD)) 16: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD)) 17: (SWANK::CALL-WITH-BINDINGS NIL #<CLOSURE (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {10054D800B}>) 18: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD)) 19: ((FLET #:WITHOUT-INTERRUPTS-BODY-1169 :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE)) 20: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE)) 21: ((FLET #:WITHOUT-INTERRUPTS-BODY-359 :IN SB-THREAD::CALL-WITH-MUTEX)) 22: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE) {F76FB4B}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THREAD ".. 23: (SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE #<SB-THREAD:THREAD "worker" RUNNING {10054D7A43}> NIL #<CLOSURE (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {10054D79CB}> (#<SB-THREAD:THREAD #1="worker".. 24: ("foreign function: #x42C72C") 25: ("foreign function: #x4038A1") 26: ("foreign function: #x447080")For run-time errors, I'd imagine something that would scrape out source-code definitions (like in Clojure's existing stack traces, when they're not opaque or reflecting action-at-a-distance that's not proximate to the actual source of the problem), it should be easy to scrape the metadata from a function or macros source meta to get line/number where it's defined as we currently do (Cider lets you hope to source-file definitions and the like based on stack traces).
I'm using vanilla CommonLisp stuff, not even very well (I'm far from an expert), but already IMO, the tooling for finding and debugging sane error messages is significantly better on average. There are Clojure libraries that try to get there; Cider does a good job trying to clean up and provide context for instance. In the case where you don't have the source, one could imagine tooling like tools.decompiler allowing interactive examination of the thing that failed too.
I've never said line-numbered stack traces are "bad" - the forensics are useful when they apply - but in the case presented earlier (nil invocation) they fail. In the case of newbs (I'm sympathetic because I've had to teach folks from scratch), they present a "wall" more often than a pedagogically useful "challenge" or an ideal "causal conversation" about what went wrong and why [I really like spec's intent here in what it provides - why - not necessarily the current execution]. In the best case, you get a lot of information to scrunge through (some of it not helpful, but at least it's detailed to include execution paths and source file lines), in the worse case (even for experienced folks, as we've heard from) you get to spend an afternoon jumping through hoops to end up at an ultimately simple problem (that maybe you could've arrived at 10x faster with a little help). I think CL provides some useful indications of enhancements that could help out (both compile-time and runtime) along with a pragmatic approach to disabling said features for production (via compiler declarations).
2
Mar 22 '18 edited Mar 22 '18
The stack trace having no file name or line number piqued my interest, as the exceptions / stack traces I encounter basically always have that information (which is possibly slightly related to my workflow, noted above, and also a large reason I don't see any issue with Clojure errors being simply JVM stack traces).
So I downloaded the CLI tools to run your example, and had the same exception. Then I started playing around with simple cases that should pass, e.g (+ 1 1), and got the same exception.
In short, you should have
(defn -main [] ..Rather than
(defn main [] ..The exception you see is unrelated to the error you expect, it's basically trying to tell you that you have no main method at all.
Correcting your code, you should now see:
clj -m test asd hello asd Exception in thread "main" java.lang.NullPointerException at test$_main.invokeStatic(test.clj:5) ^^^^^^^^^^The file and line number.
Yes, the exception in this case wasn't very helpful to a new beginner. Something along the lines of "main function not found" would be nicer. It's a low-frequencey execution point, perhaps Cognitect could be convinced to make that a special case, but broadly speaking it's not representative of errors I would expect you to see.
2
Mar 22 '18
[removed] — view removed comment
2
Mar 22 '18
Well it does prove your point in a way about unhelpful messages, it's probably the most basic error a new user to Clojure could find and would it be that hard to special case it to say "no main"?
Language design is a regular topic of discussion in the Clojure community because, it turns out, lots of us have reasonable opinions about how things should be, those opinions maybe easier to express than address if you bear the weight of stewarding a language. So, I don't expect Cognitect to be making a special case of even this most simple of special cases.
Clojure's a great language for getting stuff done, don't be put off by the errors!
→ More replies (0)6
u/yogthos Mar 20 '18
The stack trace will tell you exactly where the error is, but it will also show you lots of incidental noise. Removing the noise and providing better error messages would be very welcome in my opinion.
3
Mar 20 '18
It shows you the full context of the system at the point of error, and I want that context unadulterated.
I'd suggest that if Cognitect enforced 'better' error messages you'd have equally as many developers demanding stack traces back - for example there's no circumstance in which I want any interpretation on my behalf of stack traces in my Clojure system that emanate from the Cassandra driver (Java) or the Kafka producer (Scala).
This is not a simple problem to solve for all users, stack traces can become second nature (and anyone working on the JVM is going to be presented with them at some point), and considering the trace tells you exactly where the error is - is this really where time and energy should be spent?
5
u/joinr Mar 21 '18
Nothing says you can't have access to raw stack traces. That can be retained and not shown unless asked for, just like we have print-meta
1
Mar 21 '18
It's less a problem of access to raw stack traces, more that I think it's unlikely a single contextual interpretation of stack traces exists across all users in all cases.
0
Mar 22 '18
[deleted]
1
u/yogthos Mar 22 '18
Yeah Cursive does make this nicer It also works with ultra, so you can get colorized and cleaned up trace in Cursive.
5
u/halgari Mar 20 '18
While this is true, and I also have been using Clojure since around 2010, the problem is that decoding the stack traces takes cognitive load. I've done a fair amount of work in Python, and there's a few things that language does that makes its stack traces a much better experience:
Ties source code to each line, so when have an error at a given line in
foo.pythat line is included in the stack trace. IIRC some later version even include the ability for column offsets.Stack traces are printed in reverse order from Clojure. I wouldn't mind long traces as much if the last item in the trace (the closest to my cursor in the repl) was the line that caused the error
Intermediate results are removed. If you have a error in the internal hashing function of a dict you don't see the entire stack of C functions that are working on the dict. You only see the Python frames, and perhaps a single line that mentions that you're calling
dict.__setitem__. In Clojure every function invocation involves about 2-3 stack frames due to AFn, RestFn and static var "stuff" (the .invokeStatic calls).1
Mar 20 '18
I think you've raised an interesting point that may explain why I'm so at ease with stack traces in Clojure (other than they are bread-and-butter to a Java developer):
Ties source code to each line,
The stack traces that I consider almost always have the precise namespace and line of the error that occurred, because my workflow generally revolves around an editor pane of a ns with the REPL as an exploratory tool.
I'm not so worried about ordering, but I note that Cursive does flatten some of the intermediate / redundant results these days.
3
u/joinr Mar 21 '18
I live in the repl too, with raw traces. Doesn't help when the entire trace is pointing at stuff in clojure.core that doesn't obviously relate to the actual offending form.
4
Mar 20 '18
"It's possible to find the cause of a problem when presented with a stack trace" is not mutually exclusive with "It is very unpleasant to find the cause of a problem when presented with a stack trace".
1
Mar 20 '18
"It is very unpleasant to find the cause of a problem when presented with a stack trace" is one narrative, where a more positive for new programmers on the JVM is "stack traces are necessarily verbose because they contain as much information as possible, and in short time you can become familiar with parsing them, it becomes second nature"
4
Mar 20 '18
I've been using Clojure for longer than you have; I can find what I'm looking for in Clojure stack traces, but I find it more pleasant to do the same task in nearly every other language I know. (The only exception is Erlang, but Erlang has distributed tracing functionality that makes up for it.)
1
Mar 20 '18
Lets just say we've both been using Clojure long enough to have an informed opinion.
In your experience, which JVM hosted language has a more pleasant error reporting experience? Maybe there are lessons we can learn from other languages hosted in the same ecosystem.
*edit, I should add I didn't intend to suggest you're a new user to the JVM or Clojure, I use plenty of the libraries you have open sourced - more that I think it's valuable to counter the narrative to new users that stack traces are unknowable and all should give up hope.
2
Mar 21 '18
Clojure is the only JVM language I've used, but Urn is similar in that it's a lisp which is hosted on a runtime designed for a different language: http://urn-lang.com/ Urn is source->source instead of bytecode generation, so different strategies apply.
10
u/seantempesta Mar 20 '18
You'll have to excuse my hyperbolic claim, but clearly the majority of users think this is a real issue if it's the number one complaint (for years now). And yes, a familiarity with Java does help, but that isn't conducive to bringing in new users from different ecosystems.
4
Mar 20 '18
I agree that a majority of respondents to the survey indicated a concern with error messages, I suspect it's probably indicative of the divide between regular Java developers and not. I'm not sure that represents a majority of users, though that's splitting hairs. Either way it's a good reason for Cognitect to focus their efforts in the area.
For me the JVM is a key factor in my use of Clojure, and I'd encourage new members of my team not to give up in horror at the first sign of a stack trace, given they are likely unavoidable considering the host and Java/JVM dependencies we leverage.
3
u/seantempesta Mar 20 '18
I'm not sure that represents a majority of users, though that's splitting hairs.
Fair point. I can only speak from my own experience and from what I’ve read on the net.
given they are likely unavoidable considering the host and Java/JVM dependencies we leverage.
Compiler and runtime design of programming languages isn’t my expertise, so I’ll defer to others about what can be done. Naively I’d think all exceptions could be caught at a top level and something a bit nicer could be presented instead of a normal java stack trace?
Or maybe a —dev flag where all core specs are instrumented and then nicer messages could be displayed (maybe with expound)?
1
Mar 20 '18
I'm not a language designer either, but I look forward to seeing how the language evolves.
4
Mar 20 '18
There's no doubt it could and should be improved but it's the number one complaint because there isn't much else to complain about. And everyone seems to feel the need to crack a joke about it whenever they discuss Clojure. It's really not that big a deal if you've dealt with stack traces from any language, there's nothing especially scary about JVM stack traces.
1
u/ares623 Mar 21 '18 edited Mar 21 '18
It's quite a lot for an outsider coming from non-Java mainstream languages to pick up
functional programming with immutable, persistent datastructures
with Lisp-y syntax, but not quite Common Lisp or Scheme
with intimate Java stacktraces
need to familiarize the Java ecosystem
(optional) Emacs
Points 1 & 2 are addressed by tutorials, documentation, and books already.
Point 3 will hopefully be solved soon.
I don't know if there's currently something for point 4. The ecosystem is huge.
12
u/reborgml Mar 21 '18
The open comments section contains some well articulated (although not novelty) critique and source of frustration. There's a lot of positives too, but they tend to be single sentence. Since it took me a while to parse it, I extracted the most interesting in a gist https://gist.github.com/reborg/a9736c8f6045aa53e6022eb452a93db5
2
1
5
u/troublemaker74 Mar 20 '18
Thanks for this survey! I know I'm not alone when I think this...
Clojurescript is where all the cool stuff is happening. JS Devs are gaining more and more interest in Clojure when they see how easy, fun, and elegant it is to make fancy JS or even React apps without dealing with webpack, babel, or a billion dependencies.
13
u/SSID_Vicious Mar 20 '18
Is there a reason the number of respondents is stable for a few years now? Is it not advertised enough, is the community not growing anymore, something else?