As anyone who has been following the discussion of EDP will be aware, I am interested in programming, but have until very recently favoured an extremely high-level language called BLOG. The principle of this language is that you describe in English in a blog post or comment what you want an algorithm to do, after which a probabilistic process operates. At the end of this process, if you are lucky, your description gets translated into a language that a computer can understand and the algorithm is implemented. The amazing thing is that one often is lucky. I believe that BLOG is closely related to a language called GRADSTUDENT that various mathematicians have used in the past. (My attention was drawn to the latter language on some blog or other, possibly even this one, but I can no longer find the reference.) [It has now been supplied to me.]
However, BLOG and GRADSTUDENT have certain disadvantages. One is that one does not have complete control over what one is doing. Another is that one feels slightly guilty using it. I have recently decided that it is high time I learnt to program in a more traditional language, and last week I went to a short course put on by the Cambridge computer science faculty called “C for absolute beginners”.
I’m sure a significant percentage of people reading that last sentence will react by thinking that C was not the right language to choose, so let me defend the choice. One reason for it was that that happened to be the course that I could get to. Another is that C is a very standard language. And yet another is that I am not necessarily looking at this stage for the perfect language for my needs. In fact, I don’t even know quite what my needs are. Rather, I just want to learn some language, after which it should be easy to adapt to another one (though I have heard the view expressed that if you learn C then it gets you into bad habits that you have to get out of if you want to get good at an object-oriented language such as C++).
It’s not quite true to say that I am an absolute beginner, because about thirty years ago I used to be able to write simple programs in BASIC. In a funny way, that experience has made it harder to get to grips with C and similar languages, because in BASIC you didn’t have to do weird things at the beginning of a program such as writing #include <stdio.h> at the beginning of a program, or defining a function called “main” that had nothing to do with what you were trying to do. (OK, you could argue that main is precisely what you are trying to do, but the fact remains that in BASIC you can just get down to the program without these preliminaries.) I finally lost my fear of the #include <stdio.h> line when the course instructor said that the “h” stands for “header”. I then thought to myself of how I don’t understand the beginnings of the LaTeX files I write (because at some stage in the past I copied them from someone else) and it doesn’t matter. So now I think of that first line as putting some useful stuff at the beginning of the file that I don’t actually have to think about. And from what I understand, that is the right way to think of it, at least for a beginner.
In a way, what I most wanted to do was learn how to write, compile and run any program at all. It seemed to be a big barrier to get the computer to do anything. And the main thing I’ve got out of the course is to lose my fear of that barrier. (Needless to say, it doesn’t seem quite such a barrier now that I’m the other side of it.) I got back to my office and as a quick test I wrote, without referring to the booklet we were given, a program to input two numbers and output their sum. And it worked!
Annoyingly, I can’t seem to get C to work on my laptop (a Mac). From the internet I worked out that I needed to download something called Xcode, which I did, but then it wouldn’t instal because I have OS 5 point something rather than OS 6 point something. But surely one doesn’t need the most up-to-date Mac operating system just to run C. (Incidentally, before that I tried just tying the commands cc and gcc into a unix terminal, but they were not recognised.) Another problem I have on a Mac is that it doesn’t like me creating files with the extension .c. None of this is a problem in my office, where I have Linux installed in a straightforward way. (I know I’ve got Linux on my Mac too, but as I say, it doesn’t seem to come with C as standard.)
I should perhaps add that I’ve attempted to understand C and C++ in the past, and although I didn’t manage, it was a big help this time round that I had seen at least some of it before. Here’s another example of something that seems weirdly complicated to someone brought up on BASIC. In BASIC, I seem to remember there was a command called “input”. If you were writing a program to add two numbers, it would be something like this (but I can’t remember exactly what it would be): print “What is X?”; input X; print “What is Y?”; input Y; Z := X+Y; print “The sum is”; print Z. But with C and scanf it feels more complicated somehow. Perhaps it’s just the declaration of all the variables and their types that feels complicated, though I think I could get to like heavily typed languages.
I don’t know where this is going to lead. It already felt pretty complicated when we learnt about file handling (things like processing the data from one file and copying it into another), and we didn’t get on to how one might plot graphs — so I probably can’t yet do anything useful for EDP. But it’s a little start, and something I should have done years ago.