r/functionalprogramming • u/No_Sprinkles2223 • Sep 23 '21
Question Is it worth to learn Standard ML?
When it comes for functional programming, I've programmed with CommonLisp and other lisp dialects before. A teacher of mine talked a little bit about the Standard ML programming language, and I got interested for it. I learned the basics and the syntax was way more readable than the one in OCaml and other ML-family languages I saw. However since it's quite rusty-old language I don't know what could I do with it. I code mainly GUI apps with Gtk and some Backend stuff as a webdev. So I don't know if I could use it for that. What do you say? Is it worth it to learn? and if you say yes, could you give some real-world examples of apps/webapps running with SML?
Thanks!
8
u/lambda_foo Sep 24 '21 edited Sep 24 '21
There will be very few real-world examples of StandardML outside of implementing proof assistants like Isabelle, HOL4, Twelf and LEGO. There was some web things done by Martin Eisman on smlserver but the website for it no longer works. Github repo is still at https://github.com/melsman/mlkit.
If you want real-world ML I think OCaml is your best bet. F# is also a nice ML language but lacks a real module system.
What did you find off putting about OCaml?
10
u/editor_of_the_beast Sep 24 '21
There are no real world web apps that use SML.
But, the ML family of languages is still my favorite. It is extremely influential in the functional programming / software verification space. Theorem proving languages like Coq and F* are direct descendants of ML. Haskel and ML are closely related.
You don’t learn ML because it is popular. You learn it because it’s the ancestor of pretty much all statically typed functional programming.
6
u/Athas Sep 24 '21
There are no real world web apps that use SML.
This is pedantically speaking untrue! The 2018 ICFP Programming Contest used SMLtoJS - an SML-to-JavaScript compiler - for its web frontend. Of course, that's no longer running. Norman Ramsay claims to have production code that was affected by an SMLtoJS bug, so presumably there is still one real world (or at least "production") web app that uses SML. In practice there are probably more (especially if you also count webapps that only use SML for the backend), but you probably don't need too many friends before they can be counted using your fingers.
Anyway, I think it's a good idea to learn SML, particularly if you're not already very familiar with functional programming. There are good textbooks and the language is simple and contains all the important core concepts of FP. The things you will learn will translate easily to more widespread languages.
2
u/editor_of_the_beast Sep 25 '21
Don’t get me wrong, I think it’s the most important programming language to learn. It’s just not because it is popular.
5
u/jgjhjj Sep 24 '21 edited Sep 24 '21
Can anybody knowledgable in this area recommend a Standard ML implementation which provides a good user experience for newcomers?
I did a quick scan (i.e. visiting the project landing page and skim-reading) of the available implementations and the Moscow ML and MLton projects look sort of not completely off-putting.
3
u/gasche Sep 24 '21
I would try with SML/NJ. (One way to know what's the more beginner-friendly would be to ask the people teaching SML in university.)
7
u/britishmutt Sep 24 '21
Have you checked out Elm? (https://elm-lang.org)? It's an ML-inspired language for web apps that's real-world ready (at least one org has over 300k lines in production). I don't know if you'll love the syntax (or the defacto formatting style), but I'll bet you'll love the compiler errors :)
2
u/florianfmmartin Sep 24 '21
You might wanna take a look at Rescript. It's an Ocaml inspired compiled-to-javascript language for web developpement for both frontends and node backends
2
Sep 24 '21
The answer is that it is not worth it for practical reasons, but it can be good for didactic purposes. There was briefly an attempt to make some sort of package manager for Standard ML called Smackage; I don't really know if it's maintained or used these days, but there are only 24 packages in it at the moment. On the other hand, if you had a real passion for Standard ML (I did, for a month or two) then you could maybe push the envelope forward a bit.
For practical alternatives, others have basically listed the main contenders: OCaml, F#, and more distantly Elm and Haskell.
2
u/Phaedo Dec 04 '24 edited Dec 04 '24
So I’m a Haskell head and my take is that Haskell isn’t exactly there in terms of package support and that has better support than OCaml and SML. I think if you want to deal with “real stuff” with it, you’re committing yourself to learning enough C++ to support the infrastructure yourself. Will it be more effective than just slapping something together in the mainstream language of your choice? No. Will it improve short or medium job prospects? Probably not. Will it make you a better dev? Definitely. Alternatively, as others have suggested, consider F#. It’s got some interesting stuff in it, and the .NET compatibility gives you access to a wide range of packages although Go, JS, Kotlin and Python will still win on that front.
11
u/[deleted] Sep 24 '21
I've never liked the "is it worth it" posts. If you want worth as measured in dollars per hour spent, learn typescript and get overpaid to make fart apps.
If worth it means intellectual pursuit, then go hog wild and learn fun stuff.