
Compiling to Lua - jgrahamc
http://blog.cloudflare.com/cloudflares-new-waf-compiling-to-lua
======
programminggeek
I can't help but feel like Lua is one of those languages that is fantastic,
but gets basically ignored for most things outside of a particular niche (game
scripting). Perhaps that is why it is still such a fantastic language...

~~~
Jare
It's the other way around, it gets ignored because it is consciously designed
and maintained to serve a very particular niche: high performance extension
language. I wouldn't consider Lua a fantastic language anywhere else.

~~~
nilved
It's designed as a simple and performant language. Embedding within games, for
example, is one area where those traits are very valuable. That doesn't mean
Lua is only good for embedded programs or games: Lapis and Luvit are
testaments to how Lua is great for building web applications.

On top of that, LuaJIT means it blows conventional languages like Ruby and
Python straight out of the water. Not only is it a good language for web
development, it's a remarkable one.

~~~
tzs
Could Python or Ruby be compiled to Lua? Such languages are hard to compile to
static typed languages like C, but Lua is dynamic like they are, which should
remove a lot of problems.

~~~
nilved
Technically yes, but it would likely only be possible with a restricted subset
of the language. Python and Ruby have a large standard library and set of
built-in functions, because they're "batteries included" languages. Lua is
quite the opposite: it doesn't even have access to the file system unless you
implement that or use a module. So you'd either end up using a limited Python
without features absent in Lua, or you'd need to bridge the gap in
functionality with a very large runtime library.

If you're looking for a more expressive syntax, check out MoonScript. It's an
awesome language that you could consider Lua's CoffeeScript analogue.

~~~
kodablah
Lua does have file system access:
[http://www.lua.org/manual/5.2/manual.html#6.8](http://www.lua.org/manual/5.2/manual.html#6.8)

~~~
spc476
In that it can open files. It does not, however, have a way to enumerate files
in a given directory---that requires a module to handle.

~~~
jekub
I fully agree with you but just want to add that you can do it in "pure" Lua :

for file in io.popen("ls "..dir):lines() do ... end

This should never be used in real applications and a proper filesystem module
should be used instead. But, I find it very useful for quick one-shot scripts
I write for batch processing some files.

------
senthilnayagam
is cloudflare using openresty( its author agentzh works for cloudflare)? or
their own nginx + lua implementation?

~~~
eastdakota
We use openresty and, yes, agentzh, the project's creator, is on our team.

~~~
the1
why not pay him to get websocket support out? who prioritizes his work queue?

~~~
justincormack
What a bizarre comment. They are paying him.

He has said that someone could sponsor him to do it in his own time
[https://github.com/chaoslawful/lua-nginx-
module/issues/165](https://github.com/chaoslawful/lua-nginx-module/issues/165)

