Activate your free membership today | Log-in

Monday, July 7th, 2008

LLVM and running C as well as Python in the browser

Category: JavaScript, Python

Dan Morrill doesn’t like JavaScript 2. His reasoning is a little like the folks who don’t want Java.Next to try to copy features from every other language, but to just be the best static language, and let other languages like Scala, Groovy, JRuby (and the hundreds of others like Fan) go in different directions on the same Java platform.

You could argue the same for the browser platform. Why push JavaScript 2 further than cleaning it up, and instead allow other languages to augment it.

This is where technology such as IronMonkey come in, as well as the work that Scott Peterson is doing, written up here:

Scott Petersen from Adobe gave a talk at Mozilla on a toolchain he’s been creating—soon to be open-sourced—that allows C code to be targeted to the Tamarin virtual machine. Aside from being a really interesting piece of technology, I thought its implications for the web were pretty impressive.

If I followed his presentation right, Petersen’s toolchain works something like this:

  1. A special version of the GNU C Compiler—possibly llvm-gcc—compiles C code into instructions for the Low Level Virtual Machine.
  2. The LLVM instructions are converted into opcodes for a custom Virtual Machine that runs in ActionScript, a variant of ECMAScript and sibling of JavaScript.
  3. The ActionScript is automatically compiled into Tamarin bytecode by Adobe Flash, which may be further compiled into native machine language by Tamarin’s Just-in-Time (JIT) compiler.

The toolchain includes lots of other details, such as a custom POSIX system call API and a C multimedia library that provides access to Flash. And there’s some things that Petersen had to add to Tamarin, such as a native byte array that maps directly to RAM, thereby allowing the VM’s “emulation” of memory to have only a minor overhead over the real thing.

The end result is the ability to run a wide variety of existing C code in Flash at acceptable speeds. Petersen demonstrated a version of Quake running in a Flash app, as well as a C-based Nintendo emulator running Zelda; both were eminently playable, and included sound effects and music.

Posted by Dion Almaer at 8:50 am
7 Comments

++++-
4.3 rating from 16 votes

Friday, January 12th, 2007

Creating a Flex application using the TurboGears framework

Category: Adobe, Python, Screencast

Screencasts are a nice way to learn certain things. Adobe has done a fun one, and got their own James Ward, and the knowledgeable Bruce Eckel together to write some code.

The coding session is the pair of them building a sample app from scratch using TurboGears on the backend, and Flex on the front end.

It is fun to see Bruce using plain old vi for his python hacking, and James gets to go into uber-IDE land with the Flex Builder (built on Eclipse).


Posted by Dion Almaer at 7:31 am
Comment here

+++--
3.9 rating from 25 votes

Monday, November 6th, 2006

Pyjamas: Pythons answer to GWT

Category: GWT, Python

If you are a python coder who doesn’t like JavaScript and wishes she could stay in python land more, maybe pyjamas is the framework for you.

It is an early stage port of sorts of GWT.

Given that a lot of python goes on at Google, they may be interested in this themselves, and it would be really nice if the underlying JavaScript was shared where it made sense:

  • Shared ugly browser handling fluff
  • Java oddity handling
  • Python oddity handling

Then other languages and platforms could come to the party and play too.

Pyjamas

Posted by Dion Almaer at 6:54 pm
9 Comments

++++-
4 rating from 28 votes

Monday, May 1st, 2006

MochiKit Releases Version 1.3

Category: JavaScript, Library, Python

mochi kit logo
MochiKit, “a lightweight JavaScript Library”, has released version 1.3.1. The highlight of this release is MochiKit.Signal - a simple universal event handling system. Other features include additional examples, improved documentation, and changes and tweaks to Async, Base, Logging, and Dom and packages.

For the full list of changes, check the version history, or just download it and try it. Also, if you are coming to the Ajax Experience, don’t miss Bob’s Intro to MochiKit if you are interesed in this library.

Posted by Rob Sanheim at 10:38 pm
9 Comments

++++-
4.3 rating from 30 votes

Monday, February 20th, 2006

The Future of JavaScript: an Update from Brendan Eich

Category: Firefox, JavaScript, Programming, Python

Brendan Eich has posted a status update on some of the work going into the upcoming JavaScript 2, aka ECMAScript Edition 4 (ES4). One feature that should look familiar to Python hackers are generators and iterators, as seen in the following example taken from a console session:

JAVASCRIPT:
  1. js> function count(n) {
  2.     for (var i = 0; i <n; i++)
  3.         yield i;
  4. }
  5. js> g = count(10)
  6. [object Generator]
  7. js> g.next()
  8. 0
  9. js> g.next()
  10. 1
  11. js> two_to_nine = [i for i in g]
  12. 2,3,4,5,6,7,8,9
  13. js> squares_to_20 = [i * i for i in count(20)]
  14. 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361

Why go with the Python style and syntax?

Given the years of development in Python and similarities to ECMAScript in application domains and programmer communities, we would rather follow than lead. By standing on Python’s shoulders we reuse developer knowledge as well as design and implementation experience. The trick then becomes not borrowing too much from Python, just enough to gain the essential benefits: structured value-generating continuations and a general iteration protocol.

Brendan also mentioned that support for XUL in Python is almost done, and should land back into the main Firefox codebase from the DOM_AGNOSTIC2_BRANCH soon.

The official spec that will lead the way is ECMA TG1, which is being worked on by Brendan along with colleagues from Mozilla, Adobe, and Microsoft. Lets hope Brendan's vision for JavaScript's future will become reality:

My gut says that we will successfully evolve JS into a much stronger language, with a better and more standard library ecosystem, for the next ten years of its life. I will wager that other browsers will follow the ES4 standard, possibly even in 2007.

Posted by Rob Sanheim at 7:00 am
33 Comments

++++-
4 rating from 108 votes

Tuesday, January 31st, 2006

Django adopts Dojo as Ajax framework

Category: Dojo, Programming, Python

django logo
Django, the Python "Web Framework for Perfectionists", is bundling Dojo for Ajax with its 0.92 release, due in out in a few weeks. The initial integration will use Dojo in the admin interface of Django, but the toolkit will be available for any part of a Django app.

It was recently announced that the Java framework WebWork 2.2 will be released with Dojo under the hood, so this looks like another vote of confidence from the open source community in Dojo's quality.

Thanks to Eugene, who also blogged about the announcement.

Posted by Rob Sanheim at 11:39 pm
11 Comments

++++-
4 rating from 54 votes