1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Which programming language do you use?

  1. Sep 17, 2008 #1
    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.
  2. jcsd
  3. Sep 17, 2008 #2


    User Avatar
    Gold Member

    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.
  4. Sep 17, 2008 #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. Sep 17, 2008 #4
  6. Sep 17, 2008 #5


    User Avatar

    Staff: Mentor

    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.
  7. Sep 17, 2008 #6


    Staff: Mentor

    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.
  8. Sep 17, 2008 #7
    Does anyone uses Java for serious problems?

    By the way, thanks for the quick replies!
  9. Sep 17, 2008 #8


    User Avatar
    Science Advisor
    Homework Helper

    Pretty much no,
    Partly this is historical, scientists learnt Fortran, engineers learnt 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
  10. Sep 17, 2008 #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.
  11. Sep 17, 2008 #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" [Broken]
    Last edited by a moderator: May 3, 2017
  12. Sep 17, 2008 #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.
  13. Sep 17, 2008 #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.
  14. Aug 6, 2009 #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 shouldnt 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...
  15. Aug 6, 2009 #14


    User Avatar
    Homework Helper

    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).
  16. Aug 6, 2009 #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)
  17. Aug 6, 2009 #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.
  18. Aug 6, 2009 #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.
  19. Aug 7, 2009 #18
    Indeed. The best language to learn is the one you have to!
  20. Aug 7, 2009 #19
    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" [Broken] object to supply those services.
    Last edited by a moderator: May 4, 2017
  21. Aug 7, 2009 #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. :(
  22. Aug 7, 2009 #21

    Are you familiar with the methods to link MATLAB and C++ together? You can really get a speed boost from that.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook