Comparison of high-level computer programming languages

  • #76
9,476
2,560
For numerical calculations (as in a lot of scientific/physics programs), FORTRAN is reputed to be the fastest.
FORTRAN and C are equally as fast. But everyone knows programs spend most of their time in a small amount of code. You write in an easy to write language like Python, then a faster language like LUAJIT for the critical parts found from running the code. For example here is a quicksort in Python:

def qsort(arr):
if len(arr) <= 1:
return arr
else:
return qsort([x for x in arr[1:] if x < arr[0]]) + \
[arr[0]] + \
qsort([x for x in arr[1:] if x >= arr[0]])

Dead simple. But you may need it faster. I have written a quick-sort in assembler so I would hack that rather than use Lua or C - but that's just because I am lucky in having the code. It's not hard in Lua though - and if that isn't fast enough use assembler - but as I said I was lucky enough to have one in assembler anyway so would go for that.

In general you could go to C for the ultra critical bits, but I tend to go for assembler - JuaJIT is mostly as fast as C. And yes you still need a minimum knowledge of C - its excellent for gluing languages together, plus I don't write assembler direct but rather as assembler statements in C.

I learned FORTRAN 35 years ago and avoided it as much as possible since then - never did like it.

Thanks
Bill
 
Last edited:
  • #77
FactChecker
Science Advisor
Gold Member
5,757
2,136
FORTRAN and C are equally as fast.
That is what I always assumed, but the benchmark results that I have seen had FORTRAN slightly (but significantly) faster. I have no explanation for that and have never done my own comparison tests to verify it.
I learned FORTRAN 35 years ago and avoided it as much as possible since then - never did like it.
IMHO, even by today's standards, FORTRAN has some excellent features for scientific/engineering use that are unmatched in other general-purpose languages.
 
Last edited:
  • Like
Likes m4r35n357
  • #78
9,476
2,560
Even by today's standards, FORTRAN has some excellent features for scientific/engineering use that are unmatched in other general-purpose languages.
It does with tons of libraries to call freely available. But I still reckon for real speed its assembler. No idea why FORTRAN would be bit faster than C, but personally I just use C as glue.

Actually in my degree I had to write some numerical analysis code - I had Pascal or FORTRAN to choose from - for me no choice - I used Pascal. As a professional programmer used a language called NATURAL, but after I retired moved onto Python and Lua. Do not know C that well - just use it for glue and in writing assembler. As usual assembler is a royal pain - but fast - really fast.

Thanks
Bill
 
Last edited:
  • Like
Likes FactChecker
  • #79
FactChecker
Science Advisor
Gold Member
5,757
2,136
Actually in my degree I had to write some numerical analysis code - I had Pascal or FORTRAN to choose from - for me no choice - I used Pascal.
When I was writing simulations of air-to-air combat, the ability in Pascal to write code like "ProbabilityOfKill( GoodGuy, BadGuy) = 0.5" where GoodGuy and BadGuy were enumerated types read as text from an input file was extremely appealing. Unfortunately, I was self-taught in experimenting with Pascal and there was no internet back then. I didn't know how to read/write a file of parameters containing enumerated types as text ( like "F16", "Foxbat", 0.5 ). I thought that it couldn't be done and left Pascal in disgust.
 
  • Like
Likes bhobba
  • #80
Svein
Science Advisor
Insights Author
2,100
676
Way back when I started programming, the older guys were more or less married to FORTRAN IV. I did not care one way or the other until I had to debug a FORTRAN program - the error was that one instance of one variable was spelled wrong which made it an autodeclared variable which was never initialized but used in one particular spot.

Autodeclaration, three-way IF statements and hundreds of GOTOs - programming in assembly was less confusing.
 
  • Like
Likes bhobba
  • #81
I started coding with Pascal first. Nostalgia aside, it's not a very well-designed language. I really enjoyed C, where you had more fine control over memory allocation, and your strings could be of different lengths (and still be of type char*, unlike Pascal, where the length of the array was part of the type).

It's also a little too verbose. It's very good for a teaching language, but the smallest project I've been involved in, would be three times as large if it were written in Pascal.

Still love it thought. My first...
 
  • Like
Likes bhobba and Klystron

Related Threads on Comparison of high-level computer programming languages

Replies
5
Views
2K
Replies
17
Views
2K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
13
Views
5K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
17
Views
5K
Replies
10
Views
3K
Top