哪种语言更适合通用编程,F#或Haskell?

时间:2022-09-11 10:32:22

I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming general purpose applications?

我正在学习Haskell,您更喜欢编写通用应用程序的哪种语言(F#或Haskell)?

Which do you think is the stronger language?

您认为哪种语言更强大?

7 个解决方案

#1


19  

I'd go for Haskell. HackageDB is a great collection of libraries that are written specifically for the language. In the case of F# you'd have to use mostly libraries that are not written with a functional language in mind so they will not be as 'elegant' to use. But, of course it depends largely on how much functional programming you want to do and constraints of the project you want to use it for. Even 'general purpose' does not mean it should be used in all cases ;)

我会去Haskell。 HackageDB是一个很好的库集合,专门为该语言编写。在F#的情况下,你必须使用大多数没有用函数式语言编写的库,因此它们不会像使用那样“优雅”。但是,当然这在很大程度上取决于你想要做多少功能编程以及你想要用它的项目的约束。即使是“通用目的”也不意味着它应该在所有情况下使用;)

#2


25  

I prefer Haskell.

我更喜欢Haskell。

Jon Harrop's claim that Haskell has poor tools caused me to think a bit, since I quite disagree with this. I think that the issue here is partly one of development style. Let's compare a few tool-related characteristics of F# and GHC:

Jon Harrop声称Haskell工具很差,这让我有点思考,因为我对此非常不同意。我认为这里的问题部分是发展方式。让我们比较F#和GHC的一些与工具相关的特性:

  1. F# has extensive visual tools and GHC has none. For me, the lack of visual tools is irrelevant: I work with vi, a Unix command line, and a heavily custom build system. The lack of support for my style of development in F# would be very trying for me. On the other hand, if you prefer working under a Visual-Studio-type environment, you'd have quite the reverse opinion.

    F#拥有广泛的可视化工具,GHC没有。对我来说,缺乏可视化工具是无关紧要的:我使用vi,一个Unix命令行和一个高度自定义的构建系统。在F#中缺乏对我的开发风格的支持对我来说非常有用。另一方面,如果您更喜欢在Visual-Studio类型的环境下工作,那么您会有相反的观点。

  2. F# and/or .NET I understand has a very good debugger. GHC has only a limited debugger that runs in the interpreter. I've not used a debugger in years (much of this due to using test-driven development) and when you work mostly with pure functions, as in Haskell, a debugger is much less necessary. So for me, the lack of this tool is fairly irrelevant.

    我理解的F#和/或.NET有一个非常好的调试器。 GHC只有一个在解释器中运行的有限调试器。我多年没有使用过调试器(大部分原因是由于使用了测试驱动的开发),当你主要使用纯函数时,就像在Haskell中一样,调试器就不那么必要了。所以对我来说,缺少这个工具是相当无关紧要的。

  3. Libraries. This depends mostly on what libraries you need, doesn't it? Lots of good ones doesn't help if the one you need isn't there, and having lots of poorly-designed libraries may not be so helpful. Haskell certainly has fewer libraries than .NET, but it does have a reasonable selection, and the quality of the API design in many of them is very, very high.

    库。这主要取决于您需要的库,不是吗?如果你需要的那个不存在,许多好的没有帮助,并且拥有许多设计不良的库可能不那么有用。 Haskell当然拥有比.NET少的库,但它确实有合理的选择,并且其中许多API的设计质量非常非常高。

I don't know what F#'s interface into native code libraries is like, but GHC is great for this, due to the fantastic FFI. I wrote a Windows DDE server entirely in Haskell (yes—not a line of C, not even to deal with callbacks from Windows C libraries) and it took considerably less time and was considerably simpler than doing the same thing in C or C++. If you need native code interfaces, Haskell is certainly the better choice.

我不知道F#与本机代码库的接口是什么样的,但GHC非常适合这一点,因为它具有出色的FFI。我在Haskell中完全编写了一个Windows DDE服务器(是的 - 不是C行,甚至不处理来自Windows C库的回调),它花费的时间要少得多,并且比在C或C ++中做同样的事情要简单得多。如果您需要本机代码接口,Haskell肯定是更好的选择。

The "unpredictability" of memory usage and performance is a good point. Haskell seems to me actually reasonably predictable if you know what you're doing, but you won't know what you're doing when you start out, and you'll have a lot to learn. F# is much more similar to other .NET languages.

内存使用和性能的“不可预测性”是一个好点。如果你知道你在做什么,Haskell在我看来实际上是可以预测的,但是当你开始时你不会知道你在做什么,而且你将需要学习很多东西。 F#与其他.NET语言更相似。

Overall, this question probably comes down more to the platform than the language: the huge difference between the "Unixy world" of GHC generating native code and the "Windowsy world" of F# running on .NET is not a language issue.

