学什么才能“悟道”?函数式编程?
我已经编码几年了,没什么太复杂的。 C++是我最了解的。我最近偶然进入了 Paul Graham 的网站,编写恐怖代码,现在就在这里。
我要学习什么才能“以函数式编程的方式启发自己”? Haskell、Scheme 还是 CLIsp?
I've been coding for a few years now, nothing too complicated. C++ is what I know best. I recently stumbled into Paul Graham's site, coding horror, and now here.
What do I learn to "enlighten myself with the ways" of functional programming? Haskell, Scheme or CLisp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
正如其他答案所说,这三个都很好。
但如果您决定使用 Lisp,那么我建议您选择 Clojure,这可能是它的最新转世。
As other answers say, all three are good.
But if you decide on Lisp, then I'd suggest you go for Clojure which is perhaps its most recent reincarnation.
Haskell 是函数式风格的最强典范,强调纯函数式编程(无副作用)、强大的静态类型,以及强调多核并行性的务实实现,同时还拥有庞大的社区(http://hackage.haskell.org 以及许多在线资源)。
它因重新培训人们对编程的看法而闻名。
但这只是宣传,而不是有用的 stackoverflow 问答环节。你必须自己决定你想学什么。
Haskell's the strongest exemplar of the functional style, emphasizing purely functional programming (no side effects), strong static typing, and with a pragmatic implementation with an emphasis on multicore parallelism, while also having a huge community (around 2000 libraries available on http://hackage.haskell.org , and many online resources).
It's somewhat famous for retraining how people think about programming.
But this is advocacy, and not a useful stackoverflow question and answer session. You'll have to decide for yourself what you're looking to learn.
您听说过 F#、ML 或 OCaml 吗?这三种语言属于 ML 家族。
F# 是 Microsoft 支持的新 ML 方言,将随产品一起提供Visual Studio 2010。F#(或其他 ML 语言)的好处是,当您第一次开始时,您可以编写命令式代码并逐渐学习良好的函数式风格。
这是我为 Project Euler #2 编写的示例。当我第一次这样做时,我使用命令式风格。后来,我知道了如何使用惰性序列,这是一个强大的函数式编程概念。
Have you heard of F#, ML or OCaml? These three languages belong to the ML family.
F# is a new ML dialect supported by Microsoft and will be shipped with Visual Studio 2010. The good thing about F# (or other ML languages) is that when you first start you could write imperative code and learn good functional style gradually.
Here's an example I wrote for Project Euler #2. When I first did it, I used imperative style. Later on, I know how to use lazy sequence, which is a powerful functional programming concept.
如果您对函数式编程感兴趣,Haskell 是该列表中唯一的纯函数式语言。 Common Lisp 是一种弱函数式混合范式语言,Scheme 函数式更强,但仍然不纯粹。 Lisps 之所以有趣还有其他原因,但 Haskell 几乎是函数式编程的最先进技术。
顺便说一句,我之所以鼓励像 Haskell 这样更强大的函数式语言,是因为“学习函数式编程”的很大一部分是学习如何以不同的方式思考你的程序。如果您的语言使命令式编写感觉很自然,那么很容易陷入这种思维方式并且永远不会意识到还有其他方法可以做到这一点。
If you're interested in functional programming, Haskell is the only purely functional language on that list. Common Lisp is a weakly functional mixed-paradigm language, and Scheme is more strongly functional but still not pure. Lisps are interesting for other reasons, but Haskell is pretty much the state of the art for functional programming.
Incidentally, the reason I encourage more strongly functional languages like Haskell is because a large part of "learning functional programming" is learning how to think of your program in a different way. If your language makes it feel natural to write imperatively, it's too easy to fall into that way of thinking and never realize there's a different way to do it.
在这三个中,我认为Scheme 是最简单的,如果这是您主要关心的问题的话。 SICP 使用Scheme,它本身就是学习的一个很好的资源以函数式方式进行编程。
然而,Common Lisp 拥有许多高级功能,使其极具表现力,例如强大的错误处理(比异常更强大)、多方法以及对面向方面编程的支持。
您可能会从一种语言开始,但最终您应该学习多种语言。
Of the three, I'd say Scheme is the simplest overall, if that's your main concern. SICP uses Scheme, and is itself a great resource for learning to program the functional way.
However, Common Lisp has many advanced features that make it quite expressive, such as powerful error handling (more powerful than exceptions), multimethods and support for aspect oriented programming.
You might start with one but, in the end, you should study many languages.
三者各有优劣,因人而异。
如果您决定使用 Haskell,这是一个很好的资源:learnyouahskell 以及 现实世界的 Haskell
All three are good, depends on each person.
If you decide on haskell, this is a great ressource : learnyouahaskell and also real world haskell