3 ms·
Are there JS runtimes that are primarily synchronous? Certainly not any popular/widely used ones. Asynchrony is for all practical purposes a property of JS.
by hashkb 10y ago
Are there JS runtimes that are primarily synchronous? Certainly not any popular/widely used ones. Asynchrony is for all practical purposes a property of JS.
- tyingq 10y agoI'm not even sure there's an implementation that could do even the most common synchronous operation. Like opening a socket, sending data, and blocking on the response.
- cardiffspaceman 10y agoI'm not sure if you mean implementation of JS or of something that supports executing JS. If you start with the bare interpreter and add say, global functions, through the interpreter's extension API, they CAN be synchronous. You COULD produce a JS environment this way and run scripts in it. Your extensions could include synchronous usage of sockets. Your programs in this environment would be synchronous. Writing a decent web server in that environment would be a challenge.
- tyingq 10y agoWe're saying the same thing. The nature of the environment is slanted to async, thus, commonly available runtimes don't have much functionality that is synchronous. You can find some of it, but it's the exception, not the rule. Yes, you can build something specific, just as you can leverage async libraries in languages where it's not the common pattern.
- lucideer 10y agoMaybe not, but it's irrelevant. The point I was making is that the async features are platform APIs, they have no inherent attachment to the language. And I personally think not knowing the distinction between the language and APIs provided to it is extremely limiting and misleading for someone approaching learning programming (it was for me, I wish this had been clearer to me earlier).
- tyingq 10y ago>Maybe not, but it's irrelevant I'm not sure it is. What's available, without custom work on your own, drives the ecosystem. I can build an asynchronous application with PHP, but there's not much established practice, existing tools, shared learning and so forth. And, whatever I build that way is limited to an audience that will go out of their way to build my custom php interpreter.
- Matthias247 10y agoYou can run Javascript on the JVM with Rhino and Nashorn. There you have access to all the classical synchronous Java APIs - and you need to care about synchronization and real multithreading, which is not really javascripty.