
Lua as a Python’s secret weapon - ceyhunkazel
http://alexeyvishnevsky.com/?p=248
======
travisoliphant
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](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.

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

~~~
synchrone
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.

~~~
bhk
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](http://github.com/bhk/tooltree)

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

------
andrewmcwatters
Or you know, just use Lua.

~~~
crystalPalace
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.

~~~
jchassoul
I don't know man... lua is everywhere!, systems/infrastructure, machine
learning, voip, games, microwaves...

~~~
bogomipz
Where in systems/infrastructure are you seeing Lua used?

~~~
pvsnp
nginx, haproxy, redis all support lua scripting to name a few.

~~~
CmdrSprinkles
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.

~~~
rakoo
Any place that uses OpenResty
([https://openresty.org/en/](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.

~~~
bogomipz
>"Any place that uses OpenResty
([https://openresty.org/en/](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.

------
wiz21c
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 ?

~~~
andrewmcwatters
Yes, they're called userdata.

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

~~~
dx034
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?

~~~
joobus
There is a JIT for python: [http://pypy.org/](http://pypy.org/)

~~~
niftich
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.

------
Chris2048
Can't you achieve the same by embedding, say, rust?

~~~
steveklabnik
Yup, that'd work. [https://blog.sentry.io/2016/10/19/fixing-python-
performance-...](https://blog.sentry.io/2016/10/19/fixing-python-performance-
with-rust.html)

