Node.js for lua?

倖福魔咒の 提交于 2019-12-02 15:33:12

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

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.

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

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.

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.

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

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

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.

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!