Monday, December 22, 2008

I could have had a V8, oh wait, I do

I've always been intrigued by programming languages and what makes them tick, and what is the best one for what situation. That's why Dave Thomas's keynote at ESE still has me thinking about the mix of JavaScript and C++. So much so that I spent a few hours this weekend while waiting out the snow storm to get Google's V8 JavaScript VM building under MinGW for Wascana. I think it would be an intriguing addition to have the VM DLL available for developers using Wascana. With a few changes, I have it building and passing the unit tests and I have a patch into the V8 project. I'll make V8 available in the Wascana 1.0 alpha in the next couple of days.

Now that I have it, I have to ask myself - what the heck do you do with it? I've thought about building wrappers for the wxWidgets library to let you build thick client apps in JavaScript. wxWidgets also comes with Wascana, and thick client apps is kinda what Wascana is all about (aside from dreams of using it for game development, which could also benefit from a fast JavaScript engine).

But it's not clear where one would draw the line between JavaScript and C++. Given a C++ library like wxWidgets, or SDL, or what have you, is it enough to wrap it with JavaScript and have the developer do everything in JavaScript. Or should JavaScript just be this thing on the side that allows for extensibility of some larger application written in C++.

It makes me wonder if I'm following some crazy idea that some madman sold me in a bar in Germany. Or maybe this is challenging me to give it deeper thought, to think about how scripting and native languages are supposed to mix. Where in all this is the sweet spot of architectural balance. Or is there one? Either way, it'll be on my mind over the Christmas holiday season.

6 comments:

  1. Have you also considered Ruby and Java as a static/dynamic language mix usable via JRuby?

    ReplyDelete
  2. I was thinking more of a native/scripting mix than a static/dynamic mix. The issue I'm trying to figure out is what benefits from a VM and what doesn't. JRuby is all VM.

    ReplyDelete
  3. My personal opinion is that script (in general) should be used as a way of allowing AGILE development that can be easily switched without requiring a full-scale build and without getting into the guts of the system. Whatever that means to the particular project (for instance, in a game, you might want to script the AI so that game designers can easily tweak and modify that stuff without requiring a full build).

    ReplyDelete
  4. Great point. That really is the promise of scripting, quick turnaround to test your change.

    I wonder if it relates to how hard core of an engineering effort you need. Complex algorithms that require high performance and a strong architecture need a strongly typed scalable language like C++. For things that are relatively simple that you want to get going without the tools slowing you down, scripting would be the better answer. Hmmm...

    ReplyDelete
  5. Hey Doug, if you see this comment, where's your interest in this stand now? I've been giving some thought to the same sort of thing (considered using SpiderMonkey at one point, but discarded that because V8 looks more solid), and I'm curious whether anyone else is working on it.

    ReplyDelete
  6. I'm not sure what point I was trying to make here. Right now my mind is on NPAPI for making C/C++ plugins so you can use them with your favorite NPAPI compatable browser. Then you can use V8 in Chrome or SpiderMonkey in Firefox.

    ReplyDelete