Haskell在现实世界中的用途是什么? [英] What is Haskell used for in the real world?
问题描述
Haskell周围有很多炒作,但是,很难获得有关在实际应用中如何使用它的信息. Haskell最受欢迎的项目/用法是什么?为什么它擅长解决这些问题?
There is a lot of hype around Haskell, however, it is hard to get information on how it is used in the real world applications. What are the most popular projects / usages of Haskell and why it excels at solving these problems?
推荐答案
此功能有哪些常见用途 语言?
What are some common uses for this language?
快速的应用程序开发.
如果您想知道为什么要使用Haskell?",那么您需要考虑函数式编程语言的优势(取自
If you want to know "why Haskell?", then you need to consider advantages of functional programming languages (taken from https://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming):
功能程序往往比其ImperativeLanguage程序简洁得多.通常这会导致增强 程序员的生产力
Functional programs tend to be much more terse than their ImperativeLanguage counterparts. Often this leads to enhanced programmer productivity
FP鼓励快速制作原型.因此,我认为这是ExtremeProgrammers的最佳软件设计范例...但是我知道什么?
FP encourages quick prototyping. As such, I think it is the best software design paradigm for ExtremeProgrammers... but what do I know?
FP在功能方面是模块化的,而ObjectOrientedProgramming在功能方面是模块化的 组件.
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?
为您执行的许多内部管理任务:解构数据结构(PatternMatching),存储变量绑定(LexicalScope与 闭包),强类型(TypeInference),GarbageCollection,存储 分配,使用盒装(指针到值)还是未盒装(值 直接)表示形式...
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...
安全的多线程!不变的数据结构不受数据争用条件的影响,因此不必受到以下方面的保护: 锁.如果您总是分配新对象,而不是 破坏性地操纵现有的锁,可以将其隐藏在 分配和GarbageCollection系统.
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.
除此Haskell之外,它还有其他优点,例如:
Apart from this Haskell has its own advantages such as:
- 受数学符号启发的清晰直观语法.
- 列表理解以基于现有列表创建列表.
- Lambda表达式:创建函数时不给它们明确的名称.因此,处理大型公式会更容易.
- Haskell是完全相对透明的.任何使用I/O的代码都必须标记为此类.这样,它鼓励您将具有副作用(例如,在屏幕上放置文本)的代码与不带(计算)代码的代码分开.
- 懒惰评估是一个非常不错的功能:
- Clear, intuitive syntax inspired by mathematical notation.
- List comprehensions to create a list based on existing lists.
- Lambda expressions: create functions without giving them explicit names. So it's easier to handle big formulas.
- Haskell is completely referentially transparent. Any code that uses I/O must be marked as such. This way, it encourages you to separate code with side effects (e.g. putting text on the screen) from code without (calculations).
- Lazy evaluation is a really nice feature:
- Even if something would usually cause an error, it will still work as long as you don't use the result. For example, you could put
1 / 0
as the first item of a list and it will still work if you only used the second item. - It is easier to write search programs such as this sudoku solver because it doesn't load every combination at once—it just generates them as it goes along. You can do this in other languages, but only Haskell does this by default.
您可以查看以下链接:
- https://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming
- https: //docs.microsoft.com/archive/blogs/wesdyer/why-functional-programming-is-important-in-a-mixed-environment
- https ://web.archive.org/web/20160626145828/http://blog.kickino.org/archives/2007/05/22/T22_34_16/
- https://useless-factor.blogspot. com/2007/05/advantage-of-functional-programming.html
- https://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming
- https://docs.microsoft.com/archive/blogs/wesdyer/why-functional-programming-is-important-in-a-mixed-environment
- https://web.archive.org/web/20160626145828/http://blog.kickino.org/archives/2007/05/22/T22_34_16/
- https://useless-factor.blogspot.com/2007/05/advantage-of-functional-programming.html
这篇关于Haskell在现实世界中的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Even if something would usually cause an error, it will still work as long as you don't use the result. For example, you could put