1

Recently I learned Lua, we need it to co-work with existed C code(HTTP server).

From Lua books, we know that there maybe to way to make them co-working:

  • From Lua, you can wrap C code in share library(xxx.so) that Lua use require to import them.
  • From C, you can use existed Lua API to operate on lua_state, it's some trick but it works well.

I adopt both of them and everything seems great, by using Lua we can save a lot of time to implement our business logic. But I'm quite nervous about current architecture, although there was no serious problem in it, I always worried about it, if there was some thing happened, for example, serious performance bottleneck, memory related and so on.

Is anyone got rich experience in this, please give some some advice. Thanks.

4

1 回答 1

2

Lua 旨在与 C 和 C++ 一起工作。C API 就是为此而生的。

你不需要创建和使用共享库来扩展 Lua。这是扩展标准命令行解释器的最简单方法,但在您自己的应用程序中链接 Lua 的静态 C 库应该很容易(如果不是更容易的话)。

如果您想查看一些 Lua 的 C 库示例,请参阅的 . 还有很多其他的。

于 2013-05-28T02:38:28.020 回答