3 ms·
1. Lua is designed to be embedded, it is much easier than trying to embed Ruby or Python into a web server. 2. It is a way off an app as it runs in the same pro
by justincormack 14y ago
1. Lua is designed to be embedded, it is much easier than trying to embed Ruby or Python into a web server.
2. It is a way off an app as it runs in the same process as the web server.
3. Lua is very small and very fast, so it is fine to use it just for doing tiny things like reading cookies, there is no real overhead (most people use LuaJIT so it is compiled anyway). Remember that the point of many of these examples is to offload from Ruby as it is too slow...
Also, Lua is a very nice language, easy to learn (there is not much of it), and most of the functionality exposed is simply the built in functionality of nginx (async http), plus some libraries, so having the libraries that come with other languages is not that useful as you can't use anything blocking (like with Node) inside Nginx.
- slurgfest 14y agoI don't question that Lua is a nice language, but it seems to be repeatedly implied in this thread that it is not possible to do this with other languages, although there doesn't appear to be any evidence for that. Embedding Python in a web server is quite doable and has nothing to do with having libraries available. I'm really not seeing why everyone should switch to Lua for these tasks. That is quite different from saying that people who like Lua shouldn't use it.
- justincormack 14y agoThe libraries thing is just you dont need the libraries, which are the main advantage. Python is a 3MB binary, while Lua is 175k, for a start. This is for Nginx which is 960k. Embedding something three times the size of the host is not really an embed... Lua is embedded in all sorts of stuff, Nginx, Apache, Redis in web space for example. Python is a great language, but just not a good choice for that. But feel free to give a Python embed a go.