
LuaJit 2.0 is out - nickik
http://luajit.org/download.html
======
alberth
HUGE congrats to Mike Pall. No amount of praise to him is enough.

Hopefully, sponsors will continue to donate to this project to keep Mike fully
employed and ensure long-term commitment of this project.

I encourage sponsors to considered donating [1]

On a side note, I wish the Programming Language Shootout [2] would add back in
LuaJIT to demonstrate just how fast LuaJIT is in comparison to other
languages. It's just amazing.

[1] <http://luajit.org/sponsors.html>

[2] <http://shootout.alioth.debian.org/>

~~~
_casperc
Are there any other current benchmarks around for LuaJIT vs for instance java?

~~~
abecedarius
<https://github.com/darius/superbench> is not a big fancy cross-language
shootout, at all, but I tried a few little programs I actually cared about.
LuaJIT 'won' in the sense that of the languages I tried it had the best combo
of performance and pleasant productivity, informally. I didn't try to quantify
the latter.

(Also, no Java because I wouldn't seriously consider it for hacking-for-fun.)

~~~
alberth
Where are the results of the benchmark?

~~~
abecedarius
You can run superopt/benchmark.sh on your machine. I'm away from home and the
machine with the various languages installed.

------
nickik
I wish I could understand LuaJit completly. I think if there is any
(reasonably sized) software I would like to completly understand its this one.

There is not only lots of good algorithms but also a lot of fantastic
engineering. Things that you can not learn by reading papers.

Congrats Mike Pall. Now lets see if you can do the same for GC community that
you did to the JIT community. Good Luck.

~~~
chubot
Yeah I agree it's a very interesting piece of software.

But do you understand the prequisites -- namely processor microarchitecture? I
know that's why I don't understand it. I imagine if I did it might not be that
hard to understand.

Most people's knowledge of the stack stops somewhere around C. C hasn't
changed for 40 years. It's a portable assembly language, i.e. the common
mental model is that each construct in C is a handful of assembly instructions
on any processor. But to get LuaJIT-type performance you have to understand
exactly how the CPU works, i.e. pipelining and reordering, internal caching
algorithms, internal branch prediction algorithms, and maybe to some extent
multicore, although I guess LuaJIT is single-threaded like Lua.

Mike Pall's mental model is for sure not C (since a lot of it isn't even
written in C), but the lower level CPU architecture. And that has changed a
lot in the last 10 years. I think even if you coded a lot of assembly language
in the 80's it wouldn't necessarily translate to working on something like
LuaJIT. My impression from skimming some online posts is that he has read
hundreds of pages of Intel/ARM reference documentation from cover to cover,
for multiple CPUs. I think there are a limited number of people with the
patience to do that, since it's non-portable and changes relatively quickly.

Another problem is I think that the open source tools that are available don't
work at the right level. Like when you are running profilers, they are helping
you profile assembly code generated by a C compiler. The performance
characteristics he's taking advantage of are at a lower level. I think you
need CPU-specific performance counters and so forth, and there's a different
way of getting those for each make/model. Are there even open source tools
that allow you to get this information? I'd appreciate a pointer.

It's just a different level of abstraction than most programmers are working
with. Not that many people are even writing "low level" C these days, e.g.
something like redis. A lot of "application level" C code you see these days
is old and/or not particularly fast.

I would be interested if anyone has any pointers for this style of code other
than "read a bunch of CPU manuals". :)

