5 ms·
Studying SML should be part of the entry examination for programming language designers. It's old, has its warts, but is still vastly superior to most things th
by toolslive 2y ago
Studying SML should be part of the entry examination for programming language designers. It's old, has its warts, but is still vastly superior to most things that came later. (Type inference? check! Pattern matching? check! TCO? check!. Performance ? excellent!, ...)
- ngruhn 2y agoit's crazy, it took "the industry" 30+ years to adopt this stuff
- fire_lake 2y agoAnd they still haven’t! Although expressions over statements would be a breaking change - I can’t see any mainstream language making this switch.
- tialaramex 2y agoBarry Revzin has written a paper to try to give C++ expressions like this. It's ugly, even by the standards of C++ but it would work. The rationale is that C++ 29 or C++ 32 wil probably get pattern matching and pattern matching doesn't have great ergonomics if everything is a statement rather than an expression. There are plenty of other things C++ will need to fix once it gets pattern matching, but the direction makes sense if you insist on trying to teach this particular old dog new tricks. Also, I think Rust would consider itself to be a mainstream language, though they aren't techically "making this switch" because the language has always been expresion oriented from the outset. The Book has about two paragraphs about the statements in the language and then a whole chapter on expressions because almost everything is an expression.
- tmountain 2y agoStill waiting on real pattern matching in TyoeScript.
- no_wizard 2y agoYou won’t get it till TC39 adopts it
- BalinKing 2y agoI actually think it's becoming fairly common these days—IIRC Ruby and Rust both prioritize expressions over statements.
- int_19h 2y agoThey do, but the fact that there is even a distinction at this point is rather baffling. If your type system has the unit type and the bottom type, all statements should just be expressions having one of those two types.
- fire_lake 2y agoPeople really like their early return statements however.
- needlesslygrim 2y agoWell, Rust barely has statements [1]. Nearly everything in Rust is an expression, and AFAIK statements /are/ essentially expressions that yield `()` [2]. [1]: https://doc.rust-lang.org/reference/statements.html https://doc.rust-lang.org/reference/statements.html [2]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=12aacef98d63cb28ec12b0ae96308619 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- steveklabnik 2y ago> AFAIK statements /are/ essentially expressions that yield `()` This isn't true. The inverse is true, "expression statements" can turn an expression into a statement. What you're seeing in the playground is just how blocks are defined[1]: > The syntax for a block is {, then any inner attributes, then any number of statements, then an optional expression, called the final operand, and finally a }. In this case, you have one statement, and no optional expression. And so: > The type of a block is the type of the final operand, or () if the final operand is omitted. So that's how this works. Now, that being said, I don't think it's too terrible of a mental model to think of this situation in that way. But if we're getting into nitty-gritty details, that's not actually how it works. 1. https://doc.rust-lang.org/stable/reference/expressions/block-expr.html https://doc.rust-lang.org/stable/reference/expressions/block...
- Almondsetat 2y agodo you have any research that points to these things being useful for the industry?
- sudahtigabulan 2y agoThe languages that were actually adopted by the industry are not exactly full of great useful stuff: https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- cmrdporcupine 2y agoHaving SML (or at least OCaml) as a known language definitely would help engineers when they get into the industry and start using Rust. Back in the day when I played with these things I preferred SML/NJ over OCaml, but OCaml "won" the battle for headspace. I'd consider using OCaml for new projects, I really like the language family.
- xyproto 2y agoI also prefer SML over OCaml. I wonder how F# feels and want to give it a shot.
- int_19h 2y agoF# doesn't have many of OCaml's more advanced features. In particular, no functors and no polymorphic variants. Also the OO system is basically .NET, which isn't that surprising (but means that you don't get the neat row typing with inference that OCaml does). OTOH some of the choices it makes are a bit more pragmatic - e.g. arithmetic is overloaded for ints and floats, locals can be marked as mutable similar to record fields, and fields are scoped to record types (so different types can use the same field name).
- sheepscreek 2y agoIt’s incredible how much of an understatement it is to say that F# and OCaml were “inspired” by Standard ML. They’re practically step-siblings, sharing more similarities than I could have ever imagined. Edit: Obviously, F# is the step-sibling here, given its half-dotnet parentage. However, they’re all solid choices. Their spectacular type inference makes coding in them a very gratifying experience. I can only think of TypeScript as the closest to them among the more popular modern languages.
- moomin 2y agoC#’s inference is pretty good these days. As with most things with powerful type inference, you can make a real mess if you put your mind to it.
- int_19h 2y agoFor those curious about the differences between Standard ML and OCaml. http://adam.chlipala.net/mlcomp/ http://adam.chlipala.net/mlcomp/
- rokkamokka 2y agoThis was the language they taught in our functional programming course while I was doing my CS degree. That was around 15 years ago now. I wonder if they still use it in the course
- deleted 2y ago[deleted]
- nextos 2y agoThe Little Series, famous for The Little Schemer book, published The Little MLer in 1998. It's probably their lesser known volume, but IMHO it makes a terrific job at teaching the ML family and its features.