Haskell 编译器

发布于 2024-09-30 05:52:41 字数 119 浏览 4 评论 0原文

AFAIK GHC 是当今最常见的编译器,但我也看到其他一些编译器也可用。 GHC 真的是适合所有用途的最佳选择吗?或者我可以使用其他东西来代替吗?例如,我读到某些编译器(忘记了名字)在优化方面做得更好,但没有实现所有扩展。

AFAIK GHC is the most common compiler today, but I also see, that some other ompilers are available too. Is GHC really the best choice for all purposes or may I use something else instead? For instance, I read that some compiler (forgot the name) does better on optimizations, but doesn't implements all extensions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

请爱~陌生人 2024-10-07 05:52:41

GHC 是迄今为止使用最广泛的 Haskell 编译器,并且提供了最多的功能。不过,还有其他选择,有时比 GHC 有一些好处。这些是一些更流行的替代方案:

Hugs - Hugs 是一个解释器(我不认为它是一个解释器)包括一个编译器),它快速高效。它还以产生比 GHC 更容易理解的错误消息而闻名。

JHC - 整个程序编译器。 JHC 可以生成非常高效的代码,但它的功能还不完整(这可能就是您所想到的)。请注意,它并不总是比 GHC 快,只是有时如此。我没有太多使用 JHC,因为它没有实现我大量使用的多参数类型类。我听说源代码非常清晰易读,使其成为一个很好的编译器。 JHC 也更方便交叉编译,并且通常会生成更小的二进制文件。

UHC - Utrecht Haskell 编译器功能接近完整(我认为唯一缺少的是n+k 模式)适用于 Haskell98。它实现了许多 GHC 最流行的扩展以及一些原始扩展。根据文档,代码还不一定得到很好的优化。这也是一个很好的编译器。

简而言之,如果您想要高效的代码和尖端的功能,GHC 是您的最佳选择。如果您不需要 MPTC 或其他一些功能,JHC 值得尝试。 UHC 的扩展在某些情况下可能很引人注目,但我还不会指望它来实现快速代码。

GHC is by far the most widely used Haskell compiler, and it offers the most features. There are other options, though, which sometimes have some benefits over GHC. These are some of the more popular alternatives:

Hugs - Hugs is an interpreter (I don't think it includes a compiler) which is fast and efficient. It's also known for producing more easily understood error messages than GHC.

JHC - A whole-program compiler. JHC can produce very efficient code, but it's not feature-complete yet (this is probably what you're thinking of). Note that it's not always faster than GHC, only sometimes. I haven't used JHC much because it doesn't implement multi-parameter type classes, which I use heavily. I've heard that the source code is extremely clear and readable, making this a good compiler to hack on. JHC is also more convenient for cross-compiling and usually produces smaller binaries.

UHC - The Utrecht Haskell Compiler is near feature-complete (I think the only thing missing is n+k patterns) for Haskell98. It implements many of GHC's most popular extensions and some original extensions as well. According to the documentation code isn't necessarily well-optimized yet. This is also a good compiler to hack on.

In short, if you want efficient code and cutting-edge features, GHC is your best bet. JHC is worth trying if you don't need MPTC's or some other features. UHC's extensions may be compelling in some cases, but I wouldn't count on it for fast code yet.

冬天的雪花 2024-10-07 05:52:41
  1. Haskell 被非正式地定义为 GHC 处理的语言。
  2. GHC 是Haskell 平台的编译器。
  3. 尝试使用 GHC 优化代码可能比切换到另一个编译器更有效,因为您将学到一些优化技能。
  4. GHC 有许多非常有用的扩展。我只是不知道没有他们如何生活。

因此,对于任何严肃的事情(例如非学术、非实验、非易失性或使用许多包),务实的选择是使用 GHC。

  1. Haskell is informally defined as the language handled by GHC.
  2. GHC is the compiler of the Haskell platform.
  3. Trying to optimize your code with GHC may pay off more than switching to another compiler as you'll learn some optimization skills.
  4. There are many very useful extensions in GHC. I just can't see how to live without them.

So, for anything serious (e.g. non-academic, non-experimental, non-volatile or using many packages), the pragmatic choice is to go with GHC.

格子衫的從容 2024-10-07 05:52:41

我认为还值得一提nhc98。从主页上的简介:

nhc98体积小,易于安装,
符合标准的编译器
Haskell 98,惰性函数
编程语言。这是非常
便携式,旨在生产小型
少量运行的可执行文件
的记忆。它产生中快
代码,编译本身就很
快速地。它还配备了广泛的
自动工具支持
汇编、外语
接口、堆和时间分析,
跟踪和调试。

I think it's also worth mentioning nhc98. From the blurb on the homepage:

nhc98 is a small, easy to install,
standards-compliant compiler for
Haskell 98, the lazy functional
programming language. It is very
portable, and aims to produce small
executables that run in small amounts
of memory. It produces medium-fast
code, and compilation is itself quite
fast. It also comes with extensive
tool support for automatic
compilation, foreign language
interfacing, heap and time profiling,
tracing, and debugging.

や三分注定 2024-10-07 05:52:41

截至 2011 年,对于日常编程来说,除了 GHC 之外确实没有其他选择。 HP 团队强烈鼓励所有 Haskell 程序员使用 GHC。


如果你是一名研究人员,你可能会使用 UHC,如果你使用的是一个非常奇怪的系统,你可能只有 Hugs 或 nhc98 可用。如果你像我一样是一个复古迷,你仍然安装了 gofer、hbc 和 hbi:

$ hbi
Welcome to interactive Haskell98 version 0.9999.5c Pentium 2004 Jun 29!
Loading prelude... 1 values, 4 libraries, 200 types found.
Type "help;" to get help.
> help;
        HBI  -- Interactive Haskell B 1.3

hbi 很酷,因为 a) 它实现了 Haskell B,b) 它在命令行支持完整的语言:

> data L a = I | X a (L a) deriving Show;
data L b = I | X b (L b) deriving (Show)
> X 4 (X 3 I);
X 4 (X 3 I)

并且编译器生成漂亮的代码好代码,即使是 15 年后。

As of 2011, there's really no other choice than GHC for everyday programming. The HP team strongly encourages the use of GHC by all Haskell programmers.


If you're a researcher, you might use be using UHC, if you're on a very strange system, you might have only Hugs or nhc98 available. If you're a retro-fan like me, you still have gofer, hbc and hbi installed:

$ hbi
Welcome to interactive Haskell98 version 0.9999.5c Pentium 2004 Jun 29!
Loading prelude... 1 values, 4 libraries, 200 types found.
Type "help;" to get help.
> help;
        HBI  -- Interactive Haskell B 1.3

hbi is cool because a) it implements Haskell B, and b) it supports the full language at the command line:

> data L a = I | X a (L a) deriving Show;
data L b = I | X b (L b) deriving (Show)
> X 4 (X 3 I);
X 4 (X 3 I)

and the compiler produces pretty good code, even 15 years later.

×眷恋的温暖 2024-10-07 05:52:41

ghc 是一个可靠的编译器。说它是所有目的的最佳选择是非常有力的。寻找这样的工具是徒劳的。

使用它,如果您确实需要其他东西,那么到那时您可能会知道它是什么。

ghc is a solid compiler. saying it is the best choice for all purposes is a very strong one. and looking for such a tool is futile.

Use it, and if you really require something else then by that point you'll probably know what it is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文