Recent

Author Topic: What is the FASTEST Computer Language? 45 Languages Tested!  (Read 28651 times)

WayneSherman

  • Full Member
  • ***
  • Posts: 119
If you are a speed geek, you will probably be interested in this.

What is the FASTEST Computer Language? 45 Languages Tested! (E01)
https://www.youtube.com/watch?v=tQtFdsEcK_s

Current standings at the time of this video
Iterations per second:

Ada:  67
Pascal: 143
Fastest language: 7301
Slowest language: 1

"HD Episode 01: Retired Microsoft engineer Dave Plummer takes you on a guided tour of 45 different computer languages and drag races each against one another using a prime sieve benchmark.  From Ada to Zig and everything in between, find out which is fastest and which is slowest."

Github:  https://github.com/PlummersSoftwareLLC/Primes

Current Pascal code:  https://github.com/PlummersSoftwareLLC/Primes/tree/drag-race/PrimePascal/solution_1
Current Delphi code:  https://github.com/PlummersSoftwareLLC/Primes/tree/drag-race/PrimeDelphi/solution_1

Pull requests for faster/better implementations:
https://github.com/PlummersSoftwareLLC/Primes/pulls

Related:
https://components4developers.blog/2021/07/04/delphi-sieve-candidates-to-the-fastest-programming-language-contest/

« Last Edit: July 09, 2021, 09:01:47 pm by WayneSherman »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7440
  • Debugger - SynEdit - and more
    • wiki
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #1 on: July 09, 2021, 07:49:16 pm »
Oh no, not again...

We had this topic before.

At best it compares compilers. Not languages.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3257
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #2 on: July 09, 2021, 08:07:19 pm »
Oh FFS! The sieve benchmark was discredited in the mid-80s, because many compilers recognised the computations involved and shortcircuited the computation.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 4921
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #3 on: July 09, 2021, 08:13:12 pm »
Its not the language, its the compiler behind it..

I wish these people would get it correct.

You can use any language and with a good compiler make it the fastest.

Unless we are talking compiling speed? If so that makes no difference since its only done once for the final product.

The only true wisdom is knowing you know nothing

y.ivanov

  • Sr. Member
  • ****
  • Posts: 284
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #4 on: July 09, 2021, 09:10:13 pm »
IMHO, the video and the related GitHub project have a slightly different purpose and the title is misleading. They are rather a lecture on different programming languages. Just look at it all and you will understand what it is about. Not bad at overall.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3257
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #5 on: July 09, 2021, 11:29:43 pm »
IMHO, the video and the related GitHub project have a slightly different purpose and the title is misleading. They are rather a lecture on different programming languages. Just look at it all and you will understand what it is about. Not bad at overall.

In that case please consider my imprecation to be directed at OP who seemed to think that the numbers were significant.

In actual fact I agree that some /languages/ might be slower than others and that it's not just an implementation issue. However a lot depends on whether the programmer insists on using facilities which break all possible compiler optimisations and give the CPU's runtime branch prediction etc. problems.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

WayneSherman

  • Full Member
  • ***
  • Posts: 119
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #6 on: July 10, 2021, 01:19:21 am »
In that case please consider my imprecation to be directed at OP who seemed to think that the numbers were significant.

I did not come up with the title, nor did I comment on the performance numbers (which are from the first episode looking at Pascal, Delphi, and Ada).  In the video, Dave Plummer has a brief discussion of language history and features, and shows what code looks like in each language.  This thing started out as "Software Drag Racing: C++ vs C# vs Python - Which Will Win?" and appears to have taken on a life of its own.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3257
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #7 on: July 31, 2021, 10:56:41 am »
Comparisons are odious, and benchmarks doubly so. However they can at the very least highlight a perception problem.

I've occasionally taken a look at Seed7, which is Pascal-like but simplifies a number of concepts and increases the language flexibility enormously. Using the Montecarlo benchmark at http://seed7.sourceforge.net/benchmks/montecarlo.htm I get a runtime like

