Hacker News new | past | comments | ask | show | jobs | submit login

If you're not quite ready to whole hog on the functional purity aspect, I'd suggest you take a look at OCaml. OCaml supports many modern programming amenities, such as Garbage Collection, Higher-order Functions, Static Type-Checking, Generics, Immutable Data Structures, Algebraic Data Types and Pattern Matching, Automatic Type Inference while still allowing for imperative programming when you need it.

I'd recommend taking a look at the Real World OCaml book: https://realworldocaml.org




Doesn't Scala support the exact same features? I know OCaml is based on ML and is mostly structural, while Scala more of a Java-like curly brace lang that is nominal, but your feature list makes them sound the same.


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?


Scala 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).


Could 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.


Scala 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: