Better HN
topnewbestaskshowjobs
Log inSign up

Denommus

3 karma · joined Dec 29, 2014 (11y ago) · 4 submissions

Submissions

comment 11y ago · link · parent

Besides the object system, OCaml has a powerful module system, with first-class modules and functors (which is already basically very equivalent to what you'd expect from objects).

Besides that, objects have structural typing, and you can even create objects without classes (somewhat similarish to anonymous classes, except instead of interfaces you have the structural typing to give you something like statically typed duck typing).

OCaml also has multiple inheritance and friend classes.

comment 11y ago · link · parent

Yes, that's what I meant, I don't know why I got it wrong.

comment 11y ago · link · parent

OCaml also has both, and its object system is probably more powerful.

comment 11y ago · link · parent

Functional Programming is just composing a program with pure functions, nothing else.

Immutability and closures are required for that, because mutability may break homoiconicity (which is required for purity), and lack of closures means you can't pass state around.

Higher-kinded types are very useful for helping with lots of functional abstractions, but they are a type system feature and have nothing to do with FP. If someone claims that, this person doesn't understand FP or type systems.

OCaml and Standard ML are two examples of languages without higher kinded types but are just as good as Haskell for FP.

(Although they have a powerful module system to compensate for that).