News for hackers. Stuff that matters.
Re:Comparing Elixir and Go by sasa555 on Friday January 27, 2017 @10:21AM (#13500260)
Thanks, nice to hear that!

Basically a NIF blocks the scheduler, so if you run a tight loop for a long time, there will be no preemption. Therefore, invoking foo(), where a foo is a NIF which runs for say 10 seconds, means a single process will get 10 seconds of uninterrupted scheduler time, which is way more than other processes not calling that NIF.

There are ways of addressing that (called dirty schedulers), but the thing is that you need to be aware of the issue in the first place.

If due to some bug a NIF implementation ends up in an infinite loop, then the scheduler will be blocked forever, and the only way to fix it is to restart the whole system. That is btw. a property of all cooperative schedulers, so it can happen in Go as well.

In contrast, if you're not using NIFs, I can't think of any Erlang/Elixir program that will block the scheduler forever, and assuming I'm right, that problem is completely off the table.

Re:Comparing Elixir and Go by kyrra on Friday January 27, 2017 @10:52AM (#13500467)
As linked elsewhere here, tight loops that never preempt are being fixed in Go 1.8/1.9[0]. Looks like a flag may been added to Go 1.8 called "GOEXPERIMENT=preemptibleloops" that adds a preemptible point at the end of a loop. It's behind a flag for performance/testing reasons, but they are working on it.

[0] https://github.com/golang/go/issues/10958

Re:Comparing Elixir and Go by pmarreck on Friday January 27, 2017 @11:38AM (#13500761)
Won't pre-emptible loops lead to more irreproducible race conditions as a negative consequence, unless the preemption is done deterministically?
Re:Comparing Elixir and Go by sasa555 on Friday January 27, 2017 @12:22PM (#13501096)
Are you asking about BEAM or Go? Preemption already works in BEAM and doesn't lead to race conditions because of nothing shared concurrency.
Re:Comparing Elixir and Go by pmarreck on Saturday January 28, 2017 @08:44PM (#13511189)
I was asking about Go. I understand BEAM's advantages in that area