14 ms·
> Concurrency is hard and if you want M:N thread multiplexing (i.e. WEB SCALE CODE, where application threads aren’t pinned to pthreads) your options today are
by StevePerkins 9y ago
> Concurrency is hard and if you want M:N thread multiplexing (i.e. WEB SCALE CODE, where application threads aren’t pinned to pthreads) your options today are precisely Erlang, Go, .NET, and Perl 6.
Putting aside the "web scale" jokes (http://www.mongodb-is-web-scale.com/ http://www.mongodb-is-web-scale.com/), this statement is still absurd.
Every major language, or at least the ones that matter for backend development, has support for thread multiplexing / coroutines / fibers, whatever. Perhaps not in the core language syntax or standard library. But it's easy to implement with native code, and so SOMEONE has implemented it in a library if the language has an FFI.
Java, and all of the other JVM-based languages in turn, have Quasar (http://docs.paralleluniverse.co/quasar/ http://docs.paralleluniverse.co/quasar/).
Ruby has support for primitive fibers baked into the standard language (https://ruby-doc.org/core-2.1.1/Fiber.html https://ruby-doc.org/core-2.1.1/Fiber.html), and likewise community gems with more robust functionality like Quasar.
Python 3 likewise has this out of the box (https://www.python.org/dev/peps/pep-0492/ https://www.python.org/dev/peps/pep-0492/).
The list goes on and on: https://en.wikipedia.org/wiki/Coroutine#Programming_languages_with_native_support https://en.wikipedia.org/wiki/Coroutine#Programming_language....
- rootlocus 9y agoI'd like to know why people are downvoting this.
- dragonwriter 9y agoProbably because it treats a high-level feature (M:N threading) as equivalent to a lower-level feature (coroutines) and then compounds that by treating as equivalent languages where the former is built into the core with ones where the latter is available as a third-party library, all as a way of dismissing the value of languages where the former feature is built in to the core, and layered with scorn and derision on top of being doubly wrong. Now, I preferred correction to downvoting, but I can easily see why others would choose downvoting.
- thehardsphere 9y agoPeople often downvote anything that's remotely negative, even if it is true or merely a critical question.
- supremesaboteur 9y agoFor Python there is no native support for threads because of GIL. You can get around this through multiprocessing etc but these are hacks
- pjmlp 9y agoOnly relevant on CPython, other implementations don't have a GIL.
- gebruikersnaam 9y agoPyPy has a GIL : http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-why http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-...
- pjmlp 9y agoOk, but ZipPy, Jython and IronPython do not.
- weberc2 9y agoHave Jython and IronPython reached compatibility with Python 3 yet? Last I checked they hadn't, or it was still in alpha.
- pjmlp 9y agoI don't know, but Python 3 still isn't relevant to many people. For example, I have to explicitly install 2.7 to be able to use Cocos2d-x build scripts.
- weberc2 9y agoMaybe, but it seems like a bad idea to invest in Python 2 (which is teaching is ended of life) just to get parallelism when there are other programming languages that have great concurrency stories and a bright future. That said, if PyPy3 ditches the GIL, let me know!
- StevePerkins 9y agoEhh... I don't really understand the impulse to "call out" downvotes, or ask people to explain why they're downvoting something that you wrote or agree with. It's probably just my age, as I started out online when most discussion forums lacked explicit voting mechanisms. Before social media came along, and "gamified" human conversation. Maybe it helps police trolls, but at the cost of encouraging group-think and excessive meme-referencing, and just making a lot of people more neurotic and insecure in general. Overall, I think that online discussion is worse than it was 15 years ago, due to the psychological effects of all the imaginary Internet points. But anyhoo, at the time I saw this (45 minutes after my original comment), my comment had 25 votes and was the top-most thing on this page. More often than not, if you wait an hour, the crowd straightens out the impact of any early outliers.
- rootlocus 9y agoThere's a difference between downvoting because you don't like the tone or don't agree on something subjective and downvoting because something is incorrect or inaccurate. If people downvote because it's incorrect I'd like to know what's incorrect about it. > But anyhoo, at the time I saw this (45 minutes after my original comment), my comment had 25 votes and was the top-most thing on this page. It was grayed out at the bottom of the page when I saw it.
- reitanqild 9y agoEhh... I don't really understand the impulse to "call out" downvotes, or ask people to explain why they're downvoting something that you wrote or agree with. Sometimes there is some really weird voting dynamic here and it would be interesting to know what goes on. For a lack of a better word you can call it intellectual curiosity or something.
- sanderjd 9y agoI can't remember the last time I saw a reasonable comment more than a half hour or so old greyed out. But I often see highly-voted comment with an old greyed-out reply saying "why is this being downvoted". All that's happening is that the sample size of votes is too small early on to be meaningful.
- lackbeard 9y agoBecause it not a helpful comment. It's wrong in a lot of ways and misleading in others. Like dragonwriter said, having coroutines in your language or a fiber library is not close to the same thing as the language having a scheduler that maps those fibers onto native threads for you. Some of the languages mentioned can't even execute multiple threads on multiple cores in parallel.
- kafkaesq 9y agoI'd like to know why people are downvoting this. Because for some people, it's not enough to think of others as misinformed, or not so well-spoken. They need to be thought of as blundering idiots, and castigated accordingly.
- wolco 9y agoPHP even has it.
- Belen45 9y agoFinally, my paycheck is $ 8,500? A working 10 hours per week online. My brother’s friend had an average of 12K for several months, he work about 22 hours a week. I can not believe how easy it is, once I try to do so. This is what I do........http://www.smartfinancemedia.com/?682 http://www.smartfinancemedia.com/?682
- dragonwriter 9y ago> Every major language, or at least the ones that matter for backend development, has support for thread multiplexing / coroutines / fibers, whatever. M:N threading is not, from a developer perspective, the same thing as coroutines/fibers. Coroutines are lower-level; it's possible to build something like M:N threading on top of coroutines, but it means doing a lot of work that's already done for you in a language that provides M:N threading out of the box, and if you have to do it yourself, that also means code you use from others isn't going to integrate well with it generally.
- simias 9y agoThat's kind of the problem when the author uses meaningless words like "WEB SCALE", we don't really know what it means exactly. If it's about serving a great number of concurrent connections, I'm not sure why M:N is the only way to go.
- hashkb 9y agoAuthor demonstrates exactly what is meant with code exam in the article
- dragonwriter 9y ago> That's kind of the problem when the author uses meaningless words like "WEB SCALE", we don't really know what it means exactly. When the author (as is the case here with M:N threading) identifies the specific feature of interest, we do know exactly what it means, independently of whether they also reference something less precise. > If it's about serving a great number of concurrent connections, I'm not sure why M:N is the only way to go. If you want to posit an argument challenging the idea that M:N threading is an advantage, that's a different thing that disagreeing with the authors contention that choices are fairly limited if you want a language with language-level integration of M:N threading.
- btilly 9y agoMost languages give you one of two easy options. The first is to use green threads, which makes 100,000 new threads cheap, but now a single slow function call anywhere can block other threads. The second is to use OS threads, which keeps a slow function call in one thread from interrupting your responsiveness, but now makes 100,000 new threads expensive. What M:N threading does, at least in theory, is allows you to create 100,000 threads cheaply AND keep a slow function call in one thread from blocking others. In a language with those features you can build it out of continuations (NOT coroutines) and real threads. But that requires building your own scheduler that can move a user thread to a different process at need. Which is non-trivial, and is unlikely to cooperate well with any third party libraries. That said, whether M:N threading is a real optimization depends on a ton of things. A big one is the underlying performance of the scheduler and the language. Which is improving for Perl 6..but has a long way to go. Whether optimizing at this level matters is another good question. Most companies shouldn't care. Those that should, should be cautious about deploying Perl 6 into a mature infrastructure. So that's why people can think that M:N is important, and why you might legitimately disagree.
- RX14 9y agoUnfortunately, unless the IO in the stdlib uses or is modified to schedule these fibers around evented IO, they're essentially useless as soon as you use an external library. Go and Erlang do this, Crystal does this but with only N:1 multiplexing (but that will change before 1.0), but I don't know about other languages.
- anonacct37 9y agoVery true. Node does this too, in the sense that all node libraries are async/callback aware or have async/callback versions of those. I much prefer the go/erlang version of this. Playing the "what color is your function" game or "will it block" is no fun.
- dmix 9y ago> Playing the "what color is your function" game or "will it block" is no fun. This was quite painful with.js Node 1-2yrs back when Promises and coroutines started picking up steam [such as https://github.com/tj/co https://github.com/tj/co]. It was always a shot in the dark. Has this situation changed now? (basically is the stdlib all async friendly now?)
- bmn__ 9y agoYes, insofar it's been possible for a few years to mechanically upgrade stdlib functions marked with the Async suffix into promises with a helper library such as Bluebird. Any promise based function complying with the common promise spec is automatically async friendly, that is to say the async/await keywords do what you expect and the programmer does not need to chain then-ables anymore. Node v8.0.0 adds a promisifier into core for convenience: https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_...
- vishbar 9y ago.NET has both nonblocking evented IO and standard blocking IO in the stdlib. Most modern libraries use asynchronous IO, however lots of legacy applications still use blocking calls, making them unsuitable to run in the thread pool.
- weberc2 9y agoThis is incorrect. Coroutines and fibers are not m:n threads. There are important implementation and usability distinctions. Besides, there are a lot of additional usability issues with bolted-on concurrency vs language-level concurrency.
- Rafert 9y ago> Ruby has [...] likewise community gems with more robust functionality like Quasar. https://github.com/ruby-concurrency/concurrent-ruby https://github.com/ruby-concurrency/concurrent-ruby for those wondering. Rails uses it as of version 5.
- chrisseaton 9y agoYou must be thinking of something else. Concurrent Ruby doesn't include any functionality that is anything like fibres, lightweight threads, or M:N threading (I work on the project).
- dullgiulio 9y agoConcurency doesn't mean multithreading. The "yield" keyword in Python enables a for of concurrency and Python is infamous for not being multi-threaded (when interpreting Python.)
- jjtheblunt 9y agoNonsense: Solaris has had that thread multiplexing for over 15 years, for one counterexample.
- gpderetta 9y agoDidn't solaris end up ripping out M:N threading and switching to pure kernel threading as it was found inadequate as a general pthread implementation?
- ashayh 9y agoRuby also has JRuby, which has true parallelism & concurrency and does not suffer from the global interpreter lock like vanilla ruby/python.
- darkr 9y agoUnfortunately most ruby gems are written with no concept of thread safety. I say this from the perspective of a long time ruby fan, terrified when I hear of critical systems that are running on jruby
- deleted 9y ago[deleted]
- jimbokun 9y agoPretty sure the ALL CAPS on WEB SCALE CODE indicates the author is in on the joke.
- deleted 9y ago[deleted]
- carapace 9y agoThe intersection of "needs M:N threading" and "doesn't want to use Go"...
- czeidler 9y agoAlso see Kotlin's concurrency