Lazarus

Programming => General => Topic started by: WayneSherman on July 09, 2021, 07:34:11 pm

Title: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: WayneSherman on July 09, 2021, 07:34:11 pm
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/

Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Martin_fr on July 09, 2021, 07:49:16 pm
Oh no, not again...

We had this topic before.

At best it compares compilers. Not languages.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl 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
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: alpine 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.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl 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
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: WayneSherman 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? (https://www.youtube.com/watch?v=D3h62rgewZM)" and appears to have taken on a life of its own.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl 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

Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: fcu 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
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov 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.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Blade 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.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl 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
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: BobDog 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.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov 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.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Fred vS 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. ...
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: lucamar on July 31, 2021, 07:46:02 pm
This needs mode objfpc or objdelphi to work.

Or passing -Sc option to the compiler.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on July 31, 2021, 07:50:11 pm
This needs mode objfpc or objdelphi to work.

Or passing -Sc option to the compiler.

That's strange, since the program as I gave it didn't originally need anything like that... and I did supply the commandlines etc. that I was using.

Does 3.2 change the default?

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Fred vS on July 31, 2021, 08:01:11 pm
This needs mode objfpc or objdelphi to work.

Or passing -Sc option to the compiler.

That's strange, since the program as I gave it didn't originally need anything like that... and I did supply the commandlines etc. that I was using.

Does 3.2 change the default?

MarkMLl

Huh, I just tested your program without change and compile it with fpc 3.2.0.:

Code: Bash  [Select][+][-]
  1. $ fpc sinx2area.pas

 and indeed it compiles without problems.
So sorry for my post, it is not relevant.

@ BobDog, here on Linux 64 with fpc 3.2.0 it works without any change.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on July 31, 2021, 10:05:12 pm
So sorry for my post, it is not relevant.

@ BobDog, here on Linux 64 with fpc 3.2.0 it works without any change.

No apology needed from you, I assure you.

MarkMLl
Title: Re: What is the FASTEST Human Language? 45 Languages Tested!
Post by: Kays on July 31, 2021, 10:17:56 pm
[…]
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.
Yes, there is a compiler switch called {$cOperators} (https://freepascal.org/docs-html/current/prog/progsu10.html). By default it’s off, but in the standard fpc.cfg(5) located at /etc/fpc.cfg there is a line
Code: Bash  [Select][+][-]
  1. # Allow goto, inline, C-operators, C-vars
  2. -Sgic

[…] Or passing -Sc option to the compiler.
That's strange, since the program as I gave it didn't originally need anything like that... and I did supply the commandlines etc. that I was using.

Does 3.2 change the default? […]
No. Confer another thread on C-style assignments from earlier this month:
COperators Off is the default as far as the compiler is concerned. The fpc.cfg includes the -Sc. Also this will not change due to backwards compatibility.
Title: Re: What is the FASTEST Human Language? 45 Languages Tested!
Post by: MarkMLl on July 31, 2021, 10:31:22 pm
No. Confer another thread on C-style assignments from earlier this month:
COperators Off is the default as far as the compiler is concerned. The fpc.cfg includes the -Sc. Also this will not change due to backwards compatibility.

Definitely something that I've not changed in my fpc.cfg, but it was originally created in 2015 so the installation default might have changed since then.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: winni on August 01, 2021, 12:22:25 am
Hi!

In the deep jungle of my backups I found:

fpc 2.4.2:   -Sc off by default in fpc.cfg
fpc 2.6.0:   -Sc off by default in fpc.cfg


Winni


PS: Both 2012
Title: Re: What is the FASTEST Human Language? 45 Languages Tested!
Post by: Fred vS on August 01, 2021, 12:38:49 am
By default it’s off, but in the standard fpc.cfg(5) located at /etc/fpc.cfg there is a line:

Ha, ok, indeed, in my fpc.cfg there is:

Code: Pascal  [Select][+][-]
  1. # Allow goto, inline, C-operators, C-vars
  2. -Sgic

Thanks for the tip.

Fre;D
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: PascalDragon on August 01, 2021, 12:32:42 pm
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.

And do they document which PRNG they use? FPC's Random is documented to be a Mersenne Twister (though the generated sequence is not guaranteed to be that of a raw MT) and MTs are known to be on the slower side of things. So maybe right here you're comparing the performance of one PRNG to another instead of compiler A to compiler B.

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.

C operators are enabled by default in the default configuration file.

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

Development of optimizations is a work-in-progress. Also in general only code will benifit that does fit the corresponding optimization requirements (e.g. global variables will never benefit from regvar optimizations, cause global variables are by definition volatile).
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 01, 2021, 03:18:39 pm
And do they document which PRNG they use? FPC's Random is documented to be a Mersenne Twister (though the generated sequence is not guaranteed to be that of a raw MT) and MTs are known to be on the slower side of things. So maybe right here you're comparing the performance of one PRNG to another instead of compiler A to compiler B.

Absolutely fair observation. As it happens I found an example on the Rosetta Code website yesterday evening which has variants for both Pascal and Seed7:

Code: Pascal  [Select][+][-]
  1. program GMP_Demo;
  2.  
  3. uses
  4.   math, gmp;
  5.  
  6. var
  7.   a:   mpz_t;
  8.   out: pchar;
  9.   len: longint;
  10.   i:   longint;
  11.  
  12. begin
  13.   mpz_init_set_ui(a, 5);
  14.   mpz_pow_ui(a, a, 4 ** (3 ** 2));
  15.   len := mpz_sizeinbase(a, 10);
  16.   writeln('GMP says size is: ', len);
  17.   out := mpz_get_str(NIL, 10, a);
  18.   writeln('Actual size is:   ', length(out));
  19.   write('Digits: ');
  20.   for i := 0 to 19 do
  21.     write(out[i]);
  22.   write ('...');
  23.   for i := len - 20 to len do
  24.     write(out[i]);
  25.   writeln;
  26. end.
  27.  
  28. ~$ time ./GMP_Demo
  29. GMP says size is: 183231
  30. Actual size is:   183231
  31. Digits: 62060698786608744707...92256259918212890625
  32.  
  33. real    0m0.032s
  34. user    0m0.027s
  35. sys     0m0.004s
  36.  

Code: [Select]
$ include "seed7_05.s7i";
  include "bigint.s7i";
 
const proc: main is func
  local
    var bigInteger: fiveToThePowerOf262144 is 5_ ** 4 ** 3 ** 2;
    var string: numberAsString is str(fiveToThePowerOf262144);
  begin
    writeln("5**4**3**2 = " <& numberAsString[..20] <&
            "..." <& numberAsString[length(numberAsString) - 19 ..]);
    writeln("decimal digits: " <& length(numberAsString));
  end func;

~$ time ./GMP_Demo.s7_exe
5**4**3**2 = 62060698786608744707...92256259918212890625
decimal digits: 183231

real    0m0.003s
user    0m0.000s
sys     0m0.004s

I don't, unfortunately, have time to go hunting for or transcribing larger programs to see how they behave. However- and please understand that I'm not trying to be negative here, just concerned- I feel that the fact that there appears to be such a difference in underlying performance is something that can't be evaded by saying "but look at all the great stuff that we've built on top of it!".

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 03, 2021, 03:23:20 pm
As an experiment, I've just written a little program which brute-forces the modular multiplicative inverse for a few million numbers, and find that it shows FPC in a far more favourable light (roughly 32 secs rather than Seed7's 50ish). In addition FPC was far easier to work with since its reporting of bad syntax was far more sensible, and by default it has more datatypes (e.g. Seed7 only supports 64-bit integers).

So while I think that some of the other results might have been "interesting curios" and while the "cut-down-but-extensible" nature of Seed7 is definitely interesting, I happily apologise to anybody who thought I was being alarmist or spreading FUD.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov on August 03, 2021, 04:04:00 pm
I know seed from 10-15 years back when Mertens was a regular in comp.lang.misc. It was really the meta programming and not fixating any rule for a language that seemed to be interesting to him.

Note that the seed7 "compiler" compiles to C, so you are probably effectively comparing codegeneration to gcc.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 03, 2021, 04:53:37 pm
I know seed from 10-15 years back when Mertens was a regular in comp.lang.misc. It was really the meta programming and not fixating any rule for a language that seemed to be interesting to him.

Which interests me as well. One of the things I've found most difficult is getting sensible listings after the basic syntax has been augmented by imported modules... and then of course rolling back anything which should be strictly local.

Quote
Note that the seed7 "compiler" compiles to C, so you are probably effectively comparing codegeneration to gcc.

Yes. Hence I was wondering whether when GCC recompiled a program plus all imports it was managing to eliminate stackframes etc. to a far greater extent than FPC can manage with precompiled libraries and units.

Obviously the separate compilation feature of FPC makes overall compilation far faster.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov on August 03, 2021, 05:13:56 pm
Yes. Hence I was wondering whether when GCC recompiled a program plus all imports it was managing to eliminate stackframes etc. to a far greater extent than FPC can manage with precompiled libraries and units.

GCC has much more elaborate LTO probably than FPC has, but I doubt that is enabled by default. It usually requires multiple compile passes.

I think it can simply optimize a single file more. But as said, such one file math benchmarks are extremely atypical of normal programming. Most code calls non local functions/methods in most of its functions/methods.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Blade on August 13, 2021, 06:25:02 pm
I'm surprised nobody has mentioned the website, benchmarksgame.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html

They have been claiming to show "Which programming language is fastest?", for years now.  At least they have a wider range of tests.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: mercurhyo on August 13, 2021, 10:52:15 pm
well let me laugh about speed. It only belongs to the "driver" on cars and on compilers.

If someone is used to drive a ferrari this someone will push the limits of a skoda car
if someone is used to drive a skoda this someone will never ever push the limits of a ferrari

in compilers world it's exactly the same

enjoy
 :P :D

SO NO site nor benchmurk are impartial and never will be. conjectures are kings of nonsense right?
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: rsz on August 13, 2021, 11:39:56 pm
On the benchmarks game website, take a look at Free Pascal n-body (https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-fpascal-1.html) vs GCC C++ n-body (https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-gpp-0.html), the C++ one has manual SIMD intrinsics. Some benchmarks also compare single threaded to multi threaded.

The results should not be taken at face value without reading the source of both programs, but I doubt anyone who is looking to decide on a language or looking for some quick numbers will actually read the source.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: mercurhyo on August 14, 2021, 01:36:00 am
https://www.youtube.com/watch?v=HWpi9n2H3kE (https://www.youtube.com/watch?v=HWpi9n2H3kE)

ALL compilers end to build machine code. so if the programmer knows machine code concepts and specific compiler tricks to achieve better machine code then ANY BENCHMURK is JUST CRAP and waste of time. this is true for DECADES.... any compiler no matter the language
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: BeniBela on August 14, 2021, 01:59:50 am
Or this: https://greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf

Looks like all the fastest languages  have an LLVM version

Even Intel just moved their compiler to LLVM. If Intel does not have the resources to maintain the optimizations necessary for a fast compiler, it is hopeless for FPC. If FPC wants to be the fastest language, the LLVM mode should be the default
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MathMan on August 14, 2021, 01:39:21 pm
Or this: https://greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf

Looks like all the fastest languages  have an LLVM version

Even Intel just moved their compiler to LLVM. If Intel does not have the resources to maintain the optimizations necessary for a fast compiler, it is hopeless for FPC. If FPC wants to be the fastest language, the LLVM mode should be the default

Hm, looking at table 5 of said report one could also come to the conclusion that Pascal is the second best language after C when considering the trinity of execution speed, memory and energy consumption. I couldn't identify the actual Pascal compiler used (but I only x-read the report) - however I do pass this result to the core dev team of Free Pascal with great respect.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 14, 2021, 02:00:51 pm
Or this: https://greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf

Looks like all the fastest languages  have an LLVM version

Even Intel just moved their compiler to LLVM. If Intel does not have the resources to maintain the optimizations necessary for a fast compiler, it is hopeless for FPC. If FPC wants to be the fastest language, the LLVM mode should be the default

What is the LLVM overhead in terms of files etc.? At present an FPC compiler is defined by a single file in (e.g.) /usr/local/bin which knows where to find the associated backend files: I'm concerned that relying on LLVM might change that and it would risk an almighty mess of different LLVM versions and variants brought in by the basic OS and user-installed development tools.

Apart from that, I believe that one of the core developers (Jonas?) highlighted an LLVM shortcoming a few weeks ago... possibly something to do with floating point exceptions?

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: mercurhyo on August 14, 2021, 08:21:13 pm
Or this: https://greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf

Looks like all the fastest languages  have an LLVM version

Even Intel just moved their compiler to LLVM. If Intel does not have the resources to maintain the optimizations necessary for a fast compiler, it is hopeless for FPC. If FPC wants to be the fastest language, the LLVM mode should be the default

SMH

your link is about energy....!

Either you talk speed either yoou talk energy saving ... make your choice LOL inject 2L gas / 100km in a ferrari or 50L / 100km
thats not the same problem at all
cheers
 :D :D :D :D :D
what did you expect then? ferrari faster than bike? tooooo baaaaad
ROFL
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Leledumbo on August 14, 2021, 10:32:20 pm
If FPC wants to be the fastest language, the LLVM mode should be the default
Not something the core team will ever do, reading at this wiki article (https://wiki.lazarus.freepascal.org/LLVM#Frequently_Asked_Questions), even if they do admit on certain programs (that typically benchmarks focus on) LLVM does generate a faster code.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Fred vS on August 14, 2021, 10:46:05 pm
Looks like all the fastest languages  have an LLVM version.

You are welcome to test-support-continue the already well advanced mselang (https://github.com/mse-org/mselang/releases) project.

Fre;D
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: devEric69 on August 15, 2021, 10:28:03 am
Hello @Fre;D,


[off topic /on]

I have a question about mseide-msegui (https://github.com/mse-org/mseide-msegui). If I understand correctly, there are visual controls (of msegui) that are drawn by calls to X11 (like fpGUI (https://github.com/graemeg/fpgui/)). I know that fpGUI has an independent package (fpgui_ide.lpk) that I just need to be required in a Lazarus project in order to create an X11 application (I also know that you have written an IDE-designer in order to create X11 RAD forms).

My question - general culture - is: is there a msegui package (*.lpk) that can be also required from a Lazarus project (really sorry, I'm just an application builder knowing nothing about compilers; no more time to disperse myself towards something else, different from Lazarus [^])? If so, are the msegui and fpGUI controls compatible, adaptable (in a same X-11 application, rather targeted at the base for a true graphic server having no desktop installed on it, AFAIK the boundary between Wayland and X11)?


[^] just to understand how to turn around the --pcp in order to create an organisational pattern to put me back into the context of an old release (historised with SVN) and debug it, was a huge intellectual effort\challenge for me :D.

[off topic /off]


Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: PascalDragon on August 15, 2021, 01:27:45 pm
If FPC wants to be the fastest language, the LLVM mode should be the default

No one said that this is our goal. Yes, we want FPC to generate good, fast code, but speed is not everything.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Seenkao on August 15, 2021, 03:01:40 pm
If FPC wants to be the fastest language, the LLVM mode should be the default
Я не думаю, что это хорошая идея! Заглядывать и оптимизировать код - это да. Но менять одно на другое? Зачем? Что нельзя сделать, что уже сделано в LLVM?

Я занимаюсь разработкой и постоянно смотрю код, который получаю в конце компиляции. Если мне не нравится этот код, я стараюсь его улучшить. Я понимаю, что определённый код меня не устроит. По сути, лучший код ни один компилятор вам не сделает. Но компилятор достаточно неплохо оптимизирован. И, вам не нужно оптимизировать каждую свою строчку кода, для улучшения конечного кода (по простой причине, что за вас многое уже сделали).

Google translate:
I do not think it's a good idea! Peeking in and optimizing the code is yes. But change one for the other? What for? What cannot be done, what has already been done in LLVM?

I am doing development and constantly looking at the code that I get at the end of compilation. If I don't like this code, I try to improve it. I understand that a certain code will not suit me. In fact, no compiler will make the best code for you. But the compiler is quite well optimized. And, you don't need to optimize every line of your code to improve the final code (for the simple reason that a lot has already been done for you).

To improve / speed up your code, you should watch code that is constantly being executed. If you can minimize / optimize it, then this will be the end result. You! And only YOU! The person who will be responsible for your code! The compiler will take your code and optimize as "taught" it. Knowing how the compiler works, you can also improve the performance of your program!
Для улучшения/ускорения работы кода, вы должны смотреть код, который постоянно выполняется. Если вы его можете минимизировать/оптимизировать, то это и будет конечным результатом. Вы! И только ВЫ! Тот человек, который будет отвечать за ваш код! Компилятор примет ваш код и оптимизирует как его "учили". Зная работу компилятора, вы так же можете улучшить работу своей программы!
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Fred vS on August 15, 2021, 03:15:00 pm
[off topic /on]

Hello @Fre;D,

I have a question about mseide-msegui (https://github.com/mse-org/mseide-msegui). If I understand correctly, there are visual controls (of msegui) that are drawn by calls to X11 (like fpGUI (https://github.com/graemeg/fpgui/)).

Hello Eric.
Correct.  Both fpGUI and MSEgui use direct call to X11 for Unix OS (Linux, FreeBSD and old XQuartz Mac OS), gdi for Windows.


 I know that fpGUI has an independent package (fpgui_ide.lpk) that I just need to be required in a Lazarus project in order to create an X11 application (I also know that you have written an IDE-designer in order to create X11 RAD forms).

The fpgui_ide.lpk contain only the path of the source of fpGUI.
It allows you to create also a Lazarus lpi project files compatible with fpGUI.
But you still need to use the fpGUI form-designer, fpGUI is not compatible with Lazarus form designer (and his object-inspector).

My question - general culture - is: is there a msegui package (*.lpk) that can be also required from a Lazarus project (really sorry, I'm just an application builder knowing nothing about compilers; no more time to disperse myself towards something else, different from Lazarus [^])?

There is no msegui-lpk at the moment but if you use ideU (https://github.com/fredvs/ideU/releases), there is a prj to lpi converter.
This will convert the mseide/ideU prj project into a lpi Lazarus project.
So, like for fpGUI, you may use Lazarus ide and all feature of the code editor but the Lazarus form-designer/object inspector will not work, you will need to use the MSEide/ideU form-designer/object inspector.

If so, are the msegui and fpGUI controls compatible, adaptable (in a same X-11 application, rather targeted at the base for a true graphic server having no desktop installed on it, AFAIK the boundary between Wayland and X11)?

fpGUI and MSEgui are two different project.  Their components are not compatible (but they use the same X11 pascal header to access the X11 libraries).
Andrew Haines translated Wayland-headers for fpc: https://github.com/andrewd207/fpc-wayland
He did also the interface Wayland/fpGUI but this is not yet totally working well.
Of course this could be used later for MSEgui too.
Also Graeme said that he will do a interface Mac-Cocoa/fpGUI (but it seems that he forgot it  :-[ ).

Fre;D

[off topic /off]
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Fred vS on August 15, 2021, 03:33:03 pm
If FPC wants to be the fastest language, the LLVM mode should be the default

No one said that this is our goal. Yes, we want FPC to generate good, fast code, but speed is not everything.

If fpc could optimize speed of float calculation and approach the speed of LLVM it would be great.

Fre;D
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: devEric69 on August 15, 2021, 08:57:45 pm
[off topic /on]
@Fred, thank you very much for the time taken for your clarifications between fpGUI and MSEgui (I guess that only the way of drawing the controls is common; the main message loop - depending on the type of application - and their messages must be incompatible).
[off topic /off]
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Mr.Madguy on August 22, 2021, 04:56:23 pm
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
Interesting idea. I also had such idea, when wanted to implement closures by myself. They're just syntax sugar around interfaces, so they should be easy to implement. But I don't have enough experience with FPC sources to do everything right and not brake anything. And then I realized, that it would be great to have extendable syntax. Even whole language could be build from scratch around compile-time extendable syntax. I would call it MetaPascal.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 22, 2021, 05:36:09 pm
Interesting idea. I also had such idea, when wanted to implement closures by myself. They're just syntax sugar around interfaces, so they should be easy to implement. But I don't have enough experience with FPC sources to do everything right and not brake anything. And then I realized, that it would be great to have extendable syntax. Even whole language could be build from scratch around compile-time extendable syntax. I would call it MetaPascal.

I think quite a lot could be done by going back to a fairly austere ALGOL-like base, with a design dogma that under no circumstances should types be promoted implicitly. On top of that allow explicit definition of operators and functions, and have traits associated with types indicating which operations could be inherited by subtypes, which needed to be redefined and so on.

However I think a serious stumbling block is the behaviour when a stack frame is unwound on function exit. Modern languages assume at least that there is a hook here which e.g. allows dynamically-allocated local strings to be freed and any exception state to be unwound, but it complicates explicit exit/return handling (i.e. as distinct from simply falling out of the end of the function) and has the potential to be a resource hog if units can be precompiled separately. I suspect that precompilation also implicitly complicates template/generic handling, and it's interesting that Stallman once looked at a language (Pastel) which allowed parametric types but found that this required that the entire program's abstract syntax tree be held in memory which was out of the question for the microprocessor-based computers of the day.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Mr.Madguy on August 23, 2021, 01:15:31 pm
All I need - is to replace this:
Code: Pascal  [Select][+][-]
  1. type
  2.   TIterator = reference to function:Integer;
  3.  
  4. var
  5.   Iterator:TIterator;
  6.  
  7. function CreateIterator:TClosure;
  8.   var I:Integer;
  9. begin
  10.   I := 0;
  11.   Result := function:Integer
  12.   begin
  13.     Result := I;
  14.     Inc(I);
  15.   end;
  16. end;
  17.  
  18. Iterator := CreateIterator;
  19.  
  20. WriteLn(Iterator);
  21.  
with this:
Code: Pascal  [Select][+][-]
  1. type
  2.   IIteratorInterface = interface;
  3.  
  4.   TIteratorMethod1 = function(Self:IIteratorInterface):Integer;
  5.  
  6.   IIteratorInterface = interface
  7.     function IteratorMethod1:Integer;
  8.   end;
  9.  
  10.   TIterator = record
  11.     Method:TIteratorMethod1;
  12.     Interface:IIteratorInterface;
  13.   end;
  14.  
  15.   TIteratorClass = Class(TInterfacedObject, IIteratorInterface)
  16.     I:Integer;
  17.     function IteratorMethod1:Integer;
  18.   end;
  19.  
  20. var
  21.   Iterator:TIterator;
  22.  
  23. function TIteratorClass.IteratorMethod1:Integer;
  24. begin
  25.   Result := I;
  26.   Inc(I);
  27. end;
  28.  
  29. function CreateIterator:TIterator;
  30.   var IteratorVar:TIteratorClass;
  31. begin
  32.    IteratorVar := TIteratorClass.Create;
  33.    IteratorVar.I := 0;
  34.    Result.Method := @IteratorVar.IteratorMethod1;//I know, it's wrong
  35.    Result.Interface := IteratorVar;
  36. end;
  37.  
  38. Iterator := CreateIterator;
  39.  
  40. WriteLn(Iterator.Method(Iterator.Interface));
  41.  
Now I need to learn how to change FPC sources for this. It would take too much time, would be too hard and counter-productive. But what if I would be able to add some Closures.pas unit to my project, where I would be able to describe closure extended syntax? It would be compiled to some sort of compiler runtime module, that would be able to handle closures at compile time.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov on August 23, 2021, 02:26:44 pm
FPC does not implement anonymous methods yet.  It has been in the works for years by 3rd party devels, but somehow it doesn't get finished (or submitted)
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Mr.Madguy on August 23, 2021, 03:38:03 pm
FPC does not implement anonymous methods yet. It has been in the works for years by 3rd party devels, but somehow it doesn't get finished (or submitted)
May be that's because they think, that it's hard to implement? It's just another way of defining classes, that doesn't require class definition itself and therefore saves many code lines. Overall whole closure structure is something like this:
Code: Pascal  [Select][+][-]
  1. function ClosureContext:TClosureContainer;//Container - in case we want to have several closures
  2.   var <SomeOtherVariables>, <ClosureVariables>;
  3. begin
  4.   Result.Closure1 := <Closure1>;
  5.   Result.Closure2 := <Closure2>;
  6.   Result.Closure3 := <Closure3>;
  7. end;
  8.  
Turns into:
Code: Pascal  [Select][+][-]
  1. IClosureInterface = interface
  2.   <Closure1>
  3.   <Closure2>
  4.   <Closure3>  
  5. end;
  6.  
  7. TClassImlementingClosures = class(TInterfacedObject, IClosureInterface)
  8.   <ClosureVariables>
  9.   <Closure1>
  10.   <Closure2>
  11.   <Closure3>
  12. end;
  13.  
So, it's just matter of turning one code into another code. That's why having extendable syntax would be great for this task.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: marcov on August 23, 2021, 04:01:07 pm
FPC does not implement anonymous methods yet. It has been in the works for years by 3rd party devels, but somehow it doesn't get finished (or submitted)
May be that's because they think, that it's hard to implement? It's just another way of defining classes, that doesn't require class definition itself

It is primarily added for Delphi compatibility and there it is primarily used to schedule tasks in other threads.  But yes, it must dynamically capture state. (though that is horribly wonky in Delphi too, as it often captures references to state rather than the state itself). And it must all be memory safe in the end (though that builds on top of existing interfaces infra).

Why it takes so long I don't know, and since there is little info to base speculation on.

Quote
So, it's just matter of turning one code into another code. That's why having extendable syntax would be great for this task.

The syntax is already fixed by Delphi
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Seenkao on August 23, 2021, 05:20:24 pm
All I need - is to replace this:
Code: Pascal  [Select][+][-]
  1. type
  2.   TIterator = reference to function:Integer;
  3.  
  4. var
  5.   Iterator:TIterator;
  6.  
  7. function CreateIterator:TClosure;
  8.   var I:Integer;
  9. begin
  10.   I := 0;
  11.   Result := function:Integer
  12.   begin
  13.     Result := I;
  14.     Inc(I);
  15.   end;
  16. end;
  17.  
  18. Iterator := CreateIterator;
  19.  
  20. WriteLn(Iterator);
  21.  
with this:
Code: Pascal  [Select][+][-]
  1. type
  2.   IIteratorInterface = interface;
  3.  
  4.   TIteratorMethod1 = function(Self:IIteratorInterface):Integer;
  5.  
  6.   IIteratorInterface = interface
  7.     function IteratorMethod1:Integer;
  8.   end;
  9.  
  10.   TIterator = record
  11.     Method:TIteratorMethod1;
  12.     Interface:IIteratorInterface;
  13.   end;
  14.  
  15.   TIteratorClass = Class(TInterfacedObject, IIteratorInterface)
  16.     I:Integer;
  17.     function IteratorMethod1:Integer;
  18.   end;
  19.  
  20. var
  21.   Iterator:TIterator;
  22.  
  23. function TIteratorClass.IteratorMethod1:Integer;
  24. begin
  25.   Result := I;
  26.   Inc(I);
  27. end;
  28.  
  29. function CreateIterator:TIterator;
  30.   var IteratorVar:TIteratorClass;
  31. begin
  32.    IteratorVar := TIteratorClass.Create;
  33.    IteratorVar.I := 0;
  34.    Result.Method := @IteratorVar.IteratorMethod1;//I know, it's wrong
  35.    Result.Interface := IteratorVar;
  36. end;
  37.  
  38. Iterator := CreateIterator;
  39.  
  40. WriteLn(Iterator.Method(Iterator.Interface));
  41.  
Now I need to learn how to change FPC sources for this. It would take too much time, would be too hard and counter-productive. But what if I would be able to add some Closures.pas unit to my project, where I would be able to describe closure extended syntax? It would be compiled to some sort of compiler runtime module, that would be able to handle closures at compile time.

Точнее, вы делаете больше работы, для того чтоб сделать больше работы в дальнейшем? Я смотрю на второй код, и вижу что он больше. Как при создании, так и при использовании.
В чём преимущество второго кода?

google translate:
More specifically, are you doing more work to do more work in the future? I look at the second code and see that it is larger. Both in creation and in use.
What is the advantage of the second code?
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: Mr.Madguy on August 23, 2021, 05:24:04 pm
It is primarily added for Delphi compatibility and there it is primarily used to schedule tasks in other threads.  But yes, it must dynamically capture state. (though that is horribly wonky in Delphi too, as it often captures references to state rather than the state itself). And it must all be memory safe in the end (though that builds on top of existing interfaces infra).

Why it takes so long I don't know, and since there is little info to base speculation on.
They're usable in any callbacks, that require state passing. While classes are data with code attached to them, closures are opposite - they're code with data attached to them. Test cases are implemented via closures in my project. There are thousands of them. It has taken many months to write this code. That's why their code should be kept as minimum, as possible. Rewriting this code using classes/interfaces would be massive job. But overall my goal is to fully migrate to Linux and get rid of Windows/Delphi dependency. I would want to help with it, but starting to dig into FPC sources from scratch - is too big thing for me and I really think, that it would be counter-productive.

Example of using closures in my project:
Code: Pascal  [Select][+][-]
  1. procedure AddTests(ATestCase:TObjectContainerTestCase<TAbstractList<Integer>, TArray<Integer>>;ASorted:Boolean);
  2.   var TestHelper:TAbstractTestHelper;
  3. begin
  4.   TestHelper := ATestCase.TestHelper;
  5.   with TestHelper do begin
  6. ...
  7.     ATestCase.AddTestCase(
  8.       'Query test',
  9.       True,
  10.       function(var ASource:TAbstractList<Integer>):TAbstractList<Integer>
  11.       begin
  12.         Result := ASource.Query(TDelegatedPredicate<Integer>.Create(
  13.           function(AValue:Integer):Boolean
  14.           begin
  15.             Result := AValue mod 2 = 0;
  16.           end
  17.         ));
  18.       end,
  19.       ArrayOfInteger([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
  20.       ArrayOfInteger([2, 4, 6, 8, 10])
  21.     );
  22. ...
  23.   end;
  24. end;
  25.  
Not 100% good example, because it doesn't show, that TestHelper methods or ASorted can be used inside callbacks, therefore it doesn't show all pros of using closures. One can argue, that above code can be implemented via static procedures.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: PascalDragon on August 26, 2021, 03:03:05 pm
Why it takes so long I don't know, and since there is little info to base speculation on.

The feature itself is feature-complete, the remaining part is reintegration into main and right now the provided code is essentially akin to a cancer. Before that is restructured I'm not going to integrate that.
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: damieiro on August 26, 2021, 10:44:22 pm
pure assembly  :D :D

Really any ALGOL 60 (68?) descendant would have the same speed potential. It would only be a compiler matter. C, Pascal, Ada, teoretically can achieve same speed.
In certain (broad) way, C<->Pascal translation is nearly automatic.
And even i would say that pascal should do even better speed because compiler has more information (strong typed, and things like that).
On the other hand, it's difficult today thinking in a big app made with only one languaje. OS (platform) are in Cs* and even same compiler with same languaje (even C) could perform different from one OS to another...
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 27, 2021, 08:25:13 am
Really any ALGOL 60 (68?) descendant would have the same speed potential. It would only be a compiler matter. C, Pascal, Ada, teoretically can achieve same speed.

I'm sorry, I disagree. As a specific example, a language which relies heavily on termination code at the end of every block to unwind temporary allocations and exception handlers will always be slower than one that doesn't provide that facility, and that is generally made worse if separate compilation prevents that from being optimised away (due to callbacks expecting the same stack layout).

Apart from that, just about everything is derived from ALGOL these days. Classic FORTRAN and COBOL have (thankfully) withered as have environments such as Lisp, Prolog, Smalltalk and Forth, and their descendants are quick to point out how much they've borrowed from ALGOL/Pascal/Ada: control blocks, data structures and the rest. But some of those descendants couldn't be implemented without heavy use of either reference counting or garbage collection, and again those are inherent time-wasters.

Quote
In certain (broad) way, C<->Pascal translation is nearly automatic.
And even i would say that pascal should do even better speed because compiler has more information (strong typed, and things like that).
On the other hand, it's difficult today thinking in a big app made with only one languaje. OS (platform) are in Cs* and even same compiler with same languaje (even C) could perform different from one OS to another...

I've had people in the past trying to convince me that UNIX-based systems could /only/ be programmed in C.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: damieiro on August 27, 2021, 11:02:43 am
Quote
'm sorry, I disagree. As a specific example, a language which relies heavily on termination code at the end of every block to unwind temporary allocations and exception handlers will always be slower than one that doesn't provide that facility, and that is generally made worse if separate compilation prevents that from being optimised away (due to callbacks expecting the same stack layout).

Apart from that, just about everything is derived from ALGOL these days. Classic FORTRAN and COBOL have (thankfully) withered as have environments such as Lisp, Prolog, Smalltalk and Forth, and their descendants are quick to point out how much they've borrowed from ALGOL/Pascal/Ada: control blocks, data structures and the rest. But some of those descendants couldn't be implemented without heavy use of either reference counting or garbage collection, and again those are inherent time-wasters.

Well, nothing to say, your point is valid, i agree. I was thinking more on c/pascal/ada tree of algol68.

Quote
I've had people in the past trying to convince me that UNIX-based systems could /only/ be programmed in C.

I've thinking a lot of times that i would love that history will make pascal - again- used as OS languaje. Any knows if there is being tried a OS coded in pascal or something like that?. It would be funny repeating the story of Linus Torvalds redoing kernel in FreePascal.
Sometimes i have thought (but i have no time) of making a mini OS made only in pascal as a start point for doing something bigger. Dreams...


Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 27, 2021, 11:10:32 am
Well, nothing to say, your point is valid, i agree. I was thinking more on c/pascal/ada tree of algol68.

But FPC does have arbitrary unwind code at the end of functions and procedures, which is how locally-defined strings and dynamic arrays are freed.

Quote
I've thinking a lot of times that i would love that history will make pascal - again- used as OS languaje. Any knows if there is being tried a OS coded in pascal or something like that?. It would be funny repeating the story of Linus Torvalds redoing kernel in FreePascal.
Sometimes i have thought (but i have no time) of making a mini OS made only in pascal as a start point for doing something bigger. Dreams...

Yes, there've been many: as a specific example, Cray's OSes were coded in Pascal (although the anti-Pascal purists would attempt to save face by saying that because it was enhanced beyond the standard definitions it wasn't really Pascal). I've used Modula-2 for a microkernel plus network etc. BUT robust type checking becomes a problem as soon as you're passing variable-sized packets around which negates a lot of Pascal's advantage.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: damieiro on August 27, 2021, 11:38:59 am
Quote
Yes, there've been many: as a specific example, Cray's OSes were coded in Pascal (although the anti-Pascal purists would attempt to save face by saying that because it was enhanced beyond the standard definitions it wasn't really Pascal). I've used Modula-2 for a microkernel plus network etc.

I would search for these (itches my curiosity). Are there modern ones?.

Quote
BUT robust type checking becomes a problem as soon as you're passing variable-sized packets around which negates a lot of Pascal's advantage.
I don't know why. Even in the worst case one can take these as raw data, have fun with pointers and then process that like a C code. Well, i'm talking lightly without seeing the real problem. In worst scenario one will be like C and a nice reading code :)
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 27, 2021, 11:48:54 am
Quote
Yes, there've been many: as a specific example, Cray's OSes were coded in Pascal (although the anti-Pascal purists would attempt to save face by saying that because it was enhanced beyond the standard definitions it wasn't really Pascal). I've used Modula-2 for a microkernel plus network etc.

I would search for these (itches my curiosity). Are there modern ones?.

Most of the Cray engineering documentation and sources was destroyed: SGI had a beach bonfire party when they bought them. People like Chris Fenton have had some success scraping stuff together from old disk packs. As far as modern work is concerned, the thing that springs to mind is Oberon. There's also a modern Pascal-based stand-alone project for the Raspberry Pi although the name escapes me and I don't know how heavily it relies on assembler.

Unfortunately, most people these days think that "writing an operating system in XXXX" means yet another GUI built on top of Windows or Linux.

Quote
Quote
BUT robust type checking becomes a problem as soon as you're passing variable-sized packets around which negates a lot of Pascal's advantage.
I don't know why. Even in the worst case one can take these as raw data, have fun with pointers and then process that like a C code. Well, i'm talking lightly without seeing the real problem. In worst scenario one will be like C and a nice reading code :)

But the last thing you want if considering a robust language is to be passing pointers around without the compiler having the opportunity to check and enforce the size of the associated data... which is exactly what you get with stream-based protocols like TCP.

MarkMLl
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: damieiro on August 27, 2021, 02:49:50 pm
Thanks MarkMLI

I will see the http://www.projectoberon.com/home  i allways love read Wirth

Quote
But the last thing you want if considering a robust language is to be passing pointers around without the compiler having the opportunity to check and enforce the size of the associated data... which is exactly what you get with stream-based protocols like TCP.
Yes, but i do not know a robust solution for this. Only say that FreePascal con do with same or better readibility than C and same performance. Designing a new protocol in...3..2..1..  >:D
Title: Re: What is the FASTEST Computer Language? 45 Languages Tested!
Post by: MarkMLl on August 27, 2021, 04:29:27 pm
Thanks MarkMLI

I will see the http://www.projectoberon.com/home  i allways love read Wirth

Quote
But the last thing you want if considering a robust language is to be passing pointers around without the compiler having the opportunity to check and enforce the size of the associated data... which is exactly what you get with stream-based protocols like TCP.
Yes, but i do not know a robust solution for this. Only say that FreePascal con do with same or better readibility than C and same performance. Designing a new protocol in...3..2..1..  >:D

A moderately-robust solution is descriptor-based protected memory with fine granularity, in which case you can- in principle- pass descriptor references around as atomic operations and rely on the hardware checking for overruns. But that pitch has been queered by the grossly inadequate number of descriptors in the PM x86 architecture, which means that almost everybody dismisses it out of hand.

MarkMLl
TinyPortal © 2005-2018