3 ms·
I agree that you can vastly reduce state is a large number of cases. It just seems strange to write in a purely functional language when there are many language
by jiggy2011 15y ago
I agree that you can vastly reduce state is a large number of cases. It just seems strange to write in a purely functional language when there are many languages out there that combine functional style with the ability to write in an imperative way.
I can quite happily write programs in python without any real side effects, indeed as you suggest I usually try and divide my functions between those which have side effects and those which don't. So what advantage would I get for picking haskell instead? Other than marginally shorter programs?
FP seems to be picking up steam recently, is this just because we are doing more computation in the cloud and CPUs are getting more cores rather than more raw clock speed or am I missing something?
- nightski 15y agoThe advantage is that you can reason about the correctness of code. Sure, if you write an entire code base depending on its size you may be able to reason about all the side effects in your head. But when moving to a larger project, or one developed by a team - all bets are off. It is really important to have the effects embedded in the type system. Even with a large test suite. On top of this, having professionally written C/C++ for years in the embedded systems space I can say that Monads for IO is not awkward. In fact, it feels far more powerful because you are not limited to the awful semicolon operator for chaining effects. Lastly FP != slower (even on single core). I agree Haskell can be hard to reason about performance wise at times due to choosing lazy by default. However, have you ever heard of Sisal? Many strict by default FP languages are quite fast, however they sacrifice purity. But to be honest, with experience Haskell can be damn fast also.
- jiggy2011 15y agoInteresting, my question is more though why now? Since LISP has been around for a very long time and FP has had very little mainstream interest until the last year or 2.
- nickik 15y agoGood question. I think its a couple of diffrent things. 1. Java is not really evolving, people are frustrated 2. Multicore is difficulte and FP claim they are better at it. 3. Complexety of ever bigger codebases 4. Java Script not longer the worst language in the world, people start to understand whats powerful about it and want to know what more is possible.
- danieldk 15y agoAdditionally, I think that Haskell really has to offer something over most other FP languages. Many features of dynamic impure FP languages have already been ported to languages such as Ruby or Python. What Haskell provides over, say Lisp, is exceptionally strong typing and isolation of side-effects. This is a quality that cannot be ported to mainstream languages easily. So, why didn't Haskell become more popular earlier? I think that's simple: the GHC compilers has improved tremendously over the past years, Hackage has grown considerably, and there are now more books oriented at practical programming.
- mooki 15y agoAfter spending some time exploring different functional languages, if FP does make it at all - my money would be on Haskell. There is something to be said for focused languages that does one thing but does it really well, and the feeling of security when a certain style is enforced over a codebase. I probably wouldn't use it for anything today, but in another couple years maybe. The ecosystem seems like it's reaching critical mass.
- nickik 15y agoI think Clojure is ready right now. For "standalone" languages haskell seams to be on a good way, some people are allready doing start ups with it.
- jhuni 15y agoActually most Lisps offer optional means of static verification and static typing for when its necessary. Furthermore, Lisps have vital metaprogramming features that Haskell lacks which are essential for symbolic AI applications.