I gave a talk about Virtual Observatories (and other astroinformatics stuff)
to the recent STFC Introductory Summer School in Astronomy 2011, in Glasgow. Here are a few extra notes that occurred to me later, spontaneously or as the result of questions from attendees at the school.
The slides are on the web at the summer school site (you'll need the relevant password to get them). Or they're here.
Why C++?
Why indeed?
There are very few questions to which the correct answer is C
, and even fewer to which the answer is C++
.
One really good question that was asked in the computing session, and afterwards, was If C++ is so awful, why do so many people use it?
My facetious answer was: machismo! While I don't think this answer is entirely wrong -- there's a persistent air of harder-core-than-thou when people talk about their use of C++ -- it's probably not complete, and a more serious answer is called for.
At the time when C++ was becoming popular, there was a fairly clear need for some way of bringing object orientation to C, in order to make it feasible to build larger C-like systems (it was object-orientation because that was the higher-order fashion at the time; if the history had been a little different, the monster could have been agent-C or concurrent-C).
The other main contender was Objective C, which is an attractive, and in particular attractively restrained, alternative way to bring object orientation to C. Despite its various virtues, Objective C hasn't taken off in the same way that C++ has, and its main visibility nowadays is within OS X and iOS (that's a pretty important niche, but niche it nonetheless is).
I'd claim that almost all of the real software engineering need for an object-oriented C-like language is satisfied by Java, which is just about as flexible and just about as fast, but a whole lot more principled, portable and intelligible.
About the only good reason to take up C++ is because you have to use a library or framework implemented in C++, or because you're joining a community which is already committed to that. Even then, if you doing mind going against the flow a bit, quite a lot of the use of such libraries could be done in Java, which by design has reasonable support for calling out to C++.
I'm a poor cheerleader for Java. As I said in the talk, Java is officially a Very Boring Language. But since one of my main criticisms of C++ is that it is way too Interesting for its own good or for your mental health, you'll appreciate that this isn't intended to be a criticism.
So what language should I learn first?
This isn't my favourite langauge either, but Python has a number of really good features:
- It's a scripting language, which means that it's designed to be quick to pull a program together.
- Despite that, it's reasonably fast, and it's possible to build large systems in Python.
- It's extensible, so it's possible to call out to libraries written in other languages, such as C. This means you can use existing important libraries, in a language you can integrate large systems with.
- There are large libraries written in Python, and it's on many people's shortlist of languages to choose for writing extension APIs for new services.
Python won't lead you into any particularly bad habits. Plus, it's fairly commonly used within astronomy, which means you're likely to be able to find someone nearby who knows a bit about how to solve your problem.
I've heard about Perl...
Yes, and I've heard of sado-masochism. It doesn't mean I want to go off and experiment.
Perl was once a very Good Thing (it was one of the languages which persuaded people that you can do a lot with scriping languages), and I've written a fair amount of Perl in my time. But Psycho-Killer Hallucinogenic AWK++ is probably no longer the best tool for all jobs.
Anything else I should know?
Not a huge amount -- you'll pick up what you need.
I plugged Software Carpentry in the talk (I wish I was on commission). Whether or not you work through the lessons on that site, the syllabus is good as a checklist of things you should think about investigating.
I was involved with the Starlink Project for a while, and one of the things I produced during my time with the project was a document called the Theory and Modelling Resources Cookbook. That was last updated in 2003, so most of the specific advice is rather out of date. However, looking back, quite a few of the generic remarks are still reasonable, so this might be worth a look.
Interestingly, I see that in that document I am much less rude about C, C++ and Perl than I would be now ('would be?!).