Code: [Select]
/usr/local/src/seed7$ s7c -O2 -oc3 sinx2area.s7
SEED7 COMPILER Version 3.1.510 Copyright (c) 1990-2021 Thomas Mertes
Source: sinx2area.s7
Compiling the program ...
Generating code ...
after walk_const_list
740 declarations processed
219 optimizations done
277 evaluations done
14 range checks inserted
107 index checks inserted
96 overflow checks inserted
Calling the C compiler ...
gcc -w -O2 -ffunction-sections -fdata-sections -c tmp_sinx2area.s7.c 2>tmp_sinx2area.s7.cerrs >/dev/null
Calling the linker ...
gcc -Wl\,--strip-debug -Wl\,--gc-sections -o sinx2area.s7_exe tmp_sinx2area.s7.o /usr/local/src/seed7/seed7/bin/s7_data.a /usr/local/src/seed7/seed7/bin/seed7_05.a -lm -ldl 2>tmp_sinx2area.s7.lerrs >/dev/null

/usr/local/src/seed7$ time ./sinx2area.s7_exe
0.8953136

real    0m0.627s
user    0m0.622s
sys     0m0.005s

while with the comparable Pascal program

Code: Pascal  [Select][+][-]
  1. program sinx2area;
  2.  
  3. const
  4.   n= 10000000;
  5.  
  6. var
  7.   x, y: double;
  8.   i: longint;
  9.   num: longint= 0;
  10.  
  11. begin
  12.   Randomize;
  13.   for i := 0 to n - 1 do begin
  14.     x := 2.0 * Random();
  15.     y := Random();
  16.     if y < Sin(x * x) then
  17.       num += 1
  18.   end;
  19.   WriteLn(2.0 * num / n)
  20. end.
  21.  

I get this with different levels of optimisation:

Code: [Select]
/usr/local/src/seed7$ fpc sinx2area.pas
Free Pascal Compiler version 3.2.0 [2020/11/20] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling sinx2area.pas
Linking sinx2area
20 lines compiled, 0.2 sec

/usr/local/src/seed7$ time ./sinx2area
 8.952804208E-01

real    0m1.026s
user    0m1.025s
sys     0m0.000s

/usr/local/src/seed7$ fpc -O1 sinx2area.pas
Free Pascal Compiler version 3.2.0 [2020/11/20] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling sinx2area.pas
Linking sinx2area
20 lines compiled, 0.2 sec

/usr/local/src/seed7$ time ./sinx2area
 8.946775794E-01

real    0m1.064s
user    0m1.013s
sys     0m0.000s

/usr/local/src/seed7$ fpc -O2 sinx2area.pas
Free Pascal Compiler version 3.2.0 [2020/11/20] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling sinx2area.pas
Linking sinx2area
20 lines compiled, 0.2 sec

/usr/local/src/seed7$ time ./sinx2area
 8.946207762E-01

real    0m1.094s
user    0m1.090s
sys     0m0.001s

/usr/local/src/seed7$ fpc -O3 sinx2area.pas
Free Pascal Compiler version 3.2.0 [2020/11/20] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling sinx2area.pas
Linking sinx2area
20 lines compiled, 0.2 sec

/usr/local/src/seed7$ time ./sinx2area
 8.946905732E-01

real    0m1.087s
user    0m1.079s
sys     0m0.004s

/usr/local/src/seed7$ fpc -O4 sinx2area.pas
Free Pascal Compiler version 3.2.0 [2020/11/20] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling sinx2area.pas
Linking sinx2area
20 lines compiled, 0.3 sec

/usr/local/src/seed7$ time ./sinx2area
 8.948547840E-01

real    0m1.067s
user    0m1.067s
sys     0m0.001s

Now I am sure that somebody will point out that there are compiler directives or command-line options that will speed that up, but that's hardly the point.

Here we have two languages, of comparable functionality, and in terms of performance FPC is perceived as inferior.

MarkMLl

Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

fcu

  • Jr. Member
  • **
  • Posts: 70
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #8 on: July 31, 2021, 12:11:03 pm »
something i've experienced with fpc but didn't know how to report it
i've done alots of benchmarks with defernet levels of optimization (-O1..4), the weird thig is all gives the same result 

while on other compilers like gcc / vc you'll find for example -O3 produce much faster code than -O1

jamie

  • Hero Member
  • *****
  • Posts: 4921
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #9 on: July 31, 2021, 03:04:26 pm »
something i've experienced with fpc but didn't know how to report it
i've done alots of benchmarks with defernet levels of optimization (-O1..4), the weird thig is all gives the same result 