总的来说,这个问题可能更多地归结为平台而不是语言:GHC生成本机代码的“Unixy世界”与运行在.NET上的F#“Windowsy世界”之间的巨大差异不是语言问题。

#3


9  

I'd say F#, as you can access the entire .Net framework. However, that's more of a library thing.

我会说F#,因为你可以访问整个.Net框架。然而,这更像是图书馆的事情。

#4


8  

It depends what you want to do:

这取决于你想做什么:

Haskell is the more purely functional language of the two.

Haskell是两者中更纯粹的功能语言。

F# is more of a hybrid language, and not purely functional, but has a great set of base class libraries that you can use to do modern things easily on Windows or Mono.

F#更像是一种混合语言,而不是纯粹的功能,但有一组很棒的基类库,你可以用它们在Windows或Mono上轻松地做现代事物。

#5


6  

I think Jon Harrop has a serious downer on Haskell for some reason. It's simply not true that it is not used outside of academia in fact it is widely used in investment banking and far more so than F# and OCaml are and for good reason. If you want a job functional programming then learn Haskell as there are far more posts advertised for Haskell programmers than F# or OCaml. I'm sure F# will gain popularity as it has Microsoft behind it and it is starting from zero but at the moment Haskell has a clear lead.

我认为Jon Harrop出于某种原因对Haskell严重打击。事实上,它并没有在学术界之外使用,因此它被广泛用于投资银行业务,远远超过F#和OCaml,并且有充分的理由。如果你想要一个工作函数式编程,那么学习Haskell,因为为Haskell程序员宣传的帖子远远多于F#或OCaml。我相信F#会受到欢迎,因为它支持微软,它从零开始,但目前Haskell有明显的领先优势。

Probably 2 or 3 years ago, OCaml led the field in practical functional languages but since then Haskell has overtaken it with more libraries, more features, better performance and wider commercial use.

大概2到3年前,OCaml在实用的功能语言领域处于领先地位,但从那以后,Haskell已经用更多的库,更多的功能,更好的性能和更广泛的商业用途取代了它。

#6


4  

You might find this blog post by Neil Mitchell informative:

你可能会发现Neil Mitchell的这篇博客文章内容丰富:

F# From a Haskell Perspective

F#来自Haskell的观点

The comments are also illuminating.

评论也很有启发性。

#7


2  

I'd say it depends on why you are learning it. If you are doing it for the experience of a pure functional language, go for Haskell. But if you are definitely going to use the language for more than that, F# is might be the better choice.

我会说这取决于你为什么学习它。如果你是为了体验纯粹的函数式语言,那就去Haskell吧。但是如果你肯定会使用这种语言,那么F#可能是更好的选择。

#1


19  

I'd go for Haskell. HackageDB is a great collection of libraries that are written specifically for the language. In the case of F# you'd have to use mostly libraries that are not written with a functional language in mind so they will not be as 'elegant' to use. But, of course it depends largely on how much functional programming you want to do and constraints of the project you want to use it for. Even 'general purpose' does not mean it should be used in all cases ;)

我会去Haskell。 HackageDB是一个很好的库集合,专门为该语言编写。在F#的情况下,你必须使用大多数没有用函数式语言编写的库,因此它们不会像使用那样“优雅”。但是,当然这在很大程度上取决于你想要做多少功能编程以及你想要用它的项目的约束。即使是“通用目的”也不意味着它应该在所有情况下使用;)

#2


25  

I prefer Haskell.

我更喜欢Haskell。

Jon Harrop's claim that Haskell has poor tools caused me to think a bit, since I quite disagree with this. I think that the issue here is partly one of development style. Let's compare a few tool-related characteristics of F# and GHC:

Jon Harrop声称Haskell工具很差,这让我有点思考,因为我对此非常不同意。我认为这里的问题部分是发展方式。让我们比较F#和GHC的一些与工具相关的特性:

  1. F# has extensive visual tools and GHC has none. For me, the lack of visual tools is irrelevant: I work with vi, a Unix command line, and a heavily custom build system. The lack of support for my style of development in F# would be very trying for me. On the other hand, if you prefer working under a Visual-Studio-type environment, you'd have quite the reverse opinion.

    F#拥有广泛的可视化工具,GHC没有。对我来说,缺乏可视化工具是无关紧要的:我使用vi,一个Unix命令行和一个高度自定义的构建系统。在F#中缺乏对我的开发风格的支持对我来说非常有用。另一方面,如果您更喜欢在Visual-Studio类型的环境下工作,那么您会有相反的观点。

  2. F# and/or .NET I understand has a very good debugger. GHC has only a limited debugger that runs in the interpreter. I've not used a debugger in years (much of this due to using test-driven development) and when you work mostly with pure functions, as in Haskell, a debugger is much less necessary. So for me, the lack of this tool is fairly irrelevant.

    我理解的F#和/或.NET有一个非常好的调试器。 GHC只有一个在解释器中运行的有限调试器。我多年没有使用过调试器(大部分原因是由于使用了测试驱动的开发),当你主要使用纯函数时,就像在Haskell中一样,调试器就不那么必要了。所以对我来说,缺少这个工具是相当无关紧要的。

  3. Libraries. This depends mostly on what libraries you need, doesn't it? Lots of good ones doesn't help if the one you need isn't there, and having lots of poorly-designed libraries may not be so helpful. Haskell certainly has fewer libraries than .NET, but it does have a reasonable selection, and the quality of the API design in many of them is very, very high.

    库。这主要取决于您需要的库,不是吗?如果你需要的那个不存在,许多好的没有帮助,并且拥有许多设计不良的库可能不那么有用。 Haskell当然拥有比.NET少的库,但它确实有合理的选择,并且其中许多API的设计质量非常非常高。

