4 ms·
The problem is that problem clojure code is the gift that keeps on giving, and it boils down to the problem I have with clojure in general: Bad clojure code is
by shadowmint 10y ago
The problem is that problem clojure code is the gift that keeps on giving, and it boils down to the problem I have with clojure in general:
Bad clojure code is unmaintainable spaghetti code; which gets worse over time, as people attempt to 'patch on' fixes without doing the heavy lifting of trying to figure out:
- What was the original author actually trying to do?
- Why the heck did they do it like this?
- How do we create the same functionality and prove it works with these rubbish tests that only test the individual units of work, not the application function?
- Why is it all in one giant file?
I've never seen code bases descend into chaos as fast as our clojure ones have.
Nice, elegant clojure is a pleasure to work with for personal projects, but I'm never using it professionally again.
You might argue it doesn't reflect on the language, but I think it does. Given what I've seen, I'd argue that clojure has an inherent complexity that results in poor code quality outcomes during the software maintenance cycle.
...specifically, sections of bad code have a disproportionately negative effect (compared to other languages) on the surrounding code and negatively impact the entire project's code quality.
You hack something out for a deadline? You better go back and clean it up, because if you don't that codebase is screwed. shrug That's just been my experience over the last year on three different code bases.
- bootload 10y ago"I've never seen code bases descend into chaos as fast as our clojure ones have." Is this a function of the teams or the language?
- shadowmint 10y agoPossibly, but there's nothing particularly wrong the other code they maintain in our case.
- abecedarius 10y agoI've only played with Clojure a little bit. Can you explain what makes bad Clojure code especially bad? Or why the badness leaks into the surrounding code? (The impression I've gotten is that the persistent data structures are very nice, and the language has some good ideas to go with them, but overall it didn't entice me away from Scheme or Common Lisp. But that impression doesn't explain why you had this bad experience with troublesome Clojure code.)
- yogthos 10y agoI've been working with Clojure professionally for the past 6 years and I've had a very positive experience. My team finds that code is actually very maintainable. Two main reasons for this are that Clojure is immutable by default, and it has minimal syntax. Immutability allows projects to be naturally compartmentalized. You can do safely do local reasoning on parts of the project. Meanwhile, simple and consistent syntax means that it's easier to read and understand the code written by others. There are far less language quirks to remember than in most languages. I also find that the editor integration with the REPL is a huge plus as well. Whenever I run into code that I'm not sure about, I can just run it and see what it does.
- jraines 10y agoNo language I've used is exempt from the possibility of people writing bad code evoking those questions. In fact I've had these reactions at various times to code in every language I've worked in (including Clojure, to be sure), but I don't agree with your argument about Clojure having greater than average inherent complexity. Once you get comfortable with parens, the core seq functions, and even a basic understanding of laziness & immutability, so much of the inherent complexity you find in many programs just goes away. Well -- most of the time. Again, Clojure is not going to stop you from negating these niceties with bad decisions. The one thing I'd maybe admit to it being a little above average on is the temptation to over-engineer due to novelty or feeling clever. Let's rub some core.async on it! Parallelize all the things! It's actually easier to do this because of the lack of inherent complexity in Clojure -- as the author mentions, everything is oriented around simple maps & lists, so juggling them and squeezing them through Rube Goldberg machines of transformations and mystery macros is definitely a thing you can do. But, ideally, you just learn to . . . not do that. Like abusing Ruby metaprogramming.
- shadowmint 10y agoOnly in good clojure code. Tell me you've never picked up a piece of clojure code and gone, WTF does this do? What are these global channels for? Why is the whole application constantly updating a top level full-application-state atom? Why are we blocking indefinitely with some magical invisible state hidden in a closure as we iterate over a collection of objects to process? If you have a beautiful clojure code base, it's fantastic... But, ideally, you just learn to . . . not do that How do you fix a bad code base when the functions aren't pure (global injections, global channels), or are 'pure' only in the sense the input is the entire application state, including non-pure objects like a database handle? Or your functions are non-deterministic due to some kind producer/consumer race condition? I get it; don't do that. ...but what do you do when it's too late, and someone has already made those bad decisions? Where are the debugging tools to help you figure out what's going on, and the refactoring tools to help isolate code units and replace them? I mean, sure, you could argue that's an issue in any language, but all I can say is that I've used a lot of other languages, and the only other similar experience I've had was working with perl.
- spraak 10y agoThis is why as much as I dislike Go, I'm glad to use it on a team
- daxfohl 10y agoThis has been my experience as well. It allows you to write extremely dense code, without type checks to help you out. And it imposes a functional paradigm, again without type checks to help you out. And it makes new developers think in ways they're not used to, again without type checks to help them out. So the combination of these makes certain that some way or other, teams will write contorted code that is in major need of refactoring ... without type checks to help them out. I switched to F# and "get" FP much better now. I'd know what I was doing if I ever switched back to Clojure. But I have no good reason to personally, and all the aforementioned reasons not to professionally.
- collyw 10y ago>Bad clojure code is unmaintainable spaghetti code; which gets worse over time, as people attempt to 'patch on' fixes without doing the heavy lifting of trying to figure out: Couldn't you say the same thing about most languages?
- btschaegg 10y agoThat would be my take on this too. If you get code written by people who don't know the language, the result is pretty much always dreadful. I know of no language that mitigates this. However, I'd be interested in which parts of Racket and CL klibertp thinks are making them better languages than clojure.
- weavejester 10y agoIt may be that you've been unlucky. I've been using Clojure for nine years now, and the majority of codebases I've worked on have been very clean. My experience is that Clojure tends to produce flat codebases, whereas OOP languages produce codebases that tend to be deeply nested. I can't prove any of this; it's all anecdotal, but I thought I'd mention that your experience might not be typical.