Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 languages.

Since I am use 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 persistant nodes.

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

share|improve this question
10  
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. –  delnan Dec 4 '11 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? –  afuzzyllama Dec 4 '11 at 16:45
3  
@delnan: Languages do have performance characteristics. –  Jon Harrop Feb 23 '12 at 14:05
2  
@JonHarrop How so? A programming language is merely some syntax and associated semantics. –  delnan Feb 23 '12 at 14:08
1  
@Ubermensch: The Feynmann diagrams work was by Dr Thomas Fischbacher, IIRC. FFTW is primarily OCaml source code that generates C code (which is often distributed to avoid the dependency on OCaml). Many people often use FP to mean extensive use of higher-order functions rather than purity (controlled side-effects). That kind of FP has many uses in number crunching and is even seen in Fortran. Purity is less useful there for the reasons you gave. –  Jon Harrop Feb 24 '12 at 13:53
show 15 more comments

3 Answers

up vote 13 down vote accepted

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.

share|improve this answer
    
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? –  afuzzyllama Dec 4 '11 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. –  Robert Harvey Dec 4 '11 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 –  Patrick Hughes Dec 4 '11 at 17:02
    
In other words, do you need massive scalability (either now or eventually) of the kind Erlang provides? Most programs do not. –  Robert Harvey Dec 4 '11 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 '11 at 18:15
show 5 more comments

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.

share|improve this answer
add comment

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#.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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