Most every language has a sweet spot, something it does better than any other language around it.
C and C++ are really good for writing console video games because of its speed, portability, and deterministic finalization. Perl is really good at string manipulation. Java has a gazillion OSS frameworks and application servers. Ruby is damn pretty and has a couple of really super productive web frameworks.
Erlang has a very succinct and elegant syntax, a syntax that is highly optimized for writing recursive functions. One could argue that’s just a property of being a functional language, but I think there’s more too it than just being functional.
C# 3 has a decent functional syntax that is clearly more succinct than Java or C# 2, but it just doesn’t stack up to Erlang.
Warning: don’t use these code samples in production code! They use Ω(n) extra storage space and are toy functions.
For example, take this Erlang quick sort function:
qsort([]) -> [];
qsort([Pivot|T]) ->
qsort([X || X <- T, X < Pivot])
++ [Pivot] ++
qsort([X || X <- T, X >= Pivot]).
That is, IMO, beautiful code. Small, compact, succinct, powerful, readable. On the other hand, what does a comparable implementation look like in C# 3?
static IEnumerable<int> Qsort(IEnumerable<int> list)
{
if (list.Count() <= 1)
return list;
int pivot = list.First();
var tail = list.Skip(1).Take(list.Count() - 1);
var result = new List<int>();
result.AddRange(Qsort(tail.Where(o => o < pivot)));
result.Add(pivot);
result.AddRange(Qsort(tail.Where(o => o >= pivot)));
return result;
}
It works, it doesn’t contain any loops and only one if statement (the initial C# 2 version was even longer and uglier), but its still very much lacking in the beautiful code department. Did you also notice it was more than twice as long as the Erlang function? Perhaps you can improve the syntax?
I don’t have numbers to prove this, but the Erlang implementation can also be made faster with a lot less effort since each recursive call can be run in parallel. Try that in C# without writing extra threading code. Even if you did, your threads are probably going to be a lot slower than the light weight threads in Erlang.
Recursive functions in Erlang are definitely a sweet spot.