News for hackers. Stuff that matters.
Re:Introduction to Go 1.1 by davidw on Tuesday March 26, 2013 @04:42AM (#5441921)
I'm interested in tracking Go as a replacement for Erlang. Some things that should probably happen:

* GC works on 32 bit systems.

* Scheduler improvements so that things are a bit more robust ( http://code.google.com/p/go/issues/detail?id=543 )

* A fairly solid library implementing supervision trees or something like it.

* Probably some other things, but those strike me as the big ones. The important thing is for the system to be able to run for months at a time.

I think they'll get there eventually. Maybe not 100%, but 'good enough' sooner or later.

Re:Introduction to Go 1.1 by jerf on Tuesday March 26, 2013 @09:22AM (#5443040)
Right now, as near as I can tell, you basically can't implement an Erlang supervision tree in Go. You don't have anything like linking, which really has to be guaranteed by the runtime to work properly at scale, so bodging something together with some 'defer' really doesn't cut it. You also can't talk about "a goroutine", because you can't get a reference or a handle to one (no such thing), you can only get channels, but they aren't guaranteed to map in any particular way to goroutines.

I've done Erlang for years and Go for weeks, so I'm trying to withhold judgement, but I still feel like Erlang got it more right here; it's way easier to restrict yourself to a subset of Erlang that looks like a channel if that is desirable for some reason than to implement process features with channels in Go.

Re:Introduction to Go 1.1 by JulianMorrison on Thursday March 28, 2013 @07:47AM (#5454268)
Defer and recover are guaranteed by the runtime, so deferring a recovery that launches a goroutine which sends a value on a child-died channel is not quite a bodge. However as you point out unlike Erlang there are no PIDs, so you'd either need a channel per child or an ID per child. And the whole thing would be very, very manual.

Something like

  type Crash struct {
    PID int
    Panic interface{}
  }

  var crashed = make(chan Crash)

  func parent() {
    go child()
    oops := <-crashed
    panic(oops)
  }
  
  func child() {
    defer func() {
      if r := recover(); r != nil {
        crashed <- Crash{1, r}
      }
    }
    panic("boom")
  }
Re:Introduction to Go 1.1 by JulianMorrison on Tuesday March 26, 2013 @07:33AM (#5442493)
That issue is quite simply a misinterpretation of goroutines.

Erlang: perform a maximum number of reductions, then switch, or switch on IO. The number of reductions is cleverly adjusted so that a process which is swamping other processes will be throttled.

Go: switch on IO.

Go's design is much simpler, and closer to Ruby Fibers than to Erlang processes, except that goroutine scheduling can use multiple threads. To cooperatively switch without doing IO, call runtime.Gosched().

Re:Introduction to Go 1.1 by lmfao on Tuesday March 26, 2013 @05:09AM (#5442014)
The first thing is one of the major issues I have with go at the moment. Lots of my servers are forced to run on 32 bit, due to certain software requirements and it bothers me to not be able to write go daemons for it.
Re:Introduction to Go 1.1 by davidw on Tuesday March 26, 2013 @06:01AM (#5442169)
The system I'm working on is an embedded-ish platform that should probably be 32bit in order to save on memory.
Re:Introduction to Go 1.1 by trailfox on Tuesday March 26, 2013 @05:35AM (#5442098)
Akka is also a viable Erlang alternative.
Re:Introduction to Go 1.1 by waffle_ss on Tuesday March 26, 2013 @10:21AM (#5443439)
Looks like a nice library but I don't think it's a serious contender to replace Erlang because the JVM just isn't made for the level of concurrency that Erlang's VM is. Off the top of my head as an Erlang newbie:

  * You're still using Java threads, so the potential to access [shared memory][1] is there (i.e. "shared nothing" can't be guaranteed).
  * You're still subject to global GC pauses, whereas the Erlang VM has per-process GC.
[1]: http://doc.akka.io/docs/akka/snapshot/general/jmm.html
Re:Introduction to Go 1.1 by trailfox on Tuesday March 26, 2013 @10:33AM (#5443516)
Recent benchmarks and related responses resulted in Akka out-performing Erlang (read the full post): https://plus.google.com/112820434312193778084/posts/HdKFx4VQ...

Shared memory when running on the same machine is actually more efficient since there is no need to copy immutable objects.

If the sophisticated low-latency GC options available on the JVM are not sufficient for you feel free to fire up more JVM instances on the same machine or on other machines.

Re:Introduction to Go 1.1 by waffle_ss on Tuesday March 26, 2013 @12:13PM (#5444240)
I assume you mean the comment that links here, with Akka getting 2.1M messages/sec? http://uberblo.gs/2011/12/scala-akka-and-erlang-actor-benchm...

If you follow the comments there, someone improved the Erlang benchmark to 3M messages/sec, beating Akka once again: http://musings-of-an-erlang-priest.blogspot.dk/2012/07/i-onl...

> Shared memory when running on the same machine is actually more efficient since there is no need to copy immutable objects.

Many Erlang processes fit onto an OS-level thread or process, so passing messages is very fast ("copying" shouldn't be equated with context switching OS threads).

> If the sophisticated low-latency GC options available on the JVM are not sufficient for you feel free to fire up more JVM instances on the same machine or on other machines.

Akka is a library and can't make guarantees about how the JVM will perform garbage collection of actors while Erlang has it built into its VM. No amount of creating new JVM instances will change that.

Re:Introduction to Go 1.1 by trailfox on Tuesday March 26, 2013 @12:34PM (#5444397)
> I assume you mean the comment that links here

You assume incorrectly. I'm referring to the version where Scala was 44% faster than Akka: https://plus.google.com/112820434312193778084/posts/HdKFx4VQ...

In any event the application logic in Java will likely outperform erlang. See: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t... where Java outperforms Erlang by 3-30x in most cases and uses significantly less memory in most cases.

> Many Erlang processes fit onto an OS-level thread or process, so passing messages is very fast ("copying" shouldn't be equated with context switching OS threads).

Many Akka actors fit into a single process and there are many actors per OS level thread, so this isn't really a useful point for comparison.

> Akka is a library and can't make guarantees about how the JVM will perform garbage collection of actors while Erlang has it built into its VM. No amount of creating new JVM instances will change that.

The JVM does the GC, not the library. Is 100 microseconds not short enough for your application? http://mechanical-sympathy.blogspot.com/2012/03/fun-with-my-...

Re:Introduction to Go 1.1 by waffle_ss on Tuesday March 26, 2013 @01:01PM (#5444591)
Your 44% link is after crippling the benchmark by de-parallelizing it on top of using a poorly written Erlang implementation. I suggest you read the actual blog post that your Google+ post links to, including its comment section and the links posted therein (which is how I arrived at my links): http://www.krazykoding.com/2011/07/scala-actor-v-erlang-gens...

> Is 100 microseconds not short enough for your application?

GC time is not a useful benchmark by itself. The important thing with the JVM is that you can't predictably reason about when the global GC will happen (global GC pause). Your JVM actors aren't shielded from these global GC events so building a soft real-time system is less practical under the JVM than the Erlang VM IMHO.

Re:Introduction to Go 1.1 by trailfox on Thursday March 28, 2013 @05:58AM (#5454001)
The benchmark doesn't "cripple" by de-parallelizing. Execution is already in parallel, it just uses regular collections as the concurrent ones weren't worth the performance overhead and in the end Akka ran 44% faster than Erlang. In the comments you refer to having 50% Erlang is roughly the same as 44%, so I don't thing there is much performance difference even though Java/Scala is faster than Erlang in general.

Regarding soft realtime requirements Erlang may be a better choice, but I doubt there are too many use cases where it will make much difference.

Re:Introduction to Go 1.1 by abraininavat on Tuesday March 26, 2013 @01:03PM (#5444603)
Both of your points apply just as well to Go as they do to JVM/Akka, making JVM/Akka just as serious a contender as Go by those standards.
Re:Introduction to Go 1.1 by davidw on Tuesday March 26, 2013 @06:18AM (#5442211)
Good point; I wonder what kind of memory usage you could squeeze that in to.
Re:Introduction to Go 1.1 by JulianMorrison on Tuesday March 26, 2013 @08:05AM (#5442627)
https://code.google.com/p/jetlang/ is a rather Go-like model, with lightweight processes (optionally backed by a thread pool) and typed channels. Much less functionality than Akka but if you want low memory overhead, it's hard to beat.
Re:Introduction to Go 1.1 by trailfox on Tuesday March 26, 2013 @06:32AM (#5442254)
It should run comfortably on any modern server, might be tricky if you have severe memory constraints though.