What is Haskell actually useful for?
For instance, if I start learning Haskell, what can I find myself using it for. What are some common uses for this language that I hear is a functional one?
What are some common uses for this language?
Rapid application development.
If you want to know "why Haskell?", then you need to consider advantages of functional programming languages (taken from http://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming):
Functional programs tend to be much more terse than their ImperativeLanguage counterparts. Often this leads to enhanced programmer productivity
FP encourages quick prototyping. As such, I think it is the best software design paradigm for ExtremeProgrammers... but what do I know?
FP is modular in the dimension of functionality, where ObjectOrientedProgramming is modular in the dimension of different components.
The ability to have your cake and eat it. Imagine you have a complex OO system processing messages - every component might make state changes depending on the message and then forward the message to some objects it has links to. Wouldn't it be just too cool to be able to easily roll back every change if some object deep in the call hierarchy decided the message is flawed? How about having a history of different states?
Many housekeeping tasks made for you: deconstructing data structures (PatternMatching), storing variable bindings (LexicalScope with closures), strong typing (TypeInference), GarbageCollection, storage allocation, whether to use boxed (pointer-to-value) or unboxed (value directly) representation...
Safe multithreading! Immutable data structures are not subject to data race conditions, and consequently don't have to be protected by locks. If you are always allocating new objects, rather than destructively manipulating existing ones, the locking can be hidden in the allocation and GarbageCollection system.
Apart from this Haskell has its own advantages such as:
1 / 0
as the first item of a list and it will still work if you only used the second item. You can check out following links:
I think people in this post are missing the most important point for anyone who has never used a functional programming language: expanding your mind. If you are new to functional programming then Haskell will make you think in ways you've never thought before. As a result your programming in other areas and other languages will improve. How much? Hard to quantify.
There is one good answer for what a general purpose language like Haskell is good for: writing programs in general.
For what it is used for in practice, I've three approaches to establishing that:
Indicates that it is good for graphics, networking, systems programming, data structures, databases, development, text processing ...
And finally, my opinion on what it is really strong at:
I hope that gives you a sense on how broad your question is, if it is to be answered with any specificity.
链接地址: http://www.djcxy.com/p/7424.html上一篇: 功能性GUI编程是否可行?
下一篇: 什么是Haskell实际上有用的?