lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2011/12/4 Richard Hundt <>
Try 5e10 iterations or more. If you've got a newish Intel or AMD CPU, you'll probably be seeing times of 20-50 ms for that loop with LJ2. Most of that time will be spent parsing, compiling and garbage collecting the AST (It's way more expensive than it should be, which is why I started the rewrite: the eval() implementation was just painfully expensive. The cost was mainly in the parser actually, which is pretty horrid as it does far too much local backtracking, and the newer code proves that it can be made really fast).

Actually, with 5e9 iterations it takes 10s for me, which is around 2ns per iteration, which is around C speed on my CPU. I'm using an Intel Core2 Duo 1,8Ghz underclocked laptop CPU. :)

Also the primitive type checking operation is based on getmetatable(), which is compiled by LJ2. And LJ2 is just blazingly fast anyway. In general I found that the runtime typechecks had negligible impact on performance when running under LJ2 with JIT turned on. Turning JIT off makes it noticeable, but still, when comparing performance to Python or Ruby, with LJ2 in interpreter mode, performance is very competitive.
That is interesting.

If you're interested in contributing ideas or code, let me know off list. I think that if you were going to go with the language, that we could collaborate in making it do what you need in terms of OO goodies and such. Thus far I've been working in isolation and it'd be useful to have someone with a real use case for trying it out ;)

Alright, here's my "wishlist" :)
- Class system with single-inheritance and mixins(aka components, interfaces)
- Overloadable, default values directly in the member declaration(this is where e.g. java fails, it can't handle default values with polymorphism well)
- Function type guards.

Looking over your tests, you actually already have 1 and 3, nice! I can't test 2 right now since your inheritance seems to be broken, but it sounds like something that is easily done.

Oh, and to give some feedback.. I believe that "has member is readonly" is rather hard to read, seeing as it looks like an english sentence, but really isn't. I'd actually go for a more C-like idiom, e.g. "CONST member"  there. :)