C# F# vs Haskell vs Lisp - 学习哪种语言?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2236690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
F# vs Haskell vs Lisp - which language to learn?
提问by empi
I've heard a lot about functional programming languages and I'm willing to learn one. I guess it will be mostly for fun, however, I hope it will improve my programming skills.
我听说过很多关于函数式编程语言的知识,我愿意学习一门。我想这主要是为了好玩,但是,我希望它能提高我的编程技能。
I have mostly C#/.NET background, so my first choice is to learn F# (because of .NET and familiarity with Visual Studio). On the on other hand, I wonder if F# has features like Lisp macros or Haskell higher order functions.
我主要有 C#/.NET 背景,所以我的第一选择是学习 F#(因为 .NET 并且熟悉 Visual Studio)。另一方面,我想知道 F# 是否具有像 Lisp 宏或 Haskell 高阶函数这样的特性。
Could you compare F#, Haskell and Lisp? Which one will be the language of your choice?
你能比较 F#、Haskell 和 Lisp 吗?哪一种将是您选择的语言?
采纳答案by Robert
F# is my language of choice, but I'd strongly recommend learning them all. They are all quite different and interesting in their own right. Here's a quick over view to each one (with perhaps a slight F# bias), you can easily find more info by googling:
F# 是我的首选语言,但我强烈建议您全部学习。它们各有千秋,各有千秋。这是对每个人的快速概览(可能有轻微的 F# 偏见),您可以通过谷歌搜索轻松找到更多信息:
F# - is a language that makes it easy to program in the functional style, lets you easily copy objects rather than mutating them. It also gives you interesting data types, like tuples and algebraic data types, useful language constructs such as pattern matching and list comprehensions. It also has OO and imperative features and good access to libraries, since you can use any .NET framework component.
F# - 是一种可以轻松地以函数式风格进行编程的语言,让您可以轻松地复制对象而不是改变它们。它还为您提供了有趣的数据类型,如元组和代数数据类型,有用的语言结构,如模式匹配和列表推导式。它还具有面向对象和命令式功能以及对库的良好访问,因为您可以使用任何 .NET 框架组件。
Haskell - is a pure and lazy functional language, making a rare or even unique beast. This means there are no side effects at all, unless they are tracked by a monad. Haskel too has tuples, algebraic data and pattern matching.
Haskell - 是一种纯粹而懒惰的函数式语言,造就了稀有甚至独特的野兽。这意味着根本没有副作用,除非它们被 monad 跟踪。Haskel 也有元组、代数数据和模式匹配。
Lisp - whereas F# and Haskell are statically typed, lisp is dynamically typed. It has distinctive syntax which uses lots of parentheses and provides an interesting macro feature that allows you to make transformations to the program itself and extend the syntax.
Lisp - F# 和 Haskell 是静态类型的,而 lisp 是动态类型的。它具有独特的语法,它使用了大量括号,并提供了一个有趣的宏功能,允许您对程序本身进行转换并扩展语法。
回答by Tony The Lion
回答by Peter
I had the same question once
我曾经有过同样的问题
Since then, I have done some programming in F#. Now I am very glad I did, since it is realy helpful to understand LINQ in C# and that happened to be my background too. (I almost never use foreach in C# now since I learned F#)
从那以后,我用 F# 做了一些编程。现在我很高兴我做到了,因为在 C# 中理解 LINQ 真的很有帮助,这也恰好是我的背景。(自从我学习 F# 以来,我现在几乎从不在 C# 中使用 foreach)
I learned through F# a lot of things about lazy evalution, lists and sequences, all of which you could pick any language for with good support for lists, tuples, and so on (like any functional language I guess), but if you pick F#, all of this will be very useful in C# too. Maybe you already know all of this stuff and use it right, but in case you don't, pick F#.
我通过 F# 学到了很多关于惰性求值、列表和序列的东西,所有这些你都可以选择任何语言,对列表、元组等有很好的支持(就像我猜的任何函数式语言),但是如果你选择 F# ,所有这些在 C# 中也将非常有用。也许您已经了解所有这些内容并正确使用它,但如果您不知道,请选择 F#。
I started out here: a very nice video tutorial, very impressive and a very inspiring tutor.
我从这里开始:一个非常好的视频教程,非常令人印象深刻,也是一个非常鼓舞人心的导师。
回答by Arve
This is a very subjective question.
这是一个非常主观的问题。
My opinion is that Scheme (a Lisp variant) and reading SICPis the right thing. You will learn a lot.
我的观点是 Scheme(一个 Lisp 变体)和阅读SICP是正确的。你会学到很多东西。
But for practical purposes and if you are a .NET developer then maybe F# is better.
但出于实际目的,如果您是 .NET 开发人员,那么 F# 可能更好。
回答by Marko
Why choose? Learn both Lisp and Haskell on your own. No point in learning F# on your own time though. If you need it for work, you'll learn it at work ;)
为什么选择?自己学习 Lisp 和 Haskell。不过,在自己的时间学习 F# 没有意义。如果您在工作中需要它,您将在工作中学习它;)
EDIT: The guy was looking at language to learn for fun. Well, Lisp and Haskell are good candidates since fun is all they are going to be used for (no paid jobs there). He "might" (although unlikely) have opportunity to use F# at work (he is in MS shop), so why learning something in free time when he can be paid learning it at work.
编辑:这家伙正在寻找语言来学习乐趣。好吧,Lisp 和 Haskell 是很好的候选人,因为他们将用于乐趣(那里没有带薪工作)。他“可能”(尽管不太可能)有机会在工作中使用 F#(他在 MS 商店),那么为什么他可以在工作中学习并获得报酬的情况下在空闲时间学习一些东西。
回答by Nemanja Trifunovic
I learned all of them to a diffeent degree, and would advise starting with Scheme (a Lisp dialect) - simply because it is easiest to learn. Haskell and F# are statically typed, which is a big advantage for real-life projects, but IMHO they have a little "too much" syntax and are not as easy to pick up as Scheme.
我在不同程度上学习了所有这些,并建议从 Scheme(一种 Lisp 方言)开始——因为它最容易学习。Haskell 和 F# 是静态类型的,这对于实际项目来说是一个很大的优势,但恕我直言,它们的语法有点“太多”,不像 Scheme 那样容易上手。
There is a nice Scheme implementation for .NET - IronScheme. You can take a look at my article "Playing with IronScheme" to see if you like it.
.NET 有一个很好的 Scheme 实现 - IronScheme。你可以看看我的文章《玩转IronScheme》,看看你是否喜欢。
回答by nickik
I don't know F# but I like to play with it sometimes. My language is Clojure which is very functional and works on the CLR too, but the JVM version is the main version.
我不知道 F#,但有时我喜欢玩它。我的语言是 Clojure,它非常实用,也适用于 CLR,但 JVM 版本是主要版本。
It overs you a lot of the stuff you want. The main diffrence to F# is that Clojure is dynamicly typed and it has really good way handle concurency (one of the best I would say).
它覆盖了你很多你想要的东西。与 F# 的主要区别在于 Clojure 是动态类型的,并且它具有非常好的处理并发性的方法(我想说的最好的方法之一)。
BTW. Did you know that F# was made because Haskell was to hard to get running on the CLR? (Thats not the whole story of course but its part of it)
顺便提一句。您是否知道 F# 的诞生是因为 Haskell 很难在 CLR 上运行?(当然这不是故事的全部,而是其中的一部分)
回答by Justin
Nobody actually answered this specific question: "I wonder if F# has features like Lisp macros or Haskell higher order functions."
没有人真正回答过这个具体问题:“我想知道 F# 是否具有像 Lisp 宏或 Haskell 高阶函数这样的特性。”
F# does not offer macros. Also, it does not offer higher-kinded types (which is what I thought you were asking at first).
F# 不提供宏。此外,它不提供更高级的类型(这是我最初认为您要问的)。
F# does offer higher-order functions in that you can easily write a function that takes a function and returns a function. In fact, C# (or really any .NET language) can do this as the Func
delegate is part of the .NET framework.
F# 确实提供了高阶函数,因为您可以轻松编写接受函数并返回函数的函数。事实上,C#(或任何 .NET 语言)可以做到这一点,因为Func
委托是 .NET 框架的一部分。
回答by Kakadu
If We compare this three languages I'll recommend Haskell. It is more practical than LISP I think (because it's type system) and more powerful and clever than F#. As far as you know F# is a .NET port of OCaml and to some extent it is not ideoligally clear as Haskell is or as OCaml is. I'll recommend you study Haskell or OCaml to know how inconvinient F# is.
如果我们比较这三种语言,我会推荐 Haskell。我认为它比 LISP 更实用(因为它是类型系统)并且比 F# 更强大和更聪明。据您所知,F# 是 OCaml 的 .NET 端口,并且在某种程度上它不像 Haskell 或 OCaml 那样在意识形态上清晰。我建议您学习 Haskell 或 OCaml 以了解 F# 是多么不方便。