5 ms·
Things Scala lacks which OCaml has: 1. Tail call elimination 2. A full-featured module system 3. Functors (functions at the module level) 4. First-class module
by silentOpen 13y ago
Things Scala lacks which OCaml has:
1. Tail call elimination
2. A full-featured module system
3. Functors (functions at the module level)
4. First-class modules
5. GADTs
6. Polymorphic variants
7. A decidable type system
8. ... more?
Things OCaml lacks which Scala has:
1. Traits
2. Implicits
3. Trivial Java FFI
4. Seamless syntactic macros (c.f. camlp4)
5. ... more?
- seanmcdirmid 13y agoScala has 1, 5, and 6. It lacks 7, and about 2/3, which are basically the same, where scala at least supports mixin constructions (which you can also get from class-parameter ised functors, though maybe not in Ocamel).
- silentOpen 13y agoCould you elaborate on Scala's TCO support? I was under the impression that only self-tail calls are eliminated and only if the stack trace would be provably unused. Doesn't the JVM require stack traces? Can you use CPS in Scala? I see now that Scala can encode GADTs in case classes. What mechanism is available to encode polymorphic variants? Particularly, I am interested in writing matches over unions of polymorphic variant types. I disagree that 2 and 3 are the same (structural module subtyping, nesting, inclusion differs from applicative functors). I believe you can achieve mixins with OCaml through the object system but it's not clear to me that this addresses functor signature checking. Another Scala bonus: 5. Objects can implicitly be null.
- seanmcdirmid 13y agoScala has TCO support, but maybe not as advanced as Ocaml, being limited by the JVM and all. CPS is heavily used in scala these days, as far as I can tell by reading Ingo Meir's work. I was confused about polymorphic variants. Scala doesn't seem to have that. I did a lot of work with units (dr. scheme-style functors) before, and when I moved to scala for my postdoc, I found all my patterns expressible using mixins and nominal types...I didn't miss the modules (1st class or otherwise). Scala has a non-null-ability option, but most programmers I think would find null damn convenient.
- unhappy_dino 13y agoNew account, but old comment because I have been shadow-banned a few minutes ago: You need to pick a decent runtime which supports proper tail calls and everything just works fine. I consider the sad fact that scalac tries to do TCO too an ugly hack necessary to reduce the pain of poor VM implementations. Regarding 5.: null is a legacy feature for Java interop. It's not commonly used in Scala. If you decide to use null in Scala anyway, you will need to have a really good reason. Otherwise people will feel that you just spit in their face.
- happy_dino 13y agoScala has 1., 2., 3., 4., 5. 6. seems to be a fix for an OCaml-specific issue. 7. is obsolete (imho), because with macros the most important benefit of decidable type systems (knowing that compilation will terminate) is gone anyway.
- unhappy_dino 13y agoNew account, but old comment because I have been shadow-banned a few minutes ago: Scala has 1., 2., 3., 4., 5. 6. seems to be a fix for an OCaml-specific issue. 7. is obsolete (imho), because with macros the most important benefit of decidable type systems (knowing that compilation will terminate) is gone anyway.