It’s been a while since my last post, but the wait has been worthwhile. I’ve been working on converting Ben Hood’s amqp library for as3 with my converter. It’s been an educational experience on a couple of fronts getting more familiar with the issues of conversion from as3 to haxe, AMQP/RabbitMQ, and flash vs neko io issues.
The resulting library, hxampq, is up on github with a couple examples to experiment with.
While working on this I ran into issues with trying to map a flash lib to neko. Flash only has asychronous IO, while Neko is synchronous IO only. In my examples I create a thread to deal with the socket data and pass messages back and with neko’s Thread and Deque API.
In my tests, I ran into a latency issue with RabbitMQ. I was trying to send an empty message from a swf, to rabbit, then read that message from a neko server, send a message back to rabbit on another q, and have the swf read it. The resulting “roundtrip” time was measured over thousands of samples. I was getting terrible times anywhere from 7 to 60ms. I was running the servers on an Ubuntu VM on my local machine. Doing a direct connection from a swf to neko and sending bytes back and forth showed times of 3ms. It turns out that the issue is Linux TCP/IP related. The Nagle algorithm is buffering these tiny packets. The issue could probably be solved by sending a lot more data at once. So after enabling TCP_NODELAY in RabbitMQ (this should be the default now with 1.5.0 and on the repo), I tried sending data from one swf to another swf over RabbitMQ and got 3ms! But sending data to neko is still slow around 30+ms. Looks like I’ll have to tinker with the neko socket code to enable high performance tcp/ip options.Read Full Post | Make a Comment ( 1 so far )
Please feel free to join it and let the group know what you’re converting or running into any issues.
Update: I’ve uploaded Windows and Mac OSX binaries to the files section of the google group.Read Full Post | Make a Comment ( None so far )
Previously, I attempted to convert the AsWing project with as3tohaxe and decided instead to go after a smaller code base, the as3flickrlib. I spent the majority of the time dealing with converting the xml processing which as3tohaxe doesn’t handle (and I’m not sure ever will), but the rest of the codebase went through for the most part without a hitch. So my conversion efforts are now on github.
Next project is the flare vis kit!Read Full Post | Make a Comment ( None so far )
Since the last blog post, as3tohaxe converter now has expression parsing, “as” converted to “cast ()” calls, and a program, as3tohaxe.hs, to run through a directory recursively and convert!
So I gave the converter the AsWing codebase as its first big test and ran into a couple problems.
The parser was bombing on some unidentifiable characters which turned out to be the UTF8 header sequence “\239\187\191″ or EF BB BF in hex. At first I just tried removing those characters but couldn’t with vim because the character is “zero width”. So I used a hex editor, 0xED, and the parser ran without issue. So I’ve updated the lexer to handle the header as whitespace.
The second problem I came across was one file taking a particularly long time converting. I think it has to do with one of the statements which has a nested expression.
((((((((("GridLayout[hgap=") + hgap) + ",vgap=") + vgap) + ",rows=") + rows) + ",cols=") + cols) + "]");
I still need to verify this.
Update: The nested expressions were causing the slowdown. I removed redundant work being done by the parser and got a huge speedup.Read Full Post | Make a Comment ( None so far )
So after a couple of months of study, I finally put together my first Haskell project, as3tohaxe, an Actionscript 3 to haXe converter. And now it’s up on github for everyone. The code is a mess because I’m still green with Haskell (and haXe!). It’s just a start, but I hope to continually improve the translator as I work on my haXe projects.
Here’s what it can do so far:
- converts basic types int to Int
- cleans up the package braces
- renames the constructor to new or main
- converts default arguments
- moves member variable initializers into the constructor
- converts access control attributes (e.g. protected to public)
- and more eventually
Parsing expressions is on the todo list.Read Full Post | Make a Comment ( 2 so far )