32 comments

[ 1.8 ms ] story [ 81.0 ms ] thread
Lua is amazing. I've used it to reimplement an API served by Python and it was consistently twice as fast i.e. half the time to serve a request compared to the Python framework in basically the same code.
What did you use as the web server / process manager? Was it embedded lua in nginx (maybe lapis as the web framework?) or otherwise? Please share more.
turbo is a tornado clone on lua and lapis is awesome too, turbo is a stand-alone server, lapis runs inside openresty the nginx + lua server.
If you're looking for a fun hobby project, you might check out this project, which is a Lua-based web server. It includes a graphical Lua debugger with a browser-based UI, powered by the Lua-based web server.

http://github.com/bhk/tooltree

See 'documentation' -> 'monoglot' -> 'Introduction'

Yes. It uses lapis. Running on top of nginx so huge configurability for all sorts of things.
As anyone experience with adding new types to Lua ? I mean, in a fundamental type, not just simulating them with regular Lua features. For example, adding a 128 bit float number ?
Or you know, just use Lua.
Unless you have a job where you can choose your own tech stack or are otherwise self-employed are there really non-game development jobs that use Lua? I like the language and have used it for scripting games before but have never seen a single job posting for that skill set. I even have it on my resume and I'm fairly certain no one has ever noticed.
I don't know man... lua is everywhere!, systems/infrastructure, machine learning, voip, games, microwaves...
Where in systems/infrastructure are you seeing Lua used?
nginx, haproxy, redis all support lua scripting to name a few.
You may be missing the point

A lot of things have lua bindings and a lua interface. But once you stop being your own boss, your control over which interfaces and bindings to use shrinks drastically.

I believe the question was more: What fields/industries are actually USING the lua interface by default? Where would being able to say "I am very experienced with lua scripting" be a particularly strong asset.

Any place that uses OpenResty (https://openresty.org/en/) is bound to use Lua not just as scripting aid but as a language to actually build applications. Cloudflare is famously using it, along with I believe Taobao who first supported its development.
>"Any place that uses OpenResty (https://openresty.org/en/) is bound to use Lua not just as scripting aid but as a language to actually build applications."

This is not true at all. Where I work we use OpenResty in places for a WAF but we don't touch Lua for anything else. You don't need to know much Lua for this.

Using something as an embedded language is a little different than building standalone systems/infrastructure projects with something.

Yes this was more my question.
Lua is a small general tool used in bunch of fields and industries, the question about who does what by default tell us nothing.

I agree that in any organization if the choice of use a tool is not in your hands you are forced to use something else well, that don't have anything to relate with lua or with any other programming language.

That's a people problem you accepted when hired, but can move to other happy place that used lua or python, or ... etc (=

I worked with the Chicago office of a large trading software company that used Lua. It was part of the initial tech stack because the CTO (they were a start up that got acquired) played World of Warcraft. Now they still use it. Only time I ever ran into in an industry I wasnt expecting though.
You'd think that if there is a job where you can do silly things like embed Lua in Python, you can just use Lua on that particular job.
I suspect that this is not using stock Lua, but LuaJIT instead. Stock Lua wouldn't be much different than Python itself.

The real gains come from Mike Pall's amazing JIT implementation, not the language itself.

>Stock Lua wouldn't be much different than Python itself.

Stock Lua is also much faster than Python.

But LuaJIT is (usually) much faster than the standard Lua interpreter.
"Lupa is a very fast and thin wrapper around Lua or LuaJIT."

"It complements Python very well. Lua is a language as dynamic as Python, but LuaJIT compiles it to very fast machine code, sometimes faster than many statically compiled languages for computational code. The language runtime is very small and carefully designed for embedding. The complete binary module of Lupa, including a statically linked LuaJIT2 runtime, only weighs some 700KB on a 64 bit machine. With standard Lua 5.1, it’s less than 400KB."

https://pypi.python.org/pypi/lupa

Which leads to the question why there is no proper JIT implementation of Python. It's so widely used that you would expect someone coming up with one eventually. Or are language features so different that they don't allow an implementation similar to LuaJIT or Julia?
Python is much more complex than Lua. In fact, one of Lua's greatest features is it's extreme and elegant simplicity.

I believe it is a lot harder to make a Python jitter. And it would never be as fast as a Lua jitter.

There is a JIT for python: http://pypy.org/
And although the article doesn't state that PyPy is a JIT, it's one of the implementations that the author tries to obtain a speedup.
CPython 3.6 has a frame evaluation api, specifically for JIT integration

Pyston is the only CPython JIT currently however

Lua is indeed a pretty nice language for some use-cases and it's nice to see this example. It would also be great to see a comparison to Numba which is a Python JIT particularly suited for fast numerical computing with Python: http://numba.pydata.org

Numba provides speed-ups over NumPy and Python and does so in way very easy for Python programmers to use with decorators on Python functions. Numba can be used to easily build new "ufuncs" which are NumPy's universal functions and it has multiple interfaces for programming the GPU directly from Python for even higher performance.