Haskell有什么大惊小怪的? [英] What's the fuss about Haskell?
问题描述
我知道有几个程序员在他们之间一直在讨论Haskell,所以大家似乎都喜欢那种语言。 Haskell的优点看起来有点像天才程序员的标志。
有人可以举几个Haskell例子来证明它为何如此优雅/优越吗?
另一个关于Haskell的非常整洁的事情是它的类型系统。这是严格的类型,但类型推理引擎让它感觉像是一个Python程序,当你做出了一个愚蠢的类型相关的错误时,神奇地告诉你。 Haskell在这方面的错误信息有些欠缺,但随着您对自己的语言更熟悉,这就是打字应该是的!
I know a few programmers who keep talking about Haskell when they are among themselves, and here on SO everyone seems to love that language. Being good at Haskell seems somewhat like the hallmark of a genius programmer.
Can someone give a few Haskell examples that show why it is so elegant / superior?
The way it was pitched to me, and what I think is true after having worked on learning on Haskell for a month now, is the fact that functional programming twists your brain in interesting ways: it forces you to think about familiar problems in different ways: instead of loops, think in maps and folds and filters, etc. In general, if you have more than one perspective on a problem, it makes you better enabled to reason about this problem, and switch viewpoints as necessary.
The other really neat thing about Haskell is its type system. It's strictly typed, but the type inference engine makes it feel like a Python program that magically tells you when you've done a stupid type-related mistake. Haskell's error messages in this regard are somewhat lacking, but as you get more acquainted with the language you'll say to yourself: this is what typing is supposed to be!
这篇关于Haskell有什么大惊小怪的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!