r/javascript • • Oct 29 '10

c# programmer: JavaScript is "completely single threaded and blocking" in relation to fetching from a URL.

/r/programming/comments/dxv7a/asynchrony_in_c_5_part_one/c13rj6k
0 Upvotes

26 comments sorted by

View all comments

-12

u/Not_Edward_Bernays Oct 29 '10

when I am waiting for a url to fetch, I can still interact with the browser.

so it is not really blocking. in the c# example, if he doesn't do all of his bullshit, then it really will block him and it will be obvious that it is.

9

u/[deleted] Oct 29 '10

It depends on how Archive(FetchUrl()) in the C# example works internally.

For example, it may spawn a thread and do all the work in that thread, and return immediately (ala, how DOM operations work in a browser). This doesn't take C# 5. You could do that with C# 1.0

I don't think you understood the article at all.

3

u/octatone Oct 29 '10

looks like your shift key is blocked

0

u/greim Oct 29 '10

In both browser-based JS and node.js, IO is passed off to modules written in C or C++, meanwhile JS loops and hangs out and is free to do other stuff. Yes, this is non-blocking and asynchronous and all that good stuff.

But what I think these good C# folks are trying to say is that with C#, this capability is not implemented as separate modules which are then bolted onto the implementation and exposed through a callback-driven API, but rather are a core part of the language, and have been factored into the language design at a core level in such a way as to be somehow more convenient.

It's a C# thing, you have to just let it go man.