back

by vslira·6y ago·view on hn ↗
Dan Grossman's "Programming Languages, Part A" (In Coursera) made me fall in love with SML. Highly recommended.
3 comments
This course finally made me understand the WHY of FP. Comparing and Contrasting the major programming paradigms at a high level, but also actually writing code was a great combination. Before that I just thought it was only used for people doing math and finance (which wasn't even close to right, lol)

SML is kind of like the lisp of FP. It's just the minimal core of parametric polymorphism and hindley-milner type inference, so as a beginner you don't spend thought cycles language-specific features (that would make it more useful as a general purpose language) - you just learn and understand the core concepts and techniques (such as building intuition for how to replace different kinds of loops with recursion and pattern matching) that will apply to all FP/HM languages.

> SML is kind of like the lisp of FP.

Lisp is the Lisp of FP.

SML is more the SML of FP. Alternatively, SML can be viewed as the Lisp of statically-typed FP, in that, loosely, SML : Static FP :: Lisp : DynamicFP

"Functional programming" is a term with a few meanings.

Notably, the paper that (I believe) coined the term, "Can Programming be Liberated from the Von Neumann Style?" by John Backus, spent a fair amount of ink on specifically calling lisp out, and contrasting it from what he had in mind. IIRC, he felt that FP was preferable to the lisp model because lisp gives you too much power: Mutable variables, ways of composing functions that are potentially more error prone due to domain/range mismatch gotchas, stuff like that could all be impediments to ensuring the correctness of programs. I think that, to some extent, a sort of Haskellian fastidiousness about correctness is what he felt this proposed functional style of programming was all about.

Scheme is the lisp of FP. My understanding is that idiomatic lisp is quite imperative.
So is scheme quite often. It appears functional looking at idiomatic scheme code relying on tail-recursive programming for loops, it appears procedural/imperative if you look at all the mutation used in scheme code (fun fact: the Scheme standards R*RS do not speak of functions but of procedures). Higher-order functions aren't used all that much in many scheme code bases which is odd from the perspective of a Haskell dev.
Thanks for the info. My knowledge of the lisp family is quite limited outside of emacs lisp (which usually has a quite imperative feeling).
With my limited experience lisp is significantly not functional, or better is definitely an outlier in an unusual direction in the cluster of functional languages.

To me it feels much more like a symbolic computation oriented language.

But maybe it is because I associate too much fp with some kind of parametric typing

Also got to know SML in this course. It changed a lot the way I code and think, even in Java.

What I would like is a language as simple as SML in the JVM. Kotlin was the closest thing I found with good adoption.

>SML is kind of like the lisp of FP

Out of curiosity, what is lisp the lisp of? (It's not lambda calculus, for that is the lisp of lisp.)

> SML is kind of like the lisp of FP

You don't consider lisp the lisp of FP?

Most Lisps (and certainly Common Lisp) have enabled a functional style, but were never particularly "pure". You have to squint a little bit and gloss over some parts to call them functional programming languages.

Haskell is the poster child, but quite rich in syntax and concepts. So while I wouldn't really agree with grandparent, it's at least defensible to see Standard ML as a small core, a kernel of functional programming languages.

I think here it is important to note, that the definition of Functional Programming is kind of fluid and has changed considerably over the decades.

For a long time, there was no distinction between pure- and non-pure FP langauges and Lisp was certainly considered a FP lang. Yes, Lisps are typically not pure FP, but they are still FP (unless you define FP to mean pure FP, but that's kind of not in line with usage of the terms).

That being said, much Lisp code (CL or Scheme alike) is probably as functional in style as Python code.

Seems like many around here got to know sml through this course. I hope Dan Grossman and his colleagues can see how much effect they had :)
Yes! I did this many years ago, when it was all one course. I only got around to doing the SML part but it really improved how I approached learning new programming languages and frameworks (not just FP languages). I'm very thankful for what I learned, it has really help my a huge amount in my career! I'd highly recommend it to anyone who feels overwhelmed with all the 'new stuff' coming out. Much of it can be learned much easier if you look a little deeper and can ask the right questions.