top | item 27095922

OCaml is 25

227 points| fortran77 | 4 years ago |discuss.ocaml.org | reply

122 comments

order
[+] legobmw99|4 years ago|reply
The history of programming languages is one of my personal interest fields, and I find it fascinating how, 25 years on, many of the most popular languages are still slowly encorporating core features of functional languages like OCaml: records, enumerated (sum or variant) types, pattern matching and destructuring, true tail calls, type inference.

To be clear, I’m in favor of these changes, and I don’t denigrate any existing language for not having them, I just still marvel seeing HN headlines like “Python to get match statement”, “Record Types in Java”, “Tail Call support in Rust” and appreciate all the more the things OCaml (and before it, ML) have gotten right for so long.

[+] simias|4 years ago|reply
Keep in mind that a language like Rust would've been effectively unusable in its current form 25 years ago due to the RAM and CPU requirements by the compiler.

As CPU and RAM increases you can make smarter compilers and generalize things like type inference, bigger compilation units and higher level constructs that rely heavily on compiler optimization for good performance.

Many people think that Rust and C++ are too slow to compile today, imagine what it would've looked like on a Pentium II CPU with 128MiB of RAM!

[+] nestorD|4 years ago|reply
> I find it fascinating how, 25 years on, many of the most popular languages are still slowly encorporating core features of functional languages like OCaml

Yes! Ocaml was my first programming language and I have been baffled at how languages I learned subsequently tended to miss what I considered basic utilities like proper pattern matching and tail calls (happily those ideas are now finally entering the mainstream).

[+] okareaman|4 years ago|reply
I'm not trying to be oppositional or take anything away from what you said about OCaml, but I'm interested in the evolution of programming languages and watching how the best ideas are borrowed or stolen and incorporated into new languages, sometimes with additions that improve upon the original. That's why I always check out new languages that are posted on HN. I like to see if the author has a new idea and then which language picks up on it. It's interesting to ponder such things as what will be the C++ response to Rust?
[+] solmag|4 years ago|reply
Applies to ML family of programming languages in general.
[+] bosswipe|4 years ago|reply
But the question is why didn't any of the functional languages with these desirable features ever reach mainstream popularity.
[+] adenozine|4 years ago|reply
Biggest thing impeding Ocaml for the average developer is the situation with the Stdlib, and multicore.

It's not exactly a struggle to get Base or Core working, but it's way less streamlined than it really ought to be. I see things like F# picking up some popularity and it strikes me as a bit of a tragedy on Ocaml's part. .NET is pretty bad to work with, imo. I know C# people will hate that, and indeed if I was meaning C# then they'd be right to feel that way. The fact is, there are few FP languages with a deep platform (like JVM, .NET, js/browser) already, and even fewer pleasant enough to work with on a daily basis.

I've been blessed to use Ocaml for some of my statistics work, and I'm watching very close the OWL project (ocaml.xyz), and hopefully it will come together nicely.

Still, I see the quickstart process of F#, Scala, Clojure, Elixir, even Haskell, and it's just much less headache than Ocaml for the first 10-15 minutes.

Ultimately, I don't know. I use Python a LOT, and I REALLY enjoy it. A lot of what people don't like about Python just doesn't get in my way that much. Really the only thing that I could see myself yearning for in the language is pattern-matching (which we're getting soon) and some form of piping with better lambda support. I really miss |>, <| in the way I build my tools, but in the end I get along just fine.

I'm glad that SO many languages have taken inspiration from Ocaml, and I'm sure that as time goes on, many more still will draw water from the plentiful well of its beautiful type inference, compiler architecture, domain modeling capabilities without annotations, et al.

Finally, I think it remiss to sorta colloquialize projects by a sum of their most recent decisions. It's not difficult to look around and go "Man, ReScript is sort of a shit-show, ReasonML doesn't really offer anything except different syntax at this point, and there's typescript anyhow, which has a vastly superior dev experience in just about every modern code editor." But that doesn't do justice to how incredibly epic it is that a project is still alive and competitive at a deep, academic level, across continents, for 25 years. I could munge around my emails and find projects starting near me that are using things like Coq (now called something else, I think), it's very much still alive for important technical work even throughout the Numpy-pocalypse.

Anyhow, this comment is a mess. Congratulations Ocaml team. Keep on truckin'. <3

[+] baby|4 years ago|reply
As a newcomer it’s a fantastic language but the tooling and the ecosystem story is really lacking. I really think the language needs more hype in order to get more people to do things for it. The versioning story of dependencies is almost inexistant, the interaction between the package manager (opam) and buil tool (dune) is filled with issues, there are no conventions in the way you set up a project (you can put your files in any folder), stdlib vs base? Poor documentation, poor compiler errors, poor managements for patches (opam pin) and different versions of the compiler (opam switch creates a local repo in all your projects), etc.

Coincidentally I’ve been writing up an OCamlbyexample page that hopefully I can post here at some point to motivate people to learn the language:)

[+] adsharma|4 years ago|reply
Python's pattern matching is not the same as Ocaml's. It's a statement, not an expression. But I like your line of thinking. Create a variant of python with ML like features without sacrificing compatibility too much.

An effort in this direction is a transpiler I'm working on. So far it sticks to a strict subset of python3. But I'm open to incorporating ML like features in an incompatible way if there is a compelling argument.

By sticking to a statically typed subset we've already given up some compatibility.

[+] fishmaster|4 years ago|reply
There's also the issue with the non-existent unicode support.
[+] haxiomic|4 years ago|reply
Can anyone recommend a good primer to learn OCaml? (ideally aimed at so someone familiar with traditions C-style languages)

The material I’ve found has been quite dense where I’m just looking to learn enough to be dangerous

[+] xiaolingxiao|4 years ago|reply
I recall being exposed to OCaml in an intro to programming language class in college. Learning recursion was pretty mind blowing but ironically, it puts everyone in the class on the same footing: many who have programmed in OOP were just as baffled as those who have never programmed. Looking back, it was a good gateway into discrete math in general.
[+] ocaml_rant|4 years ago|reply
<rant> After working professionally with OCaml for a few years, it's kind of a shame that the language is 25y old and hasn't become popular.

The documentation of libraries is awful, there's the Async/Lwt split, small ecosystem, the IDE support is flaky (breaks every now and then when you upgrade, doesn't work properly in VS Code).

My diagnosis (specially after talking to people in the Rust community) is that there's a weak sense of community and weak leadership. The response to conflict is "screw this, I'll do it my own way", instead of making decisions as a community. It's kind of the wild west, people going in different directions doing what they want. There's no alignment in focus or effort to really drive things forward.

We are moving away from OCaml. If you are considering it for medium or large production systems, I urge to stay away from it </rant>

[+] lukego|4 years ago|reply
Congratulations!

I remember trying it out 22 years ago and in retrospect I did not appreciate what a young language it must have been :)

[+] amai|4 years ago|reply
So young and already so unknown.