22

I've been putting time into learning functional programming and I've come to the part where I want to start writing a project instead of just dabbling in tutorials/examples.

While doing my research, I've found that Erlang seems to be a pretty powerful when it comes to writing concurrent software (which is my goal), but resources and tools for development aren't as mature as Microsoft development products.

F# can run on linux (Mono) so that requirement is met, but while looking around on the internet I cannot find any comparisons of F# vs Erlang. Right now, I am leaning towards Erlang just because it seems to have the most press, but I am curious if there is really any performance difference between the two systems.

Since I am used to developing in .NET, I can probably get up to speed with F# a lot faster than Erlang, but I cannot find any resource to convince me that F# is just as scalable as Erlang.

I am most interested in simulation, which is going to be firing a lot of quickly processed messages to persistent nodes.

If I have not done a good job with what I am trying to ask, please ask for more verification.

19
  • 13
    Languages don't have speed. Specific language implementations running a specific program on a specific input (this may include the whole outside world, depending on the program) have a speed.
    – user7043
    Dec 4, 2011 at 16:43
  • 1
    F# runs on the .NET runtime and Erlang runs on its own VM. Erlang's processes are considered to be lightweight vs languages that are in its domain (like Scala). For a simulation spawning nodes and passing a lot of messages, is the .NET/Mono runtime just as good as Erlang's VM or is Erlang's VM superior? Dec 4, 2011 at 16:45
  • 3
    @delnan: Languages do have performance characteristics.
    – J D
    Feb 23, 2012 at 14:05
  • 2
    @JonHarrop How so? A programming language is merely some syntax and associated semantics.
    – user7043
    Feb 23, 2012 at 14:08
  • 1
    @delnan: Semantics place limitations on optimization. For example, dynamically-typed languages are prohibitively difficult to optimize in practice. The lack of value types on the JVM results in a lot more heap allocation than on .NET and, consequently, much greater stress on the GC. Like code generators, garbage collectors can and do exploit information like immutability in order to improve performance. The design of a programming language has a huge effect on this.
    – J D
    Feb 24, 2012 at 11:22

3 Answers 3

23

What do you mean by "viable?" "Having the most press" is not necessarily the best way to choose a language.

Erlang's claim to fame is its capability of massive parallelization. That's why it's commonly used in Ericsson phone switches. Erlang is soft-realtime, so you can make certain performance guarantees about it.

F# benefits from the optimization capabilities of the .NET Jitter. In addition, the language itself is designed to be a high-performing functional language (it being a variant of OCaml, widely used in the financial industry because of its speed).

Ultimately, unless you plan on running millions of tiny agents at the same time (which is what Erlang is optimized for), F# should be up to the task.

This page explains the appropriate use cases for Erlang.

12
  • By "viable" I meant scalable. I know that having press doesn't mean that that language in necessarily better, but it seems that Erlang has been proven (at least by Ericsson). What do you mean by agents? Processes? Dec 4, 2011 at 16:55
  • 1
    Yes. Erlang has been proven to handle many phone calls on an Ericsson switch at the same time. You have to figure out if your use case is similar. I see that as a relatively specialized use case; if this characteristic is absent in your application, I don't see any advantage to using Erlang, and the Erlang page actually describes some use cases for which Erlang is not suitable. Dec 4, 2011 at 16:59
  • 2
    Agents, actors, it's a design concept that comes up a lot in functional language discussions; I'm surprised that you haven't run across it yet. en.wikipedia.org/wiki/Agent-based_model Dec 4, 2011 at 17:02
  • In other words, do you need massive scalability (either now or eventually) of the kind Erlang provides? Most programs do not. Dec 4, 2011 at 17:02
  • 1
    F# also has the agent model - using the slightly cryptically named 'MailboxProcessor' which is the same sort of thing as in Erlang. I can't comment on the relative performance characteristics of each though.
    – FinnNk
    Dec 4, 2011 at 18:15
8

Few objective statements can be made on this subject because the performance of these two languages is strongly dependent upon the application and programming style.

The only advice I can give is that F# has the performance advantage of a static type system and the CLR does a good job leveraging this in order to improve performance. F# does have asynchronous agents and message passing but it has not been optimized and synchronous code is often over 10× faster.

Erlang is dynamically typed which puts its at a significant disadvantage in terms of performance (expect a lot more boxing) but it was built from the ground up to support fast message passing between asynchronous agents so that may well be a lot faster than the equivalent F#. However, I have no benchmark results to back this up: it is just my expectation.

As an aside, both Erlang and F# are relatively fringe languages with small communities and, due to their different target markets, people familiar with both are rare. The only person I can think of who nearly qualifies is Jesper Louis Andersen but I'm not sure how much F# he has done.

6

You should read this post by Joe Armstrong: http://erlang.org/pipermail/erlang-questions/2012-February/064277.html

The short of it is that Erlang was not designed to be fast! It is reasonably fast in many cases but that is secondary to issues like fault tolerance and stability.

The truth is both Erlang and F# are nice languages, and while I have only taken a quick look at F# I have written a book on Erlang: Building Web Applications With Erlang and I can say that it is a fun language to work in.

I would also point out that there seems to be a boom in functional language books to be published in the next 6-9 months. I know of at least 4 on Erlang (including mine), One on Haskell, as well as Titles on OCaml, Clojure and F#.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.