Sunday, November 28, 2010

Lua Demo += Skywriter

The Lua demo now has a nicer interface using Skywriter, and some additional bugfixes under the hood.

Check it out, and let me know if you find any problems!

Friday, November 26, 2010

Lua Improvements

It seems there are people interested in running Lua on the web :) The Lua demo was on Hacker News, and some people noticed that certain things don't work - thanks for the feedback! - so I spent a few hours figuring out what was wrong. After some small fixes, the demo will now handle these statements:
  • for k,v in pairs({'foo','bar'}) do print(k,v) end
  • for x = 1,10 do print(x) end
  • for k,v in pairs(_G) do print("->", k,v) end
which people mentioned did not work before.

The output seems ok, but I'm not totally sure that it's 100% correct, since my Lua skills are pretty rusty. That's also why I didn't notice the issues in the beginning - I saw that 'hello world' worked, and thought all was well ;)

If people really want to see this work properly, let me know about any other problems. I'm happy to work on it, I just can't do it without feedback since I don't know where to start testing. (Is there a standard test suite for Lua?)

The issues that had to be fixed in Emscripten were
  • Lua uses varargs in ways that the existing code didn't support. So I improved that. Varargs are now emulated in a way that is basically identical to C.
  • A few missing stdlib functions.
So, small stuff. In fact I'd be surprised if there were any big issues left, at this point, given the amount of code known to compile properly, but there are probably a lot of small things left to fix.

Thursday, November 25, 2010

Emscripten 0.6!

Demo: Lua. Thanks to rasjidw and puffnfresh!

Other major changes since the last release:
  • SAFE_HEAP checks for invalid reads/writes and nonportable LLVM bitcode. This is important as LLVM optimizations can lead to nonportable bitcode. We need to figure out which optimizations are at fault, so we can use the other optimizations - they should make us much faster.
  • Much more optimized compilation of very large projects - both in terms of memory and speed. I am now able to compile Sauerbraten without the JS engine giving up ;) - still a very long way from getting it to run, though.
See the Changelog file for additional updates.

Tuesday, November 16, 2010

Worth mentioning...

First committed patch by someone other than me! Thanks puffnfresh :)

Friday, November 12, 2010

Now What?

For several months I've known that when I get home at night, I have tasks X and Y to do in Emscripten in order to move it forward. Last night, however, I took out the guitar instead. Suddenly, there is not much to do - basically the goals of the project have been achieved, Emscripten can compile things like the Bullet physics engine and run it on the web. As far as the core code-generating capabilities are concerned, Emscripten is pretty much complete.

So, what now?
  • There are some additional optimizations and enhancements that can be done, like nativizing structures or emulating multithreaded code.
  • There are various tooling improvements that can be done, like making it easier to glue together web code and compiled code.
  • Emscripten could be used in other ways, for example, it could be combined with something like Rubinius that generates LLVM code from Ruby, allowing running Ruby code on the web.
  • Various code cleanups and refactorings could be done.
I'm not in a rush to do any of these - none is urgent or essential. I guess I'll get around to them eventually, or perhaps someone else will.

Right now, I'm considering doing one or both of the following:
  • Return to my original goal, that of bringing Syntensity to the web. In other words, to compile a version of Syntensity using Emscripten. The time of 3D-environments-on-the-web is almost upon us, and when it is, we need to make sure that the main tools for it are open source and platform agnostic. Sadly, currently the main contenders are not such.
  • Some other side project, got at least two ideas in my head of things I'd like to hack up. They are very experimental and speculative though, so they may end up a waste of time. But if they succeed...

Tuesday, November 9, 2010

Bullet/WebGL Demo

Click on the screenshot for a live demo.

Monday, November 1, 2010

Emscripten 0.5!

Another Emscripten release has arrived, this time the focus was on building a large real-world library: Bullet Physics. For those unfamiliar with it, Bullet is an awesome physics library written in C++, which has been used in many places, including commercial games and movies.

Here is the demo for this release:

Ran 168 tests in 1060.329s


:P Just kidding, a real demo will follow. I'm working on something with Bullet and WebGL, but didn't want to delay the release for it.

About the work in this release: Bullet is much larger than other projects Emscripten was tested on before, and a large part of the work was to speed up the compiler. The result is that Emscripten now takes a reasonable amount of time - if it takes 10 minutes to build the Bullet C++ sources into LLVM bitcode, then it takes a similar amount of time to convert that into JavaScript using Emscripten (and it takes an even longer amount of time to run that through the Closure Compiler for additional optimization). So at this point there isn't much more reason to optimize for speed of compilation - it's in very good shape, fitting into the build process without slowing things down noticeably.

As expected, various small bugs were found while building Bullet, and a few additional tests were added to check for specific issues. There is also an automatic test for Bullet as a whole.

Overall, at this point Emscripten is capable of compiling large projects effectively; quite a lot of the original goals of this project have been achieved. Still lots of cool stuff left, though! More about plans for the near future in another blog post very soon.