Recent

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

WayneSherman

  • Full Member
  • ***
  • Posts: 243
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: 9791
  • 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: 6676
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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

alpine

  • Hero Member
  • *****
  • Posts: 1038
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #3 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.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #4 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & 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: 243
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #5 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: 6676
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #6 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

MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & 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: 89
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #7 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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #8 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: 177
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #9 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: 6676
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #10 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & 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

  • Sr. Member
  • ****
  • Posts: 394
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #11 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: 11382
  • FPC developer.
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #12 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 »

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #13 on: July 31, 2021, 07:31:41 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.

Hello.
This needs mode objfpc or objdelphi to work.
Just add this at begin (or compile with -Mobjfpc).
Code: Pascal  [Select][+][-]
  1. program sinx2area;
  2. {$mode objfpc}{$H+}
  3. ...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: What is the FASTEST Computer Language? 45 Languages Tested!
« Reply #14 on: July 31, 2021, 07:46:02 pm »
This needs mode objfpc or objdelphi to work.

Or passing -Sc option to the compiler.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018