Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is the Perl programming language useful?

  1. Nov 19, 2007 #1
    Hello all, I was wondering, since I read in a document that programming is used alot in physics work, if Perl programming was any use? I dont know much about programming or even computers for that matter all I know is that Perl is mostly a text based programming system and I assume that its not used because its not binary? I picked up a few Perl books and that helped me understand the basics, I didnt get too far into it before sending it back to the library, too much work going on at the time. But if I was to pick up a book at a library that would help me with later physics work in college, to get a basic idea, what type of programming should I try and learn? C++ or C? Any tips?
  2. jcsd
  3. Nov 19, 2007 #2
    I would probably recommend Python over Perl for physics. Python has a number of physics-related computation and visualization modules available, such as SciPy and VPython. It would be worth learning one of C(++) or Fortran for extremely computationally intensive tasks, but for most quick and dirty computations, Python should suffice.
  4. Nov 19, 2007 #3
    Ah, thanks, any idea where I could find a book that could teach that? The only books my library has are JavaScript and Perl and C(++).
  5. Nov 19, 2007 #4


    User Avatar
    Science Advisor
    Homework Helper

    The o'reilly book learning python is pretty good.
    Or the online tutotrials http://docs.python.org/tut/
    For maths there is a (free) heavy duty numerical add-in http://numpy.scipy.org/

    Python is as easy to use as Perl but has rather clearer and less confusing syntax.
  6. Nov 19, 2007 #5
    Not so sure if I would say easy personally, haha. But thanks for the links, I'll definitely check them both out.
  7. Nov 19, 2007 #6


    User Avatar
    Science Advisor
    Gold Member

    I'm going to echo these guys on the basis of personal experiences & preferences. "Serious stuff" ~ Python (which don't require or for some reason want to do e.g. with C++ or something related)(Python is being used & taken into use all over the place with respect to physics appls), "misc scripting, data processing etc." ~ Perl. Would also highly recommend to make sure you get a compiled language like C++ to your repertoire.
  8. Nov 19, 2007 #7
    Perl has special capabilities that make it especially good for dealing with large text-like data sets; however it can work with "binary" and mathematics just the same as any other programming language. The difference is mostly a matter of what features of the language get the most focus.

    Although I have used Perl for many years and am very fond of it, I must second (third?) the recommendation that you would be better off using Python. Python has many of the same advantages as Perl, but it is "cleaner". Perl has a lot of special rules that make it very quick and natural to use when you are writing small tools-- but, when you try to write large structured programs these special rules mostly get in the way. Also Perl is hard to learn, because the special rules make it so complicated, and it will teach you bad programming habits. Python on the other hand makes everything simple and clean and easily-organized. Python is also a good pick if you are going into physics simply because from what I hear Python has a lot of institutional support in the areas of Physics and Engineering. (Although for some reason Perl seems to be popular with Biologists!)

    I DEFINITELY think that Perl/Python are better for your uses than C/C++. Those languages are a large investment, so to speak, and the ways in which that investment pays off will not be very useful to you personally. Perl and Python hide a lot of low-level things about programming from you, whereas C/C++ make those low-level things front and center. If you try to learn C/C++ you will probably spend all your time learning to be a "programmer" and very little actually getting anything done.

    I don't know how best to go about learning Python though, sorry! But I have found that O'Reilly books are almost always good. If you go with O'Reilly though be careful though to get the "learning python" (is that the name?) book and not the "programming python" book, because the "programming python" book is all about advanced techniques assuming you already know the language. (I made this mistake once myself...)
  9. Nov 20, 2007 #8
    I don't know a thing about physics programming, so maybe I should be ignored. On the other hand, maybe not, since I'm just echoing what's already been said.

    There's some quote about Perl that I just can't seem to find that basically says that the problem with Perl is that if you write a program with it and then come back to look at it the next day, you won't have a clue what its supposed to do.

    Programming in Python has been one of the best experiences of my programming life. It seems to make everything easy enough and the online tutorial/documentation is great. I would definitely use it for everything if I were still programming.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook