5 ms·
> if you haven't coded in a language like OCaml, Haskell, ML etc. you really don't know enough about what strong static types offer to discount them. Java, C a
by zzzeek 5y ago
> if you haven't coded in a language like OCaml, Haskell, ML etc. you really don't know enough about what strong static types offer to discount them. Java, C and C++ have much weaker checks of correctness and lack type inference + pattern matching that make strong types pleasant to work with.
Those are all functional languages, so this argument seems to be the "functional is better than OO" argument, typing is not the primary factor (but of course to the degree that FP allows static typing to be more intuitive, that's a plus). What examples of static typing with OO or procedural languages that are only a "pleasure to work with" can we look at ?
- klysm 5y agoI think functional languages historically have much better type systems but recently, more procedural languages have taken a lot of those innovations and integrated them (e.g. typescript, rust)
- kragen 5y agoThe simply-typed lambda-calculus [01940] predated Abadi and Cardelli's object-calculus or sigma-calculus [01996] by 56 years, and both of those have trouble with side effects; the kind of non-sharing thread-safety guarantees Rust's type system can provide for mutable data structures stem from Jean-Yves Girard's "linear logic" [01987] and Wadler's "linear types" [01990], although Reynolds published a POPL paper in 01978 that we can recognize in retrospect as having invented a Rust-like affine typing system. I've never been able to make heads or tails of Girard's paper but http://pauillac.inria.fr/~fpottier/slides/fpottier-2007-05-linear-bestiary.pdf http://pauillac.inria.fr/~fpottier/slides/fpottier-2007-05-l... is an introductory divulgation of some of the pre-Rust history of this stuff. It makes me think I should read Wadler's 01990 paper. So I think functional languages kind of had a head start, but also in a sense they have an easier problem to solve. ML's type system doesn't even have subtyping, much less mutation and resource leak safety.
- tome 5y agoThanks, that presentation is absolutely fascinating!
- bmitc 5y agoOCaml and F# are functional first multi paradigm languages. They’re perfectly fine being used for OOP.
- Zababa 5y ago> What examples of static typing with OO or procedural languages that are only a "pleasure to work with" can we look at ? OCaml and Rust would fit the bill. You can do procedural and OO in both. You could add Scala to that. I think the conclusion is not that "functional is better than OO" but "they both have their strength and are not mutually exclusive".
- cb321 5y agoYou could add Nim [1] to that list. Many people say it has "the ergonomics of Python but the strong static typing of C++/Rust." [1] https://nim-lang.org https://nim-lang.org
- lolinder 5y agoIn additional to what others have mentioned (OCaml has OOP), Kotlin is very good. It's not as expressive as ML-family languages, but sealed classes + null safety + type inference makes for a very fluid, almost dynamic programming experience that still has strong guarantees.