News for hackers. Stuff that matters.
Re:Ask HN: Why isn't Erlang more popular? by Nogwater on Friday February 21, 2014 @12:22PM (#7278024)
Not knowing enough about Erlang/OTP or Go: Would it be possible for more of OTP to be replicated in a Go 2.0? What's missing? What would it take? What can never be replicated?
Re:Ask HN: Why isn't Erlang more popular? by jerf on Friday February 21, 2014 @12:41PM (#7278157)
You can recover a substantial portion, but there's a few things you can't quite get back. Since Go is a mutable-state language, and also a shared-state language (isolation is by convention, not by language design), you have to live with the consequences of that. In my supervisor tree implementation, the restart of a monitored goroutine is just to fire off a new goroutine on the exact same object again; if you still have bad state lying around and immediately crash again, well, too bad, the supervisor can't do anything about that. (Except not thrash the processor with endless restarts.) In contrast, when an Erlang supervisor restarts a process, it is guaranteed to be a fresh process with no shared state from the one that just crashed. It's much more likely to not immediately crash.

(I fiddled with having the user specify a closure that is supposed to "create" a new object for the restart, but then simplified that away when I realized that the closure itself could well have mutable state too. Better just to stick with the simpler interface and document the consequences of failing to clean out state at the beginning of your monitored code. On the plus side, so far the interface for the supervised-things is "Serve()" and "Stop()", and nothing else; hard to argue with that level of simplicity!)

You also won't ever be able to recover live code restarts; you can try to transfer all state to a new process, including file handles, but that's a lot of implementation work. (I'm stuck right now on the fact that my connections are encrypted, and the encryption code won't let me even get to the state, let alone transfer and reconstitute it somewhere else. Someone's got some code for moving file handles around on GitHub but I can't seem to Google it up.) Most people already live in a world where live restarts are difficult or impossible, though, so they won't miss that. Getting a REPL into a live Go server is impossible, at least with Go itself, and will also probably never be as clean as Erlang. (Go "2.0" could fix that with an official Go interpreter, which is the missing bit. I can handle the sockets, I can bind readline and give you a nicer REPL, but interpreting Go is a challenge. Progress is being made, I believe as part of the new compiler implementation, but I'm not sure anyone has this as an explicit goal.) Again, most people live in a world where they already don't have a REPL into their running code, and therefore won't miss this.

There's also some more subtle semantic differences, but I'm saving that for a blog post. (It gets long, especially if I first have to explain Erlang, which is what the blog post does.)

Re:Ask HN: Why isn't Erlang more popular? by mononcqc on Friday February 21, 2014 @04:08PM (#7279449)
I'd have to say your idea of supervisors misses the point.

Supervised processes provide guarantees in their initialization phase, not a best effort. This means that they are always restarted to a known stable state. It's not just a question of retrying, it's a question of returning to a piece of data and environment that is reliable. I wrote on this more in details at http://ferd.ca/it-s-about-the-guarantees.html

If you reuse the same exact object again that can be modified, you lose these guarantees entirely, and it becomes a question of convention and attention to detail rather than something provided for you.

The REPL is a vital part of my every day Erlang experience. I can't imagine living without one when things get tricky in production and that pre-built tools aren't enough. Being able to poke around and inspect everything while it runs is great.

Re:Ask HN: Why isn't Erlang more popular? by jerf on Friday February 21, 2014 @07:56PM (#7280490)
"I'd have to say your idea of supervisors misses the point."

I think it's unfair to explain how I "missed the point" to me when I'm the one who brought it to your attention in the first place, when I called it out explicitly as a weakness, in the context of a post explaining how OTP can not be completely ported into Go without loss. I did after all explain in a parenthetical that I tried to fix it, realized the fix wasn't really a fix, and decided just to go simple and idiomatic after that.

The thing is, while it is sad that we lose that characteristic of supervisors, there are still other useful characteristics: Sensible restarts; naive restart code has a lot of pathological cases. I rather expect my library to ship with a couple at first too, but we (yay open source) can fix it in one place, once. Composition of supervisors is a great way to build applications, with self-contained pieces; the whole "hierarchy" still applies, though I find with the elimination of the restart strategies it gets a lot simpler, for better and for worse. It's still nice to be able to build code and easily slot it into a management system, even if it can't quite be as powerful.

A complete translation is impossible, but an idiomatic one may be, and I'm already finding it useful even in my little coding efforts.

