Hacker News new | ask | show | jobs
by hutao 22 days ago
I've always felt that ML hit the sweet spot between functional and imperative programming. It affords conveniences such as algebraic data types and first-class functions, but unlike Haskell, it doesn't require monadic programming to use IO or mutable references.

ML also has an interesting module system, which achieves similar goals as object-oriented programming, but in a very different way. While mainstream "class-based" OOP identifies the data type with the unit of encapsulation, ML has "modules," which are separate entities from types, and which may both define types and values as members. However, a downside of this approach is that you sacrifice late binding, as the module language and "core" language are stratified into different layers. Instead, dependency injection is achieved through module-level functions, called functors,

A lesser-known fact is that ML originated as the scripting language for the LCF proof assistant (which is where the name "ML," or meta language, comes from). In the LCF tradition, the inferences rules of the logic are implemented in a trusted kernel, then clients use those inference rules to write tactic scripts that construct theorem objects. This design was supported by ML's module system: theorems were defined as an abstract type in a "kernel" module, and the inference rules were defined as functions inside the module. Here is a tutorial that explains the LCF design better than I can: https://www.cs.cmu.edu/~fp/courses/15317-f17/recitations/rec...

4 comments

If only Microsoft had more love for F# instead of slowly copying its features into C#.

At least it is still officially developed getting new features, unlike C++/CLI and VB that only get bug fixes and updates to keep running on top of recent .NET versions.

This rests entirely on the same same sort of conservative attitude towards new experiences that holds the other half of the development world back. The Java world. People generally do not want to learn new things, they want "faster horses", which incidentally is what C# and Java is these days.

This is why we can't have nice things.

Java with Streams and "functions" is a lot better than what I left behind 15 years ago. But it is still extremely primitive compared to what F#, Rust and Scala offers. And I know this because I have spent 10+ years EACH using all of these in anger. So 20+ years.

Agreed it is the "We were not out to win over the Lisp programmers; we were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp." approach.

Thing is, for 99% of corporate software, it hardly makes a difference, even more so with AI generated stuff going forward.

So yeah, we can't have nice things, especially when money and profit are part of it.

This is just not true, the last bit you say. That is the same old trope about F#, Rust or Scala being niche, things people that don't have to earn money or feed children can do. I worked 100% in those languages from 2012 through 2023.

But sure, with AI, maybe this will matter less because people don't care about the code anymore.

I would not place Rust in the same bucket as Scala or F# in terms of industry adoption.

F# is as it is.

Scala in 2026, especially after Scala 3, isn't doing great either.

Most Scala companies, nowadays also do Java and Kotlin, and in countries like Netherlands, according to discussions on Reddit, most consulting offers seems to have vanished.

Rust hit jackpot with the adoption across all major OS vendors and hyperscalers, being slowly certified for deployment into high integrity computing, and landing on the Linux kernel.

However even with all that, just look at Android, where Google proudly talks about their Rust adoption, yet Rust is not officially supported for app development, Java and Kotlin are, with NDK still only allowing C and C++, and that is mostly for game developers anyway.

I am not. I am saying that had I been a good little Java/ C# developer, then I would never have learned Rust and all of the things that come with that.

Scala is not doing great, probably because they took too long to get 3 finished and good.

Yes. Companies are going back to Java because this is what all the convervative guys and girls want to use. That fact is what I am criticizing. You want fast horses, you don't want nice things.

So now you have Maven, semi-typed code intermingled with container logic because you cannot abstract over anything, you have millions of lines of impenetrable tests. Just like we all did in 2006. You all love this because learning things is not your forte :) That other stuff is for academics and niche.

> a downside of this approach is that you sacrifice late binding, as the module language and "core" language are stratified into different layers

https://people.mpi-sws.org/~rossberg/1ml/1ml-extended.pdf

https://github.com/rossberg/1ml

Isabelle is still a very active LCF proof assistant, and it's still written in Poly/ML. It's pretty aggressively concurrent under the bonnet, and leverages Poly/ML well for that. There's still HOL4, which predates Isabelle and is still going, and it also recommends using Poly/ML.

I mostly worked with HOL Light which started as a CAML project and now runs on OCaml.

and you get concurrentML. People get all wet in the pants by the actor model and CSP, but my god CML is much nicer in every way.

I had a weird introduction to programming. I spent my first half year doing php, and them went all in on scheme and sml. Which is nice in many ways, but I do have a hard time accepting many of the completely braindead (subjective opinion, of course) choices of most of the popular languages.

I do think clojure is a pretty nice compromise. Rich has good taste, obviously. Clojure's core.async could be less async and more CML in my taste. Wrapping a simpler async api in cml is easy. Implementing CML on top on core.async is either very hard or full of compromises.

Could you share more about what makes CML so awesome?
it is like CSP but with first class events. In CSP you have to manage complex protocols yourself, whereas in cml you can compose larger even trees and then do one sync.

a classic example of something that is trivial in cml but requires a mediator in CSP or go is two fibers swapping values atomically where a fiber can pull out at any time. in cml it is about 20 lines of code that can be in a library. it composes with other events.

in csp it is a "server" that manages the swap which means you lose the sectability.

Evert time you want to have any kind of protocol, cml wins.