Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 393
Shahbaz Avatar asked Jun 06 '10 18:06

Shahbaz


4 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.

like image 158
Clement J. Avatar answered Nov 19 '22 20:11

Clement J.


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

like image 30
Shahbaz Avatar answered Nov 19 '22 21:11

Shahbaz


See lualibevent and lua-ev and also Lua Gem #27

like image 10
Doug Currie Avatar answered Nov 19 '22 21:11

Doug Currie


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.

like image 6
polypus74 Avatar answered Nov 19 '22 21:11

polypus74