Live data from Hacker News

What was wrong with SML?

blog.plover.com

31–40 of 82 posts

Re: What was wrong with SML?

#31

> In Structure and Interpretation of Computer Programs, Abelson and Sussman describe an arithmetic system in which the arithmetic types form an explicit lattice. Every type comes with a “promotion” function to promote it to a type higher up in the lattice. When values of different types are added, each value is promoted, perhaps repeatedly, until the two values are the same type, which is the lattice join of the two…

Wouldn’t that last example be incorrect mathematically? For example, if the Int8 was -10 and the UInt16 was 10, what would that casting do? Would a better promotion be Int32 for both? Just curious, Julia is a language I’ve been very interested in using for a long time, just haven’t had the opportunity to sit down and learn yet.

Re: What was wrong with SML?

#32

IMHO Haskell's lazy evaluation has some significant disadvantages compared to SML's strict evaluation. In particular, lazy evaluation makes it difficult to find the performance bottlenecks in a particular piece of code or to determine the time complexity of an algorithm just by reading it. Furthermore, subtle changes in how a function is written (for instance, making a multiplication function not evaluate the right o…

It would be nice to have a language that could treat both strict and lazy evaluation as equally first-class, as opposed to having one be the default (whether "strict" as in ML or "lazy" as in Haskell) and the other only being expressed by syntactical kludges. This may well be possible by relying on logically-inspired features like polarity and focusing, and endowing data types with strict or lazy "natural" polarities…

Any strict language can implement laziness. The inverse may(?) not be possible.

Re: What was wrong with SML?

#35
How about OCaml? I studied it alongside SML and liked it a bit better. Whenever something in SML struck me as a poor design choice, I looked over and saw that Caml had done something about it. (I felt the "O" was a completely unnecessary addition.)

Re: What was wrong with SML?

#36
post #6

I still actively use SML - mlton or smlnj usually, polyml too. I’m aware of the issues raised in this post but haven’t ever found them to be a source of much headache. To be honest, the biggest headache is moving between compilers and their different build processes. Other than that, the fact that the language isn’t really changing is a big attraction for me. CakeML is also a very cool project in SML land.

I am curious what you use SML for. Any examples? Just interested in seeing what you can do in SML.

Re: What was wrong with SML?

#37
post #28

I'm not really convinced by the author's first example. While an element of type bool is an instance of type a, an element of type bool -> bool is not an instance of type a -> a. The issue is precisely an issue of variance, which is mentioned in reference to Scala, but somehow it's glossed over. The type a -> a is covariant in its second argument, but contravariant in its first argument. As a result, you cannot "spec…

This is pretty fundamental to the Hindley-Milner system of parametric polymorphism (which I believe was the first such system?). The 'a is treated as a universally quantified type variable that can be unified with concrete types [1]. 'a=int and 'a=bool are two possible ways to unify the type variable, yielding int->int and bool->bool as signatures that unify with 'a->'a. Similarly 'a list -> 'a means a function that takes a list of some type, and returns an element of the same type (the built-in List.hd function is an example), while 'a list -> 'b is a looser type signature meaning "takes a list of some type, and returns some value, not necessarily of the same type", so int list -> int and int list -> bool would both fit the 2nd schema.

This is all sound if the language is pure, which ML originally was.

There's also a relevant discussion at Stackoverflow. [2]

[1] This is a fairly concise summary of the quantification rules: https://jgbm.github.io/eecs662f17/Notes-on-HM.html

[2] "Does Scala have a value restriction like ML, if not then why?" https://stackoverflow.com/questions/48594769/does-scala-have...

Re: What was wrong with SML?

#38
post #6

I still actively use SML - mlton or smlnj usually, polyml too. I’m aware of the issues raised in this post but haven’t ever found them to be a source of much headache. To be honest, the biggest headache is moving between compilers and their different build processes. Other than that, the fact that the language isn’t really changing is a big attraction for me. CakeML is also a very cool project in SML land.

I am curious what you use SML for. Any examples? Just interested in seeing what you can do in SML.

Mostly programming languages related: code analysis, compilers, code generators, and formal verification tools. Outside PL work, I’ve used it to build some modeling and simulation tools. I also use it for misc. little tools that I need every so often where I want the type system to help me out. For a brief few years (‘09-‘15) Haskell played this role for me but I went back to SML after getting frustrated with various parts of that ecosystem.

Re: What was wrong with SML?

#39

Earlier quoted context omitted.

It would be nice to have a language that could treat both strict and lazy evaluation as equally first-class, as opposed to having one be the default (whether "strict" as in ML or "lazy" as in Haskell) and the other only being expressed by syntactical kludges. This may well be possible by relying on logically-inspired features like polarity and focusing, and endowing data types with strict or lazy "natural" polarities…

Any strict language can implement laziness. The inverse may(?) not be possible.

It's the opposite, no? Basically every lazy language has some way to force evaluation, but in most strict languages laziness is never fully supported. Closest I can think of is a Scheme with continuations, but even then it takes some extra work. I know in CL even primitive laziness takes a lot of work and a code-walker, and whatever it's other flaws Common Lisp is at least adaptable.

Re: What was wrong with SML?

#40

SML was the First Language used for the Computer Science degree I took. I felt at that time, and continue to feel years later (that degree course now teaches Java as First Language) that this was a good decision despite the fact that most graduates don't end up using SML to write anything. In the course of my education I experienced some things which I'm convinced are a bad idea even though they worked out OK for me…

I feel like there should be some expected order. Like BASIC->functional->scheme or something. Maybe switch them around, or throw in Python. There are a bunch of hurdles for new programmers to jump over, and it seems like maybe the best way to get them over them is with a different language for each. When my roommate took his intro CS course in Python he was mystified by type errors since they're often somewhat hidden. In Java the next semester the boilerplate made the whole program feel less understandable, but a semester or two later and it could have taught valuable lessons.
Post reply on HN