鹦鹉到底是什么?

发布于 2024-07-06 02:01:08 字数 150 浏览 23 评论 0 原文

我知道 Parrot 是一个虚拟机,但我觉得我并没有完全理解它背后的想法。

据我了解,它是一个用于处理多种语言的虚拟机。 它是否正确?

使用虚拟机而不是解释器有什么优点?

Parrot 具体做了什么事情,让它变得如此重要?

I understand that Parrot is a virtual machine, but I feel like I'm not completely grasping the idea behind it.

As I understand, it's a virtual machine that's being made to handle multiple languages. Is this correct?

What are the advantages of using a virtual machine instead of just an interpreter?

What specifically is Parrot doing that makes it such a big deal?

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

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

发布评论

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

评论(7

韵柒 2024-07-13 02:01:08

Chris 介绍了面向用户的差异,所以我将介绍另一面。

Parrot 是基于寄存器的而不是基于堆栈的。 这意味着编译器开发人员可以更轻松地优化为给定代码段分配寄存器的方式。 此外,从理论上讲,从 Parrot 字节码到机器代码的编译可以比基于堆栈的代码更快,因为我们运行基于寄存器的系统,并且有更多的优化经验。

Chris covered the user-facing differences, so I'll cover the other side.

Parrot is register-based rather than stack-based. What that means is that compiler developers can more easily optimize the way in which the registers should be allocated for a given piece of code. In addition, the compilation from Parrot bytecode to machine code can, in theory, be faster than stack-based code since we run register-based systems and have a lot more experience optimizing for them.

淡笑忘祈一世凡恋 2024-07-13 02:01:08

Parrot 是一个专门设计用于处理多种语言,尤其是动态语言的虚拟机。 尽管涉及一些有趣的技术,但由于它可以处理不止一种语言,因此它将能够跨越语言界限。 例如,一旦它可以编译 Ruby、Perl 和 Python,就应该很容易跨越这些界限,让我可以使用 Python 中的 Ruby 库、Python 中的 Perl 库,所以无论我喜欢什么组合。

Parrot 始于 Perl 世界,许多从事该工作的人员都是经验丰富的 Perl 人员。 Parrot 没有使用当前已经过时的 Perl 解释器,而是允许 Perl 拥有诸如可分发的预编译模块(其他人已经拥有很长时间)和更智能的垃圾收集器等功能。

Parrot is a virtual machine specifically designed to handle several languages, especially the dynamic languages. Despite some of the interesting technology involved, since it can handle more than one language, it will be able to cross language boundaries. For instance, once it can compile Ruby, Perl, and Python, it should be easy to cross those boundaries to let me use a Ruby library in Python, a Perl library from Python, so whatever combination that I like.

Parrot started in the Perl world and many of the people working on it are experienced Perl people. Instead of using the current Perl interpreter, which is showing its age, Parrot allows Perl to have features such as distributable pre-compiled modules (which everyone else has had for a long time) and a smarter garbage collector.

梦在夏天 2024-07-13 02:01:08

其他人已经给出了很好的答案,所以我剩下的就是解释“动态”语言的实际含义。

在虚拟机的上下文中,这意味着变量的类型在编译时未知。 在“静态”语言中,类型(或至少其父类)在编译时是已知的,并且许多优化都建立在该知识的基础上。

另一方面,在动态语言中,您可能知道变量是否保存容器类型(如数组)或标量(字符串、数字……),但在编译时您拥有的类型信息要少得多。

另一个特点是动态语言通常使类型转换变得更加容易,例如在 perl 和 javascript 中,如果您使用字符串作为数字,它会自动转换为数字。

Parrot 旨在使此类操作变得简单快速,并允许在编译时不知道类型信息的情况下进行优化。

Others have given excellent answers, so what remains for me is to explain what "dynamic" languages actually mean.

In the context of a virtual machine it means that the type of a variable is not known at compile time. In "static" languages the type (or at least a parent class of it) is known at compile time, and many optimizations build on that knowledge.

On the other hand in dynamic languages you might know if a variable holds a container type (like an array) or a scalar (string, number, ...), but you have much less type information at compile time.

Another characteristic is that dynamic languages usually make type conversions much easier, for example in perl and javascript if you use a string as a number, it is automatically converted to a number.

Parrot is designed to make such operations easy and fast, and to allow optimizations without knowing having type informations at compile time.

放飞的风筝 2024-07-13 02:01:08

Parrot 是一个字节码解释器(可能在未来阶段带有 JIT)。 想想 Java 及其虚拟机,只不过 Java(目前)更适合静态语言,而 Parrot 从一开始就适合动态语言。

另请参阅科迪的出色回答! 强烈推荐。

Parrot is a bytecode interpreter (possibly with a JIT at a future stage). Think Java and its virtual machine, except that Java is (at the moment) more geared towards static languages, and Parrot is geared towards dynamic languages from the beginning.

Also see Cody's excellent answer! Highly recommended.

染柒℉ 2024-07-13 02:01:08

这是官方 Parrot Wiki

您可以在那里找到很多信息和链接。

Parrot wiki 主页的底部还显示来自 Planet Parrot feed 聚合器的最新标题。

除了 VM 之外,Parrot 项目正在构建一个非常强大的工具链,以便更轻松地移植现有语言或开发新语言。

Parrot VM 还将为许多强大的新 Perl 6 功能提供其他语言的底层支持(请参阅 官方 Perl 6 Wiki 了解更多 Perl 6 信息)。

Parrot 将提供不同语言模块之间的互操作性,例如,其他语言可以利用 CPAN 的庞大 Perl 6 版本(庞大的 Perl 5 模块档案,Perl 6 将能够通过即将推出的 Perl 5 模块档案来访问)。 Perl 5.12)。

