Fork me on GitHub
#clojure-dev
<
2017-06-28
>
andy.fingerhut02:06:44

@matan I have no say in matters involving what gets accepted into Clojure, but I would ask you to at least consider what might meet your goals that could be written as a separate library that didn't require changes to its core code. My main motivation for suggesting this is that if you find a way to achieve that, then you own your own destiny schedule-wise for releasing something useful.

matan03:06:28

@noisesmith you are right, the core problem is preserving sufficiently explanatory context at every point that can throw. that is the rudimentary thing. although in the example put forth up there, would input validation have avoided the need? (at the cost of some runtime cpu cycles, in dev mode)

noisesmith03:06:14

yes, in that case input validation could tell you that it needs map-entries or hashmaps, and lists are not accepted - in fact input validation will do a lot more to clarify than automatic rewrite of error messages will

noisesmith03:06:25

and I have a strong hunch this is the point of having spec in clojure.core

matan03:06:54

I tend to agree!

matan03:06:00

Alas, it would probably take years until validation is added in the core language, I suspect that would never happen because the community will favor the needs of already experienced developers (over helping those spending time with error messages which is what beginners spend a large amount of their time with)

noisesmith03:06:33

validation is already being added - for example 1.9 has a spec for the ns form and no longer accidentally works if you use require instead of :require

matan03:06:39

Wow, interesting developments...

matan03:06:00

Is it widely used in clojure's core in 1.9?

noisesmith03:06:31

I'm not sure how extensively it's in there, but this is why spec is in core instead of being a library, so that core specifications can give better errors

matan03:06:39

@noisesmith that's very good I think. as a beginner, I spent maybe 20% of my time deciphering error messages.

seancorfield03:06:20

I think the problem here is that solving the error message issue is extremely hard in the general case, but in reality there's a handful of "weird error messages" that Clojure produces that everyone just has to learn as a beginner, and folks need to learn a little bit about how to read a stacktrace (which is a very valuable skill for life).

seancorfield03:06:19

So there's a big trade off between the complexity and difficulty of solving the "bad error messages" without affecting performance vs the (relatively) short period of pain as each newcomer comes up to speed.

seancorfield03:06:26

Some people have already started complaining about the explanations produced by spec failures, even tho' the messages provide the exact details of what's wrong -- but they provide a lot of information.

rickmoynihan23:07:40

seancorfield: For what it’s worth I think these complaints against spec are definitely warranted. For what its worth the spec errors are incredibly useful but very poorly formatted which makes them very hard to read; simply because there tends to be a lot of noise.

seancorfield23:07:49

True. The formatting leaves a lot to be desired!

rickmoynihan23:07:10

I honestly think it’s the main problem with spec just now, and think some basic formatting would go a long way to convert people from saying “Clojure has terrible error messages” to “Clojure has great error messages”. See here for a pitch I made: https://groups.google.com/d/msg/clojure/mIlKaOiujlo/Ls1H5HzbCwAJ

noisesmith03:06:44

right- but for cases where all you are doing is slowing down the compiler - many of us are willing to pay that price since we already avoid compiling new code in our code hotspots if we aren't totally insane

matan03:06:07

I have some reservations about "short period of pain". In my philosophy, usability should be a property of developer tools, not just the applications they create.

seancorfield03:06:14

I'd say most Clojure developers would not accept that slowdown -- if you don't AOT everything (and AOT is horribly fraught with all sorts of problems!) then you'll pay the compilation cost during the initial warm up of your application.

matan03:06:40

Aren't clojure.spec validations only activated in dev mode?

noisesmith03:06:47

all I'm talking about is the extra work spec introduces...

seancorfield03:06:03

@matan I think it's reasonable for Clojure tooling to try to ease the beginner curve -- but it is not reasonable to expect the compiler to do that if it slows it down.

seancorfield03:06:36

@noisesmith I am happy to have spec instrumentation in place during development, but it's potentially a big overhead in production.

seancorfield03:06:05

The current use of spec in core is around macros so it's a compile-only penalty.

seancorfield03:06:41

(or rather, it's a read-time penalty 🙂 )

matan03:06:47

I think that's where we humbly defer. I want developers joining my team with clojure, all personality types not just those that never err or are willing to dig up the core language's stack trace to analyze why the core language is having trouble with their input on ocassion.

matan03:06:20

Doesn't spec come with that feature to disable all validations outside dev mode?!

seancorfield03:06:36

But as a Clojure (or Java or any JVM language) developer, you'll always have to read stacktraces...

seancorfield03:06:16

@matan That's exactly what I said:

matan03:06:32

Of course. The question is whether an error is explanatory, v.s. requiring analyzing the core language's source code...

seancorfield03:06:38

It's more than you enable instrumentation in dev mode (but not in production unless you want to).

matan03:06:52

Yes right, correct

seancorfield03:06:06

And I'm saying you get used to the error messages very quickly.

matan03:06:21

Well I think spec enables both types of devs then

matan03:06:42

@seancorfield is that a statistic? or a sample of 1 persons? 🙂

seancorfield03:06:02

It's opinion 🙂

matan03:06:04

I think this varies with different people lol

matan03:06:19

Well thanks for the discussion!

seancorfield03:06:47

Yup, but I do agree with the core team's overall prioritization so far...

matan03:06:56

In light of this discussion, me too, as much as spec will possibly be used to improve additional core library pieces, in that humble regard

seancorfield03:06:51

Would I like error messages to be better? At this point, I don't care much for myself, but yeah it would be nice for all the future Clojure devs so, yeah, it's worth spending some time on but I think systemic approaches (like Spec) are going to provide better leverage.

matan03:06:59

If the language is to persevere, I think you might be underestimating how important this vector of improvement might be though. We don't see the world flooding the clojure download page do we? 🙂

seancorfield03:06:40

I suspect there are a few key places in the core code where catching a particular exception and throwing a better one might really help -- but I'd be concerned about performance and how to ensure any performance penalty could be limited to dev-only.

seancorfield03:06:59

I don't think Clojure needs to flood the world tho'. Clojure is "successful enough". It's never going to go truly mainstream, because "OMG! Parens!", so the error messages are much less of an obstacle than other key aspects of the language.

seancorfield03:06:50

@matan For a while, I was very upset about clojure.string's behavior when faced with null string inputs. Given that (str nil) produces "", I argued for a while that having nil input be treated like "" in clojure.string would make the library a lot less frustrating...

seancorfield03:06:01

...I figured that 9 times out of 10, the most expected behavior would be ""-for-`nil`... so I built a version of clojure.string that behaves like that... and it was nice to use but it was noticeably slower 😞

seancorfield03:06:44

And then other folks convinced me that treating nil as "" would not universally be good behavior and would mask all sorts of other errors.

matan04:06:22

@seancorfield Yes we all had such examples indeed

matan04:06:42

Going back to "OMG! Parens!", that too can be alleviated with proper error messages!

seancorfield04:06:10

It can be alleviated by tooling 🙂 An editor that auto-balances parens and colors them (rainbow for matching parens is good, as well as pastel colors to make them less visible).

matan17:06:24

Well, at least I forwarded your note on upcoming use of spec inside clojure.core in 1.9, to that project that tried to accomplish similar things (https://github.com/Clojure-Intro-Course/clojure-intro-class). If I get it right, they also try to match exception text and replace messages in-flux.

matan17:06:51

In email, I'm notified the codebase is currently unstable and should be for the meanwhile avoided

matan17:06:17

Thanks for the yesterday/morning discussion