~~~
haberman
I think that most sampling profilers like oprofile
(<http://oprofile.sourceforge.net/news/>) or perf
(<https://perf.wiki.kernel.org/index.php/Main_Page>) will give you CPU-level
profiling and performance counters. The UI of those tools isn't super-
friendly; if you're on OS X the "Instruments" app gives the same information
with a far superior UI.

I have written a JIT that uses LuaJIT's dynamic assembly language engine
DynASM (<http://luajit.org/dynasm.html>). DynASM is an incredibly piece of
engineering, it lets you write really readable code for generating machine
code at runtime, and is extremely small and low-overhead.

I keep meaning to write an article that demonstrates how to use LuaJIT for a
small but interesting JIT. I just never quite get around to it. I always wish
that I could use to implement the Universal Machine from ICFP 2008
(<http://www.boundvariable.org/task.shtml>), which is absolutely the most
delightful problem ever, but as I recall it makes extensive use of self-
modifying code which makes JIT-ting much more difficult and less effective.

~~~
nickik
> I keep meaning to write an article that demonstrates how to use LuaJIT for a
> small but interesting JIT. I just never quite get around to it.

Please do.

------
zdw
There have also been a few changes in the roadmap for LuaJIT, as announced
here:

[http://www.freelists.org/post/luajit/LuaJIT-
Roadmap-20122013...](http://www.freelists.org/post/luajit/LuaJIT-
Roadmap-20122013-UPDATE)

------
dbaupp
Changelog: <http://luajit.org/changes.html> (extremely detailed)

------
minikomi
What are people using LuaJit for in the wild?

Particularly interested in Android integration - has anyone used it for any
projects? From my admittedly small experience using it, I love the language,
and would really like to use it in some way practically.

~~~
StavrosK
I'm using it for <http://www.instahero.com/>. Not mobile development, but I
love the speed and sandboxing features.

~~~
minikomi
Thanks for the reply!

How are you using it? With a lua web framework, or more low level stuff?

edit: great looking site btw.

~~~
StavrosK
Thank you! I'm not developing the site in it, I'm using it for allowing the
users to write their own analytics reports in an easy, fast and secure manner.
It's just the bare LuaJIT interpreter with some simple libraries I'm
developing for analyzing reports more efficiently.

~~~
minikomi
Ah, kind of like webscript.io!

The sandboxing does seem to afford it a lot of cool use cases

------
gavinlynch
Something tells me there is an MC Hammer joke in here regarding being 2.0-Lua-
Jit-To-Quit, but I'm not sure I can find the phrasing to excite the level of
humor I was hoping for...

Oh well, congrats on the release anyway! :)

~~~
hyuuu
haha nice, this is like, one version only joke, once they hit 2.1, that wont
fly

~~~
StavrosK
2.1-Lua-Jit-To-Quit-.1

------
spicyj
Huge congrats to Mike Pall on the release. The man is a machine when it comes
to this sort of thing.

------
pdog
I understand that for LuaJIT 2.0, the whole VM has been rewritten. What's
changed? What's new?

~~~
dmpk2k
If you're referring to LuaJIT 1 vs 2, the big differences are that LuaJIT 2
has a trace-tree JIT, and interpreters for each platform written in assembly.
The improvement in performance is significant: LuaJIT2's interpreter alone is
faster than LuaJIT1's JIT.

It's hard to compare LuaJIT1 and 2, since LuaJIT2 is the most advanced JIT for
a dynamically-typed language on the planet. The performance it can achieve
with zero type annotations still blows me away.

~~~
rayiner
Pedantry: it's actually not a trace-tree JIT. It doesn't treat traces as
trees. See: <http://lambda-the-ultimate.org/node/3851#comment-57679>

~~~
nickik
Yes. Thats a very importend point, its one of the majar diffrences between
LuaJit and most other advanced trace jits.

Also everybody should read that thread, at least once a year.

------
moe
I wonder if a kickstarter could convince him to look at a Ruby VM ;)

~~~
riffraff
well, he does have plans until luajit3... maybe we can book him in advance?
I'd still like a fast ruby in five years :D

~~~
ksec
May be someone should work on Ruby to Lua instead? Using Lua and LuaJIT as a
underlying languages. Like Coffescript to Javascript.

That would be a lot faster then working on Ruby VM. And since Ruby 2.0's VM is
still as slow as hell compared to LuaJIT

------
mamcx
Is possible to use this for build a language? (I wanna to create my own
language, but hope for something easier than LLVM, java, do it from zero in C)

~~~
z3phyr
Yeah people are trying to port clojure on LuaJIT.. It is possible.

~~~
graue
I got curious and looked into this. The relevant effort seems to be this, a
new backend for the ClojureScript compiler which compiles to Lua instead of
JavaScript:

<https://github.com/raph-amiard/clojurescript-lua>

<http://raph-amiard.github.com/ClojureScriptLua.html>

~~~
z3phyr
Actually they use clojurescript because, the compiler is already writern in
clojure. They just need to bootstrap it to th VM.

------
comex
I'd like to use Lua, partly to take advantage of LuaJIT and partly because
it's an interesting language, but it drives me crazy that it lacks things like
'continue' and '+='. Maybe I should use MoonScript, but that completely
discards Lua's aesthetics, which is hardly better.

~~~
catwell
Lua 5.2 added "goto", which basically solves the lack of "continue". LuaJIT
supports it too.

