
Unix System Programming with Standard ML (2001) [pdf] - vector_spaces
http://www.mlton.org/References.attachments/Shipman02.pdf
======
voidhorse
Standard ML is _almost_ the perfect language—functional-first without all the
heavyweight and seemingly endlessly proliferating categorical abstractions
which keeps the level of knowledege one needs to be productive low. Plus it’s
easy to drop into old school imperative code when needed.

The only thing holdong sml back in my eyes is somewhat clunky syntax and the
module system—which is great at first but quickly becomes tricky once you
start having to use functors.

A modern, reimagined sml that keeps its core while adopting some of the nicer
syntactic improvements from other langs in the family and improving the module
system would be a god send

~~~
chriswarbo
SML modules are a classic example of a "shadow language" (
[https://gbracha.blogspot.com/2014/09/a-domain-of-
shadows.htm...](https://gbracha.blogspot.com/2014/09/a-domain-of-shadows.html)
). I'd like to see an ML-like language where modules/interfaces are normal
values, functors are just normal functions, etc.

Modeling such a system at the value level is easy enough, but having it run at
compile-time introduces some tricky issues (especially around IO).

~~~
cannam
Andreas Rossberg's 1ML is (was?) an effort to unify the module syntax with
that of functions and values ([https://people.mpi-
sws.org/~rossberg/papers/Rossberg%20-%201...](https://people.mpi-
sws.org/~rossberg/papers/Rossberg%20-%201ML%20--%20Core%20and%20modules%20united%20\[JFP\].pdf),
[https://github.com/rossberg/1ml](https://github.com/rossberg/1ml))

The module syntax is certainly clumsy in comparison to the rest of the
language, and it's not just the syntax - everything about functor arguments is
a bit murky.

~~~
wuschel
Is ML used in industry? If so, what would be the scenarios/use cases?

~~~
Koshkin
ML is a general-purpose programming language, and as such its use case cannot
be narrowly specified. (They say it's good for writing compilers, but I
wouldn't latch on that.)

~~~
icedchai
He asked if it was used in industry. This can be answered by looking at job
postings or TIOBE.

------
gmfawcett
A similar, nicely written book for Ocaml:

[https://ocaml.github.io/ocamlunix/](https://ocaml.github.io/ocamlunix/)

------
jerry40
Few years ago I took a course by prof. Dan Grossman on Coursera, there was a
part about SML and I so liked it (the language and the course). Now I want to
read Okasaki's "Purely Functional Data Structures" book and try to reproduce
the code examples in SML.

~~~
the_af
Programming Languages by Dan Grossman, I took it too. Pretty good course, and
a nice intro to static typing and FP with SML. Also nice: the DrRacket part, I
wasn't familiar with lisp/scheme-like languages. Also also nice: how you can
tell he doesn't really like Ruby ;)

~~~
jerry40
Oh yes, and I can remember the episode when he jumped while explaining some
idea in order to make this moment unforgettable. Shame on me, I forgot what
idea it was but still remember his jumps :)

------
lwb
As someone with absolutely zero experience with ML languages of any kind,
would this be the best intro for me to get into it? Or would I be better off
with OCaml?

~~~
gmfawcett
Eventually I would learn Ocaml, as it's the more sensible language for most
production code (community, tooling, ecosystem, etc.). But there's nothing
wrong with learning SML first. 90% of what you learn will be transferable to
Ocaml. Starting with SML might help you focus on the "essence" of ML languages
rather than getting overwhelmed by the impressive range of options that Ocaml
opens up.

The MLton implementation of SML -- while not necessarily the best ML to
practice on -- is particularly interesting because it's a whole-program
optimizing compiler. It has a reputation for producing very compact, efficient
machine code. Having said that, Ocaml is still a comparatively simple language
-- compared to say, Haskell or C++ -- and its native compiler is well known
for turning out decent and very predictable code (predictable in the sense
that you can read some source code and have a decent understanding of what
kind of machine code it will get compiled into).

If you decide to learn Ocaml first, but want to stick to "essential ML", I
would recommend Jason Hickey's "Introduction to Ocaml" [1] over the more
modern "Real World Ocaml" [2], as the latter book introduces every bell and
whistle that Ocaml offers, and has a much more ecosystem-dependent focus
(third party libraries, third party tooling, etc.). Still a fine book, but I
think it emphasizes advanced Ocaml features a bit too much for an introductory
text.

[1]
[http://courses.cms.caltech.edu/cs134/cs134b/book.pdf](http://courses.cms.caltech.edu/cs134/cs134b/book.pdf)
[2] [https://realworldocaml.org/](https://realworldocaml.org/)

~~~
lwb
Great comment, I'll bookmark those!

~~~
e12e
Absolutely recommend following gps advice on starting with sml - ocaml has
some... Bumps. But the other option would be to just start with the reasonml
dialect of ocaml:

[https://reasonml.github.io/](https://reasonml.github.io/)

And just FYI, reasonml "is-a" ocaml, so you can also build binaries with the
regular compiler back-end - you're not "locked" to targeting js.

~~~
firethief
> And just FYI, reasonml "is-a" ocaml, so you can also build binaries with the
> regular compiler back-end - you're not "locked" to targeting js.

The full isomorphism is great. I started with the Reason syntax and when I
decided I preferred standard syntax[1], I just use formatting tools to convert
my codebases in O(1) effort.

1: Because of tool maturity, and the ecosystem around the standard syntax
specifically. I wanted to be able to run `dune utop`, but getting that working
with Reason was a WIP; and then there's syntax extensions... And docs are in
the OCaml syntax, except the BS ecosystem, which is conveniently bilingual

------
mhd
Note that despite the origin of the link the book seems to use SML/NJ, not
MLTon.

~~~
brudgers
Nothing against MLTon, but SML/NJ seems to be in more common use based on my
experience with the [SML] tag on StackOverflow.

~~~
saityi
I like to use SML/NJ for development and experimentation, and MLton for final
compilation.

SML/NJ is a really nice development environment, and using a different
compiler like MLton or Poly/ML for the final compilation forces you to use the
more common, standard subset of ML rather than implementation-specific
features.

------
_sbrk
Ah, Standard ML. That brings back great memories of my compiler class at
University. This was the first functional language that I was truly
comfortable with, and a great tool to write our toy compiler.

