Haskell有什么大惊小怪的? [英] What's the fuss about Haskell?

查看:123
本文介绍了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屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