You are on page 1of 3

CMPT376: Assignment3 Final

Naoya Makino 301117541


nmakino@sfu.ca
March 29, 2010

Knowing you are an Erlang enthusiast, you told me a couple of times that Erlang
is the best language out there; it increases your productivity, gives you a path towards
concurrent programming, and makes non-stop applications much easier to write. Then
that conversation made me think about Erlang and my favorite language: C++. I
discovered Computer Language Benchmarks Game, and I made comparisons between
Erlang and C++. Hopefully this comparison makes you rethink about other languages and
try out C++ next time.

According to this benchmarks game, C++ is substantially faster than Erlang in all
benchmarks and use less memory. Giving CPU, memory, and code size equal weight, for
example, C++ is 40 times faster than Erlang in reverse-complement and 22 times faster in
k-nucleotide. Other nine benchmarks also show that C++ performs faster than Erlang, in
average of 11 times. In terms of memory-use, C++ also consumes smaller, in average of
1/6 times, than Erlang. For the case of mandelbrot, C++ uses memory 21 times smaller
than Erlang. This concludes that C++ performs much faster than Erlang and consumes
less memory. If you want to see faster performance in relatively limited memory
situation, then you can take the advantage of C++ and realize much faster performance. I
am talking about 10 times faster than Erlang in many situations, so it is worth
considering. The following table summarizes all the points I made above and shows “how
much the fastest C++ GNU g++ program used compared to the fastest Erlang HiPE
program” [1].

(Table 1, [1])

In regard to this benchmark games, C++ has one limiting feature: a code size.
Taking the average of 11 benchmarks, C++ is twice as big as Erlang in code size; in the
CMPT376: Assignment3 Final
Naoya Makino 301117541
nmakino@sfu.ca
March 29, 2010

worst case (k-nucleotide), C++ takes four times bigger than Erlang. This is considerable
if you are implementing relatively large programs.
Another benchmark result gives us an interesting point. When I compare all major
programming languages (a list available here) in all 11 benchmarks, C++ is the second-
ranked language, only 1.1 times slower than C GNU gcc (the top-ranked language) while
Erlang is 18th, about 11 times slower than C++. In addition, when you look at the slowest
performance of C++ and Erlang, C++ is only three times slower than the fastest programs
in C (the best ranked language), while Erlang is 40 times slower. That is, Erlang has a
wide range of performance depending on what programs you are running, while C++
performs in much tighter range, faster. Therefore, you should pay a special attention
when you are writing in Erlang as it ranges widely, resulting in noticeable performance
slow down. The table 2 shows one comparison – time used (elapsed time) – for all
benchmarks, numbered 1.00 as the fastest programming language (C GNU gcc).

Languages |- |--- 25% Median 75% ---| -|


C++ GNU g++ 1.00 1.00 1.01 1.11 1.81 3.01 3.01
Erlang Hipe 2.81 2.81 5.79 12.62 20.94 40.25 40.25
(Table 2, [2])

Comparing C++ and Erlang using these benchmarks, I would like to make few
notes regarding the credibility. These results of benchmarks might be specific to the
programs written. In fact, these benchmarks are relatively small programs; C++ has an
advantage over Erlang which is suitable for more complex and concurrent systems; these
benchmarks do not give you advantages of Erlang: distributed, reliable, and soft real-time
concurrent systems. If you are wondering how the programs are measured, the site gives
you a detailed summary of how they do it (Link). As long as I concern, these
measurements are fair enough, giving us a good comparison with other programming
languages. I made a comparison on Ubuntu single-core, 32-bit systems, and this is
measured giving CPU, memory, and code size equal weight. Thus, this should not affect
the performance of the languages.

After all, these comparisons are to show you how other programming languages,
C++ in this case, could benefit you and improve your productivity. I hope this gives you
good insights of C++ and makes you try it out. I am looking forward to having another
language talk with you.

Cheers

Naoya
CMPT376: Assignment3 Final
Naoya Makino 301117541
nmakino@sfu.ca
March 29, 2010

Reference:

[1] "C++ GNU g++ speed ÷ Erlang HiPE speed" Computer Language Benchmarks
Game. March 27 2010
<http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=gpp&lang2=hipe>

[2] "Which programming languages are fastest?" Computer Language Benchmarks


Game. March 27 2010
<http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=all>

You might also like