r/Clojure • • Jun 11 '16

My Increasing Frustration With Clojure

http://ashtonkemerling.com/blog/2016/06/11/my-increasing-frustration-with-clojure/
92 Upvotes

39 comments sorted by

13

u/gepardcv Jun 11 '16

The author raises some fair points: Clojure has always had surprisingly sharp edges. Experienced hackers tend to get used to them and stop caring, though — this problem has come up in the community before.

That said, many of his complaints boil down to the lack of argument checking. Well, that comes with the dynamic typing territory. Clojure leans in the direction of performance over safety, so it explicitly avoids runtime type checks, and makes do with documenting expected arguments. I wonder how that will square with core.spec, but for now, the tradeoff remains part of the Clojure DNA. It makes sense that the core team shows no interest in changing it.

As for CIDER and parsing test run output: yup, it's ugly. Feel free to run tests from the REPL when the conveniences don't work. I do this all the time, no big deal. Or you could submit a patch. :)

21

u/[deleted] Jun 11 '16

Okay, I'll edit the post. It's pretty clear that nobody is getting the point I'm trying to get across. And according to my own post, that's my fault.

It's not that Clojure has sharp edges, it's that the official response is either silence or "you're wrong, the code is right." I couldn't care less how they fix some of the bugs I mentioned, as long as its not a passive-aggressive note and a "wontfix"

32

u/yogthos Jun 11 '16

I had the exact experience you describe when I tried to contribute to add nil checks in clojure.string functions. I was told that it's not a problem because working on a string is Java interop and that's expected behavior.

Except, the fact that Clojure strings are backed by Java strings is an implementation detail that I shouldn't care about as the user. Conversely, strings are already treated as collections and all the standard collection manipulation functions will handle nil intelligently.

So, now you have this quirky error prone behavior for strings, that's justified in a very hand wavy way. No real discussion, I was just told that this is the behavior and we like it.

5

u/inushi Jun 11 '16

I can't find a reference quickly, but I seem to remember reading some of the early design/publicity materials for Clojure, and one of the original designs was that Clojue explicitly acknowledged and embraced the fact that it was hosted on Java. My recollection of the spirit of that old document was that Clojure did not intend to be agnostic about the runtime that it is hosted on: you are using Clojure because you like the JVM.

I suspect that old doc was written before cljs, and I don't have a good sense for the modern viewpoint of the community.

11

u/yogthos Jun 12 '16

Embracing the JVM is not at odds with handling strings consistently in any way though. Here's an example of Clojure embracing the JVM working with the java.util.HashMap:

(get (doto (java.util.HashMap.) (.put "foo" "bar")) "foo")
=>"bar"

This doesn't prevent get from handling nil intelligently however:

(get nil "foo")

So, why then why would this be any different:

(subs "foo" 1)
"oo"

(subs nil 1)
=>java.lang.NullPointerException: null

2

u/snaky Jun 12 '16

So, why then

From the comment at original blog

in order to be able to continue with their work they've got to believe that they were good decisions, and even if they don't personally believe they were good decisions they have to defend the decisions as if they were good decisions, for the good of the team. This isn't badness on their part, it's just normal human group psychology.

1

u/walkingthehotdog Jun 15 '16

I'm not sure it's a good idea to base your argument on get, as the docs for get explicitly state that nil is returned if the key is not present. Consider instead, nth, which doesn't make that guarantee in the same way that subs doesn't make that guarantee.

(nth "foo" 1)
\o

