I've been looking at akka recently and it's pretty impressive. It looks like it has most of the killer features of erlang - location transparency, supervision hierarchies, and more. Are there any features erlang has that akka doesn't?
5 Answers
Disclaimer: I am the PO for Akka
- Erlang does copy-on-send - Akka uses shared memory (immutable objects) for in-VM sends
- Erlang does per-process GC - Akka uses JVM GCs
- Erlang has OTP - Akka integrates with the entire Java ecosystem (Apache Camel, JAX-RS, etc etc)
- Erlang does the process scheduling for you - Akka allows you to use many different Dispatchers with endless configuration opportunities
- Erlang does hot code reload - Akka can support it, but it's less flexible because of JVM classloading
Those are the ones from the top of my head.
On the other hand, using Akka means that you can use Scala, Java, Groovy or JRuby to write your applications.
-
40Erlang objects are also immutable and the concurrency model does not require copy-on-send within the same node. BEAM for large objects sends a reference. Source: this SO answer by @rvirdig.– FooFMay 19, 2012 at 13:29
-
27Erlang does copy-on-send to make GC more efficient -- it can work in per process basis. This is why there are no huge GC pauses in Erlang apps as opposed to JVM/Akka apps. May 28, 2012 at 5:35
-
4Well, Andrey, that sort of depends on which JVM / GC you're using. azulsystems.com/products/zing/whatisit May 28, 2012 at 12:10
-
5Erlang has a reduction number for each process, even you are in a busy heavy computation loop, Erlang VM can pause the process and let other hungry processes to take more CPU cycles. That's a very important feature that JVM doesnot provide.– DanielJun 4, 2015 at 2:57
-
6@MaX Erlang is often 5x slower than Java because lack of JIT support. But Erlang has no GC pause, it's designed for concurrency and 7*24 telecom applications, Erlang concerns more about process fairness, avoiding starvation and deadlock, it is not designed for throughput like JVM. So, it's really orange and apple.– DanielJun 4, 2015 at 3:01
In Erlang processes are guaranteed to be switched approximately each 1000 reductions. In such a naive framework as Scala/Akka agent owns a scheduler until it finishes work in receive. Checkmate. Game over. Hasta la vista:) People, do not waste your time on pseudo techs. I shocked that guys here compare Scala with Erlang.
Also there are many other so called "killer features", but here is my advice, do not think in terms of features, think about idioms that enables particular language. Scala steals "best features", Erlang enables/implements you with right idioms to build systems reliably, with high level language that driven from those right idioms. When you learn Erlang you are rebuilding your mind, your way of thinking about distributed reliable system, Erlang teaches you and upgrades you. Scala is just another one imperative (oh, sorry, multiparadigmal, funny word) language that tries to steal good features from other languages.
-
10Erlang way of making all IO implicitly asynchronous is very elegant. Async IO can done using NIO APIs in Scala, which doesn't look like check-mate to me, but a less elegant solution.– HRJSep 7, 2011 at 15:16
-
8what in the hell are you talking about?! how is processing 1000 straight tasks better than a roundrobin scheduling, or even near a smallestmailbox scheduling!!– FUDMar 28, 2013 at 4:23
-
8@vjache - I agree. My many years as a java programmer has taught me that you will at some point have to investigate the layer below you. Scala/Akka seems to be just another layer on top of lots of other layers (Eg. nio, netty, etc), all of which you will need to understand at some point. Even though I've only just started working with Erlang, it looks like I will have fewer layers that I need to understand to get the job done. Distributed programming in Erlang feels much lighter weight to Scala/Akka, probably in a similar way that python was the lighter alternative to java for web apps. Nov 30, 2013 at 13:42
-
@FUD: maybe he meant 1000 Erlang instructions? he couldn't have meant 1000 messages... Mar 5, 2014 at 2:19
-
2@ErikAllik He meant 1000 "reductions". Think of a reduction as a token to execute a bit of code (it's not, but it does the job for explaining...). After 1000 reductions, the scheduler switches to a different process. More infos at erlang.org/pipermail/erlang-questions/2001-April/003132.html– AegisAug 28, 2014 at 14:09
Nearly nobody mentions process isolation. Without guarantees of "your thread cannot mess with my junk", distributed systems are much more difficult to reason about. (They're already difficult enough with Erlang's processes.)
AFAIK (which isn't far, given my limited direct experience with the JVM), only Erlang actually gets process isolation "right" on the JVM. Mr. Google can give some hints on where to find research by Fox and Candea (?) on research systems that use a "micro-reboot" technique ("recovery-oriented computing"). An Erlang developer reads that research and says a couple of things:
- Welcome to the club, what took you so long?
- The JVM makes it awfully, awfully hard to join, though. :-)
-
Process isolation is indeed super nice. However, even Erlang isn't immune to a NIF gone awry. Jun 9, 2016 at 9:23
For me, hot code swapping in an entire Erlang cluster without downtime (for example: make:all([netload]) is one of the Erlang killer features.
But let's reverse your question: What does akka have that Erlang doesn't? Of course you can add dozens of extensions and libraries (scala, akka, spring, osgi, ...) to Java to try to come close to Erlang. But where is the point? In sum all these extensions are much more complex than learning the simple Erlang language that now has proven for over 2 decades that it can do the job offering top scalability with zero downtime.
-
32IMO, Scala is a much better language on the syntax level than Erlang. It has objects, traits, proper namespaces, proper type safety, no ugly record syntax, etc. The community is larger, I can use all available Java tools and it just feels more polished.– ryeguyDec 20, 2010 at 16:59
-
17@ryeguy: "better language on the syntax level" ... hmm, define "better" for "syntax". When I compare languages syntax is the most irrelevant factor (because it is only a matter of taste or to what you are used). Dec 20, 2010 at 20:00
-
5
-
3hot code swapping becomes a pain if you need to maintain state between different code versions, in the end it's easier to shutdown the process and migrate state on startup– OlegYchOct 18, 2013 at 11:19
-
4@ryeguy The syntax of a programming language is next to irrelevant; what matters are its semantics. Erlang is a functional PL so of course it doesn't have objects. Traits, type safety etc are due to Scala being a strongly typed language, while Erlang is dynamically typed; that's a design choice. Nevertheless, I would invite you to take a look at Elixir if you want the benefits of Erlang with a more modern feel ;)– AegisAug 28, 2014 at 14:12
Probably Erlang is better for bigger distributed systems (following vjache's answer) but for a normal server when you just want use the full power of multiple CPUs then Akka is good choice— provides good abstraction, performance and integration with the Java ecosystem.