Which programming language do you use?

In summary, the conversation revolved around the use of programming languages in scientific computation. While Fortran and C/C++ were the most popular for simulations, other languages such as Python, MATLAB, and Mathematica were also mentioned for visualization and smaller problems. There was no consensus on the best language for scientific computation, with some preferring Python and others sticking to what they know best. Java was mentioned as a language that is not commonly used for serious scientific problems, but can be useful for certain tasks. It was also noted that often people use the language they are most comfortable with, rather than the most appropriate for the task at hand. In an industrial setting, older codes and languages are often still used due to their extensive testing and approval for certain
  • #1
Undisciplined
9
0
Hi All,

I am a physicist from Hungary. I was involved in quite a few programming tasks back in the university, especially in the field of Density Functional Theory, which needed complex computations. I used Fortran and later C++, for Object Oriented programming gave quite a few advantages that were useful for our purposes.

I work as a software developer now, I use Java, which is - as far as I know - out of the scope of scientific computations; but who knows, for some tasks it may be the language (especially, where extreme speed is not an issue).

I was just wondering if people in science, especially in physics, still use Fortran or C/C++ or some other special languages. I read some papers on this new experimental language from sun, called Fortress. Does anyone uses it yet?

If anyone here is interested in this topic, please share your thoughts, I'm very much interested in these trends in scientific computation.

Any answers would be appreciated.
Thanks.
 
Physics news on Phys.org
  • #2
As far as I know, people prefer python for programming and for scientific computation mathematica and matlab.

Although there isn't any consensus here, you use what is best for your needs.
 
  • #3
Well, as always, it depends on what suits your problem.

Fortran and C/C++ are the most popular for simulations, especially when it comes to parallel programming.

Then there are mathematica, MATLAB and IDL, that I have mostly seen used for visualisation and for small problems.
 
  • #5
In my experience quite often people use not a language that is best suited for the task, but the language that they know best. Especially when you need to do some quick and dirty tests this approach makes sense, as it is usually much faster to get the result with tools at hand than to learn new tools. For larger problems investing in a new language may be beneficial.
 
  • #6
Good point Borek: when you only have a hammer everything looks like a nail.

I like Mathematica for figuring stuff out, and I primarily use C++ for "production level" things. But I try to keep an eye on other languages (e.g. Python, Java, C#) so that if I ever find myself in a situation where they would be particularly helpful I can use them.
 
  • #7
Does anyone uses Java for serious problems?

By the way, thanks for the quick replies!
 
  • #8
Undisciplined said:
Does anyone uses Java for serious problems?
Pretty much no,
Partly this is historical, scientists learned Fortran, engineers learned C and so C++ was an easy step.
Early Java didn't have have separate float/double types (IIRC) and was very slow.
Most scientists coming from Fortran/C thought procedurally rather than OO and it's not clear that OO is such a good mix for most scientific problems.
Java doesn't (didn't?) have such good library support (NAG etc)

I would say that Python has now overtaken Java as the popular dynamic scientific programming languge
 
  • #9
This is true. But mainly for early Java, as you wrote. I don't think, however that mathematical libraries have been implemented in Java in great number:(

By the way, NAG (and I guess some other) libraries can be called from Java code. I don't know how efficiently, though.
 
  • #10
You can take a look at calling NAG from Java through JNI here if you are interested:

http://www.nag.com/doc/TechRep/html/Tr1_04/Tr1_04.html"
 
Last edited by a moderator:
  • #11
In an engineering or "industrial" setting (ie, not academia) the computer codes are often old and the investment in developing them was significant. So, we continue to use Fortran since this was in use when the codes were developed. In the nuclear power business, the codes have been extensively reviewed and tested, and some of the codes themselves have been reviewed and approved for certain uses. That makes it very unlikely that a new code will be written from scratch. I have also seen C++ used to code new graphical user interfaces, which allow the old fortran code to be run on a PC. Some people also use PERL for programs they write themselves, since it is supported on the Unix systems.
 
  • #12
Please don't leave out VBA "Visual Basic for Applications" I have written modules in Acess and Excel that will design entire heat exchangers. LOL. You use what the company has when they are too cheap to purchase to correct software.
 
  • #13
I pretty much stick to what languages that i respect the most, and what I know a 'fragment' of... [who cares what's popular or mainstream]


Basic, PL/I, Fortran...

One day, I'll add C and Mathematica to the list.

I will agree with MathematicalPhysicist though:

'people prefer python for programming and for scientific computation mathematica and matlab. Although there isn't any consensus here, you use what is best for your needs.'

Most people do seem to like Python and Mathematica for getting their feet wet.

I still think Fortran and C are here to stay and the most useful. They were, are, and will be important for quite a while, if not near forever.

I only wish that one day i could have the ability to see some small chunk of code and instantly, know what the equivalents are in Basic <-> C <-> PL/I, back and forth.

then again still like flowcharting, gotos,line numbers, kitchen-sink languages that arent like Pascal, and Knuth's scary 3 books. [oh and Forman Acton's outstanding and slightly intimidating text on numeric computing]


As long as you can think in a language,hope the code is readable [or well-documented] and got enough books on programming in it, that's most of the battle.

About a decade ago, i read one physicist who's comments stuck with me.
Fortran and C for him were the most useful ones, and one shouldn't discount the usefulness of Basic, PL/I and Assembler, since they came in handy...

Not so sure his experiences would match others, but for *me* it made a lot of sense. Basic seems to be the easier of the languages for people to write in and think conceptually for many, and Fortran is just an older, fancier and slightly more difficult form. PL/I is like a deluxe super Fortran. And at the other end is Assembler, and something similar yet a lot more managable, being C. High end and low end languages in a nutshell.

