![]() | ![]() |
|
And, to be honest, writing Java bytecodes is cooler and more fun to implement. (Although tracing down verifier errors can be a huge headache.) Although Caucho Technology is primarily focused on providing robust and bug-sparse products to its customers, the engineers need to play, too. JavaScript's great strength is in its object model, using
prototype-based inheritance to retrieve fields. Essentially this
means that objects are inheritable hashtables, rather than Java
fields. This gives greater flexibility and makes it simpler to use
properties; they never have to be declared.
JavaScript's function calls differ dramatically from Java's calls. JavaScript functions are first-class objects; Java functions are bound to an object. JavaScript functions can be assigned to variables and put in arrays. They even have properties of their own. In addition, they take a variable number of arguments. This flexibility does come at a price, although a careful implementation can minimize the performance cost.
Global variables must remain in the global hashtable. Scouring
the ECMAScript spec over and over again has shown no way of getting
around this. For example, global variables can be watched with the
I said that resin® can usually put local variables into Java
variables. Using For the same reason, resin® doesn't implement some of the obscure JavaScript 1.2 extensions, i.e. those allowing a function call access to its caller's local variables. That's not possible in Java without degrading to a hashtable. JavaScript property accessing translates to field references and
method calls. Function calls can only overload based on length because
JavaScript is not strongly typed. For example, resin® can't
overload like the A library provider can get
around this by creating an interface class, similar to a BeanInfo
class, that describes the binding in detail. For example, the
The primary benefit of compiling to Java bytecodes is performance. Now, admittedly, performance isn't everything. People use scripting for the flexibility and rapid prototyping availability, not the speed. That's all the more reason for an implementation of a scripting language to be fast. Scripters shouldn't worry about performance. A fast scripting language lets the scripter concentrate on writing cool applications, instead of worrying about speed. A JPython implementation paper.
Copyright (c) 1998-2008 Caucho Technology, Inc. All rights reserved. resin® and quercus® are registered trademarks, and Ambertm is a trademark of Caucho Technology, Inc. |