3 ms·
Funny, I'd say I like functional programming... and yet I disliked all the functional and/or lisp-like languages that are the bees knees these days... Scala, Sc
by captainmuon 13y ago
Funny, I'd say I like functional programming... and yet I disliked all the functional and/or lisp-like languages that are the bees knees these days... Scala, Scheme, Clojure, Haskell, F#, ... All of them have neat sides, but I'm not really productive in any of them.
There are things like too-clever type systems that get into your way, instead of catching errors. Constness can be silly in C++ if you are not careful, but that's nothing against the situation in e.g. Haskell.
Then there is type inference, which really scares me. When I write (in pseudocode):
fun add(a, b) { return a + b; }
the meaning can change depending on how this is called at a different place in my code (e.g. with strings or ints as arguments). On the one hand, this confuses me - if there is a conflict, it can be incredibly hard to debug. On the other hand, the compiler can get confused. If I call add(get_number(x), get_number(y)), I know that a and b are going to be ints, but the compiler might be unable to infer this, depending on how complex get_number is. Type inference is magic, and IMHO often not worth the saved keystrokes. I'd rather have my language use a Variant type when no type is specified (and sure, when it can infer the type, use it as an optimization).
- tel 13y agoI've heard a few interesting arguments (mostly by Gilad Bracha) against type-dependent semantics, though I don't think these arguments usually apply in this situation where you're just talking about polymorphism in (+). The argument is that if your language doesn't have type-dependent semantics then you can plug and play type systems as completely independent static analysis tools. I don't know that I buy that those tradeoffs are best, but there is something really interesting there.
- bcoates 13y agoThat's because having + perform a non-commutative operation like string concatenation is an abomination.
- peter-fogg 13y agoBut in a situation like that, you could just annotate the type. In Haskell: add :: Int -> Int -> Int add a b = a + b