Re: translating one objcaps language to another?
"Tyler Close" <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Jan 22, 2008 5:20 PM, Mark Miller <[email protected]> wrote: > On Jan 22, 2008 12:18 PM, Lex Spoon <[email protected]> wrote: > > Does anyone know of a compiler that goes from one object capabilities > > language to another? > > A first step is to decide on a mapping of basic Java (or Joe-E) types > to basic JavaScript (or Caja) types. Leaving security aside for the > moment, we already have at least four(!!) mappings between these two > languages: > > * GWT provides a JS Native API, allowing Java code translated to > JavaScript to directly call JavaScript objects. > * Rhino allows JavaScript code to call Java objects. > * The browsers provide LiveConnect > <http://en.wikipedia.org/wiki/LiveConnect>, enabling JavaScript on a > web page to talk to Java applets on that page. > * Waterken's provides both a Java and a JavaScript ref_send API, > mapping each language onto Waterken's JSON/HTTPS-based protocol. > * Once Microsoft's CLR (.net virtual machine) supports JavaScript, > then this will create a mapping between JavaScript and J#. There are two independent mappings done between Java and Javascript in Waterken, one for pass-by-construction objects and one for pass-by-reference objects. The pass-by-construction mapping is described at: http://waterken.sourceforge.net/javadoc/org/ref_send/package-summary.html There's an example of the pass-by-reference mapping at: http://waterken.sourceforge.net/bang/ The pass-by-reference mapping needs more documentation, but is pretty simple, so I'll describe it here. The goal is only to pass invocation messages between Java and Javascript. Each invocation message provides the simple name of the invoked method and an array of arguments. There's no support for method overloading, such methods are treated as if they do not exist. I think the pass-by-reference invocation marshalling is very similar to that done in Rhino, but without the support for method overloading. IMO, supporting overloading across different languages is just too tricky and so best avoided. I've written code to support overloading in the past, and the complexity was just not worth it. AFAIK, Rhino doesn't pass data over the network, so it doesn't discriminate between pass-by-construction and pass-by-reference. I think my implementation of pass-by-construction provides an interface similar to the one Rhino provides in the local only case. The difference is the absence of any methods; only fields are transported over the network. I don't know the details of the other listed mappings, so I look forward to reading the rest of this discussion. --Tyler -- Use web-keys for RESTful access-control: http://waterken.sourceforge.net/ Name your trusted sites to distinguish them from phishing sites. https://addons.mozilla.org/firefox/957/