开发者

Has anyone used Lua to build a web application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_Go百科

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

I come from a Java and PHP background to build web applications.

Has anyone used Lua before to build a web applications?

Question: If so, what are the pro's & con's of using Lua versus PHP or Java for a web application? (e.g. web server support, performance, code maintenance, etc).


As others mentioned Lua is "do it yourself" kind of environment. Also it is very fast and quite memory efficient compared to Perl/PHP/Python/Ruby especially if you are using LuaJIT. And it is very easy to integrate with C/C++ code. Usually these points are irrelevant for a typical web application where performance is usually restricted by database. Also where you don't really care about C/C++ integration and where you don't really want to do things yourself but rather you want to build on top of existing frameworks. For this reason I don't think Lua is a good fit for a typical web applications. At the same time there are some niche applications where Lua shines. For example our company specializes at building high performance HTTP servers used for adserving. So what we are using is our own HTTP server written from scratch in C++ which integrates Lua as a scripting language for our business logic. This allows us to do customization of the business logic in Lua quickly compared to what we had to do if it was pure C++. At the same time we always have an option to do performance critical parts in C++. If we were using any other scripting language we are positive it would be slower, it would use more memory and generally would be harder to integrate with C++ code. At the same time we don't really care much about loss of extensive library support were we using other scripting languages as the domain we are working in is quite specialized so usually those libraries are irrelevant for it anyway.


I am using Lua right now to build a web application! Whatever happened to software developers that "do it yourself" got a bad name - too lazy, weaned on bloated megabytes of support libraries, or what? In reality, as others have pointed out, there is decent support, just not on the scale of Python, say. Lua is by far the fastest scripting language (especially with www.luajit.org around), and much, much cleaner as a language design than any other in its league out there. This is vital for long-term maintenance.

For those using lighttpd as their webserver (me included), the added bonus is that the full power of Lua is available for mod_magnet scripts, useful for synchronous request handling/rewriting-on-steroids.


I have programmed a few websites with Lua. The first one was a raid planner for my World of Warcraft guild (that's often how you start programming in Lua...). I used mod_lua with an alpha version of Apache 2.4 for that. Two others were small contests sites for customers, developed with WSAPI, Nginx, Spawn-fcgi and Orbit. This setup is damn fast, faster than mod_lua and anything else I have seen. The pages would display instantly as if they were in cache ! The experience was very pleasant and Lua makes you quickly productive. But you better be well organized. Lua is missing a lot of batteries when it comes to web development, so you often have to implement your own and it can become messy. So I suggest you plan what you will need before you start. I used my own Lua "ORM" with MySQL and a forked version of Lua Pages for the templates. Have a look here if you want to give Lua+Wsapi+Nginx a try : http://mascarenhas.github.com/2009/10/24/wsapi-nginx-fcgi.html I think it is the best setup.


There are quite a few projects using Lua for web development.

For example, Nanoki, an HTTP and wiki engine developed in pure Lua.

Or Sputnik, which is build on top of Kepler.

That said, Lua is very much a, hmmm, "do it yourself" kind of environment.


Pros: fast, small, elegant, easy to make your own binding to a C library.

Cons: sometimes you have to write your own libraries for things you would get for free in Python.

http://luanova.org/ has a number of good posts on web development in Lua.


We use lua with great success for our backend implementation. You can also have a look at JUCI webgui for embedded devices. It uses lua for backend implementation. You can have a look at how code interacts with lua/C backend: https://github.com/mkschreder/juci

Note however that this backend is a pure jsonrpc backend so it does not create any html like php or cgi pages. Lua is perfect if all you do is handle and respond to json requests. You can also have main application in php and use lua to write the application on the backend. Or main application completely in javascript.

I think that if you are going to use lua in places where you want to generate html then you will find it lacking many features, but if you limit it to purely functional backend implementation then you will find that it works very well.


lighttpd and mod_magnet are really great platform, but I recommend that you first take a look at Kepler Project. It's a quite great beginning.

You can take your PHP/Java background useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