Monday, 15 September 2008

How to learn scientific programming

[caption id="" align="alignleft" width="300" caption="Photo by Wolfgang Staudt"]Photo by Wolfgang Staudt[/caption]

This article looks at the very basics of learning scientific programming.  Any scientist-programmer must start their education somewhere.  And we have some suggestions!

Pick one language

It's a good idea to pick one language to start with.  Each language has it's own peculiarities and you don't want to overload yourself, so it's better to start with one and go from there.  There are lots of apsects of programming that transfer well between languages, so you can learn a lot of things that will be transferable to other languages as/when you find it necessary to switch.

There are lots of languages to choose from, so you want to make sure you choose one that will be appropriate for the sorts of work you'll be doing.  For example, if you're going to be doing lots of data analysis then R, Matlab or IDL could be good choices.  If you'll be working as part of a big scientific project where Java is standard, then that would be a good choice.  It's also useful if you choose a language that's used by other people you know (and of whom you feel comfortable asking questions).  Take a look at these articles (
I , II and III ) for some advice about choosing a programming language.

Learn by doing
In software development, as in so many things, there is no substitute for actually doing it.   Actually writing code makes you concentrate fully on the various aspects, plus if you're working on an actual project then you'll be gaining experience in doing exactly the things you need to do.  And don't be shy about writing chunks of code to try things out - it doesn't matter if some things don't work the first time!

Read some books
There are a vast number of good books out there on programming.  Read some of them!  Go to the library and browse a range of books on your chosen language.  Pick a handful that you find easy to read.  This is a great way of developing a more complete understanding of programming, whether it be a specific language, a paradigm (such as object-orientation or agile programming) or even just some common-sense considerations.  The knowledge you read in a book today may very well make tomorrow's coding go a lot more smoothly.  It's also a good habit to be in, to continually learn a bit more about the skills you need to do your science.

Browse the Web
The World-Wide Web is the domain of the computer geek, which means there are loads of helpful web pages for just about any kind of programming.  If you've got a problem, it's generally worth at least Googling it to see if someone else has already solved this problem.  Note that this can work even with arcane compiler errors (just cut-and-paste the error message into the search engine).  The Web is also the home of many forums on programming and science.  If you're really stuck, then posting a question on the appropriate forum can be a great way to get help.

Ask questions
Asking someone else (a colleague, a local expert etc) for help can be a great way to learn.  Sometimes, you will encounter a problem that you just have no idea how to solve and you can't find any help in the manual or on the web.  In these cases, it's great to be able to ask someone who may have already encountered such a problem, or who has the expertise to help you solve it.  Being polite and courteous is important here.  This person is doing you a favour by answering your question/s and probably has a lot of things they need to get on with.  It really helps here to have already made an effort to answer the question yourself.  Don't be lazy just because someone else may know the answer!

Always try to learn more
Learning any new skill takes time and effort.  The people who over time become true experts are the ones who are always looking to learn more and improve.  If you try to learn a little more here and there, a few years from now you'll suddenly realise that you've actually become pretty good!  We would suggest this attitude to any type of learning.

Take a little extra time to understand properly is important
We know you're busy and that you'd like to finish your software as quickly as possible.  There is, after all, world-class science to be done.  But try to take the time as you work on it to understand each aspect of your code properly.  This has two benefits.  Firstly, it will improve the quality of your code, which will have knock-on benefits for your science.  Secondly, you'll learn more be taking this considered approach, which will allow you to better complete your subsequent software projects.  Which again will benefit your science.  (see how this all ends up helping you do good science.  It's important to realise this)

After each project, review how it went (what was good; what could you improve upon)
Hindsight is 20:20, as they say.  But what they often don't point out is that this is a great way of learning from what you've done (both good and bad).  Go back over what you've done for the project you've just finished and you'll find it helps you learn from what you've just done.  You'll see things that you could have done better.  You can now remember this for the future.   And you'll also spot things that you did really well.  This is not only pleasing, it helps you to reinforce your strengths so you'll use them more the next time.

Learning the craft of scientific programming is a long journey, but one that can be very enjoyable and fruitful.  Follow these basic pieces of advice and you'll be off to a great start!

No comments:

Post a Comment