打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Node.js for 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

asked Jun 6 '10 at 18:36
Shahbaz
2,26552540

add comment

8 Answers

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.

answered Dec 11 '11 at 11:27
Clement J.
2,452820

add comment

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

answered Jan 18 '11 at 21:57
Shahbaz
2,26552540

add comment

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.

answered Sep 7 '12 at 20:37
JohnnySoftware
1,434912

add comment

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.

answered Oct 31 '12 at 23:00
polypus74
1645

add comment

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.

answered Dec 28 '10 at 9:20
Neopallium
1,01959

add comment

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

answered Aug 27 '11 at 17:39
erbo
662

add comment

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Lua、Luajit、Python、Node.js和Java性能测试对比
Node.js技术架构
Node.js 入门你需要知道的 10 个问题
Nodejs的运行原理
【精品博文】树莓派安装最新的nodejs
CentOS7下安装Nodejs
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服