Hacker News new | ask | show | jobs
by pbiggar 2496 days ago
My previous startup (CircleCI) was written in Clojure, my current one (Darklang) is written in OCaml. I decided not to use Clojure again because it's not statically typed, and my number one frustration when I coded in the CircleCI codebase was that it was very very hard to know what shape a value had, and whether it could be null.

OCaml certainly has a lot of flaws, and is not nearly as "nice" a language as clojure, but the productivity of static typing (in the statically typed functional language sense, not the C++/Java sense) is huge. Knowing you can do a big refactor and the type system has your back is massive.

We sponsored core.typed to add types to Clojure, but there were flaws at the time (they have have been fixed since), and we didn't end up sticking with it.

So Clojure I wouldn't use again. OCaml I would, despite having significant flaws (every language has significant flaws).

3 comments

Thanks so much! This was exactly the sort of industrial benchmark I was after.

Am I correct in summarizing your experience as:

The possible encumbrance caused by types at prototyping phase is paid back several times when refactoring a production codebase?

Hmm, I think it's more that types make it possible to refactor without fear, both at the prototyping phase (when you refactor so much, I had 800 lines of python before that that I was afraid to touch) and later.
I have no idea what darklang is (your site has zero information), but what made you opt into OCaml out of all of the options out there? Any previous experience with it prior to this?
Ah, sorry about that. The blog is better at the moment (https://medium.com/darklang) but we're updating the site in the very near future.

OCaml was because I had experience with Haskell and didn't like it, and with Elm, which I did like. We tried it for a while as an experiment and it worked really well.

This whole subhread and this Elm mention are really interesting, thanks. Elm is a frontend language where I really understand the benefits of static more, because you're in a fairly controlled environment and your program isn't talking to a christmas tree of type system defying external services.

But for backend, the benefits of static sound attractive to me only on a program/product that is dominated by its internal business logic and has less interfaces to the unpredictable and constantly changing outside world. I think Darklang may be like this, from looking at the medium.com link?

Ghostwheel to the rescue

(>defn my-fun [a b] [int? -> int?])

I haven't seen anything to like in Clojure spec. Maybe I don't get it, but i really dont get it.