Honestly, i think my choices of languages were always based on how good the textbooks on the languages were, or how i liked the examples and samples of code. Where you see the examples you like and understand, i think 'chooses' our computer language.

For me a ton of good examples, makes it or breaks it for me...
 
  • #14
Apparently in Transportation, they use java, bleh!. I know BASIC (VB), and Object Pascal (delphi) quite well!. I can survive using C/C++. However, in my research group the tools mainly used are MS Excel, ArcGIS, TransCAD, SAS, STATA, and MATLAB. Visual Basic is present in the Excel and ArcGIS enviroment, and the other have their own "language". Java is used by other members for agent based modeling in the group. So far, I've not done any agent-based modeling, but if I do I'll probably use Object Pascal or make myself finish learning C/C++. (VB applications are not as stable).
 
  • #15
I use C++ for numerical computations and simulation (I know FORTRAN but I'm more comfortable with C++). I also use C++ and MPI (and sometimes OpenMP) for parallel programming. For doing small and dirty numerical computation I'll just pop up MATLAB and for math I'll use Maple. However, something like MATLAB would be impossibly slow to do anything real with (like Monte-Carlo or Power Method type Matrix Diagonalization for large matrics)
 
  • #16
I've written simple e-mail processing programs in VBA and it's quite a neat environment, but no way would I choose it for physics simulations! I agree with the comment "Java bleh!" but even Java would be better for that kind of thing! I've written programs in all the languages mentioned so far, and several others (Objective C, Algol, Lisp, Prolog, Eiffel, Oberon, Modula...) But my favourite, by far, for quick development of physics & business simulations, is Smalltalk. And the best environment (VisualWorks) is free for non-commercial use, the second best (Squeak) is free, full stop.
 
  • #17
My professor works on HEP using data from fermilab, he uses C++

However, at first he wanted me to learn Python so he could write some of his new stuff in Python or at least translate the old stuff.

So I'd put Python down as a good language to know.
 
  • #18
DukeofDuke said:
My professor works on HEP using data from fermilab, he uses C++

However, at first he wanted me to learn Python so he could write some of his new stuff in Python or at least translate the old stuff.

So I'd put Python down as a good language to know.

Indeed. The best language to learn is the one you have to!
 
  • #19
Cyclovenom said:
Apparently in Transportation, they use java, bleh!. I know BASIC (VB), and Object Pascal (delphi) quite well!. I can survive using C/C++. However, in my research group the tools mainly used are MS Excel, ArcGIS, TransCAD, SAS, STATA, and MATLAB. Visual Basic is present in the Excel and ArcGIS enviroment, and the other have their own "language". Java is used by other members for agent based modeling in the group. So far, I've not done any agent-based modeling, but if I do I'll probably use Object Pascal or make myself finish learning C/C++. (VB applications are not as stable).

You can access TransCAD from .NET to integrate it into a .NET application or access TransCAD as a COM Object to add maps or analysis functions to your own programs. The .NET classes included with TransCAD allow you to access the proprietary GISDK environment from a Windows desktop application (Windows Forms) written in any .NET language such as C#, Python, Visual Basic, etc. GISDK also allows you to call GISDK functions and macros from another application using COM. TransCAD can provide map, data, and geographic analysis services when accessed as a COM Object. You write your application in a programming language that can make COM calls, and when you need map services you call the TransCAD http://www.caliper.com" object to supply those services.
 
Last edited by a moderator:
  • #20
I've used C, FORTRAN and MATLAB.
I find MATLAB the most convenient for small calculations or when I want to test whether my algorithm works.
For big projects my favorite is C, but, unfortunately, not only a lot of old well-tested physics code has been wrtten in FORTRAN, but for some strange reason modern physicists also tend to prefer FORTRAN. And since I rely on others' code in my current research, I have to use it too. :(
 
  • #21
Cosomogirl,

Are you familiar with the methods to link MATLAB and C++ together? You can really get a speed boost from that.
 

1. What is the best programming language to use?

There is no one "best" programming language as it ultimately depends on the specific needs and goals of a project. Some popular and widely used languages include Java, Python, C++, and JavaScript.

2. Which programming language is the easiest to learn?

This also varies from person to person, but generally, Python and JavaScript are considered to be relatively easy to learn for beginners. Both have simple syntax and a large community of resources and support.

3. Which programming language is best for web development?

HTML, CSS, and JavaScript are the three main languages used in web development. HTML is used for structuring web pages, CSS for styling them, and JavaScript for adding interactivity and functionality.

4. How do I choose which programming language to learn?

First, consider your goal or project. If you want to build a website, learn HTML, CSS, and JavaScript. If you want to work on data analysis, Python or R might be the best choice. Research the job market and demand for certain languages to help guide your decision.

5. Is it necessary to learn multiple programming languages?

Not necessarily. It can be beneficial to have a strong foundation in one language, but it's also valuable to have knowledge in multiple languages to have a diverse skill set. It ultimately depends on your career goals and the type of projects you want to work on.

Similar threads

  • STEM Academic Advising
Replies
12
Views
1K
  • STEM Academic Advising
Replies
7
Views
2K
  • Science and Math Textbooks
Replies
4
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
12
Replies
397
Views
13K
  • STEM Academic Advising
Replies
4
Views
972
  • STEM Academic Advising
Replies
4
Views
2K
Replies
2
Views
859
  • STEM Academic Advising
Replies
5
Views
923
Back
Top