Here is The Official Parrot Wiki.

You can find lots of info and links there.

The bottom of the Parrot wiki home page also displays the latest headlines from the Planet Parrot feed aggregator.

In addition to the VM, the Parrot project is building a very powerful tool chain to make it easier to port existing languages, or develop new one.

The Parrot VM will also provide other languages under-the-covers support for many powerful new Perl 6 features (please see the Official Perl 6 Wiki for more Perl 6 info).

Parrot will provide interoperability between modules of differing languages, so that for example, other languages can take advantage of what will become the huge Perl 6 version of CPAN (the vast Perl 5 module archive, which Perl 6 will be able to access via the forthcoming Perl 5.12).

孤蝉 2024-07-13 02:01:08
  • Parrot 将成为 java 的目标但从未实现——所有人的虚拟机
    操作系统和平台
  • Parrot 将实现任何动态语言和真正跨平台的 Microsoft 公共语言运行时背后的想法
  • 最重要的是 Parrot 是并且将是免费的开源
  • Parrot 将成为动态语言开源编程的事实上的标准
  • Parrot will be what java aimed for but never achieved - a vm for all
    OS's and platforms
  • Parrot will implement the ideas behind the Microsoft's Common Language Runtime for any dynamic language and truly cross-platform
  • On top of everything Parrot is and will be free and open source
  • Parrot will become the de facto standard for open source programming with dynamic languages
冷情 2024-07-13 02:01:08

老实说,我不知道这是一件大事。 它已经取得了很大的进步,但还没有看到太多用处。 主要目标语言尚未真正到来,并且已经在行业专业人士中失去了巨大的关注度。 与此同时,.Net 等其他解决方案和 Jython 等项目向我们表明,此时此地可以击败任何感知到的炒作。

Honestly, I didn't know it was that big of a deal. It has come a long way, but just isn't seeing much use. The main target language has yet to really arrive, and has lost a huge mind-share among the industry professionals. Meanwhile, other solutions like .Net and projects like Jython show us that the here-and-now can beat out any perceived hype.

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