Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"NO TESTS. You must work at a startup."

LMAO. You have to hand it to Zed Shaw sometimes...

Now, seriously tho, this has been waiting to happen since forever. I always knew that when the right people started messing around with Lua, awesomeness would emerge.

Lua is the closest scripting language to C. It's faster than Python, Perl and Ruby[1]. It's not just faster, but also uses less memory. It's also extremely elegant (in language concepts[2], at least -- not too much of a fan of its syntax but whatever). But the fact is, apps running in Lua would be hard to beat in terms of single-node performance. Your $20 cloud box that struggles to keep hefty Ruby processes running (or even Python processes, though these are way smaller than Ruby processes) will suddenly be able to handle a lot more than it does today.

I think Lua for instance would make a lot of sense for the big ones: Google, Facebook, Twitter. Google has a lot of C++ code on its infrastructure[3]. Facebook resorted to C++, Java, Python, and Erlang[4]. Twitter took the Java path with Scala.

The more I build applications (and keep them running), the more I respect the Unix nature and the more I want to become proficient in C. Mastering a scripting language and knowing how to glue it to raw C, or something close to C, gives you a lot of power.

Imagine a Python+Lua stack, where you can have handlers written in Python and use small, specific Lua-based extensions to run complex computations. I'm already contemplating using something like Lunatic-Python[5] to accomplish that in an app where I have to create similarity-based clusters. Today the Python code that handles it takes about 15 minutes to run as a queued, background task. I'm very curious to see if I can bring that down with Lua-based code controlled by Python...

[1] http://shootout.alioth.debian.org/u32/which-language-is-best...

[2] http://www.lua.org/history.html

[3] http://www.quora.com/Ben-Maurer/Google-Infrastructure/answer...

[4] http://www.makeuseof.com/tag/facebook-work-nuts-bolts-techno...

[5] https://github.com/dmcooke/Lunatic-Python/blob/master/docs/l...



"Lua is the closest scripting language to C"

Hmm? Neither syntax nor semantics are really close to C, and considering the plethora of C and C-like script interpreters, this strikes me as a pretty odd statement. Or do you mean in regard to binding/FFI?


Binding, definitely.


It is also minimalist yet powerful (environments and metatables can do wonders), and very consistent.


If you're just doing Lua to get to C it's much easier to call to C directly from Python.


Strange, I haven't done a lot with Python but I've built a pretty big system in Lua and its FFI is incredibly nice, the nicest I've ever used, in fact.


Ah, I misunderstood. I thought he was intending to call C from Python by calling Lua from Python and then C from Lua. Still, calling C from Python is trivial with ctypes. Most people do not realize how easy it is:

    from ctypes import CDLL
    libc = CDLL("libc.so.6")
    libc.printf("boo")


It would surprise me if this was true because C interop and embeddability was part of the reason for the creation of Lua. I don't believe you could say the same was true for Python.

Wikipedia: "Lua is intended to be embedded into other applications, and accordingly it provides a robust, easy to use C API. The API is divided into two parts: the Lua core and the Lua auxiliary library."


You can call C directly from Lua too, with alien (http://alien.luaforge.net/).

Generating the bindings really isn't that hard, though.


Before I read up on how Alien works, I have to guess: it uses dlsym() (or the Windows equivalent) to find a function by name, and has a number of prototypical function pointer types which it uses to call the symbol returned by dlsym(), based on the number and types of parameters passed in Lua. When calling C++ it could even check the parameter types, provided they know how name mangling works for whatever platform the run on.

Now to see how close I was...


Not to get to C, but simply to get somewhat better speed, /somewhere/ between Python and C, which is where Lua stands.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: