[ prog / sol / mona ]

prog


Standard ML

1 2022-05-17 08:32

What do anons think of Standard ML? It is a simple language based on the typed lambda calculus, in contrast to Scheme which is based on the untyped lambda calculus. There are a few implementations to choose from (SML/NJ, MLton, Poly/ML, etc.) and it has a relatively large standard library for practical tasks.

2 2022-05-17 14:41

I am already a Haskell nomad wandering the harsh deserts of pure functions.

3 2022-05-17 20:57 *

I'm currently evaluating/prototyping with it for a startup idea I have, in the high assurance/white-hat IT security space. Current favourites are Poly/ML for a compiler. For libraries, I'm interested in contract.sig & .sml from mltonlib for design-by-contract, and use-lib from mltonlib for a build system. Will probably use the event-driven net I/O library from the Poly/ML contribs page too.

I registered for the Coursera course by Dan Grossman, but Real Life has intruded so I had to drop out. A pity, it looked good. Anyway, I know a few related programming languages (e.g. Haskell, Scheme, ISLisp) so probably quicker just to read books. For books, Mads Tofte's "Tips for Computer Scientists" is a great 20-page summary if you have the background to understand it. And for more detail or if you need a gentler on-ramp, Robert Harper's "Programming in Standard ML" looks good too.

I had beel playing around with ISLisp but wanted something standardised with type-checking and support for programming-in-the-large. Specifically, I wanted some way to do object-capabilities in a mainstream programming language, I've managed to port Oleg Kiselyov's OCaml code from his "Lightweight Static Capabilities" to SML without much trouble. Also wanted design-by-contract (I looked at dependent typing instead of this, but it seemed to be more trouble than it was worth). So here we are.

4 2022-05-18 00:03

Guys i think im proggers

5 2022-05-18 09:48

>>3

Current favourites are Poly/ML for a compiler.

I noticed that most implementations have only one or two maintainers. Is that concerning? Poly/ML appears to be have only one author/maintainer.

6 2022-05-18 11:42 *

>>5

Well, that's supposedly the advantage of a standardized language. If the Poly/ML maintainer gets hit by a bus, code that only uses the core language and basis (the latter is quite extensive) should compile under a different compiler like SML/NJ or mlton. In practice of course it wouldn't be that easy, compiler-specific code would need to be ported, but it's good practice to isolate this in specific modules anyway.

FYI, I picked Poly/ML because of two things: native-code compiler that can target Apple M1 CPU; and thread support.

The other possibility is to take over maintenance. I took a quick look, and the code is readable enough that submitting patches for point bugfixes or portability problems looks feasible. Working on the core compiler would require a lot of background reading though, may or may not make sense from a cost/benefit analysis.

7 2022-05-18 13:21

>>6
Overall, I find that that the Basis Library is a huge advantage for Standard ML, especially when compared to all the other "academic" programming languages out there. However, it does have some idiosyncrasies. For example, there are no list sorting functions, and there is no function for installing signal handlers.

8 2022-05-19 01:18

>>7

there are no list sorting functions

Because you can't sort lists in O(^W decent amount of time.

9 2022-05-19 05:39

>>8
How is that an excuse for not having any sorting functions in the Basis Library?

10 2022-05-20 09:43

>>9
It's left as an exercise for the programmer. The best way to learn a language is to have a real excuse to use it.

11 2022-05-20 12:56

My language has no libraries, nothing! Better start usig it then

12 2022-05-20 20:10 *

>>11
Install OCaml-

https://ocaml.org/docs/first-hour

13 2022-05-21 06:59

>>12
Britisher ML addicts refuse to use Frenchies' ML.

14 2022-05-22 09:44

>>11
My language, r7rs-small, has a few functions in it. It's so small that I could write my own implementation of it before using it for my assignment.

15 2022-05-22 10:34

>>14

It's so small that I could write my own implementation of it

I bet that it is a half-baked implementation of "R7RS-small" just like the millions of other "Scheme" implementations out there. Did you implement the full hygienic macro system required by R7RS-small? What about first-class continuations?

Standard ML is defined in less pages than R7RS-small.

16 2022-05-22 10:38

>>15

Standard ML is defined in less pages than R7RS-small.

Apologies. I was mistaken about this.
https://mndrix.blogspot.com/2017/03/programming-languages-by-spec-size.html

17 2022-05-22 20:02

>>12
I like OCaml, it seems to be a very cool language but it is so hard to actually use it for anything other than textbook exercises. With opam, dune and all these things, I just can't wrap my head around how a proper OCaml project should look like.

18 2022-05-22 20:10

>>17

"Unix System Programming with Standard ML" by Shipman clarified a lot of "how the rubber meets the road" for me. Free download at http://www.mlton.org/References.attachments/Shipman02.pdf . Although unless you're using SML/NJ, the Concurrent ML examples would have to be adapted.

Is there something similar for OCaml? I skimmed https://caml.inria.fr/pub/docs/oreilly-book/html/index.html , but I'm not as au-fait with the OCaml ecosystem so would appreciate a pointer to something more up-to-date.

19 2022-05-22 20:34

>>18
For Unix programming there's this: https://ocaml.github.io/ocamlunix/ocamlunix.html
For "real-world" examples: https://dev.realworldocaml.org/

20 2022-05-23 01:55

>>18
Plenty of free books about Standard ML and OCaml.
* https://ebookfoundation.github.io/free-programming-books/books/free-programming-books-langs.html#standard-ml
* https://ebookfoundation.github.io/free-programming-books/books/free-programming-books-langs.html#ocaml

21 2022-06-04 12:31

I like how Standard ML is even more elitist than Scheme. Standard ML has far less schisms than Scheme due to higher level of education and effort required to implement Standard ML correctly.

22 2022-07-10 08:15

Small smelly SML.

23 2022-07-10 09:12

implementing scheme correctly requires a higher level of education

sicp isnt correctly

24 2022-07-10 12:54

>>23

sicp isnt correctly

Unfortunately, many self-proclaimed "Scheme programmers" don't realize this.
https://textboard.org/sol/666
https://textboard.org/prog/499

25 2022-07-11 07:50

Why do people keep recommending SICP if it doesn't even teach you Scheme?

26 2022-07-11 15:30

>>25
SICP isn't about Scheme itself. If you want to learn Scheme, read The Little Schemer or Teach Yourself Scheme in Fixnum Days instead.

27 2022-07-11 17:47

>>26
The Little Schemer is about recursion. It covers even less of Scheme than SICP.

28 2022-07-12 01:37

There should be a little λer, for the benefit of those of us who prefer pencil & paper.

29 2022-07-12 05:41

dont cut yourself on that edge

30 2022-07-12 22:36

I wasn't really aware of SML (just by name), until I found the definitio of stzndard ml

31 2024-04-08 09:09

I want to learn Standard ML. Haskell seems too complex and I think that SML is probably more clean language than Ocaml. I don't know any of these languages I mentioned but I know R5RS. Any tips?

32 2024-04-08 09:50

Good overview of SML vs OCaml: http://adam.chlipala.net/mlcomp/

33


VIP:

do not edit these