(nth "foo" nil)
NullPointerException   clojure.lang.RT.intCast`

Consistent with subs in that undefined behavior gives undefined results.

1

u/yogthos Jun 15 '16

When called on a collection or a string gives the element at the index:

(nth [1 2 3] 1)
2

However, calling nth on a nil value produces nil as expected:

(nth nil 1)
nil

So, nth behaves consistently with get here. If you pass it a nil string then you get a nil back. You NPE when you pass it a nil index which has nothing to do with nth being called on a string.

1

u/walkingthehotdog Jun 15 '16

Ahh, my mistake on arg placement. I understand the pain, but with backwards-compatibility being one of the most prioritized ideas in Clojure, I see why they won't change it. There's the chance that existing projects rely on and handle that exception in the nil case, and changing it to return nil instead of throwing the exception could cause problems. As someone else mentioned, it'd be interesting to see Clojure make some breaking changes to a 2.0 that reimplement interface-based things with protocols, (maybe) make functions like subs behave like nth and get, etc. However, the Python and Perl communities have shown that this idea has its own problems, and I think it's also almost guaranteed not to happen. According to the latest cognicast, though, this seems to be something Rich has been thinking about.

So, we need to go to a finer granularity in how we think about dependencies, and we need to become more rigorous about saying, "I'm never going to change something under the same name in an incompatible way."

2

u/yogthos Jun 16 '16

I do agree that backwards compatibility is a major feature in Clojure. However, I think there needs to be a path for fixing quirky behaviors a well.

If you already have a nil check in place, then things will keep working just fine. Furthermore, exceptions shouldn't be used as flow control in the first place.

So, in this scenario I would argue that handling nil consistently would be a big improvement overall. If people are worried about poor data, then they should sanitize it using spec, schema, or other libraries, instead of relying on exceptions.

1

u/walkingthehotdog Jun 16 '16

The idea that exceptions shouldn't be used for control flow doesn't change the fact that the solution you're proposing is a breaking change. How to properly handle exceptions is completely different from how exceptions are handled sometimes. Things are not always so obvious, even in hindsight. Additionally, no one wants to (and many don't have the resources to) hire a dev to track down why an upgrade broke their program that used to work.

That being said, I think spec will be able to help a lot moving forward. It can handle your nil case, the OP's bad input case, the OP's bad output case, and much more. I'm really hoping some specs ship with 1.9 so users can just call instrument-all and have a bunch of safety nets out-of-the-box, but we'll see.

→ More replies (0)

8

u/JGailor Jun 11 '16

I think this is a solid article, but one thing made me raise an eyebrow:

"(don’t forget, or your DBA will wonder why Emacs has 1000+ database connections)"

Why are you connecting to a non-local db for running a test suite? That's just bad form. Some representative / generative set of test data in a local datastore should be where you are running your tests from.

7

u/[deleted] Jun 11 '16

I recognize that this isn't a common pattern, but there are organizational reasons why this is the case that I really don't want to explain in a public forum.

134

u/hagus Jun 11 '16

I think it's great that you're engaging and filing bugs, and willing to lay out some of the concerns you've encountered in a blog post.

I will say that as someone who has worked in large systems with expansive APIs and decades worth of adoption (operating systems, way larger than the JVM or Clojure) I have a very different perspective on bug management, and I'd like to offer some advice when it comes to engaging on this topic.

  • "There are a shocking number of big, bad bugs hiding in the Clojure Jira, some really old"

  • "Oh wait, some of these bugs were filed in 2009, 7 fucking years ago!"

  • "Bugs, even major ones are either closed as “wontfix”, or are ignored for years despite the pain felt by users. That’s not even covering the dismissive and distrustful attitude given in some of the replies."

The first thing to tweak is the attitude you're bringing towards the problem. You have to operate from the assumption that everyone is acting with the best of intentions, and that deviations from what you expect aren't the result of ineptitude, ignorance, or insensitivity. This is the only way you will stay sane and is the only way to give everyone around you the breathing room they need to make the occasional mistake.

Give everyone the benefit of the doubt, always! The upshot is that when you are wrong, you will have the option to be gracious about it. Your blog post should have presented these issues, which are valid issues, as situations where you feel incomplete information is leading you to experience doubts about how these bugs are managed. You skipped that step and jumped straight to claiming people are treated dismissively. Now when the humans behind the bugs come out and give you the rest of the information, you risk looking like an ass.

I know all this because I've done it … it's painful to experience :(

The second thing you need to tweak is your ability to engage in a dialog about the issues. I scanned through the six JIRAs and one Github Issue I could find in your article, and your name only came up in the Om issue, so this is the only one I can give you personal advice on. David Nolen shut it down pretty quick, like I'd expect a busy maintainer of an open source project to do.

As far as I can tell, very next thing David Nolen knows about this issue is you writing a blog post saying you were "treated shabbily". I think there are some steps missing here! Give him the benefit of the doubt, and then push back in a reasoned, calm manner. Make your argument. Pitch your case. Be prepared to be wrong, but hold on to the feeling you might be right. Don't give up, and certainly don't retreat to passive aggressiveness. These guys are all active and present on the JIRAs and the Github Issues … that is the foot in the door you need to keep the pressure up if you care about the problem.

Lastly, have a think about some of the unique constraints that come with maintaining a large, complicated code base spanning almost a decade with a rich API exposed to hard core developers. From your perspective, the fact that there's a bug and it's an old bug is a sign of mismanagement or lack of care - or even a systemic issue with the Clojure community. From my perspective, large projects accumulate heaps issues like this and it's always a trade-off. Some things to think about:

  • what off-JIRA or internal discussions happened behind each issue?

  • what unique intuitions might a Clojure core maintainer have about this issue, that you do not?

  • how busy is the Clojure core team? What is the severity and impact of other issues they're juggling?

  • how many duplicate issues or affected users are there?

  • what is the compatibility risk when changing behavior deep in the language?

When you consider these, it should be apparent that an old bug could definitely still be a bug … but the older it gets, the less likely it is to be fixed. Yes, the behavior could be wrong so it's still left open ... but after 7 years, what would break if we fixed it? Is there any way to tell? How many users have reported this? One or two? Why would we take the risk of fixing this issue?

Clojure in general has an incredibly good backwards compatibility story. It's rare for very old Clojure code to break (I heard somewhere that code from the very first Clojure book still works 100% ok on Clojure 1.8 - extraordinary). So there is a cultural element to this as well, which is that it's better to have some edgy, imperfect behavior than to pick at the scabs in the language and risk creating a new, more severe issue.

If I would make one recommendation myself to the Clojure core team, it would be to have someone scrub the JIRAs to make sure the priorities are correct at least. We know a 7 year old issue is not "critical" … honest prioritization helps a lot. Don't be afraid to shovel bugs into a bucket that makes it clear you're just waiting for this to blow up sufficiently to justify fixing it - it's not punting on the issue, it's asking the community for some specific prioritization help that you won't get if the bug is parked alongside everything else.

Anyway, Ashton, I'm sure everyone appreciates you speaking candidly. Just remember to keep an open mind and give folks the benefit of the doubt.

9

u/lintablecode Jun 12 '16

The art of cooperating with the community involves making sure people don't feel lost in the project workflow. Common priorities should be a thing too - at least be transparent.

Fixing rough edges? That would make the community happier. Spreading the word about Clojure would get easier. That's a business concern - bigger userbase - more opportunities for Cognitect to make money, I suppose.

If there are not enough devs, maybe it's time to finally open up for the community? It's not about altering big designs, it's small things that matter. And if not, what if they opened a fundraiser - "pay us money, and we'll improve error handling"?

Rough edges make Clojure a tough sell:

  • Advocating it to experienced developers of modern languages is hard. And kind of humiliating - currently I cannot show Clojure to other devs without acknowledging "yes, error reporting looks like it looks like" when I make a typo live-coding.

  • It does not feel solid when developing - a UX thing.

  • It cannot be an educational language (good luck with errors).

If these problems were fixed well enough, I think I could convince ~2 colleagues to try it out.

6

u/saint_glo Jun 12 '16

Alex Miller have left a comment on that post that addresses some of your points.

31

u/yogthos Jun 11 '16

I think this post raises very important points. I find Clojure is a great language, but I also think that it's very rough around the edges. Many quirky and surprising behaviors have crept in over the years, and these really need to be addressed proactively. Issues like this waste time for beginners and experienced users alike.

20

u/weavejester Jun 11 '16

The author raises some good points... though I have to say that I'd prefer transducers (which are essential for some of my code) over any of the issues he mentions (which can be worked around).

If I can pick apart testing in particular, its not entirely the fault of clojure.test, as that library is more flexible than people give it credit for... though arguably that's because its flexibility isn't exactly well documented.

For example, Humane Test Output overrides clojure.test/assert-expr in order to improve reporting. But a better solution (and one I use in eftest) is to take advantage of the fact that clojure.test/report has been dynamic since Clojure 1.2.0, and can be overridden with a simple binding. There's no reason that Humane Test Output needs to be as invasive as it is.

Similarly, Leiningen's test task could also take advantage of this. Instead it uses an injection hook to monkeypatch the reporter, when it could achieve the same effect with a small supporting library.

As for fixtures... well, Stuart considers the current design to have a lot of problems, and he was the original author. However, while it'll take a while to get rid of them, there's no reason we need to wait on Clojure core to build something better. Fixtures are added as metadata to the namespace, and only executed through clojure.test/test-vars. But if we write our own test-vars (as eftest does), then we can use whatever we want.

So while clojure.test has a lot of room for improvement, we can actually add those improvements without waiting for the Clojure core team, and without breaking backward compatibility.

4

u/yogthos Jun 11 '16

I think one way to address the performance concern would be to simply have a separate unsafe API. In most cases correctness trumps performance. When and if you identify a piece of code that's causing a problem, then you should tune it at that point in my opinion.

3

u/weavejester Jun 11 '16

That's not a bad idea, but I wasn't addressing performance in the post you replied to :)

3

u/yogthos Jun 11 '16

Yeah, I was thinking about the cases listed in the article, but I definitely agree with all your points as well. :)

17

u/dantiberian Jun 11 '16 edited Jun 11 '16

The thing to realise about Clojure is that it isn't an open source language like Python. It is a language controlled very tightly by Rich Hickey and Cognitect. Major work is done in secret (transducers, reducers, spec), then announced to the world as a "Here it is!" and then suggestions are taken. This goes well mostly, though it took a lot of outside persuasion that Feature Expressions weren't the best idea, and to come up with Reader Conditionals instead.

The underlying problem Clojure/Core has is their communication. If they would come out and explain their philosophy then people wouldn't get frustrated and confused when they expect the language development to work like other open source projects. Clojure's development is functioning exactly as planned. It's not a mistake.

A better way to treat Clojure is closer to a project at Apple (except for Swift). You can submit bugs, and make suggestions for future improvements, and if you really want to, provide a patch. But go into it realising that it's not a community project, and you're much less likely to get frustrated.

With all that said, the proof of the pudding is in the eating, and for the most part Clojure has developed pretty well from Rich's tight control. I'd love it if there was a Snow Leopard year for Clojure where the focus was fixing longstanding bugs and feature requests, and more focus on those in general, but the language is developing well.

15

u/yogthos Jun 11 '16

While I definitely agree that this is a very accurate description of how Clojure is being developed, I really think that a discussion regarding whether this is the right way to do things is warranted.

If Clojure is to grow as a language, then community feedback really needs to play a larger role in its development. A lot of the problems that beginners struggle with are invisible to those who've used the language for a long time. This appears to be especially the case with the Clojure core team.

When you had years to learn different behaviors and internalize the quirks, it doesn't feel overwhelming. Things make sense, and as new things come up you can learn them as you go. So, it's often hard for somebody who's already invested in the language to relate to somebody new to it.

A beginner has to learn a lot of things at once, and the more quirks there are the more likely they are to get frustrated and move on to something else.

This is why it's important for the core community to be receptive to the needs of beginners who identify the barriers to entry that are invisible to those already on the inside.

2

u/[deleted] Jun 13 '16

If Clojure is to grow as a language, then community feedback really needs to play a larger role in its development.

Just happened across a refreshing viewpoint from the go-lang community.

https://youtu.be/XvZOdpd_9tc?t=12m30s

1

u/[deleted] Jun 12 '16

I'd love it if there was a Snow Leopard year for Clojure where the focus was fixing longstanding bugs and feature requests, and more focus on those in general, but the language is developing well.

Yes, yes, yes. And let's make startup time, especially in the surrounding toolchain pieces such as lein and nrepl, part of this. For gosh sake, we should be able to start a REPL in an editor, or run "lein help" in less time than it takes the damn OS to boot up.

1

u/dgellow Jun 14 '16

we should be able to start a REPL in an editor

Isn't M-x cider-jack-in a REPL in your editor?

1

u/LoyalToTheGroupOf17 Jun 14 '16

You missed the second half of the sentence you're quoting. (S)he isn't complaining that there isn't a repl, (s)he's complaining that the repl starts too slowly.

1

u/[deleted] Jun 14 '16 edited Jun 14 '16

Exactly. I can't recall where the discussion was, but most people are seeing real world ~25 seconds and up for REPL startup times, myself included. "lein help" on my older laptop with SSD takes 8 seconds. Windows 10 can boot in 6 seconds for goodness sakes.

1

u/dgellow Jun 14 '16

ah right, I stupidly read it as (or "REPL in an editor" "lein help in less time than ...").

5

u/dustingetz Jun 11 '16 edited Jun 11 '16

I think this article is spot on. But. I think the root cause here is that many of the tools are build by the community. Great tools cost a lot of money to build, and you need to build the right thing at the right time, the cost needs to be spread across the comminuty. The community is growing (seems really fast to me) and tools are improving. The first generation tools with all their rough edges are being replaced by simpler tools that have incorporated lessons of the first gen. Improvement is accelerating. So when the core team focuses on new features like CLJC, Spec, Transit, Transducers, Datomic, ClojureScript, they are doing things that only the core team can do. There are other more opinionated things (like frameworks) that the core team isn't suited to do, everyone's app is too different.

I use Clojure not because it lets me code my java/javascript stuff a little better, but because it makes impossible things possible, the thing I am trying to build is not possible in any other ecosystem today. If that weren't the case, you're fucking right I wouldn't be using clojure, because the amount of effort i waste trying to figure out type errors is ridiculous :)

19

u/yogthos Jun 11 '16

I think lack of community engagement is a bit of a problem of itself though. Cognitect doesn't really tend to work with the community to help support and promote community built solutions.

Here's a very recent example of this. When a beginner asked what would be the best way to try building a RESTful web app to play with Datomic, lots of people from Cognitect commented that Pedestal would be the way to go.

However, Pedestal is notoriously difficult to get up and running properly and poorly documented. The user spent two weeks trying to get it to work, and didn't get the support he needed. While Pedestal may well be fantastic, it's clearly not the right choice for a beginner.

8

u/stompyj Jun 11 '16

I think lack of community engagement is a bit of a problem of itself though. Cognitect doesn't really tend to work with the community to help support and promote community built solutions.

This is probably the only thing that worries me about clojure in the long run at this point. It does feel like there are two communities, cognitect, and everyone else.

That said, I do think they're starting to make inroads and figure out how to strike the right balance.

4

u/pxpxy Jun 11 '16

Yeah I've been very happy to see at least Alex Miller post here fairly frequently (and Tim Baldridge, somewhat less frequently but at least it's indicating that he is reading this sub!)

5

u/gumvic Jun 11 '16

My favorite example:

(swap! a nil) ;; java.lang.NullPointerException

(nil 1) ;; java.lang.IllegalArgumentException: Can't call nil

(1 2) ;; java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

The same problem gets three different errors, one of them being an NPE!

On the other hand, this is a real language used in real production. Cognitect depends on it, a lot of people's money depends on it, so of course they won't do any changes unless absolutely neccessary. I guess they just don't want unexpected regressions, at their scale that's understandable.

I really hope there will be backwards incompatible Clojure 2.0 though.

1

u/v1akvark Jun 13 '16

Saw this link posted in the HN discussion regarding Clojure funding

It is not on the Clojure website any more - explanation here

Anyway, I decided to send a PayPal payment to what I think might be Rich Hickey's e-mail address, together with this note:

Please accept donation towards Clojure development. The donation is free for you to use as you see fit. You do not commit your time, or work towards any feature, requirement or bug fixing in any way, and will not be asked for anything in return for accepting this donation.

I have already received more than the value of this donation. Thank you.

Note sure if he will receive it - if anyone from Cognitect is on here, and can confirm a way to make a payment, let me know?

I don't use Clojure at my work or for any real personal projects, so am not in a position to get my company to pay for support, etc. It has been largely a learning tool for me, but I have learnt so much! Just the insight I have gained from watching his talks online is much more valuable than the donation I made.

-18

u/memanfirst Jun 11 '16

This is just some guy complaining about how he'd rather like clojure functions work. His "bugs" are really requests for different functions which others don't agree with him on.

12

u/[deleted] Jun 11 '16 edited Jun 11 '16

You clearly didn't read all the way through. Most of the article is about how they responded to bug requests, and where I perceive their efforts to be focused. If you think you can distill that down to "this guy is whiney and wants stuff fixed his way", then you really didn't understand the post.