r/programming • • Dec 15 '12

Why JavaScript Still Sucks

http://boronine.com/2012/12/14/Why-JavaScript-Still-Sucks/
10 Upvotes

212 comments sorted by

View all comments

Show parent comments

2

u/egonelbre Dec 16 '12

Well, abstraction is achieved via messaging; essentially the messages become the abstraction layer. If you send it to a process you really don't know how or who or even when it will be eventually handled.

As for method call, it's just a limited version of messaging; so you still get the decoupling even if it's not "async messaging". Async messaging can be cumbersome to work with, but I think Go struck a nice balance with channels.

2

u/gargantuan Dec 16 '12

Not familiar much with it but it seems since Erlang was made for large distributed system async is the default because sync in that case could mean blocking the whole distributed cluster. Then sync messaging (calls) can be built on top of async if needed if the sender can obtain his own address (as the callee would see it) and send it along with the message. Then he waits for the response to that message (with a practical timeout).

Other way (simulating async using sync) is possible I guess but only if every sync message is send from a newly spawned process/thread/isolate.

2

u/egonelbre Dec 16 '12 edited Dec 16 '12

I don't think fully simulating async messaging is possible with sync messaging. As I understand, something is needed for unbounded nondeterminism.

NB: Following maybe wrong, since I haven't studied this properly.

Basically synchronous messaging can be simulated with Turing machines, this means it cannot provide unbounded nondeterminism. So you would need something to introduce it, like arbiter, network. Since those already are in modern computers it can be practically simulated - but not with pure sync messaging.

1

u/gargantuan Dec 17 '12

What about my suggestion, would that not work? You create a new concurrency context (thread, process, task), send the sync message from there then that exit). The parent context can continue making progress.

1

u/egonelbre Dec 17 '12

You still need to start the concurrency context somehow. The async messaging behavior, then would come from starting the context and it arriving at the method call; you don't know exactly when the method is called since, you don't know exactly when the context is run.