News for hackers. Stuff that matters.
Re:Standard ML Family by jjice on Saturday April 16, 2022 @09:18PM (#31057572)
I used SML in my compiler course in college. Our professors loved SML and maintains a pretty popular compiler for it, so he was a wealth of knowledge and helped us along the way, which made it a much more approachable language than if I were to embark on learning it myself.

Really shows the power for statically typed functional languages, and especially the power of sum types. Representing trees with sum types is so extremely powerful and makes writing compiler oriented code feel very natural. I haven't used it since graduation, but if I had to write a compiler, I'd probably opt for an SML like language, like F#.

Re:Standard ML Family by eatonphil on Saturday April 16, 2022 @06:14PM (#31056542)
It would be great to see Julian Hyde's Morel [0, 1] on this list as well.

And also WebML [2], SOSML [3], Bright-ML [4] (had to refresh my memory from my 2020 post on the topic [5]).

[0] http://blog.hydromatic.net/2020/02/25/morel-a-functional-lan...

[1] https://github.com/hydromatic/morel

[2] https://github.com/KeenS/webml

[3] https://github.com/SOSML/SOSML

[4] https://github.com/elpinal/bright-ml

[5] https://notes.eatonphil.com/standard-ml-in-2020.html

Re:Standard ML Family by plumeria on Saturday April 16, 2022 @08:23PM (#31057300)
ReasonML isn't listed as well [0], but I see that the list was last updated on Mon Sep 7 17:22:16 PDT 2015

[0] https://reasonml.github.io/

Re:Standard ML Family by chrischen on Saturday April 16, 2022 @08:34PM (#31057357)
Technically ReasonML is Ocaml.
Re:Standard ML Family by agumonkey on Sunday April 17, 2022 @07:15AM (#31060047)
I saw your mention of SOSML on a subreddit; for someone who has never actually wrote an ml compiler, reading the js codebase was very interesting.
Re:Standard ML Family by eatonphil on Sunday April 17, 2022 @07:22AM (#31060082)
Yeah I am not a huge fan of the compiler code in SML for the ones I've looked at (though I haven't looked at them all). Often it's just one author so they often omit types on nested functions (since they're optional for the compiler) so they're nearly impossible for me to read without spending a huge amount of time on it.

Going off on a tangent, I think every language should require function parameters and return types to be explicitly typed. If that gets rid of the bulk of HM type inference that's cool. The only value to me of type inference is at the local variable level. Function type inference makes code impossible to read.

Re:Standard ML Family by yakubin on Sunday April 17, 2022 @09:27AM (#31060666)
> Function type inference makes code impossible to read.

And the type errors very non-local and therefore hard to understand. The reason is that HM type inference infers types not only in the leaves->roots direction, but also roots->leaves. An expression gets assigned a type based on the context it appears in. It works wonderfully when the program type checks, because e.g. it allows one to write something like "let x = None" in Rust instead of "let x: Option<very long type name> = Option<very long type name>::None;" as long as further uses of x (such as returning it as the value of the enclosing function) clarify its type. However, when a program is during development, you change things here and there, when one variable binding (such as a function definition), which wasn't explicitly typed, appears in at least two places which require this variable to have conflicting types, then almost certainly the error is going to be generated for a line that you as a human see completely disconnected from where the error actually is. Maybe it's in the function definition, maybe it's in one of its uses. And those things can be further obscured by several indirections of intermediate functions with successfully inferred types.

Re:Standard ML Family by eatonphil on Sunday April 17, 2022 @09:30AM (#31060676)
Yup, the number one rule for debugging ML is to add types until the error line becomes clear.
Re:Standard ML Family by sgeisenh on Saturday April 16, 2022 @06:33PM (#31056676)
Standard ML is incredibly usable but also very small (syntactically and semantically) especially compared with modern algol-family languages.

There are a couple of quality of life features missing (most notably is record update syntax), but I really enjoy that the core language has not changed in 25 years.

Re:Standard ML Family by dbmacqueen on Sunday April 17, 2022 @04:36PM (#31064242)
There is also ongoing discussion and other work on something called "successor ML" (sML). See smlfamily.org for further information. Functional record update is one of the features contemplated.
Re:Standard ML Family by qiskit on Saturday April 16, 2022 @07:07PM (#31056898)
It's great functional language to learn pattern matching, type inference, polymorphism, etc in an academic setting. Great language to compare and contrast to other languages ( dynamic, OOP, imperative, etc ), but I'm not sure how useful it is as I've never seen it used in the business world. When all you knew was C/C++/Java, standard ml throws you for a loop - in a good way.
Re:Standard ML Family by chriswarbo on Sunday April 17, 2022 @07:06AM (#31060012)
At my current job we use Scala extensively. I didn't have much experience with it, but found it pretty easy to pick up, mostly due to its similarity to StandardML (much moreso than e.g. Java, Haskell or Python; which are also clearly influences)

In fact, my only previous experience with Scala was from hacking on Isabelle/HOL, which is mostly StandardML, but happens to use Scala in the periphery (scripting, UI, etc.)!

Re:Standard ML Family by 5- on Sunday April 17, 2022 @06:34AM (#31059880)
since i grew up with ocaml, i have found this page on its differences to sml rather informative:

http://adam.chlipala.net/mlcomp/

Re:Standard ML Family by frou_dh on Sunday April 17, 2022 @08:29AM (#31060390)
Andreas Rossberg has a similar page: https://people.mpi-sws.org/~rossberg/sml-vs-ocaml.html

...and also a nice display of SML's grammar: https://people.mpi-sws.org/~rossberg/sml.html

Re:Standard ML Family by kristianp on Sunday April 17, 2022 @06:28AM (#31059860)
Is there a history of the original ML dialect out there somewhere? It's surprisingly old, having first appeared in 1973 according to Wikipedia.[1]

[1] https://en.m.wikipedia.org/wiki/ML_(programming_language)

Re:Standard ML Family by frou_dh on Sunday April 17, 2022 @08:33AM (#31060406)
That's talked about in this recent article, "The History of Standard ML" https://dl.acm.org/doi/pdf/10.1145/3386336

There's also this video presentation, "The History of Standard ML: Ideas, Principles, Culture": https://www.youtube.com/watch?v=NVEgyJCTee4

Re:Standard ML Family by technocratius on Sunday April 17, 2022 @03:19AM (#31059131)
For those (like me) who had to look it up: ML stands for meta language
Re:Standard ML Family by Athas on Sunday April 17, 2022 @05:29AM (#31059623)
This is the historic origin of the name, but I'm not sure it's still supposed to be an acronym. Modern ML may just be named with two arbitrary letters, as often happens when things named by acronyms grow beyond their original domain.

The "meta language" part refers to MLs original domain of writing tactics for proof assistants, where the "object language" was the language of the programs you were manipulating, and the "meta language" is the language in which you manipulate the programs. This also sort of makes sense when using ML to write a compiler (the "object language" is whatever you're compiling), but of course modern ML goes far beyond just language processing, even if it's still pretty good at it.

Re:Standard ML Family by seanstrom on Saturday April 16, 2022 @06:36PM (#31056698)
As a fan of ML family languages I have a question for SML lovers. What do you typically build with SML?

For context, I’m web programmer and I’m also learning game dev, can I use SML productively?

Or are there other tasks that I could use SML for?

Re:Standard ML Family by sshine on Saturday April 16, 2022 @08:04PM (#31057214)
SML for web and game dev? Why not!

There is the Rails-inspired web framework SML on Stilts: — https://github.com/j4cbo/stilts — presumably named after its great ergonomics.

And there is the SDL-powered MosGame, specifically for the Moscow ML compiler — https://github.com/Eckankar/MosGame — it comes with these examples: https://github.com/Eckankar/MosGame/tree/master/examples

But really, SML is primarily good for writing compilers.

Re:Standard ML Family by qznc on Sunday April 17, 2022 @05:05AM (#31059555)
SML could be a nice “typed Lua” for scripting.
Re:Standard ML Family by mbrock on Sunday April 17, 2022 @07:06AM (#31060013)
Especially if there was an implementation that could build from C source code in a simple way without requiring an existing SML compiler…
Re:Standard ML Family by nextos on Saturday April 16, 2022 @07:58PM (#31057176)
SML has an insanely good optimizing compiler, MLton.

With some backing SML could be the language of choice for safe and efficient applications.

Re:Standard ML Family by porcoda on Saturday April 16, 2022 @11:55PM (#31058336)
I use it for my work in program analysis, code generation, and other languages-research projects. I’ve also used it to a lesser degree for modeling and simulation problems.

You would probably be better served by F# or Ocaml for a web-oriented ML stack. SML has less of an ecosystem in that area.

Re:Standard ML Family by jlokier on Saturday April 16, 2022 @09:04PM (#31057511)
I used to work on a hardware compiler written in SML, which compiled a language called Handel to logic circuits for FPGAs.

Mostly I worked on fancy optimisation passes, and a fast gate-level simulator.

Similar to languages like Haskell which emphasise first-class algebraic datatypes (tagged unions) and pattern-matching in a concise but clear syntax, it's good for writing things that manipulate tree-like and symbol-heavy data structures like program syntax trees and circuit graphs, and quickly trying out new ideas with those.

Re:Standard ML Family by csb6 on Saturday April 16, 2022 @06:45PM (#31056764)
It is good at parsing/other compiler-related tasks. Basically anything where you are working with tree structures I think can be a good fit. It is also good as a way to learn about functional programming.
Re:Standard ML Family by chrischen on Saturday April 16, 2022 @08:36PM (#31057373)
React.

https://news.ycombinator.com/item?id=15209814

Also the commentor is one of the maintainers of the ReScript compiler, which is essentially being forked from Ocaml.

Re:Standard ML Family by rixed on Sunday April 17, 2022 @12:20AM (#31058468)
It is said ML languages are good for compilers. I would say more broadly that they are perfect for anything symbolic.