I don't know what F#'s interface into native code libraries is like, but GHC is great for this, due to the fantastic FFI. I wrote a Windows DDE server entirely in Haskell (yes—not a line of C, not even to deal with callbacks from Windows C libraries) and it took considerably less time and was considerably simpler than doing the same thing in C or C++. If you need native code interfaces, Haskell is certainly the better choice.

我不知道F#与本机代码库的接口是什么样的,但GHC非常适合这一点,因为它具有出色的FFI。我在Haskell中完全编写了一个Windows DDE服务器(是的 - 不是C行,甚至不处理来自Windows C库的回调),它花费的时间要少得多,并且比在C或C ++中做同样的事情要简单得多。如果您需要本机代码接口,Haskell肯定是更好的选择。

The "unpredictability" of memory usage and performance is a good point. Haskell seems to me actually reasonably predictable if you know what you're doing, but you won't know what you're doing when you start out, and you'll have a lot to learn. F# is much more similar to other .NET languages.

内存使用和性能的“不可预测性”是一个好点。如果你知道你在做什么,Haskell在我看来实际上是可以预测的,但是当你开始时你不会知道你在做什么,而且你将需要学习很多东西。 F#与其他.NET语言更相似。

Overall, this question probably comes down more to the platform than the language: the huge difference between the "Unixy world" of GHC generating native code and the "Windowsy world" of F# running on .NET is not a language issue.

总的来说,这个问题可能更多地归结为平台而不是语言:GHC生成本机代码的“Unixy世界”与运行在.NET上的F#“Windowsy世界”之间的巨大差异不是语言问题。

#3


9  

I'd say F#, as you can access the entire .Net framework. However, that's more of a library thing.

我会说F#,因为你可以访问整个.Net框架。然而,这更像是图书馆的事情。

#4


8  

It depends what you want to do:

这取决于你想做什么:

Haskell is the more purely functional language of the two.

Haskell是两者中更纯粹的功能语言。

F# is more of a hybrid language, and not purely functional, but has a great set of base class libraries that you can use to do modern things easily on Windows or Mono.

F#更像是一种混合语言,而不是纯粹的功能,但有一组很棒的基类库,你可以用它们在Windows或Mono上轻松地做现代事物。

#5


6  

I think Jon Harrop has a serious downer on Haskell for some reason. It's simply not true that it is not used outside of academia in fact it is widely used in investment banking and far more so than F# and OCaml are and for good reason. If you want a job functional programming then learn Haskell as there are far more posts advertised for Haskell programmers than F# or OCaml. I'm sure F# will gain popularity as it has Microsoft behind it and it is starting from zero but at the moment Haskell has a clear lead.

我认为Jon Harrop出于某种原因对Haskell严重打击。事实上,它并没有在学术界之外使用,因此它被广泛用于投资银行业务,远远超过F#和OCaml,并且有充分的理由。如果你想要一个工作函数式编程,那么学习Haskell,因为为Haskell程序员宣传的帖子远远多于F#或OCaml。我相信F#会受到欢迎,因为它支持微软,它从零开始,但目前Haskell有明显的领先优势。

Probably 2 or 3 years ago, OCaml led the field in practical functional languages but since then Haskell has overtaken it with more libraries, more features, better performance and wider commercial use.

大概2到3年前,OCaml在实用的功能语言领域处于领先地位,但从那以后,Haskell已经用更多的库,更多的功能,更好的性能和更广泛的商业用途取代了它。

#6


4  

You might find this blog post by Neil Mitchell informative:

你可能会发现Neil Mitchell的这篇博客文章内容丰富:

F# From a Haskell Perspective

F#来自Haskell的观点

The comments are also illuminating.

评论也很有启发性。

#7


2  

I'd say it depends on why you are learning it. If you are doing it for the experience of a pure functional language, go for Haskell. But if you are definitely going to use the language for more than that, F# is might be the better choice.

我会说这取决于你为什么学习它。如果你是为了体验纯粹的函数式语言,那就去Haskell吧。但是如果你肯定会使用这种语言,那么F#可能是更好的选择。