Clojure(Script) is not for everybody, but I love it because it is very natural for me to use, and it seems to fit the way that I think better than most OO languages that encourage top-down design. I agree that security, performance and correctness are good end goals, but they are not the only goals (another one that comes to mind is maintainability), and I have found Clojure to be a good means to reach those goals.
Honestly, I wasn't very impressed right away.
I hated the fact that Clojure hosts on JVM. I had not done enough Java at that point to know that JVM is a pretty solid piece of technology. People hate Java and sometimes don't even bother checking out JVM because they hate Java.
I did not like the fact that Clojure is a Lisp dialect. I had only shallow exposure to some emacs-lisp and wasn't even sure why people so excited about Lisp.
I did not like the fact that Clojure is a dynamically typed language. Learning some Haskell turned me into a big fan of typed programming, and naturally, I was quite skeptical. It was before Clojure.Spec, so until Spec was announced, I was still somewhat not sure if Clojure as a language is suited for large codebases.
It turned out - all my skepticism was unwarranted. I had worked with more than a few languages throughout my career - my first toy language was Basic, and my first "real" PL Turbo Pascal. Yeah, I guess I'm getting a bit old. Anyhow, Clojure turned out to be not just pure joy; it brought a lot of sense and clarity to my work. I never felt as productive with any other language before. Sometimes I try to rethink my positive thinking about Clojure and ask myself, maybe that's what Stockholm syndrome looks like? And I try to compare it with other languages and over and over again still feel like for me, right now, Clojure and Clojurescript make sense more than any other option. Sure, someday, it will stop making sense, and I will switch to something else, just like I did with many languages before. But until that day I will be using Clojure. Because for the type of work I'm doing today, it is probably the best option - it is nicely balanced between pragmatism and theoretical, idealistic language, hypothetical "silver bullet," which does not exist and never will.
As someone who has been using Elm at work for the last almost 2 years, but wants to move on, I’m curious about this line. I’ve been thinking PureScript or ClojureScript but admittedly I also have the strong concern of dynamically typed languages.
And I'm not going to tell you that Clojurescript is necessarily better. However, if your choice is dictated by academic curiosity, by all means, do try Purescript. But if you're seeking a tool that allows you to move fast but at the same time to be not too sloppy, maybe give Clojure a try. Beware though: you will encounter things you probably won't like:
- You will hate JVM startup times until you figure out that you don't have to restart REPL. I have some REPL sessions running for days and weeks.
- You will hate error messages. To be fair though, after using Elm, you will hate error messages in any language. Spec and libraries like Expound do improve things, but error messages never get to the level of Elm-awesome.
- If you have never used Lisp before, you will struggle with parentheses until you find a structural editing tool/plugin that works best for you. But after that, it is tough to live without them.
- And yes, you will miss the static type checker, even after learning Spec. Spec is fantastic, and you can do some pretty neat tricks with it, where for something equivalent in Haskell, you'd have to go Liquid. I missed type inference and static type checker in pretty much every dynamically typed language I've used. Clojure minimizes that feeling, but unfortunately, it never dissipates completely.
Historically, there are two camps of languages with roots in lambda-calculus: ML/Haskell and Lisp.
Clojure from the Haskellers' point of view is "worse is better" of Haskell. Haskell from Clojurists' perspective is "too ceremonial and bureaucratic."
But the truth is - you try to learn Haskell, maybe use for a bit, but the chance that you ever get to the point where you can comfortably use Haskell in production is not great. Admittedly, not too many of us developers ever get there.
With Clojure, you can get there pretty quickly. It is way more pragmatic. And every time I go back to Haskell/ML - there are things I miss that exist in Clojure, and whenever I write Clojure, there are things I miss from Haskell. My life is never will be the same
> Although I'm curious, I wouldn't ask you to explain why. You probably have your reasons. But I want to note that I love Elm. Elm is a fantastic language. For what is it made for - to build single-page web app frontends, it is hard to think of a better choice.
I'm happy to answer! Elm has been a fantastic introduction to functional programming. At work, we're very happy that we took the risk on it early on in our startup. What I'm looking for more is a more advanced language, that has things like type classes. A more open development plan would be great too.
> And I'm not going to tell you that Clojurescript is necessarily better. However, if your choice is dictated by academic curiosity, by all means, do try Purescript. But if you're seeking a tool that allows you to move fast but at the same time to be not too sloppy, maybe give Clojure a try. Beware though: you will encounter things you probably won't like:
Are the downsides of PureScript, similar to those for Haskell?
I can definitely imagine your other points being so true.
Do Clojure(Script) apps often have runtime errors because of the lack of static type checking? With Elm, there is that nice guarantee that if it compiles, then it simply won't have any runtime errors.
I'm looking to spend more time with a Lisp, before trying out Haskell.
> My life is never will be the same
I struggle to put into words why functional programming (and Elm) are are so good, it's sort of you just need to try it for a few months. Is that your experience with Clojure, or are you able to put it into words a bit more?
I can ensure that it's not like that at all. Clojure is a very productive language (see: focus on repl, clojure.spec and similar efforts) and also pragmatic.
If you and others have the feeling that it seems like a unproductive language, I invite you to take a closer look. Once I sat down and actually tried hard to learn it, it didn't take very long to get productive in it, compared to other languages I've learnt.
I beg to differ. I don't know how, maybe due to my experience and knowledge, but working with Clojure developers, discussions usually levitate towards the business problems and not the language ecosystem and tooling. Language just gets out of the way, it does not impede, does not slow you down, the distraction is minimal.
In other languages there are always talks about the syntax, about styling, about dependency conflict resolutions, subtle bugs that may or may not happen. In OOP languages - class hierarchies and patterns, interfaces, etc. There is always at least one smart-ass "rebel" in the team who writes code, adding some "nifty" tricks and esoteric, gimmicky features of the language no one else in the team knows about.
Of course, like any other language Clojure has "idioms" and like any other language it is possible to write "cryptic" code, but usually newbies learn those idioms quickly enough. Just like with irregular verbs in English - although they seem to be strange at first, you learn to use them because they are used very often.
I agree in everything else you wrote.
Once you learn Clojurescript to the sufficient level, pretty much anything feels faster to make with it.