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!

Useful programming languages to learn?

  1. Dec 27, 2012 #1
    The universe keeps (emphatically) yowling at me to learn a progamming language. As part of my research in computational biophysics I'm attempting to learn python as rapidly as possible. But I'm trying to figure out which languages are most useful to learn, and which languages I should learn, since the universe has also rudely informed me that my odds of becoming a researcher in physics are somewhere between 0 and 1, but waaay closer to 0 than 1.

    C and C++ are mentioned frequently. My father is a bit eccentric but he makes his bread by programming in Scheme and feeding it to a C interpreter while working for a big tech giant. He vigorously suggests I learn scheme.

    Any others? Would two languages suffice (C, python and scheme)?
  2. jcsd
  3. Dec 27, 2012 #2
    Hi A & L :smile:

    Honestly, I would think that learning to program very well in just one language would be sufficient. It is much less important which language you use. They all do the same things, they just use different "words" to do them. Once you know how to program in one language, it is relatively easy to switch to a new one.

    That being said, sometimes learning two different languages will help you to understand programming concepts better. Seeing the way each language handles things can give you a lot of insight. Kind of like using two textbooks to learn a new subject (which I also recommend).

    I think since you have a head start on Python, you should stick to it. C++ is also a good one, but if you think your dad will be a good resource in learning, then maybe the second language should be Scheme.

    Best of Luck!
  4. Dec 27, 2012 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Saladsamurai's remarks are bang on.

    The nice thing about doing some C is that it get you close to the hardware and lets you understand how certain things work that are hidden from you in a language like python. Scheme might help you to learn a style of looking at programming called functional programming: http://www.defmacro.org/ramblings/fp.html . C++ is a horrible, ugly, badly designed language that was scarred for life by design constraints such as the desire to make it backward-compatible with C.

    Yes. Many people who get through an undergrad CS curriculum actually can't program their way out of a paper sack in *any* language. Learn how to program in one language, python, and you're one up on them.
  5. Dec 27, 2012 #4
    Thanks guys! I'm actually quite fascinated by this point of view that many CS majors can't program worth beans, it seems utterly unexpected. A lot of my physics friends are panicking that they won't stand a chance against a full blown CS major, but I suppose I can tell them otherwise...
  6. Dec 28, 2012 #5


    User Avatar
    Science Advisor

    As others have commented, what you really want to learn is /programming/, not a programming language. And if you go into a field with "computational" in its name, you'd better learn it good. In order to become a decent programmer, you generally have to be "fluent" in multiple languages, as different languages are good for different problem domains. And in order to be a good programmer, you have to be at least a decent computer scientist (that means you need to know at least all the stuff taught in a BS course in Comp Sci, in particular algorithms and data structures to get started)

    The most useful languages if doing numerics are likely Python or Matlab (choose one), C++, and C or Fortran (choose one). You should not start with C[1] or Fortran, as starting with either one will make you learn bad programming habits. You should start with Python, as this has the best effort-to-outcome ratio, and even when knowing only Python, you can get quite far. But you should be aware that there are things which simply cannot be done with it, many of which are important in fields with "computational" in their name.

    About scheme: While scheme and common lisp are undoubtedly very powerful programming languages, you need to be aware that about 95% of the stuff they are good at can be done just as well in python (and much cleaner), and that if you seriously try to use them, you will quickly learn that you have to re-invent every single wheel (unlike in Python) and that you will be the only one in your lab using those languages. If you have some time, learn a LISP dialect by applying it to some toy project. It is fun and will make you grow as a programmer. But those are not good languages for everyday use, and nothing to get started with.

    [1] (as most of C is a subset of C++, learning C is mostly a question of learning how the C++ constructs are actually implemented. Pure C itself is redundant.)

    Edit: Yes, C++ is a horrible abomination straight out of hell (it is also a good example how you can arrive at a horrible result by doing only perfectly reasonable decisions.). However, it is still by far the best language for many kinds of applications, in particular all applications which call for *both* a software design (i.e., large applications) and raw performance (you can 100% performance in C++ if you know what you are doing). Most big applications in Windows, including Windows itself, are written in C++. There are good reasons for that.
  7. Dec 28, 2012 #6


    User Avatar
    Gold Member

    Python is the best place to learn programming, then you can move on to which ever language you please. I don't know what your level your programming expertise is, but Coursera will be running at least three free online Python courses in the next two or three months, two provided by University of Toronto (a "the very basics" type course and a "crafting quality code" type course), and one provided by Rice University (event driven programming and object oriented programming). Unless of course you have already taken them as they ran this autumn as well.
  8. Dec 28, 2012 #7


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

  9. Dec 28, 2012 #8


    User Avatar

    Staff: Mentor

    For the record, I did the FizzBuzz program (from Ben's first link) in C++ in nine minutes. If I hadn't succumbed to "oh gee, maybe this would be a better way to do it" after I was halfway through, I would have finished in five minutes. :tongue:
  10. Dec 28, 2012 #9
    Udacity is a good place to learn python.
  11. Dec 29, 2012 #10
    Do you think co-learning scheme while focusing most of my efforts on python would be a good idea? I was told that scheme will alter the way I think about solving many problems.
  12. Dec 30, 2012 #11


    User Avatar
    Science Advisor
    Homework Helper

    I think you should concentrate on python to learn programming in general if you are new to programming. Co-learning anything else is fine. But if you don't get python you probably won't get anything else.
  13. Dec 30, 2012 #12
    Ah okay, so far python is a breeze but it may just be I'm not pushing hard enough/working on any interesting projects.
  14. Dec 30, 2012 #13


    User Avatar
    Science Advisor
    Homework Helper

    That's probably the point about python. It is easy. It has sort of a minimum of syntactic formality about it and it's expressive. Take a python program and try to translate it into say, C++. Using STL classes will probably make it not that hard, but it's definitely a challenge.
  15. Dec 31, 2012 #14
    To throw a cat amongst these pigeons, I think Java would be a good language to learn after Python.

    This is because it is purely object-oriented and will teach you good project design. Its major limitation is its slow processing speed, but this is less of an issue nowadays than it used to be.

    I am not a strong programmer, but I learnt on java and can still knock out useful code when I need to (this being said, i use python scripts daily)
  16. Dec 31, 2012 #15
    I've heard from some that object-oriented programming is overrated. Is this true?
  17. Dec 31, 2012 #16
    it's main strength is when coding in a group, so you can write code that uses someone else's code without needing to see their code.

    I guess it would be overrated if you were involved in every aspect of the project and weren't worried about other people being able to use your code.
  18. Dec 31, 2012 #17


    Staff: Mentor

    Since you mentioned using you're programming for computational biophysics then I'd suggest Java and by extension Groovy. Groovy is fairly new to the scene. Its a scripting language based on java using java syntax, able to call upon java classes and fully interoperate with java without the hard requirement of using the class structure for your program. It also supports functional programming.

    I've used groovy with the Java Open Source Physics library (www.compadre.org/osp) as part of a graduate level computational physics course and it worked quite well.

    Groovy is also the base language for Grails, a web application framework with backing database which could be useful as your get further along in your project and you need to export results to the web for others to work with. That route would extend you into the realm of javascript and HTML using jquery, jsxgraph and other notable software.

    If you do go this route then I'd also suggest Eclipse or Netbeans IDE tools as they make life of a programmer more bearable and productive.

    More info on groovy can be found at: http://groovy.codehaus.org/

    and grails at: http://grails.org/
  19. Dec 31, 2012 #18

    jim mcnamara

    User Avatar

    Staff: Mentor

    This is a great way to start a flame war. Let's NOT do that, please.

    Consider another idea:

    Maybe you can think of programming languages like this: a few have become well-adapted (analalgous to Natural Selection and Adaptation) to particular niches. Example: C is mandatory if you want to do UNIX system programming or UNIX/Linux kernel development.

    COBOL is likely never going away, no matter what you may think of it. These niche languages are not likely to fade away because MEL is cooler'n all-get-out, or Numpy is your idea of perfection because GSL sucks, and Mathematica and Maple cost too much.

    There has been a proliferation of programming tools, languages, and dialects. Some new entries will fade, others will find a niche and become another de facto standard.

    to the OP:
    Pick a language - one - that has been around for a while. Learn that really well.
    You would far better off longterm to pick a language that has a standards group (e.g., ISO) behind it.
  20. Dec 31, 2012 #19
    The main advantage to knowing multiple languages is that you can read source code for programs you use more easily. For computational biophysics, you'd probably beniefit a lot from knowing fortran, as I imagine a lot of the heavy-duty codes you'll be using are written in it. Python and C are also common in computational physics.
  21. Dec 31, 2012 #20


    User Avatar
    Science Advisor
    Homework Helper

    A lot of the advice in this thread amounts to "I think you should learn my favorite language" (or even "I think you should learn the only language I've ever used").

    It doesn't matter much what language you start with, because if you do a significant amount of programming you will soon have to learn another one. And another. And another. In 30+ years of programming, I've learned and used at least 20 languages, and I've forgotten almost all the "trivia" about most of them.

    The question "which language should I learn" is a bit like "which make of car should I learn to drive in". Unless you choose a Model T Ford, or an F1 race car, the answer is "it doesn't really matter".
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook