Programming As a Part of a Science Education?
An anonymous reader writes "I'm a fairly new physics professor at a well-ranked undergraduate university. When I arrived, I was surprised to discover there were no computer programming requirements for our majors. This has led to a series of fairly animated faculty curriculum conversations, driven by the question: to what extent should computer programming be a part of an undergraduate science education (in particular, physics)? This is a surprising line of questioning to me because in my career (dominated by research), I've never seriously even questioned the need. If you are a physics major, you learn to program. The exact language isn't so important as is flow control, file handling, basic methods/technique, basic resource management, and troubleshooting. The methods learned in any language can then be ported over to just about any numerical or scientific computational problem.
Read on for the rest of the reader's questions and his experiences dealing with faculty who have their own ideas.
The reader continues, "I'm discovering the faculty are somewhat divided on the topic. There is even a bizarre camp that actually acknowledges the need for computer programming, but turns my 'any language' argument on its head to advocate the students do 'scientific programming' using Excel because it is 'easy,' ubiquitous, and students are familiar with it. They argue Excel is 'surprisingly powerful' with flow control and allows you to focus on the science rather than syntax. I must admit that when I hear such arguments I cannot have a rational discussion and my blood nearly boils. In principle, as a spreadsheet with simple flow control in combination with visual basic capabilities, Excel can do many things at the cartoon level we care about scientifically. But I'm not interested in giving students toys rather than tools. As a scientist raised on a heavy diet of open source software and computational physics, I'll hang my head in shame if our majors start proudly putting Excel down on their resumes. However, in the scientific spirit, perhaps I'm missing something. So I ask Slashdot, to what extent do you feel computer programming should be a part of an undergraduate science education? As a follow-up, if computing is important, what languages and software would best serve the student? If there are physics majors out there, what computing/programming requirements does your department have? My university is in the US, but how is this handled in other parts of the world?"
The introductory physics classes at Carnegie Mellon use VPython to run some simulations. It's pretty simple to use and intuitive. The textbook makes use of it too.
Physics requires number crunching. It's that simple. It's not much use learning differential equations if you're incapable of solving anything useful. Any physics or engineering major should learn at least basic numerical methods and how to implement them. For me, we did it with C, nothing fancy. As far as using Excel for scientific computing, some of my classmates tried to pull this in a heat transfer class. It's a joke, it'll work for something really simple, but it's no good for any serious work.
Back in undergrad, I helped my AtmoSci Masters' roommate out with several projects. At least in his case, the problems involved a lot of comma or space separated text files and mostly just limited data manipulation. Students had all been taught FORTRAN, weakly, and most classmates were trying to do it in FORTRAN. Several times, we created 20 line not-terribly-obfuscated Perl programs that worked much better than pages of FORTRAN for the task at hand.
Probably Python would be the 'cooler' kit these days. But, my former roommate, now with the National Weather Service, says it's all command-line Perl scripts there and working with me to learn Perl was one of the best things he got in college.
While MATLAB can be a bit quirky as compared to C++/Java, it's an invaluable tool for engineering and simulation related work.
I'm a pretty competent CS/EE guy so I could just as easily be doing everything in C, but whenever I'm running simulations for signal processing or approximating systems my first instinct is to go to MATLAB.
For Physics students, it would be _nice_ to learn all about memory and objects, but if they want to be useful in an experimental and simulation sense, they really ought to just learn MATLAB... it was designed for all that anyway...
...one might expect, given the ubiquity of computers, that everyone (not just science majors) have some basic understanding of programming, even if it's just -- err --- BASIC.
I'll go even further and suggest that this isn't appropriate for college, but would fit nicely into 6th and 7th grade algebra.
What good reason is there that would make Matlab insufficient for a physics major? What amount of programming does a physicist do on a given day at the job?
If a physics major wants to learn more about programming than is required to compute complex formulas in Matlab then they should probably minor or double major in Comp Sci.
I majored in Math and the only programming I did as part of my degree was in Matlab. And that was in applied classes. I was taught just enough Matlab to do the assignments.
C/Java courses would have been a waste of time. A physics major's time is best spent learning how to use existing tools rather than wasting time learning low level languages so they can reinvent Matlab functionality.
Work Safe Porn
Kind of kidding-at least in my uni the engineering and science depts. seem to use matlab for all their computational needs. It's sort of integrated into the curriculum as part of calculus 3, so invariably all the science/engr. kids take it-plus it gets thrown into other courses too, so a student's almost forced to pick it up if you want to do well.
open source modern art: laser taggi
I have mixed feelings on this topic.
With a BS and MS in physics I find programming to get in the way of what the physics is about.
On the other hand I have spent 40 years programming and find it forces one to clarify the ideas behind any area.
I was taught Algol-60 at Stanford from the computer science department. At that time the physics department did not require any programming.
The experience of Algol lead to SAIL (Stanford AI Language) and then MAINSAIL (Machine Independent SAIL) and later Oberon and now BlackBox/Component Pascal.
All of these languages were influenced by Nicklaus Wirth who taught at ETH Zurich. Dr. Wirth adopted from Albert Einstein the phrase "As simple as possible, but not simpler" as a slogan for the Oberon Language. Einstein got his undergraduate degree from ETH Zurich. So there have a beautiful blending of physics and computer science.
One needs to be able to think abstractly as well as concretely with physics. The ABSTRACT facility and Object Oriented aspects of Component Pascal aid here. But unlike Smalltalk one is not forced to use objects. One can get down to the machine level if need be using a CODE construct within the language.
Although I have seen but not used MathLab I believe such already written graphical facilities are a benefit. Why reinvent the wheel unless it is part of the learning process.
I whole heartedly reject the C/C++ class of languages as 'programming in a can'. Far, far, too complex and syntactically messy.
Keep it simple.
Here in the UK its a standard requirement. Certainly at good unis (Oxbridge, Bristol, Manchester, Imperial, St Andrews).
At Imperial, they teach C in the first year (dressed up as C++, but mostly avoiding pointers + OOP). Standard 'big' project is a simplified double pendulum, numerically integrated & used to investigate chaos.
The second year sees OOP introduced rather counter intuitively via a HEP-orientated labscript. I don't like this second year script one bit, as it teaches the 'kids to program stupid access functions that never get use and build an enormous 500+ line cathedral to eventually do a calculation that could be written in three 5-line functions.
In the third/fourth year there is a computational physics option, partly lectured (FFTs,linear algebra,numeric integration,monte-carlo/Metropolis, lots more I've forgotten) and two bits of lab coursework (metropolis model of magnetic domains, solving a simple tight-binding model electronic structure with matrix method... others I've forgotten). Code can be written in any language, though most people keep on using C(++).
Other than the 2nd yr OOP via heartache, I think its pretty good.
I believe Oxford trialled using python to teach their course. You might even be able to google down the handbook.
That said; there really is room for teaching people basic data mangling (+ gnuplot scripting?) in the aim of training experimentalists to analyse their data. Its heartbreaking to watch PhDs struggle with origin to handfit things that should be batch scripted (with provisos to avoid certain areas of data from fit etc.), or hand edit a 1000+ line file of data in Notepad to cludge it into a binary-only analysis tool.
I'm surprised this is even a question. There is a meaningful use for computers and information technology at virtually every level and function of Physics, save possibly the imagining part.
And even there, the mental muscles you acquire, solving puzzles, constructing semantic connections, seeing the big picture while managing the minutiae, all help to make you a better scientist, to see your problem newly. In fact a great physicist would want to try on at least two or three significantly different world views, just so they have the freedom to Grok their specific field in new and powerful ways. In my experience, getting mired in a narrow way of seeing things is the kiss of death for someone dancing on the fuzzy edge of unraveling the mysteries of existence and trying to see all in a meaningful and relevant way.
Additionally, the language of choice is clearly Vpython. Great for simulations, rich set of programmatic tools, quick prototyping, high level, easy to learn, tons of documentation, and huge user community with tons of ready made chunks of code available for the asking. Excel is a kiddie car. Forgive me, but trying to graphically express a tensor field in excel would be like trying to figure out how jerry-rig a Big Wheel to compete in the Indy 500. You're not going to achieve anything interesting in Excel, and it's a pitiful tool for expressing higher order concepts or visualizations. It's just not made for that for that purpose.
If you're looking to get a really sweet pie chart showing the distribution of funds for your next research grant, by all means, use Excel. If on the other hand you want to do a graphical simluation of branes colliding and view a number of possible outcomes, given by a select range of values for the simulations initial parameters, use Vpython. Let the tool fit the need.
That was my formal introduction to computing. Later on in my course, I mostly used MatLab, and occasionally C. Sometimes I had to reverse-engineer old Fortran code. I wrote my Master's thesis in MatLab (even though it was a rather computationally expensive application. In scientific applications, the time saved during design time often easily makes up for the loss in computational efficiency).
Since I started my PhD, I've tried a lot of different languages, from MatLab to Java, C# Python and, recently, F#. Even though I was brought up with OSS (my laptop runs Debian next to Windows), I have come to value the rapid development capabilities of
I think my point is: It's probably a good idea to start with powerful low-level languages like C first, but don't overdo it. It's good if your students know about the existence of Assembler and Fortran, but the important point is that they lose their fear of computers. Nowadays, teenagers grow up with computers, but they never get to see behind the web 2.0 surface. Our generation grew up with text editors and batch files. They grow up with facebook. So it's important to give them a look behind the curtains. Let them feel the power of being able to control memory adresses. Once they have lost their fear of pointers, they can move on to use high-level languages that safe loads of design time, while being able to descend down into the architecture when it really counts.
I know this is going to confirm every bad stereotype the
Maybe next semester I'll do a research colloquium on SQL and basic database construction.
There's a perfect xkcd for my sig but I'm too lazy to look it up. sudo someone go find it.
Off on a tangent... You mentioned Mathematica, I've found at my University that many students got their first introduction to programming there, and continue to use it in research, in tasks it is arguably not well suited for. Mathematica is a good way to visualize math, and perhaps a decent intro to programming, but I'm very surprised to frequently find it used for extensive Monte Carlo simulations where floating-point calculations would be much faster and sufficiently precise.
My programming was limited to one class on MATLAB. Learning to program was a common debate and conversation between the professors and management and the students.
The major issue with knowing how to program was for people who intended to goto grad school. It's definitely a huge plus for graduate work in physics and should be a requirement for anyone who intends to go further than a BS. Because I wasn't planning to get a masters or Ph.D. it was never really a problem.
A year later, I'm a SQL Server developer, so what do I know.
The issue at hand is the degree to which a specialized curriculum should "require" specialized skills from an outside field. This is a gray area and needs to be determined by the governing body/committee for whichever university or better yet field oversees the degree program.
;-).
:-)
My input...every scientist needs to understand the potential of computers and therefore programming languages but there's no need for them to be capable of programming. It's certainly a great asset if you can combine the scientific and practical capabilities into one person but there's really no need for it in the real world. If a physicist is capable of handling her work I don't actually care how she gets it done. All I ask is that the work be timely and correct.
So if you want to encourage the use of computer programming you need to establish a curriculum that actually requires the use of computers. If a student is able to bypass the computer and still complete assignments, labs, and exams, then the computer isn't really a requirement.
This is the view I take of virtually everything in life, if you have to question if something is a requirement than it's not a requirement becuase those are obvious
As for languages or technologies...I think that's the wrong track. If you're a programmer, capable of programming, then by definition you can program in any language provided you have some reference books and time to learn. Stick with stupidly simple programming languages for beginners and focus on the fundamentals so they can transfer that knowledge on to other languages.
Here's what I'd want any physics student to be able to do (regarding programming) after graduating from college with a physics degree.
1) Conceptualize the power of computers so that they can consider the use of computers to solve "challenging" problems.
2) Document the requirements of a test/model/project in a manner consistent with the principles of computer science so that they, or anyone else, can write a program using some computer language.
3) Interact with programmers to build/test/improve programs related to physics problems.
And the person I'd want to hire...the kickass physics major who doubled in computer science and is a contributor to the Linux kernel.
Back in 1974-78, all students in the University of Illinois' College of Engineering were required to take at least a semester of introductory programming. That included the Physics majors because the Physics department was under the aegis of the College of Engineering (unlike Chemistry, Biology, etc.). That this particular science was placed in the engineering school always seemed like a really weird, but good placement.
That is all.
I am a PhD student working in computational condensed matter physics. My undergrad did not have a requirement for programming - it should have. As a result, I have had to waste time catching up. The argument "they can learn it on their own" could be said about a lot of skills taught in undergraduate physics. I probably could have learned how to use an oscilloscope on my own, but I didn't have to. It was something we covered in first year lab. As a result, I know how to use this instrument properly, and the learning process was efficient. Based on what I have seen in graduate school, I think that an undergrad should learn how to use a language like C, C++, or Fortran (I'm talking about f95 mind you), as well as some scripting (bash, perl, whatever) and command line plotting tools (gnuplot for example). While environments like matlab are nice, they make it more difficult to run your codes on machines you don't own. I do a lot of this. No matter what, excel (and variants thereof) should not be promoted as an approach to scientific programming. Physics is not point and click.
There are whole classes of problems that Excel is well suited to solve. Linear propagation models, optical ray tracing for instance, is one. I remember back in the early 80's spreadsheets in general were touted as a good way to solve complicated 2-D boundary value problems via iteration because you are given a nice cell grid to start (I have foggy memories of doing this myself on whatever preceded Excel). I have seen some very impressive models built out of spreadsheets; it wouldn't have been my tool of choice, but the people putting them together could really do some impressive things.
At the undergraduate level I don't know what to say. I don't know how much programming I would force on the physics major. I am a very strong advocate of teaching mathematical methods for the major, as I had been. My professor spent some time having us learn FORTRAN, but I wouldn't say it was very productive because we were learning it for the sake of knowing it, not because we had a task to use it for (and so it really didn't set in). I didn't do any serious programming until graduate school, where I ended up becoming a FORTRAN expert after all.
I do agree that Excel can't handle real data sets, especially with the limitations of plotting 32k data points and only holding 64k in a column. On the other hand, not too much data handling you do at the undergraduate level deals with that much data.
I wouldn't say the students would be at a major handicap having only used Excel at the undergraduate level. If they are handed that particle data set in C++ objects, they'd do what I would have to do: learn C++. Between undergraduate and graduate school I made a conscience decision to learn either C or FORTRAN, since those were the languages of physics. I settled on C, picked up some books and started teaching myself. When I got to graduate school, the research I inherited was all FORTRAN, so I ended up betting on the wrong horse (at first, at least). When I got out of graduate school, I ended up learning C for the job I was doing at the time (I've since drifted into the IDL/Matlab world and now I find I'm rusty in all of them!).
You also have to be careful what you consider a grown-up language. By the time I got out of graduate school, C++ was all the rage and I kept hearing how they couldn't believe that any serious programmer would program in a non-object-oriented language unless they were either old or a Luddite.
I was once in a moderately prestigious science undergrad program. There were no programming classes as part of the curriculum. And no, this wasn't an oversight on the part of the people who designed the program. Because this was a computer science program.
(Full disclosure: I didn't make it through. Had to admit that in case any of the profs who flunked me out read this.)
That's not uncommon. MIT probably rates as the leading computer science school in the country, maybe the world. I don't know much about their program as a whole, but I do know their key freshman course spends almost no time describing any programming language. Of course, it helps that they do all their actually programs in Scheme, a language whose syntax you can write on the back of an envelope.
Which is not to say that Scheme is a trivial language. Quite the contrary. But I doubt that anybody who makes it through SICP puts "Scheme" on their resume. No, they talk about their newfound knowledge of algorithmics and data structures.
If you want to make your students skilled scientific programmers, don't make them take programming classes. Create physics classes where programming is a key element. Programming is just a tool, and do you have a class for every tool your budding physicists might use?
I know Matlab has really low (or no) cost for educational use
Usually I don't feed ACs, but here I am astonished and ask for clarifications, because we, as educational institution with a 'university' in its name, have to pay horrendous sums for the licenses of Matlab. One single seat license is close to the campus license price of Microsoft.
C/C++ is clunky, but once you know it, you can figure out most every other modern programming language.
;)
As a physics undergrad, I was required to take a Mathematica course. I already knew how to program, but for most of my classmates, it was their first time programming, with mixed results. Most ended up using it as glorified calculator, rather that actually creating structured programs...
What really annoys me is the anachronistic faculty who force their grad students to use Fortran 77...
Simon
Yes! Programming should definitely be a part of every physicist's and engineer's undergraduate education. As a physics undergrad I learned Maple and MatLab. The last course that was required was all about numerical methods to solve differential equations. Most problems that physicists encounter are too hard/tedious to work through by hand. (You can usually guess which problems will be on the test just by asking yourself what is doable in 1 hour.) Having all the students learn basic programming allowed the professors to assign homework problems that were more in depth and we could explore topics in different ways. As an experimentalist, I rarely use my programming skills in my research, and I'm certainly not the world's greatest programmer. However, I do find value my programming training, and it's something I've found that I (usually) enjoy learning. At my graduate institution, programming was not taught as part of the physics curriculum. I have been less frustrated doing homework than other students because I have not had to wrestle with learning a new program and solving a difficult problem at the same time. Also, I was taught good programming methods. Once I was able to solve a problem in 15 lines of code when it took my friend, who was self taught, about 1 1/2 pages of code. Needless to say, my solution was much easier to follow and understand what the program did. As an instructor for a 400 level class, I get frustrated that my students are so uncomfortable using a computer to generate plots and such for their homework (even with Excel). The previous instructor for the class did the homework solutions in Excel. Yes, Excel can do the problem. But it takes me far less effort to do the problems in Maple/MatLab.
Fortran is 'teh sux0rz' at more than two dimensional arrays, though. It doesn't use row major order, so the offsets are all screwed up. Don't use it to simulate four dimensional space/time unless you have something to prove to yourself and/or don't mind premature gray hairs.
If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.
Forty years ago, in the second semester of my freshman year, the physics prof told us of a wonderful opportunity to take a pass-fail class in FORTRAN. It was pass-fail because programmming was not really an academic subject, but, like using a slide rule, was necessary for doing physics. So, we all took the extra class in the evenings and did our homework with stacks of punch cards at 3AM just like all old-timers prattle on about.
From then on, data for every lab were analyzed with programs and we had to turn in our program as well as our results. It was a really good way to learn physics and programming too.