while on other compilers like gcc / vc you'll find for example -O3 produce much faster code than -O1

Me Too, I don't seem to see much different if any at all.

I haven't tested recent delphi for this, but my older versions of (D) did without doubt show a different when compiling optimized but they always warned about possible user code in some cases may not work, I never had an issue so I must of not used code that wouldn't work.

 These bench marks are all hocus pocus anyways.. its like meassuring horse power in a car, you have engine and then you have HP at the wheels, both can be misleading.

The only true wisdom is knowing you know nothing

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9600
  • FPC developer.
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #10 on: July 31, 2021, 03:14:41 pm »
Old rule of thumb is that benchmarks that have a small amount of code in a single source file are pointless for the general case.

They might model e.g. codecs or other very localized code, but hardly sizeable applications.

Blade

  • Full Member
  • ***
  • Posts: 142
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #11 on: July 31, 2021, 05:32:47 pm »
If you are a speed geek, you will probably be interested in this.

What is the FASTEST Computer Language? 45 Languages Tested! (E01)

Not interested, and from the start knew it was purposely being deceptive.  I've seen various speed comparisons over the years, and the core behind them is usually a person or group trying to push their pet language(s).  The main trick is to have code optimized for a particular test.  Limit the test to something your pet language and/or compiler does well with.  Of course you come out on or near the top or you bash rival languages that seemingly don't do so well on the specifically preselected test and criteria.  Feign ignorance or completely gaslight whenever rival skilled programmers call the person out on the how and why of their test and criteria selection. 

The key is to trick as many newbies, less knowledgeable people, and members of the media as possible before shutting down and declaring victory.  Let's not forget the trick of click-baiting for views as well.  If you are lucky, your propaganda will be regurgitated and circulated on the internet through 3rd parties for years.

Add to the stinky game, which can be played against various languages, the additional agenda to bash Pascal by rival programming languages.  Usually because they don't like non C family languages or they have a corporate agenda in play.

When a person talks about the speed of their language, the push back should be for what purpose?  Speed is always relative to what you are doing and your needs.  In fact, on the list of reasons why you are using a particular language for a specific purpose, speed might be several spots removed from the top of the list.  A lot depends on what you are doing.
« Last Edit: July 31, 2021, 05:45:29 pm by Blade »

MarkMLl

  • Hero Member
  • *****
  • Posts: 3257
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #12 on: July 31, 2021, 06:12:28 pm »
Old rule of thumb is that benchmarks that have a small amount of code in a single source file are pointless for the general case.

They might model e.g. codecs or other very localized code, but hardly sizeable applications.

Undoubtedly. But we're not talking about a mere couple of percent here, and with the demise of Delphi as a standard bearer this is enough to affect the perception of Pascal as a whole.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

BobDog

  • Full Member
  • ***
  • Posts: 141
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #13 on: July 31, 2021, 06:53:29 pm »
Comparisons are odious, and benchmarks doubly so. However they can at the very least highlight a perception problem.

. . .
. . .

while with the comparable Pascal program

Code: Pascal  [Select][+][-]
  1. program sinx2area;
  2.  
  3. const
  4.   n= 10000000;
  5.  
  6. var
  7.   x, y: double;
  8.   i: longint;
  9.   num: longint= 0;
  10.  
  11. begin
  12.   Randomize;
  13.   for i := 0 to n - 1 do begin
  14.     x := 2.0 * Random();
  15.     y := Random();
  16.     if y < Sin(x * x) then
  17.       num += 1
  18.   end;
  19.   WriteLn(2.0 * num / n)
  20. end.
  21.  


with version 3.2.2 (and 3.2.0) num+=1 is not allowed.
You should use num:=num+1;
perhaps there is a switch to enable +=, but you have not provided it.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9600
  • FPC developer.
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #14 on: July 31, 2021, 07:05:01 pm »
Undoubtedly. But we're not talking about a mere couple of percent here, and with the demise of Delphi as a standard bearer this is enough to affect the perception of Pascal as a whole.

IMHO you are fanning that wrong perception by creating dramatic threads about it. Don't adopt their narrative, but create an own narrative that is suitable to Pascal. Show apps and producitivty.
« Last Edit: July 31, 2021, 07:35:53 pm by marcov »

 

TinyPortal © 2005-2018