News for hackers. Stuff that matters.
Re:How JavaScript works: Event loop and the rise of Async pr... by m12k on Saturday October 14, 2017 @01:09PM (#15473080)
IMO thread programming via locks, mutexes and such is in the same category as assembly programming - they're necessary low level primitives that are extremely easy to get wrong, and hence they should ideally be left to specialized experts, who can use them to develop higher level abstractions (e.g. worker pools, event queues, tasks) that normal application developers can use for most of their use cases.
Re:How JavaScript works: Event loop and the rise of Async pr... by yashap on Saturday October 14, 2017 @01:57PM (#15473317)
Agreed. I've been programming primarily in Scala the last few years, which has great high-level concurrency abstractions, and the code honestly stays readable and easy to reason about. We get the odd concurrency-related bugs, but they're reasonably rare, no more common than people screwing up things like time, text encoding, not properly using db indexes, etc.

Thread-based concurrency need not be overly scary. Any concurrency model will take some time to wrap your head around, but with the good ones, once you get comfortable with them, they should feel very safe, intuitive and deterministic. Scala's approach of "Futures + immutability when you don't need mutable state, or Actors when you do need mutable state" has worked well for every problem I've encountered in the last few years, and I've certainly heard great thing's about Go's approach too.

ES6 has improved the state of concurrency in JS, it's now similarly easy to read and reason about as Scala's model, but the lack of actual parallelism is a pretty big limitation - often a deal breaker for server-side code, and still often an issue client-side.

Re:How JavaScript works: Event loop and the rise of Async pr... by hannofcart on Saturday October 14, 2017 @04:28PM (#15474092)
> but lack of actual parallelism is a pretty big limitation - often a deal breaker for...

Well, in my experience, it has been a deal breaker in a select few, rare cases. But often?

Do you routinely come across problems that could NOT be solved using a multiprocess approach (in Node) or webworkers on the client side? Could you share some of these scenarios?

Re:How JavaScript works: Event loop and the rise of Async pr... by pdpi on Monday October 16, 2017 @04:17AM (#15481641)
How about database access?

Even node uses a thread pool under the covers for that.

Re:How JavaScript works: Event loop and the rise of Async pr... by throwme211345 on Saturday October 14, 2017 @08:45PM (#15475185)
All the time. Web development is a sad excuse for experience in HPC environments. But node guys always think I/O processing in an event loop must work for everything!!!!

With that approach we can go back to the happy openmpi/mpich days and take the gargantuan performance hit that ended MPI clustering for any serious real time scientific processing.

Re:How JavaScript works: Event loop and the rise of Async pr... by hannofcart on Sunday October 15, 2017 @02:43AM (#15476167)
> All the time.

Again, I must press for examples/real scenarios.

Re:How JavaScript works: Event loop and the rise of Async pr... by throwme211345 on Monday October 16, 2017 @10:41AM (#15483491)
30 arc second permutation on a TC forecast track as it impacts multiple points of interest across multiple impact models. Heavily parallel amenable and in RT not an async endeavor.

Not giving you more 'hints'. You webdevs are kind of dull anyway. I/O this and I/O that and you'll accept untrusted input until the sec industry all drive ferraris on your mistakes.

Re:How JavaScript works: Event loop and the rise of Async pr... by asimpletune on Saturday October 14, 2017 @07:10PM (#15474837)
I like the syntax that C# provides to make the code easier to reason about.
Re:How JavaScript works: Event loop and the rise of Async pr... by GordonS on Sunday October 15, 2017 @08:04AM (#15476802)
I agree, and things like the TPL make some uses of parallelism remarkably simple
Re:How JavaScript works: Event loop and the rise of Async pr... by throwme211345 on Saturday October 14, 2017 @08:35PM (#15475143)
Disagree. Threaded programming is not that difficult. Design matters. If you are trying to back fit threads into legacy code that has a traditional process based model with massively shared data structures it can be a little ugly.

Most peoples problems come with being over clever with their per thread data/stack, priorities, affinities, attributes, etc..a simple threaded program with a couple of locks for shared data and a flat schedule is efficient and easy to understand on multi-core systems.

Event loops and aio are nice but they are not a superior standalone solution as evidenced by nodes use of libuv.