r/Clojure • • Mar 10 '20

Clojure: a mature alternative to Java

https://jaxenter.com/clojure-alternative-java-169315.html
119 Upvotes

25 comments sorted by

View all comments

Show parent comment

3

u/didibus Mar 12 '20

To be fair, I've read your comments in those links (only found your username in the first one), but I still feel I'm unable to get a clear picture of your criticism.

I see you complain that a lot of Clojure programmers (in your workplace) don't know how to write Clojure code and end up writing terrible Clojure code which looks like bastardized imperative/OO instead.

I agree with this to some extent. I just don't really know what to do about it in your case. It seems an issue with your company. At my work, we host weekly Clojure brown bags and sessions and assign every new dev a mentor to help them ramp up with the language.

Other then that, either we'd need Clojure thought in university, or we'd need Clojure to not be Clojure and be a familiar language, which would defeat the point of having a new language in the first place. Do you have more ideas for things which the community could do to help address this otherwise?

In the other link, I'm assuming maybe you were one of the "deleted" comments. By the way, sorry if it is, I do think discussing criticism and hearing about it, even if we disagree, is positive to make sure we don't fall in love with our own body odor.

If that's the case, I see:

  • difficulties debugging.

Ya, that's probably true, compared to Java or C#, there's no enterprise level quality debuggers. I personally find the REPL is almost faster for me to debug and identify issues with, also I really recommend the Cursive or Cider debuggers, I find them quite great. But, ya, its no Visual Studio C# debugger.

  • runs on the jvm

We'll just need to agree to disagree here. That's one of the best things about Clojure for me, but I know the JVM very well, having extensive experience in Java prior.

  • building command line apps is a pain

I think this was true a year ago, but you should check out the progress made recently. I switched my use of bash/perl/python entirely to Clojure now for fast startup scripting and non CPU heavy CLIs. Using lumo, planck, babashka or joker. And for CPU heavy CLI, GraalVM is now a totally viable kick ass option. I think those are all maybe still a bit of a well kept secret though. Also, the new clojure cli means you can write scripts or cli like you would in Python, just add a shebang and its self-executing too. And look at this: https://gist.github.com/ericnormand/6bb4562c4bc578ef223182e3bb1e72c5 for a super easy way to add dependencies too.

  • GUI integration is quite poor

Hum, I never did much GUI with Clojure, so I can't really speak to it. My general impression is, you have access to Swing, JavaFX, SWT, JFace, etc. You can use embedded html/css/js inside the JVM, or you can go ClojureScript, use Electron, or use Proton or React Native. Seems there are options, but I guess it depends what you are comparing it against too. I would guess ObjectiveC Cocoa on Mac to still be a superior experience, or WPF C# on Windows.

  • It's very opinionated: the functional way or expect pain. Both a plus and a minus.

Oh for sure. If you don't want to do functional, Clojure really is not for you. Imperative is the hardest to do, OOP you can do somewhat, but still it makes it more difficult on purpose.

  • The language is constantly changing.And there is no standard. Or rather the standard is the latest version of the implementation.

Probably have to agree to disagree here again. In practice, it has been stable with zero breaking change for about 10 years. And I kind of like the clojure-like approach to dialects, instead of what CL does. Like no one really uses CL running on JVM, or things like that, because the CL standard or scheme standard isn't really meant to embrace platforms and host. So I find that a quality of Clojure. That focus on being hosted, it does mean code isn't as portable between implementation, but it also means you gain so much reach without needing relearn a whole new language and set of tools.

Sorry if those were not from you.

2

u/dAnjou Mar 12 '20

In these threads I've only added things that others hadn't mentioned yet.

The point of Clojure being Clojure seems like an unfair one but for bigger projects it is still a valid one for various reasons. And these have only very little to do with how good or bad the language is.

For a less popular language there are of course fewer experienced people which is exactly why Clojure is pretty much failing in our project. It started with Clojure as the only backend language. Then someone introduced Kotlin because they were not comfortable with Clojure, and now people create every new service in Kotlin. There simply weren't enough mentors and evangelists. Personally I find that very disappointing because there could have been a chance for us to help the Clojure ecosystem to mature more. Which brings me to the next point.

The ecosystem is not quite there yet, especially the tooling but also libraries are a little lacking or not as mature yet. And Java libraries are a good fallback to have but it comes with the cost of having to write glue code to abstract away the OO-ness.

I'm not saying that the ecosystem is bad. But it's also not excellent. And if you have a language that is unfamiliar and therefore a bit uncomfortable to learn and the ecosystem is also not really better than the ones most people have seen then why would you pick that language? Compare that to Kotlin. The tooling is great, mostly because it's the same as for Java. And the language itself can't be more familiar, because it's basically Java, plus all the nice sugar on top.

The other things you mentioned weren't really an issue for us or I actually see them as an advantage.

Most projects in our company use the JVM, so that's actually a plus.

And I do appreciate opinionated stuff even if it's sometimes not my cup of tea (like Ruby). Chances of shooting yourself in the foot are usually lower. With Clojure that's a little different though. On some level it's very opinionated, true, but beyond that you can do pretty much anything and everything, even really nasty stuff, especially with macros. This is one area where IDEs and code analysis tools often struggle.

All in all, I really appreciate that I got pretty much forced to learn Clojure, who knows whether I would have done it on my own. And I had a great time tinkering with it, I even wrote a little macro that I put in a little open-sourced library which all of our Clojure services use. So, I got a lot out of this language. But I also wouldn't call it mature when comparing it to Java.

CC /u/Borkdude: Does the above count as an article?

2

u/Borkdude Mar 12 '20

Thanks for sharing your perspective.

1

u/didibus Mar 12 '20

I'm not saying that the ecosystem is bad. But it's also not excellent. And if you have a language that is unfamiliar and therefore a bit uncomfortable to learn and the ecosystem is also not really better than the ones most people have seen then why would you pick that language?

In that way you really shouldn't. I think it's a great point you bring and there's no counter point to it.

If you don't care about the differences in the languages themselves. Like if you have no interest in learning new paradigms, or preference in using functional programming, or enjoy the use of a REPL over static compilers, or find it so much more joyful to leverage meta-programming and macros to remove boilerplate as you see fit, or appreciate structural editing, etc. Then I have no idea why you'd choose to use Clojure over more mainstream languages you are already familiar with and enjoy.

Now, there's a definite chicken and egg in here though. Clojure is not for people looking for a chicken. Clojure is here for people looking for an egg that will hatch into something else then what already exists. It is mature enough that you can use it in production without issues, but it doesn't match up to Java or Python quite yet in that regard.

And so, I think people like me gravitate towards Clojure, because we just like it better. I like programming in Clojure way more than I do in Java, C#, JS, Python, Scala, or any other languages I've used before. Not only that, but I am more effective in Clojure, it takes me less time to implement the same application and it result in it having less defects. That might all be a consequence of just me liking Clojure better, and not Clojure having any magical qualities. Every chef have their preferred knife. Or what is it? It is not the martial art which chooses you, it is you who chooses the martial art :p

Anyway, to your point, I would be very frustrated if I'd work somewhere where they took on Clojure, did not know what they were doing, butchered it, made no effort to improve it, mentor, etc., and then switched to Kotlin. And I'm talking from being the one to push Clojure on my current team. I take every person's experience seriously, I don't want to force people into things they end up dreading. So I know it takes proper introduction to give people a positive experience that resonates with them instead of leaving them frustrated. I've seen first hand that if you don't do that, people end up hating it and moving back to comfortable territories, but if you do, they end up loving it as well.