|
Re: Programming in the Mid-Future
|
Posted: Mar 16, 2010 9:39 AM
|
|
> Seriously, I'm very willing to look at new dynamic or > functional stuff. Java does have a lot of boilerplate and > typing. Duck typing has advantages.
I thoroughly agree, but as a budding Haskell enthusiast, it bothers me when people conflate FP and dynamic typing as if they were the same thing. I'm not saying you're doing this, but a lot of the discussion on this thread has suffered from this confusion -- including, I suspect, Eckel's original article.
There is a growing set of problems that functional languages are believed to solve better than imperative languages -- namely concurrency. A strictly functional language will enforce immutability on your data, which does help parallelize your algorithms. This benefit is absolutely unrelated to typing, but because a lot of the more popular functional languages (Scheme, Lisp, Javascript) are weakly typed, a lot of programmers wrongly believe that weak typing and FP go hand in hand.
Haskell, on the other hand, is both strictly functional and strongly typed. In fact, if Java and C++ are considered strongly typed, then Haskell needs a category of its own. Its type system is brutal, if not bullying. You will rarely get through ten lines of code without some bizarre compiler error complaining that your types don't line up. Its type inference system seems at times like it was put there to mess you up until you know what you're doing.
The strange benefit to this is that once your code compiles, you have a pretty solid guarantee that it will work as you intended it to. You have fewer bizarre runtime errors like you see with duck typing.
This makes Haskell is the perfect counter-example to people who think that you need Scheme-like typelessness in order to program functionally.
|
|