How similar are scala and ML

Does anyone know how similar ML and Scala are? I have to read the Modern Compiler Implementation book which is available in ML, C, and Java. Of those three C is the language I know best, but I’m guessing that ML ought to be pretty easy to understand if you know Scala and Lisp. Right?

Screenshot 2020-12-17 at 13.12.45

ML uses the Hindley–Milner type system and has a markedly different syntax (and model system). Their are quite a few variants. I used Ocaml a long time ago. But I think it is similar enough to Scala that you can work through the examples. However, only OCaml and F# (derived from Ocaml) has OO support. My guess is that you will have to get to know the module system (see for example OCaml modules) to be able to translate that to Scala. Don’t know how easy that will be though.

HTHs

I’ve heard that the ML version is recommended because it’s more suitable for writing compilers. If you go with that, you may find this comparative analysis of ML modules and Scala modules helpful: http://github.com/yawaramin/scala-modules

1 Like

Small note: with Dotty/Scsla3 you now have top leve declarations. This may make some things easier in the initial examples you gave.

I think it is important to understand compilers in C++, because several important compilers are implemented in C++. But it seems to me that this adds an extra complication. Thinking about them functionally, ought to make the concepts easier to learn without worrying about how to force them into a C++ mold. That’s just my guess.