可以 C++简化 Lua VM 实现?

发布于 2024-09-01 11:35:03 字数 47 浏览 1 评论 0原文

对于那些浏览过 Lua C VM 实现的人来说,使用 C++ 会显着简化实现吗?

For those that have glanced through the Lua C VM implementation, would the use of C++ significantly simplify the implementation?

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

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

发布评论

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

评论(3

忘东忘西忘不掉你 2024-09-08 11:35:03

多年来,天才级工程师为该虚拟机付出了心血,使其尽可能简单,同时保持极高的可移植性(任何 ANSI C 编译器)和高性能(看看脚本语言的任何比较衡量标准)。除了这种努力之外,我看不出 C++ 还能如何简化任何事情。事实上,对于 C++,我担心该语言模糊重要的属性,例如成本模型。

For years, genius-level engineers have sweated blood over that VM to make it as simple as possible while remaining extremely portable (any ANSI C compiler) and highly performant (look at any comparative measure of scripting languages). Next to that kind of effort, I don't see how C++ can simplify anything. In fact, with C++ I'd worry about the language obscuring important properties like the cost model.

三人与歌 2024-09-08 11:35:03

Lua 旨在成为一种嵌入式语言。因此,VM 的“实现”分为两个不同的部分:VM 源代码的创建以及将该代码集成到要部署的工件中。我怀疑你的问题是为了集中在第一部分。太糟糕了。第二部分,即集成,会发生很多次,并且通常在 C 中比在 C++ 中容易得多。

Lua is intended to be an embedded language. So the "implementation" of the VM comes in two distinct pieces: the creation of the VM source code, and the integration of that code in the artifact to be deployed. I suspect your question is intended to focus on the first part. Too bad. The second part, the integration, happens many times over, and is generally much easier in C than in C++.

记忆里有你的影子 2024-09-08 11:35:03

C 能做的任何事情,C++ 都能做得更好。我一直认为 Lua 源代码非常难以阅读 - 在 64 位上给出了一些警告,尽管看起来还不错。

问题在于,整个用户数据的事情,对于暴露新类型来说确实不太好。我会考虑重新设计而不是重新实现。

Anything C can do, C++ can do better. I always thought that the Lua source was pretty damn hard to read - gave some warnings on 64bit, although it seemed to be OK.

The trouble is that the whole userdata thing, it's really not very good for exposing new types to. I'd look at a redesign rather than a reimplementation.

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