Archive for July, 2008

h1

Running C and Python Code on The Web

July 8, 2008

Last week, Scott Petersen from Adobe gave a talk at Mozilla on a tool chain 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.

 

Before reading this post, readers who aren’t familiar with Tamarin may want to read Frank Hecker’s excellent Adobe, Mozilla, and Tamarin post from 2006 for some background on its goals and why it’s relevant to Mozilla and the open-source community in general.

 

If I followed his presentation right, Petersen’s tool chain 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.

 

So, once Petersen’s modifications to Tamarin make their way into the next version of

Adobe Flash, we can expect to see older commercial games running in the browser. Even more impressive, though, is the sheer volume of existing code that can be made to run inside the browser: Petersen showed us the C-compiled versions of Lua, Ruby, Perl, and Python all running on the web in secure Flash sandboxes.

 

What this means for Python

 

The potential implications this has for Python are particularly interesting to me. The ability to run Python on the web is exciting, to say the least; also interesting is the fact that by sandboxing CPython in a virtual machine, we solve a lot of the security issues that currently face the language when it comes to running untrusted code.

Petersen’s work also resonates with a few goals of another project called PyPy. I’m going to try to explain the idea behind PyPy in a later post; for the time being, the slides from my April 2007 ChiPy presentation on PyPy may serve as a passable introduction.

 

In a nutshell, the difference in mindset between PyPy and Petersen’s work is that the former is radically innovative in scope and mission, while the latter is pragmatic. PyPy’s goal is essentially to move the canonical implementation of Python from C to Python itself, and then use a pluggable toolchain to translate the Python interpreter to any platform with a configurable set of language and implementation features. In one fell swoop, this modularizes the composition of the Python interpreter in such a way that innovating and maintaining different ports and variants of Python like IronPython, Jython, and Stackless no longer requires either writing an entire copy of the same interpreter in a different language or branching the CPython source code and making pervasive changes to it.

 

Rather than focusing on innovation, Petersen’s work focuses on code reuse. Instead of moving a canonical interpreter implementation from C to a dynamic language, his strategy is to simply compile the existing C code to run in a virtual machine that’s implemented in a dynamic language. Both approaches aim to obviate the necessity of “ports” of interpreters to different platforms, and as such their purposes intersect at a common subset of functionality. But Petersen’s work can’t be used to facilitate the innovation of the Python language and its implementation, while PyPy offers few or no tools to reuse existing non-Python code. Perhaps it’s possible to combine the best of both worlds by taking PyPy’s generated C interpreter and using Petersen’s toolchain to allow it to be usable on the web and other places that Tamarin runs.

 

What this means for the Open Web

 

To be honest, I’m not quite sure where the dividing line is between what of Petersen’s work is Flash-specific and what can be reused to benefit the Open Web. Since ActionScript is a sibling language to JavaScript, it’s possible that the custom VM he created can be run in a browser with relatively few modifications—albeit much more slowly in Firefox at the time being, since SpiderMonkey-Tamarin integration is not yet complete. Once that’s further along, though, I imagine it should be possible to create C “libraries” that can be used in the toolchain to allow sandboxed C code to interact with web pages rather than Flash apps. Should this be feasible, I think it will possibly be the ultimate in a relatively recent string of next-generation Javascript virtual machines that allow existing code to run safely in browsers.

 

Also, in the context of the web, download size is a significant concern because applications are essentially streamed to clients. While Petersen’s toolchain means that it’s possible to instantly inherit most of CPython’s benefits on the web, it also means that we get all of its flaws along with it—such as the fact that the standard CPython distribution is a few megabytes large. But there’s ways to get around this.

 

In any case, I’m really excited to see how both Petersen’s work and PyPy proceed. I just hope I haven’t mis-represented either one of them here due to a lack of understanding; I’ll try to correct this blog post as I become aware of my mistakes.

h1

