typed into the tiny interpreter, which would then assemble the object code in memory as it parsed the tokens and executed the resulting routine.

In recent years, Web browsers have become fertile ground for mutation and symbiosis. Two central figures in modern Web development are interpreted JavaScript and XML. (XML itself is the syntax for a variety of other languages and an abundant source of hybrid languages and mutations.) In the common Ajax programming model, JavaScript objects can be serialized to XML form, and XML encodings can be used to pass remote procedure calls back to a server. In one such encoding, XML-RPC, a standard extension called multicall is provided for the browser client to issue multiple procedure calls from the client to the server in a single transfer. An example of a single call to a method x.foo and then a series of calls to the same method using multicall is shown in Figure 8.

While implementing Ajax user-interface code for a new line of storage products, the Sun Fishworks team wanted to develop a way to minimize unnecessary client-server interactions. The first concept developed was the notion of a multicall invocation whose parameter was the result of another call. In the following example, the method x.foo is called on the result of x.bar in a single XML-RPC interaction as shown in Figure 9.

The trick here is that the new structure member methodParams indicates that the next members are not static parameters but more methods to be called recursively, with the result pushed onto a stack. Once a stack had been born, it was only natural to start throwing in operators from a stack-based language, forming an entirely new interpreted language that itself is declared as data in JavaScript, sent to the server by the existing XML-RPC serialization, and executed by extensions to our XML-RPC interpreter engine. A few of the operators that we implemented at Sun are shown in Figure 10.

This example illustrates that the symbiotic relationship between JavaScript and XML essentially allows our language to exist without requiring its own lexer or parser, and

figure 8: JavaScript, XmL-RPc, and multicall.

x.foo({ bar: 123, baz: 456 });

system.multicall(

{ methodName: ‘ x.foo’,
params: [ { bar: 123, baz: 456 } ] },
{ methodName: ‘ x.foo’,
params: [ { bar: 789, baz: 654 } ] },
{ methodName: ‘ x.foo’,
params: [ { bar: 222, baz: 333 } ] }

)

figure 9: multicall with parameterized results.

system.multicall(

{ methodName: ‘ x.foo’, methodParams: [

{ methodName: ‘ x.bar’, params: [ 1, 2, 3 ] }

] }, ...

)

figure 10: multicall with stack operators.

system.multicall(

{ foreach: [ [ 2, 4, 6 ], [

{ methodName: ‘ x.foo’, params: [] }, { push: [] },

{ div: [ { pop: [] }, 2 ] }

] ] } ...

)

 

fundamentally serves the purpose of offloading performance-critical code from JavaScript to our server and minimizing round-trips. In the videogame industry, a similar symbiosis (without the hybrid syntax) has developed between Lua and C/C++. The Lua scripting language provides a popular form for writing non-performance-critical code in videogame engines, and the Lua interpreter design makes it easy to bridge to C code.

Once two or more languages are interacting in a large software system, it becomes only natural for an ecosystem of tools (likely incorporating little languages with hybrid syntax) to spring up around them to ease the maintenance, development, and debugging of the entire system. If a rich ecosystem grows around the languages of a complete software system, both little and big, purpose-built

and general-purpose, the longer the overall environment will thrive and its constituents survive. Therefore, as we build our towers of software abstraction ever higher, we should expect to see and know more languages, not fewer.

 

Mike Shapiro ( mws@sun.com) is a Distinguished engineer at sun microsystems and is currently leading sun’s fishworks advanced engineering team in san francisco. he previously worked in sun kernel engineering where he developed a variety of technologies for solaris including pgrep, pkill, mdb, dumpadm, libproc, ctf, fmd, the Dtrace D language and compiler, smbios, and a variety of features related to cPu, memory, i/o, and software fault handling and diagnosis.

a previous version of this article appeared in ACM Queue, january 2009.

© 2009 acm 0001-0782/09/0400 $5.00

APriL 2009 | voL. 53 | no. 4 | communicAtionS of the Acm

41

References:

mailto:mws@sun.com

Archives