Lua 是游戏服务器的最佳/最快选择吗?

发布于 2024-08-08 06:26:12 字数 599 浏览 8 评论 0原文

我正在开发一个项目,我希望用户能够尽可能地修改和自定义。

开源可能是一个不错的选择,但并不是因为我想保持一些内部类关闭。

我想到的另外两个选项是作为外部库的插件和 Lua脚本编写。

库(DLL)的问题在于,跨平台兼容性是必须具备的,因为它是某种游戏服务器,主要设计用于专用服务器(通常是 Linux),但许多人也会在自己的服务器上使用它。本地计算机(主要是 Windows)。

由于它是一个游戏服务器应用程序,应该能够处理大量连接,并且与游戏性能相关的操作非常重要,因此我对 Lua 脚本存有疑问。

我的怀疑是否合理,或者 Lua 是否是一个好的解决方案? 对于我的担忧,您还能想到更好/其他的选择吗?

总结一下重要的方面:

  • 跨平台兼容性
  • 良好的性能(->在线游戏)
  • 插件/脚本,任何人都可以创建,只要他/她了解语言,可以是Lua,C或任何
  • 选项闭源插件/脚本(不是那么重要,但很好:)

I am working on a project where I want users to be able to modify and customize as much as possible.

Open source might be a good choice but not due to the fact that I want to keep a few internal classes closed.

Two other options that I thought about were plug-ins as external libraries and Lua scripting.

The problem with libraries (DLLs) are that cross-platform compatibility is a must-have because it is some kind of a game server and it is mainly designed for use on dedicated servers (often Linux) yet many people will also use it on their local machine (mostly Windows).

Due to the fact that it's a game server application that should be able to handle lots of connections and actions related to the game performance is very important so I have doubts with Lua scripts.

Are my doubts reasonable or would Lua be a good solution?
Also can you think of any better / other option for my concern?

To sum up the important aspects:

  • cross-platform compatibility
  • good performance (-> online game)
  • plug-ins / scripts that anyone can create as long as he/she knows about the language, may it be Lua, C or whatever
  • option for closed source plug-ins / scripts (not so important, but would be fine :)

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

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

发布评论

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

评论(3

ㄟ。诗瑗 2024-08-15 06:26:12

恐怕唯一能回答 Lua 是否足够快的人就是……你。我们不知道您到底在做什么以及如何实施它。我的建议是制作原型并进行测量。用 Lua 和 C/C++ 编写系统的一个小但相关的部分,测量两者的性能并确定 Lua 是否足够快。以《魔兽世界》为例,Lua 对于游戏的客户端/UI 部分来说似乎足够快,但我不能对服务器说任何话。但无论如何,我怀疑是否有比 Lua 更快、更容易嵌入的语言(免责声明:我自己没有测量过 Lua 的性能,尤其是没有针对其他类似的语言进行测试,所以对此持保留态度)

您提到 DLL 不跨平台,所以仅供参考:如果您想将 DLL 用于插件并动态加载它们,Linux 上也存在相同的功能。 “DLL”被称为“共享库”或“共享对象”,通常以 .so 为扩展名。而不是 Windows LoadLibrary,< a href="http://msdn.microsoft.com/en-us/library/ms683212%28VS.85%29.aspx" rel="nofollow noreferrer">GetProcAddress 和 FreeLibrary,有 dlopendlsymdlclose。

I'm afraid the only one who can answer if Lua will be fast enough for you is... you. We have no idea what exactly are you doing and how are you implementing it. My suggestion is to prototype and measure. Write a small, but relevant, part of your system in both Lua and C/C++, measure the performance of both and decide if Lua is fast enough. Having WoW as a case study, Lua seems to be fast enough for the client/UI part of the game, but I cannot say anything about the server. But anyway, I doubt there's language out there that's faster and easily embeddable compared to Lua (disclaimer: I haven't measured Lua performance myself, especially not against other similar languages, so take this with a grain of salt)

You mention something about DLLs not being cross-platform, so just FYI: if you want to use DLLs for plugins and load them dynamically, the same functionality exists on Linux. The "DLLs" are called "shared libraries" or "shared objects" and usually go by the extension of .so. And instead of the windows LoadLibrary, GetProcAddress and FreeLibrary, there are dlopen, dlsym and dlclose.

清醇 2024-08-15 06:26:12

没有什么可以阻止您为应用程序中的不同模块提供不同的许可,显然这排除了使用 GPL 3,因为这将立即涵盖所有内容。

There's nothing to stop you providing different licensing for the different modules in your application, obviously that precludes using GPL 3 as that would immediately cover everything.

久光 2024-08-15 06:26:12

你有没有想过AngelScript?我对它也不太了解,但它似乎有类似 C++ 的语法,并且非常灵活且非常跨平台。

Have you ever thought of AngelScript? I don't know much about it either but it seems to have a C++ like syntax and is pretty flexible and extremely cross-platform.

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