9 Reasons Why Application Developers Think Their CIO Is Clueless

July 2, 2008

As CIO you hold one of the most important executive positions in your company. And, to lead successfully, you must earn the respect of both the business and your information technology organization. But earning the respect of application development professionals is no easy task: The CIO position has been a revolving door as of late and many application development professionals have become cynical.

How Not to Be Clueless

“My CIO is clueless.” These are words you don’t want to hear if you want to earn the respect of your application development professionals. So how do you avoid being a clueless CIO? Steer clear of these behaviors:

1. The CIO is a control nut.
If you want to be a Controller then get a job in the accounting department. Okay, so maybe you are not a certifiable control nut. Maybe it is just a strategy you are employing because your direct reports can’t get the job done. If this is the case, then control is not the solution. Have the courage to replace those managers that aren’t strong. Control won’t work in the long run anyway.

2. The CIO is aloof.
Stop thinking about your golf game. You may have a great team—strong individual managers and team chemistry—but your leadership is still necessary to keep things on course (not the golf course). Besides, no matter how much you practice, your golf game will still be mediocre, but you can be at the top of your game as CIO if you work at it.

3. The CIO gulps vendor Kool-Aid.
Did you know that there are more than 34,750 registered lobbyists in Washington, D.C., for just 435 representatives and 100 senators? That’s 64 lobbyists for each congressperson. I wonder how many vendor account managers there are per CIO. You are smart enough to know that vendors are trying to sell you and you won’t be fooled wholesale. Yeah right. Their influence can eat away at you without you even realizing it. Be even more skeptical than you are now. Just say no.

4. The CIO is a technical dinosaur.

Unless you are running for president of the United States, experience does matter. Technology has changed since you were writing RPG on the mainframe umpteen years ago. And for you younger guys who made your bones writing VB or Java Web apps, make sure you know why there is so much buzz about Ruby on Rails and multicore programming. Your ability to talk tech will go a long way to earning the respect of application development professionals.

5. The CIO is ubergeeky.
Application developers respect a CIO who has deep technical knowledge, but your job is to lead, not to tell them how to architect systems, write code or tap an Ethernet coaxial cable. Rise to your leadership position and trust your technical people to get the job done. And if you don’t trust them then you are either a control nut (see number one) or you don’t have the right people.

6. The CIO thinks changes can happen overnight.
Sorry to have to break this to you: You are not a wizard and your magic wand doesn’t work.

7. The CIO doesn’t know the difference between resources and talent.
The fastest way to lose respect is to put clueless managers in charge. Clueless managers equal clueless CIOs. Can you ever imagine Doc Rivers, coach of the 2008 world champion Boston Celtics, talking about player resources like they were interchangeable? “I need two guard resources.” “I need a center resource.” No. Talent and teamwork make winning teams. Talent matters. Don’t pay lip-service to talent. Find a way to locate and use the talent in your organization. You will only be as good as the team you assemble.

8. The CIO collaborates to death.
Whether it is the character flaw of being indecisive or some middle-school notion of democracy, you are in charge. Collaboration is critical, but you also need to make the right decision at the right time. Collaborate like Captain Kirk. “Spock?” “Bones?” He gets opinions from his experts but there is never any question about who will make the final decision. And, if you never watched Star Trek then you shouldn’t even be a CIO.

9. The CIO spends all of his time trying to get promoted to CEO.
Not gonna happen, sailor. Despite the seemingly perfect career path for CIOs, it just doesn’t seem to happen. Only a handful of CIOs ever got the top job at any of the Fortune 500 companies. Keep your secret aspirations to become CEO to yourself or change your aspirations. Application developers need to know that you are there for them—that you are not CIO du jour.

To Thine Own Self Be True

Leadership can take many forms and styles but one thing all successful leaders have in common is that they earn and keep the respect of the rank and file. Be your own leader and maximize your success by earning the respect of your application development professionals and avoid being a clueless CIO.