Skip to main content
added 919 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211

The best two examples I found were the new Nashorn JavaScript Engine created for Oracle for the JDK8, and Rhino JavaScript Engine created by Mozilla. They both are EcmaScript compatible, and they both allow the creation of Java classes. Nothing in these engines requires the use of event-driven programming to deal with concurrency. These engines have access to the Java class library and since they run on top of the JVM they probably have access to other concurrency models offered in this platform.

Consider the following example take from (although I did not try this)JavaScript, The Definitive Guide to illustrate how to use Rhino JavaScript.

print(x); // Global print function prints to the console
version(170); // Tell Rhino we want JS 1.7 language features
load(filename,...); // Load and execute one or more files of JavaScript code
readFile(file); // Read a text file and return its contents as a string
readUrl(url); // Read the textual contents of a URL and return as a string
spawn(f); // Run f() or load and execute file f in a new thread
runCommand(cmd, // Run a system command with zero or more command-line args
[args...]);
quit() // Make Rhino exit

You can see a new thread can be spawned to run a JavaScript file in an independent thread of execution.

Well, we can kiss our portability good-bye. ThereIt looks like there is simply no way that, in terms of the concurrency models, we can guarantee that all these libraries will play nice in all environments. 

Although in the realm of browsers they all seem to work similarly, and since Node.js runs in an event loop, many things may still work, but there not guarantees that this should work in other engines. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

The best two examples I found were the new Nashorn JavaScript Engine created for Oracle for the JDK8, and Rhino JavaScript Engine created by Mozilla. They both are EcmaScript compatible, and they both allow the creation of Java classes. Nothing in these engines requires the use of event-driven programming to deal with concurrency. These engines have access to the Java class library and since they run on top of the JVM they probably have access to other concurrency models offered in this platform (although I did not try this).

Well, we can kiss our portability good-bye. There is simply no way that, in terms of the concurrency models, we can guarantee that all these libraries will play nice in all environments. Although in the realm of browsers they all seem to work similarly, and since Node.js runs in an event loop, many things may still work, but there not guarantees that this should work in other engines. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

The best two examples I found were the new Nashorn JavaScript Engine created for Oracle for the JDK8, and Rhino JavaScript Engine created by Mozilla. They both are EcmaScript compatible, and they both allow the creation of Java classes. Nothing in these engines requires the use of event-driven programming to deal with concurrency. These engines have access to the Java class library and since they run on top of the JVM they probably have access to other concurrency models offered in this platform.

Consider the following example take from JavaScript, The Definitive Guide to illustrate how to use Rhino JavaScript.

print(x); // Global print function prints to the console
version(170); // Tell Rhino we want JS 1.7 language features
load(filename,...); // Load and execute one or more files of JavaScript code
readFile(file); // Read a text file and return its contents as a string
readUrl(url); // Read the textual contents of a URL and return as a string
spawn(f); // Run f() or load and execute file f in a new thread
runCommand(cmd, // Run a system command with zero or more command-line args
[args...]);
quit() // Make Rhino exit

You can see a new thread can be spawned to run a JavaScript file in an independent thread of execution.

It looks like there is no way that, in terms of the concurrency models, we can guarantee that all these libraries will play nice in all environments. 

Although in the realm of browsers they all seem to work similarly, and since Node.js runs in an event loop, many things may still work, but there not guarantees that this should work in other engines. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

added 72 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211

Well, we can kiss our portability good-bye. There is simply no way that, in terms of the concurrency models, we can guarantee that all these libraries will play nice in all environments. Although in the realm of browsers they all seem to work similarly, and since Node.js runs in an event loop, many things may still work, but there not guarantees that this should work in other engines. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

Well, we can kiss our portability good-bye. There is simply no way that, in terms of the concurrency models, all these libraries will play nice in all environments. Although in the realm of browsers they all seem to work similarly. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

Well, we can kiss our portability good-bye. There is simply no way that, in terms of the concurrency models, we can guarantee that all these libraries will play nice in all environments. Although in the realm of browsers they all seem to work similarly, and since Node.js runs in an event loop, many things may still work, but there not guarantees that this should work in other engines. I guess this is probably one of the disadvantages of EcmaScript compared to other more extensive specifications like those defining the Java Virtual Machine or the CLR.

added 72 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211

Now, the decision of using an event-driven design for Node.js is a bit less evident. In hisCrockford gives a good explanation in the video shared above. But also, in the book, The Past, Present and Future of JavaScript, its author Axel Rauschmayer says:

Now, the decision of using an event-driven design for Node.js is a bit less evident. In his book, The Past, Present and Future of JavaScript, its author Axel Rauschmayer says:

Now, the decision of using an event-driven design for Node.js is a bit less evident. Crockford gives a good explanation in the video shared above. But also, in the book, The Past, Present and Future of JavaScript, its author Axel Rauschmayer says:

added 170 characters in body; Post Made Community Wiki
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 6 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
deleted 1 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 16 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 4 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 4 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 4 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 4 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 62 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
added 62 characters in body
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading
Source Link
Edwin Dalorzo
  • 78.9k
  • 25
  • 151
  • 211
Loading