Mixing Scala, Java, Ruby, JS, and PHP -- all in one process -- is simple and straight-forward on the JVM.
That said, the language of the web is HTTP and REST and open APIs, not injection/eval of JavaScript.
Mixing Scala, Java, Ruby, JS, and PHP -- all in one process -- is simple and straight-forward on the JVM.
That said, the language of the web is HTTP and REST and open APIs, not injection/eval of JavaScript.
Please tell me how code in PHP can get a response from a function in JavaScript? What if that response is a Date object? What if that Date object was extended with additional functionality? What if that Date object stored additional values in unexpected places? A huge advantage of Javascript is that everything is an object and everything can be modified.
When you try to make that work, you'll start placing restrictions on what can and what can't be passed. Global scope will be a nightmare. You'll try to hack together a scheme that casts responses into primitives. In the end, you'll end up with a stifling environment where interoperabilty is a theory that is never used in production because it was crippled to make it functional to the point of being useless.
Here's one example; Rhino provides pretty seamless bridging from JavaScript to Java:
https://developer.mozilla.org/en/Scripting_Java
I've used it to run user-supplied JS inside the JVM.
PHP is pretty easy too:
http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp#JavaPH...
Scala is even more lightweight here:
http://www.codecommit.com/blog/java/interop-between-java-and...
Bear in mind that these are all for the JVM, which wasn't even designed with the intention of being a general-purpose multi-language VM.
Have you used Java libraries in JS or vice-versa? That's the problem the parent is referring to.
Then solve the problem I put before you.
It's an easy one. I want to pass a modified Date object with stored procedures that modify the value based on geolocation. I want to pass it from a Javascript function to PHP/Java/whatever. Make it work. Please.
That said, if you give me some example code, I'll demonstrate its use in a JavaScript/Java hybrid implementation when I have some spare moments.
I did. Please solve the problem I put forward. If you solve it, you win.
function multiplyString(str, times) {
while (times) {
str += str;
times -= 1;
}
return str;
}
We could write: <?php
console->log(multiplyString("Hello", 3));
?>
You then ask, "What if the response is a Date object?" You would call it the same way, and get back a Date object.The rest of your question adds a bunch of other suppositions, all of them fairly vague and none of which seem particularly more salient than the first two. If you have a particular reason to think this would be intractable, maybe you could explain in more detail the problem you see, and perhaps an example of where it shows up in popular multi-language runtimes and interfaces.