As for the REPL... yes, that is an unmitigated loss, no question. I'm mitigating it in my personal app with a lot more flexible logging and some more external controls, but there is no true replacement for a REPL. Though... we may get a REPL someday, it just may be either a mere subdialect of Go or a separate scripting language. I've resisted putting a dependency on one of the very young Go scripting languages in my project, but theoretically in another year or two this might at least be mitigated.

Re:Ask HN: Why isn't Erlang more popular? by mononcqc on Friday February 21, 2014 @11:36PM (#7280993)
Fair enough.
Re:Ask HN: Why isn't Erlang more popular? by pjungwir on Friday February 21, 2014 @05:17PM (#7279831)
It is funny to me that Erlang combines unique tools for application stability with the ability to edit stuff online in production. I'm not saying I never launch a production Rails console, but seeing that in Erlang is a weird juxtaposition. I'd love to understand better how those fit together comfortably in an Erlanger's world view.
Re:Ask HN: Why isn't Erlang more popular? by uwiger on Saturday February 22, 2014 @08:14AM (#7281967)
In practice, one will have to refrain from some of the crazier stuff when working interactively in the shell of a production system. However, it's extremely useful for debugging and minor adjustments by a skilled engineer. Things you can do include inspection of data structures, (very) careful tracing, loading of instrumented modules or minor corrections.

Since Erlang is dynamically typed, practically all data structures can be inspected at run-time, and one particularly nice thing about the Erlang shell is that it tends to be responsive even when the system is operating at near-maximum load.

Re:Ask HN: Why isn't Erlang more popular? by neuroscr on Saturday February 22, 2014 @04:35AM (#7281559)
>Someone's got some code for moving file handles around on GitHub but I can't seem to Google it up:

https://github.com/sharvil/flingfd

Re:Ask HN: Why isn't Erlang more popular? by mh- on Friday February 21, 2014 @03:30PM (#7279209)
really looking forward to that blog post. I clicked to your github profile in your other comment upthread, but realized I was already following you there after seeing gomempool. :)
Re:Ask HN: Why isn't Erlang more popular? by waffle_ss on Friday February 21, 2014 @12:54PM (#7278255)
Besides the issues that jerf mentioned, Erlang also has per-process garbage collection built right into the VM. Last time I checked Go's garbage collection was still stop-the-world, mark-and-sweep, making it less suitable for soft real-time systems than Erlang.
Re:Ask HN: Why isn't Erlang more popular? by jerf on Friday February 21, 2014 @01:25PM (#7278459)
"Go 2.0" probably can't ever quite fix that, but there's some potential for improvement; one can imagine as an optimization the compiler being able to determine a particular goroutine really is isolated (no shared state with anything else at start time, communicates only via channels that are full copiers of state, etc.) and independently GC's them, and also excludes them from the "stop" in the "stop the world". But yes, it is stop-the-world, and I'm keeping a close eye on the GC performance in the app I'm transitioning. (So far the numbers are working out OK, but it's definitely in the range I have to watch out.)
Re:Ask HN: Why isn't Erlang more popular? by waffle_ss on Friday February 21, 2014 @01:41PM (#7278566)
Yeah I don't doubt there are some smart people out there that could make something like that happen (look at Azul and their pauseless GC for the JVM for example). However, it will be a tough fix when compared to the simple/pure approach Erlang takes.
Re:Ask HN: Why isn't Erlang more popular? by erichocean on Friday February 21, 2014 @02:40PM (#7278953)
For the life of me, I cannot understand why Oracle hasn't bought Azul and made it available to all, for free.

Azul only works well on multi-processor machines with LOTS of RAM, but when it does, it beats everything else out there by a mile. You'd think Oracle would want that.

Re:Ask HN: Why isn't Erlang more popular? by voidlogic on Saturday February 22, 2014 @09:39AM (#7282146)
The Go situation is changing:

runtime: concurrent GC sweep Moves sweep phase out of stoptheworld by adding background sweeper goroutine and lazy on-demand sweeping.

https://codereview.appspot.com/46430043/

Re:Ask HN: Why isn't Erlang more popular? by seiji on Friday February 21, 2014 @12:28PM (#7278067)
Erlang is like Lisp in that once you build a language up to a level of "reliable disturbed system language," you've basically re-implemented Erlang.
Re:Ask HN: Why isn't Erlang more popular? by limmeau on Friday February 21, 2014 @02:36PM (#7278926)
Is "disturbed system" intentional? Nice term for a bunch of processes which are expected to die occasionally.