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

Scala is more functional because it encourages immutability more strongly and allows better abstractions like typeclasses, higher-kinded types while being roughly even on the modularity front with OCaml (there are a few things easier done in OCaml and a few things easier done in Scala) and beating the shit out of F#.

Not having a separate module and object system is another plus when compared to OCaml.

It unifies OO and FP better than OCaml and F#, because OO implemented in OCaml and F# feels like the designers tried to make a point about how much they dislike OO. What's the first thing OCaml/F# devs tell others about OO in their langauge? To avoid it.




They tell people to avoid the things called objects in OCaml which essentially are just row-typed dynamic records and an inheritance system. Really it's the inheritance system people are taught to avoid... Same as anyone in OO is being taught now.

OTOH OCaml, as an ML, inherits an outstanding module story which is really the core of OO anyway. I'd happily say OCaml is a better OO language than Scala for that reason.


The module story is pretty comparable and many things can be translated directly between OCaml's module system and Scala's.

With the module being roughly equal, and while objects suck in OCaml, but don't suck in Scala, I'm kind of surprised by your judgment.


The module system is the object system fwiw. The things OCaml calls objects are just dynamic row-typed beasties which is why nobody recommends them (except to use as phantom parameters to get your own row typing).


Thanks for the clarification.

Although I rather prefer the functional first approach of the ML language family and actually dislike how typeclasses and HKT are currently supported in Scala.

They look like workarounds based on programming patterns trying to make Scala look like Haskell, with proper support only expected for Dotty, if I understand them correctly.

No trolling, I only dabbled a bit in Scala.


HKTs aren't workarounds. They're fully supported. I suppose you have to use type lambdas to partially apply type constructors but that's not a big deal.

Implicits for typeclasses aren't really a workaround. Implicits parameters are an extremely powerful type-level programming tool. Typeclasses just require slightly more boilerplate than Haskell. And encoding recursion in the type system on things like HLists is rather straightforward and readable using implicits. In contrast, Ocaml and F# don't have the tools to express HLists or much of the type level stuff in Shapeless.




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

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

Search: