Why do you need FORTRAN, C, C++ for physics

In summary, Java is being replaced by Scala and other newer JVM languages as the preferred language for scientific computation. Java is still used by many engineering firms, but its days appear to be numbered.
  • #1
Superposed_Cat
388
5
Okay I get that FORTRAN was made for science and C AND C++ are fast but why do you have to know one of them? (or so I heard). Thanks for any help.
 
Technology news on Phys.org
  • #2
Why do you need more than just a hammer in your toolbox?
 
  • #3
the and was supposed to be lowercase sorry. But I meant why those specific languages?
 
  • #4
FORTRAN came about first for scientific applications and later COBOL was developed for business.

C was the defacto language for Unix machines and was being used as a cross hardware platform assembly language as newer CPUs came on the market. At one time, Unix machines had a feature that would take C source code transmitted over the network, compile it and update the executable, saving it wherever you wanted which was subsequently disabled when a college student created one of the first worms that infected 6000+ machines (http://en.wikipedia.org/wiki/Morris_worm).

C++ piggybacked on C (and literally too: where code was translated by the CFRONT program from C++ into C code and then compiled) introduced OO concepts to the UNIX world and became the preferred choice over Objective-C which was proprietary at the time and SmallTalk the first OO language.

SmallTalk while popular in OO research wasn't adopted for mainstream OO due to the limitation of coding in an IDE like environment where you could change anything in the SmallTalk core and where you had to export the whole workspace to someone else's machine for them to run your program. and they in turn had to import it and hope it didn't change something they had altered.

Given those choices FORTRAN, C and C++ survived to the present day.

So if you were writing a computer simulation of some physical problem you'd choose FORTRAN because of the large body of supporting libraries. Later as Unix got more popular you would choose C because it was available on more machines more so than FORTRAN. If you were a CompSci person you'd write it in C++ for greater modularity.

ADDENDUM: Matlab and Java are now taking over as the preferred languages for simulation. Matlab is primarily used by engineering students who then want to use it when they get a job (smart marketting on Matlabs part).

Java for many reasons: students learn it, its easier to learn than C++, runs cross-OS and cross-HW including Android HW has a lot of library support including the Open Source Physics library of methods and ODEs.
 
Last edited:
  • Like
Likes 1 person
  • #5
Thanks
 
  • #6
jedishrfu said:
ADDENDUM: Matlab and Java are now taking over as the preferred languages for simulation.

Yeesh, let's hope that's not true. Matlab is proprietary and Java is ill-suited to scientific computation.
 
  • #7
Daverz said:
Yeesh, let's hope that's not true. Matlab is proprietary and Java is ill-suited to scientific computation.

but it is true...

and the future of Java appears to be heading toward Scala and its syntactical sugar, scriptability and its model of OO + Functional Programming...
 
  • #8
jedishrfu said:
but it is true...

and the future of Java appears to be heading toward Scala and its syntactical sugar, scriptability and its model of OO + Functional Programming...

Good, all the new JVM languages (Scala, Clojure, JRuby, etc.) will allow some of the good parts of the Java ecosystem to survive (the JVM itself*, the "cross-platformness") while marginalizing the fundamentally broken part: Java the language.

* Footnoted because one can definitely make the argument that the JVM class loader is a bit of a disaster.
 
  • #9
I would have thought that mathamatica and fortran/c++ would be more popular than java+matlab. MATLAB is very limited and has terrible graphics and java just isn't anyone I knows' cup of tea. That was the first OO language me and my friends learned and we all changed soon after.
 
  • #10
Many engineering firms use MATLAB more than Mathematica and buy into the MATLAB libraries as well. Its an expensive solution but MATLAB supports them and that make the firms feel more secure. In addition, MATLAB can interface with Java code although not seamlessly and with C code.

You will find out more about this when you get out of academia.
 
  • #11
I'm not even in academia yet, thanks for the help.
 

1. Why can't I just use any programming language for physics?

While it is possible to use any programming language for physics, certain languages like FORTRAN, C, and C++ are better suited for scientific computing. These languages are designed to efficiently handle large amounts of data and complex mathematical operations, which are essential for many physics calculations.

2. Can't I just use a high-level language like Python for physics?

High-level languages like Python are great for general-purpose programming, but they may not be as efficient as lower-level languages like FORTRAN, C, and C++. In physics, where calculations can involve massive amounts of data and require high-speed processing, these lower-level languages are often preferred.

3. What are the advantages of using FORTRAN, C, or C++ over other languages?

In addition to their efficiency, FORTRAN, C, and C++ have been widely used in the scientific community for decades. This means there is a large library of well-tested and optimized code available for these languages, making it easier for physicists to build upon existing work and collaborate with others.

4. Do I need to know all three languages to work in physics?

No, it is not necessary to know all three languages. Depending on your specific field of physics, you may find that one language is more commonly used than others. However, having a working knowledge of all three can make you more versatile and better prepared to work with different research groups.

5. Can I use FORTRAN, C, or C++ for other scientific fields besides physics?

Yes, these languages are not limited to just physics. They are commonly used in other scientific fields such as engineering, astronomy, and computational chemistry. Their efficiency and ability to handle complex calculations make them valuable tools for many scientific applications.

Similar threads

  • Programming and Computer Science
Replies
2
Views
929
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
14
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
12
Replies
397
Views
13K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
Back
Top