11 ms·
Standard ML in 2020
- Joker_vD 6y agoWait, what happened to SML/NJ? AFAIK it's still in development. Also, it has an absolutely "lovely" versioning scheme.
- eatonphil 6y agoNot totally sure, but it's definitely not as active as the first three I mentioned. The last commit is from over a year ago [0]. Although the SML/NJ website shows releases presumably from 2020. [0] https://github.com/sml-nj/smlnj https://github.com/sml-nj/smlnj
- doyouevenchop 6y agoThere is a lot of active development going on in their SVN repository http://smlnj-gforge.cs.uchicago.edu/scm/viewvc.php/?root=smlnj http://smlnj-gforge.cs.uchicago.edu/scm/viewvc.php/?root=sml...
- ratmice 6y agoyeah, that svn->git conversion was a one-time thing, and not fully kept in sync automatically. A bit unfortunate as recent releases have fixed one of the main for smlnj/reasons to use other compilers in that it now supports x86-64.
- eatonphil 6y agoThanks all! Updated with SML/NJ in the major list again too.
- hajile 6y agoThey really need to go where the developers are...
- Shoop 6y agoThis git repo is quite out of date. The best place to look for updates is the smlnj website: https://www.smlnj.org/ https://www.smlnj.org/
- gautamcgoel 6y agoI used Standard ML for a research project in college and really fell in love with it. Yes, at times it feels a bit old, but nothing felt bad. One of the creators of Standard ML (Harper, I think) wrote a really beautiful textbook, Introduction to Programming in Standard ML, which I think is the best textbook on programing I've ever come across. I'm glad that Standard ML is still kicking.
- bachmeier 6y agoML for the Working Programmer is an awesome textbook to use to learn programming. It is free to download on the author's website: https://www.cl.cam.ac.uk/~lp15/MLbook/pub-details.html https://www.cl.cam.ac.uk/~lp15/MLbook/pub-details.html
- doyouevenchop 6y agoI started learning SML earlier this year - it's quite a nice language and it's a shame that the ecosystem isn't better. For fun and educational purposes, I began working on a Standard ML compiler [1] and VSCode extension in Rust as well - with the end goal being a psuedo-clone of MLton. Currently taking a short break from it to work on some other stuff, but I'm mostly done with monomorphization [1] https://github.com/SomewhatML/sml-compiler https://github.com/SomewhatML/sml-compiler
- BoysenberryPi 6y agoI first came across Standard ML in Dan Grossman's Programming Language course on Coursera[1]. After previously trying Haskell and Scala, this is where the benefits of functional programming and static typing really clicked for me. Really wish the language had caught on outside of academia so I had an excuse to use it more. In addition to the implementations mentioned in the blog post, The University of Chicago created Manticore[2] and Tohoku University in Japan created SML#[3] [1] https://www.coursera.org/learn/programming-languages https://www.coursera.org/learn/programming-languages [2] http://manticore.cs.uchicago.edu/ http://manticore.cs.uchicago.edu/ [3] https://www.pllab.riec.tohoku.ac.jp/smlsharp/ https://www.pllab.riec.tohoku.ac.jp/smlsharp/
- eatonphil 6y agoThanks for sharing Manticore! I didn't mention SML# because most of the documentation is in Japanese and it's hard to find recent info. There is an unofficial fork on Github but it explicitly states that it is unofficial so... not something I'd recommend to a general audience. Edit: nevermind! I checked out their docs again and it seems to be decently translated. I'm still not sure where their code is actually hosted, just that you can download releases. So added it to the list of major implementations!
- fbsvvc123 6y agoI’ve always enjoyed working in SML - usually my default choice is SML/NJ. Most recently Ocaml has been my ML of choice due to a coworker preferring it, but lately I’ve revisited SML for a new project since I like how small the language and basis library is.
- jez 6y agoWhich SML implementation has the best editor tooling? The article mentions that certain SML implementations have seen better support for parallel and concurrent programming than OCaml, but Merlin and ocamlformat for OCaml are great as far IDE tooling go. Which SML implementation has the best tooling for things like go to definition, reveal type at cursor, and format file?
- eatonphil 6y agoNone of them have invested very much in tooling as far as I know. There are some small sml-modes for emacs or plugins for vim but they only do basic syntax highlighting. One of the biggest missing things for SML tooling is parsers for SML written in SML. They tend to be written in the implementation language and not exposed as a library. So you don't see SML formatters or documentation generators so much. There have been a few attempts at this but they haven't seriously caught on.
- Munksgaard 6y agoMLKit is a (quite performant) SML implementation written in Standard ML, including the parser.
- eatonphil 6y agoActually now that I look, the one formatting tool I saw come out this year is based on a parser that apparently SML/NJ exposes. https://github.com/ProjectSavanna/autoformat/blob/master/run.cm https://github.com/ProjectSavanna/autoformat/blob/master/run...
- jp0d 6y agoI'd no knowledge of SML until I came across the Programming Languages course by Washington Uni on Coursera. I tried learning Scala first but then never got anywhere. This course was amazing. Unfortunately, didn't have enough time to dedicate to it. Thanks to this post, I'm excited to try again. :)
- yakubin 6y agoI've recently picked it up, reading "ML for the working programmer". The language is fairly simple, everything just fits. However: 1. Both Vim and Emacs are horribly annoying with their automatic indentation for SML. There is a lot of fighting against the editor in this department. In Emacs e.g. you have to delete whitespace all the time, because otherwise you'd have top-level function definitions shifted 80 characters to the right. 2. I've used Poly/ML and SML/NJ so far. Both of them are purely interactive, meaning I can't just compile a program into ELF and ship it somewhere else without the compiler. That makes it a no-go for me for real-world use. 3. The interactive modes of Poly/ML and SML/NJ don't support readline shortcuts. They are the most cumbersome REPLs I've ever used. 4. Inline type declarations (as opposed to Haskell-style type declarations on a separate line) are very noisy - they make reading the code harder. Omitting them (which is the rule in SML in practice) leads to hard-to-decipher compilation errors when you write a new piece of code and you made an error somewhere which confused the type-inference about your intentions. Suddenly forgetting about a word or a set of parentheses in one function results in errors in another perfectly-good function. It's the horror of C++ templates all over again.
- eatonphil 6y agoNot a huge fan of ML for the Working Programmer, personally. I'd love to see (or one day write) the equivalent of Practical Common Lisp (which itself needs an update at this point) because MftWP is sooo dated. But I can see how it's a decent enough intro. Regarding your points: 1. Yeah editor support sucks. I normally edit in text mode with my own minimal keyword highlighting or ocaml-mode. 2. Poly/ML can definitely generate binaries! Most distros ship with `polyc` that will build the binary for you. But this is just a shell script around opening the REPL and calling some dump image function (like how you build a binary on SBCL). MLton and Poly/ML definitely allow you to build binaries. I don't know about SML/NJ. 3. For sure a pain. I use rlwrap [0] to work around this, which is ultimately simple enough! 4. Interesting! I personally find Haskell-style decorations so much more a pain since they're not inline. SML is very much like other major languages in the way it does inline types (TypeScript, Go, C#, etc.). [0] https://github.com/hanslub42/rlwrap https://github.com/hanslub42/rlwrap
- 6y ago
- wilsonthewhale 6y agoAs someone reasonably versed in OCaml but knows nothing about SML, what are primary differences? Given that OCaml has much better tooling and more of a community, what draws people to SML still?
- reikonomusha 6y agoSML’s compilers and implementations are state of the art. Advanced optimizing compilers and multicore are already huge differentiators. Also, Standard ML is, well, standardized. The standard isn’t perfect but it at least allows for a strong ecosystem of independent implementations.
- zepto 6y agoI was under the impression that ocaml’s optimization was pretty good. Granted multicore is not here yet.
- hajile 6y agoOcaml's optimization is very good, but not perfect. For example, if you need 32-bit integers instead of 31-bit integers, your performance is going to tank due to boxing. MLton is a whole program optimizer (rather than function at a time like Ocaml) and wrings out a ton of performance though compile times are quite a bit longer.
- smabie 6y agoI believe flambda is whole program, could be wrong tho
- hajile 6y agohttps://www.cs.cornell.edu/courses/cs3110/2017fa/htmlman/flambda.html https://www.cs.cornell.edu/courses/cs3110/2017fa/htmlman/fla... As of 3 years ago it wasn't, but maybe that has changed. Whole program compilation isn't without its downsides though. It seems pretty common to develop in SML/nj because of fast compiling then doing final performance profiling and deploying with mlton (having a standard helps). Function at a time is also more amenable to caching and reusing part of the previous compile.
- barrister 6y agoHere is a paper[1] written by Andreas Rossberg, specification author of Web Assembly, that discusses the defects in the definition of Standard ML. I believe he tried to address many of these issues with Alice ML[2]. [1] https://people.mpi-sws.org/~rossberg/papers/sml-defects-2013-09-18.pdf https://people.mpi-sws.org/~rossberg/papers/sml-defects-2013... [2] https://github.com/aliceml/aliceml https://github.com/aliceml/aliceml
- eatonphil 6y agoMy biggest personal gripe is no nested functors. SML/NJ does support this as an extension but since no other implementation does you effectively can't use it if you want decent performance (that SML/NJ doesn't really give). I'm also pretty jealous of OCaml's modular implicits, just because it saves you typing the module name before an operator (i.e. MyModule.+ vs just + implied by context). It also kinda sucks that operator precedence is defined at the module level and cannot be exported. You have to always redefine a library's operator precedence yourself.
- tomp 6y ago> I'm also pretty jealous of OCaml's modular implicits, Have modular implicits already been implemented? I thought they were still trying to figure out the details of the resolution...
- eatonphil 6y agoAh, well as with most OCaml planned features I gave up on waiting. Maybe they haven't finished this one.
- c-cube 6y agoWhat ocaml got recently, though, is do notation in the form of "let operators". It's very handy for applicative or monadic style.
- dan-robertson 6y ago
- hajile 6y agoStandardML really hits a nice sweet spot in language design. The syntax is super-easy to learn (The BNF for the whole fits in a mere 2 pages[0]), but contains a lot of features in that small package. Rather than tacking on functional features (eg, Java with lambdas), these features have been carefully considered and streamlined and include bits like proper tail calls and currying. You get nice bits like actually sound types (hindley-milner types as Milner was also one of the SML spec authors), generics (way better than typical interfaces), type inference that actually works, and modules (super-powerful encapsulation). Pattern matching in all it's awesomeness is also on display. SML has an amazing concurrency story (CML is rather like golang channels, but better with better typing and a bit more flexibility) and compilers like PolyML or Mlton are very fast (once again, around the same as golang). Despite this, the language doesn't have the academic flaws of its descendants like Haskell. SML isn't a lazy language, so reasoning about performance is much easier than some other functional languages. SML doesn't pretend the world is a pure function. You are free to make functions that have side effects. While most primitives and data structures are immutable by default, they either have mutable variants (eg, vector and array) or can be used as if mutable with refs (something like typesafe pointers without all the reference/dereference bits). [0] https://cse.buffalo.edu/~regan/cse305/MLBNF.pdf https://cse.buffalo.edu/~regan/cse305/MLBNF.pdf
- eatonphil 6y agoHave you used CML for any real projects? Very curious to see. I've always used Poly/ML when I wanted parallelism.
- bjoli 6y agoOf you are a lisp person guile has a parallel CML implementation called guile-fibers. I used it, just for fun, in a static site generator. That was fun and worked great.
- skissane 6y ago> Despite this, the language doesn't have the academic flaws of its descendants like Haskell. Can you elaborate on what those flaws are?
- waltherg 6y agoI usually have at least some broad, high level understanding of what tech outside my narrow scope looks like. Reading the comments here I have zero clue what you're talking about. Is this what my less technically inclined colleagues feel like when people talk about e.g. machine learning and Python?
- coldtea 6y agoThe comments thus far seem pretty tame. What are you talking about? Haven't seen any heavy Haskell-type monadology talk in this comment section for example... At worst, you might not know the name of specific SML compilers/implementations mentioned. But I don't see anything here that a Python guy with a general grasp of PL wouldn't know...
- Multicomp 6y agoSo I use F# and plan to look at rust in 2021 for my "compile to native code" toolset since .net is not everywhere and .net native appears to be moving very slow to release F# to native code support. should I consider taking a look at some description of standard ml instead of rust? It seems like rust has pattern matching and immutability which matches to F# pretty good? My use cases are mostly desktop class machines, with optional extensions to single board computers and maybe, maybe, mobile devices of some kind. Utility programs, soap and rest web services, guis for the rest apis etc.
- eatonphil 6y ago> So I use F# and plan to look at rust in 2021 for my "compile to native code" toolset since .net is not everywhere and .net native appears to be moving very slow to release F# to native code support. I have projects that generate native binaries on Linux. Here's an example Makefile [0]. > should I consider taking a look at some description of standard ml instead of rust? It seems like rust has pattern matching and immutability which matches to F# pretty good? Library and tooling support in F# and Rust is significantly more developed than in Standard ML. To me the best use case for Standard ML today is in language development. If its ecosystem were more mature it would be a great choice for application development. But today that's just not the case unless you use a version like Morel that is backed by the JVM (and its ecosystem). [0] https://github.com/eatonphil/dbcore/blob/master/Makefile#L3 https://github.com/eatonphil/dbcore/blob/master/Makefile#L3
- bgorman 6y agoOCaml would probably the easiest transition if you want native binary support, F# even has an OCaml compatibility mode.
- lmm 6y agoI wouldn't. Standard ML is good, but it doesn't have the momentum that Rust does, and it doesn't have much that Rust doesn't.
- galaxyLogic 6y agoSo should I pick StandardML or OCaml?
- brmgb 6y agoSML is a nice language with a cleaner syntax and is standardized. Still, my answer would be OCaml without questions. It has better tooling, better performance, a larger community, a larger ecosystem, more features and more work being done on it with basically no downsides.
- kzrdude 6y agoDumb question, but since there are many Standard ML implementations, do they all implement the same language? Or just variants/visions of the same language? And is there any standardization on any particular implementation?
- eatonphil 6y agoIt's like Common Lisp or Scheme: there's a formal spec and many implementations implement the spec. There's no reference implementation like CPython or MRI Ruby.
- Sophistifunk 6y agoCan anybody point me to a thorough tutorial and matching impl that will install cleanly on OSX? Or should I do it in a VM? I'd very much like to learn me some ML.
- eatonphil 6y agoHere's a pretty recent guide someone made. More info exists on the reddit.com/r/sml/wiki page. https://saityi.github.io/sml-tour/tour/00-00-welcome.html https://saityi.github.io/sml-tour/tour/00-00-welcome.html
- Sophistifunk 6y agoGreat, appreciate it.
- red2awn 6y agoI am designing a language based on OCaml/Standard ML, what are some of the problems present in these languages that can be fixed by a new design without being constrained by a spec or backwards compatibility?
- hajile 6y agoAvoid Ocaml's syntax soup. I'd also avoid making it easy to bolt on a bunch of syntactic extensions ala camlp4 Keep your standard library standard. Module Typeclasses One, immutable string type. Make it UTF-32 by default (you can always store in a smaller format behind the scenes and extend). Make it multiline. Allow variable interpolation (typeclasses should help). SML structural typing and anonymous records are better than nominal typing. Skip on syntax bloat like named parameters. Overload your math operators instead of having special float operators like Ocaml (once again, typeclasses make this much easier). Rethink imports. F# requires you to add tons of files in the correct order to an XML. Ocaml imports all the things from the folder and blows up if you use the same module name twice. SML needs to standardize `use`. I'd recommend something like JS static import statements. If you build good documentation, good compiler errors and good tooling, more people coming to the project and help make a better compiler (a reversal of this is the big issue with SML right now in my opinion).
- maattdd 6y agoAnonymous record in SML is equivalent to polymorphic record in OCaml ? (basically, "structural" record)
- c-cube 6y agoUse utf8 strings, not utf32. It's the standard in most new languages for good reasons. Have a standard iterator type. Syntax wise, something closer to rust would help newcomers (see ReasonML maybe).
- red2awn 6y agoDo you think it make sense to include a character type that is basically a variable-size utf8 extended grapheme cluster?
- deccanchargers 6y agoI want to get into ML. Which do you think is better ? Ocaml or SML ?
- Munksgaard 6y agoWorth noting: A colleague of mine recently released an implementation-agnostic package manager for Standard ML https://github.com/diku-dk/smlpkg https://github.com/diku-dk/smlpkg
- sword_smith 6y agoIt was the first language that was taught in computer science at the University of Copenhagen until around 2015, then they changed that language to F#/ Judging from the activity on Stack Exchange, it seems to be pretty dead. Maybe a few universities around the world still teach it? It can't be more than I handful I guess. https://stackoverflow.com/tags/sml/topusers https://stackoverflow.com/tags/sml/topusers
- cannam 6y agoMy favourite thing about SML is that it's a relatively idiot-proof language. It has something of Python's "one obvious way to do it" - a good chance of being able to understand someone else's code. This is partly because the language is small and features many sensible decisions, and partly because it isn't particularly malleable at the syntactic level (compared to your Lisps or Haskell). The tradeoff is that it can be more laborious than other functional languages. My code would be shorter if it had record updating, a single-character lambda syntax, contextual operators for real or int arithmetic, etc. Not only does it lack syntactic sugar for associative containers, it doesn't even have them in the standard library. Nor sorting, nor random numbers, nor complex numbers or matrices, nor uniform type-to-string formatting or string interpolation. Some of these holes can be filled by libraries, but then library choice becomes a problem. I can live with an awful lot of that though, given the relative clarity of the language, the really practical module system, and the delightful feeling you get when using a language standardised over 20 years ago that, once written, your code can stay written.
- tsm 6y agoI learned Common Lisp in high school and took a course called "Discrete Math and Functional Programming"[0] my freshman year of college (the prof wrote the textbook). To me it felt like a math course (covering predicate logic, sets, graphs, and eventually the lambda calculus. It was also the first time I had to write proofs outside of geometry class), but all of the teaching was paired with examples in ML. For example, half the homework one day would be writing proofs about powersets, and the other half would be writing ML functions to create and manipulate powersets. It was a really neat idea, and it felt like ML got out of the way and just let me program without having painful syntax or semantics. That said, my biggest ML programs would be five functions spanning ~30 lines loaded into an smlnj interpreter. I never got to deal with functors and modules and who knows what else, and am sorry that I don't know how to "program in the large" in ML. I'm now a professional Clojure dev and would love to see how ML does things. I own a copy of ML for the Working Programmer (which I see @eatonphil is panning below) and the ML compiler book by Appel, neither of which I've read. Maybe I'll make the time one of these months…it'd be nice to have a Motivating Project though. 0: https://cs.wheaton.edu/~tvandrun/dmfp/ https://cs.wheaton.edu/~tvandrun/dmfp/