Hacker News new | ask | show | jobs
by eduction 1217 days ago
I have been using Clojure for a solo project for a while now and find it shockingly productive. I initially planned to limit how much of the language "surface area" I explored to keep focused on solving the problem but was able to productively use much more of Clojure than I expected:

-core.async for concurrency that led me speed up some tasks from ~1000ms to ~40ms (well, core.async got me to about 100ms, or closer to 5x speedup on other tasks, and then other optimizations got me the rest of the way). Also using refs for some very limited data sharing across go threads (apparently actually using refs and dosync, aka mvcc data structures, is rare).

-spec for parsing a dsl and validating input

-macros for a select few syntax and core async optimizations (avoiding unnecessary go block usage)

-multimethods for extensibility

-a fair amount of Java interop to use best in class libraries

-transients to help optimize performance in some places

-even transducers a few places (maybe 1 percent of my code if that, but still)

-edn for dsl files

I sense that where people have more friction is trying to work with other people, in teams and organizations. In the right organization this can clearly work, dedicated Clojure shops, but there can be resistance in other organizations, and it has to be "smuggled in", and people worry about the ability to hire (especially for orgs that tend not to train heavily - nubank clearly trains a lot of programmers on Clojure but many shops don't want to do this level of training). And then people will avoid using certain advanced features like macros or even some functional conventions (recursion, reduce and map etc instead of vanilla loops) because they worry it will make it harder to onboard people without Lisp or FP experience.

I honestly think this is Clojure's big challenge, entrenched expectations and conventions in the industry and a desire to pull programmers off the shelf. In this talk (the one we're all commenting on) Rich and others point at the productivity and fun of REPL driven development -- finding some way to really grow that and somehow take it to the next level -- as a possible solution, to offer yet another carrot to encourage people to make the leap to Clojure. It sounds like a good idea but I have no idea what that looks like exactly.

I honestly think the answer to getting more Clojure penetration may be the passage of time, as happened with python. I know nubank/cognitect has been funding some open source work with small grants on top of Alex and Rich's work (and Stuart's?). This kind of basic grunt work can pay off long term. But it's not a sexy answer and if it doesn't work you're at a dead end.

1 comments

I have also been using CLJS/Clojure for a solo project. I debated between CL and Clojure for the backend, but CL’s package ecosystem is too weak to be justified. What other languages did you consider for your stack and what did you think were the tradeoffs?
This is sort of a next generation successor to a personal project written years ago in Perl (evolving from a form fit tool to something much more general and flexible). I originally was going to do it in Ruby but after learning Clojure and doing a bunch of book exercises (toy coding tasks) I thought Clojure would be a better fit. (When I learned Python I considered that but it did not seem any better of a fit than Ruby and since my use case was web oriented it seemed like Rails could eventually be useful.) It remains a personal project but one I (unlike the predecessor) think is good enough to eventually open source.

I think my motivators to do in Clojure were edn (dsl files are a key part of what I'm building), the concurrency story being strong, Java interop for libraries (Ruby wasn't necessarily missing anything but without the Java libs Clojure would not be an option), and a general belief that Clojure's overall approach (data oriented, LISP, functional) would prove generally more productive (I believe this is true but have no evidence since I never tried building it in another language). Spec has been an unexpected benefit as it saved me from writing a lot of validation code and because it can be used as a parser for the DSL (it does most of the heavy lifting).

How has your experience with CLJS? I have been using vanilla CLJ but curious to some day try CLJS.

CLJS has been surprisingly good. re-frame really simplified a lot of the development. There are some oddities with trying to work out whether something is a JS problem or a CLJS problem, but for a solo project, it has been pretty good. CLJ/S seems to me a good spot between practicality and idealism (CL being the latter for some things). It's the most practical Lisp atm, and it can't get better than that.