Node.js 用于 lua?

发布于 2024-09-04 20:50:01 字数 297 浏览 10 评论 0原文

过去几天我一直在玩node.js(nodejs),它太棒了。据我所知,lua 没有类似的 libev 和 libio 集成,这让我们可以避免几乎任何阻塞调用并以异步方式与网络和文件系统交互。

我正在慢慢地将我的java实现移植到nodejs,但令我震惊的是luajit比v8 JavaScript快得多并且使用的内存少得多!

我想象在这样的环境中编写我的服务器(非常快速且响应迅速,内存使用量非常低,非常具有表现力)将极大地改善我的项目。

作为lua新手,我只是不确定这样的事情是否存在。我将不胜感激任何指点。

谢谢

I've been playing around with node.js (nodejs) for the past few day and it is fantastic. As far as I can tell, lua doesn't have a similar integration of libev and libio which let's one avoid almost any blocking calls and interact with the network and the filesystem in an asynchronous manner.

I'm slowly porting my java implementation to nodejs, but I'm shocked that luajit is much faster than v8 JavaScript AND uses far less memory!

I imagine writing my server in such an environment (very fast and responsive, very low memory usage, very expressive) will improve my project immensly.

Being new to lua, I'm just not sure if such a thing exists. I'll appreciate any pointers.

Thanks

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

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

发布评论

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

评论(9

Saygoodbye 2024-09-11 20:50:01

最近对应的一个项目是 Luvit "(Lua + libUV + jIT = pure Awesomesauce )”。

来自 公告

这基本上是 luajit2 + libuv (背后的事件循环库
节点)。它像 Nodejs 一样编译为单个可执行文件,并且可以
运行 .lua 文件。它与库存 luajit 有何不同
发行版是它添加了几个内置模块和一些
语义略有不同。

请注意,我们没有作为 apache 或其他任何东西的 CGI 脚本运行
像那样。 lua 脚本 http 服务器。你得到你的
每次向服务器发出 http 请求时都会调用回调。

A recent corresponding project is Luvit "(Lua + libUV + jIT = pure awesomesauce)".

From the announcement:

this is basically luajit2 + libuv (the event loop library behind
nodejs). It compiles as a single executable just like nodejs and can
run .lua files. What makes it different from the stock luajit
distribution is it has several built-in modules added and some
slightly different semantics.

Notice that we're not running as a CGI script to apache or anything
like that. The lua script is the http server. You get your
callback called every time an http request is made to the server.

放肆 2024-09-11 20:50:01

看起来以下正是我正在寻找的内容:
LuaNode https://github.com/ignacio/LuaNode

Looks like the following is exactly what I was looking for:
LuaNode https://github.com/ignacio/LuaNode

梦明 2024-09-11 20:50:01

您还可以查看 luv:

https://github.com/richardhundt/luv

来自 lua 邮件列表的


<块引用>

luv 与 Luvit - LuaJIT + libuv (Node.js:s/JavaScript/Lua/) 有何关系?

事实并非如此。 Luvit 大量借鉴了 Node.js 的架构
(反应器回调等),静态链接到 luajit,提供
它有自己的模块系统和可执行文件。 Luv只是一个Lua模块
绑定到 libuv。关键的区别是 Luv 更像是一个 mn
线程引擎结合了协程和操作系统线程,同时使用
libuv 事件循环的底层。

因此,除了它们都绑定到 libuv 之外,它们没有
有很多共同点。

You might also have a look at luv:

https://github.com/richardhundt/luv

from the lua mailing list:

How does luv relate to Luvit - LuaJIT + libuv (Node.js:s/JavaScript/Lua/)?

It doesn't really. Luvit borrows heavily from node.js's architecture
(reactor callbacks, etc.), links statically against luajit, provides
it's own module system and executable. Luv is just a Lua module which
binds to libuv. The key difference is that Luv is more like an m-n
threading engine combining coroutines and OS threads while using the
libuv event loop under the hood.

So other than the fact that they both bind to libuv, they don't have
much in common.

凶凌 2024-09-11 20:50:01

您可能想看看 Luvit 或浏览 Lua Github 站点。我认为它采用了在 Lua 内部实现 Node.js 功能的方法。您可以在客户端和服务器端编写 Lua 代码。以下是 Luvit 在 Lua 中执行 Node.js 功能的方法的描述。

You might want to take a look at Luvit or a gander at the Lua Github site. I think it takes the approach of implementing Node.js functionality right inside Lua. You write Lua code on the client side and on the server side. Here is a description of Luvit approach to doing Node.js functionality in Lua.

尹雨沫 2024-09-11 20:50:01

如果我理解问题正确,请查看 http://openresty.com/

if i understood the question right, take a look at http://openresty.com/

岁月如刀 2024-09-11 20:50:01

luvit 的目标就是 Lua 之于 Node.js 之于 Javascript。绝对是一个有前途的项目。

luvit aims to be to Lua exactly what Node.js is to Javascript. Definitely a promising project.

鱼窥荷 2024-09-11 20:50:01

你可以通过lua-handlers获得node.js风格的非阻塞IO。

它甚至有一个异步。 HTTP 客户端,这使得启动并行 HTTP 请求变得非常容易。请参阅 test_http_client.lua 文件作为 HTTP 客户端接口的示例。

You can get node.js style non-blocking IO with lua-handlers.

It even has an async. HTTP Client, which makes it really easy to start parallel HTTP requests. See the test_http_client.lua file as a example of the HTTP client interface.

桃气十足 2024-09-11 20:50:01

您还应该检查一下青金石。它是 OpenResty 的一个非常轻量且快速的框架: http://leafo.net/lapis/

我真的很享受它并预测它会有一个光明的未来!

正如您对利用 OpenResty 构建的任何东西所期望的那样,它的基准测试非常好:https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=query

Lapis 的作者还为 Lua 编写了一种类似 CoffeeScript 的语言,称为 MoonScript这非常好:
http://moonscript.org/

You should also check out Lapis. It's a very lightweight and fast framework for OpenResty: http://leafo.net/lapis/

I've really been enjoying it and predict it will have a bright future!

As you would expect with anything built to leverage OpenResty, it's benchmarks are insanely good: https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=query

The author of Lapis also wrote a CoffeeScript-like language for Lua called MoonScript which is quite nice:
http://moonscript.org/

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