How I learned to stop worrying and love DJGPP


February 24, 1998

The morning after my Yaroze 'awakening' (as we like to call it in therapy), I rose from my bed to the early morning sounds of birds chirping and with a new-found sense of determination. Like when you see a great movie, the buzz of the previous night was still with me. I started to flick through "A Guide to C", and although it began in a fairly straightforward manner, after a few pages it began to throw sentences at me that took three or four readings to understand. Uh-oh. James had said this was a fairly useful book (it's what he used to learn C), but it was causing me trouble before the end of the first chapter. It was encouraging that I vaguely understood the more rudimentary concepts it outlined, but after skipping ahead to sections on "Arrays, Strings and Pointers" and "Binary Trees" I realised that I would never learn C from this book without a great deal of help. "A Guide to C" seems to have been written to accompany university courses, rather than to teach complete home-alone novices (like myself) C. Surely there was something a tad beginner-friendlier? In a state of concern and brooding despair, I trotted down to the local bookstore and browsed the 'Computer Programming' section (in the company of numerous bearded gentlemen). After half an hour or so (despite the vast number of titles), I reckon the books available could be neatly divided into three categories:

1) References for people who already know how to program C, but need a book to help them pick up on mistakes, etc. These books are for professional C freaks, and should be avoided like the plague by beginners. They have titles like "The C Programming Language" or "The Complete C Reference".

2) Books for people doing C at university, or on similar courses. I reckon "A Guide to C" falls into this category. If you can program in another language already, and are quite computer-literate and mathematically-minded, a book like this might suit you - although I suspect you'd still struggle with some of the trickier elements. These tomes have titles like "C by Dissection", "The Basics of C" or "The Student's C Handbook".

3) Books for regular people (like me) who want to learn C from a book, probably from scratch. These books have vaguely encouraging titles, like "Learn C in 21 Days", "C from Scratch" or "C for Dummies". If life were a Douglas Adams novel, they would have "Don't Panic" emblazoned on the front in warm, friendly letters.

I have no ego. I plumped for "C for Dummies: Volume One" because it starts you right at the beginning. It assumes you have zero programming ability, and takes about 20 pages to cover what most of the other books do in 5, spelling out exactly what you're doing and why you're learning it. At the time of writing, I'm actually about two-thirds of the way through (a week after buying it) and I have to say, I recommend this book to anyone who wants to learn C. It was a bit simplistic to start with (even for me!) but by the time you get to the vaguely tricky stuff you'll be glad you had such a thorough grounding in the basics! The only downer is that "C for Dummies" comes in two volumes - and although when put together they cover a fair bit more than the other books, the total cost of the two volumes is still over £40. Still, if you're serious about learning C (and you suspect you might benefit from the softly-softly approach) this isn't a huge amount of money (especially as the "Dummies" books also function as references when you're finished with them). Oh yeah, the "C for Dummies" books are also written in a chatty, slightly jokey style which might put some people off (i.e. if you prefer dry, dull, turgid textbooks).

A few words of warning about all of these books. First of all, as you might have suspected, they are bloody expensive i.e. "C for Dummies: Volume One" costs £18.99 in the UK (and then Volume Two is £23.99 - grrrr)! That said, most of the other books are about £25-30. Another important point is that all of them assume you have a 'reasonable working knowledge' of computers (specifically, PC's). I can only assume that anyone contemplating taking up Yaroze coding has a 'reasonable working knowledge' of how their computer works. Although programming in C has turned out to be less tricky (so far!) than I thought it might be, I don't want to make it sound like a piece of piss. If you don't really know how to use DOS, or are new to computing in general, you should really get good at the basics before diving in at the deep end (i.e. learning programming). That said, I can't imagine too many people reading this who wouldn't call themselves reasonably competent computer users. The final (and possibly most important) point is that all these books assume you have access to (and know how to use) a C compiler. Don't panic: I'll explain what that means later on (and if you use Windows 95, I'll explain how to get hold of the excellent freeware compiler I use - DJGPP).

I didn't actually buy the 'Dummies' book that day. I reckoned that I needed a while to mull over the options. In a games-o-centric frame of mind, I picked up a copy of "Joystick Nation" (JC Herz's paean to the halcyon gaming days of the eighties) to keep me going, which was an entertaining (if not exactly mind-shattering) read. There were a few niggling remarks which suggested JC might be slightly more clued-up if she played less of those eighties games of her youth and got stuck into some modern classics like Mario 64 and Resident Evil, but her heart is definitely in the right place. I guess that's the evil of print - it dates so quickly.


February 25, 1998

Today was designated "Get my C compiler up and running so I can go out and buy a C book" day. If you got all freaked out when I mentioned 'C compiler' a few paragraphs back, don't worry! At this moment I suppose I should quickly explain my limited understanding of what a C compiler is. Basically, you type in your C program which looks something like this (except normally much longer!):

#include <stdio.h>

void main()

{

printf("Whoah, dude! This is, like, such a cliché…\n");

}

Next step is to save it as some file with a '.c' extension, like "cheese.c". You then use a program called a C compiler to turn your dainty C code into an actual executable file! The feeling of satisfaction after creating your first EXE file is indescribable (or maybe I'm just too embarrassed to describe it). I can't remark on the numerous C compilers out there, but if you plan on learning C on a Windows 95 PC, you should get hold of DJGPP, which is a port of the GNU GCC C compiler made available as freeware by the Free Software Foundation. Bless 'em! DJGPP actually runs in a DOS box, but it does require to be in a Windows environment so if you're a real dinosaur and just use DOS, you're on your own! The DJGPP homepage is at:

http://www.delorie.com/djgpp/

There are loads of files available to download, and different people may need different ones. To save you the hassle I had, I can tell you that all you need to get in order to compile C programs and learn C on a Windows 95 PC are the following:

(explanations courtesy of the DJGPP FAQ)

readme.1st

(This explains how to install DJGPP and get started with using it)

faq210b.zip

(The latest edition of a FAQ list. Use it whenever you have problems installing and using DJGPP)

bnu27b.zip

(The GNU Binutils, including `as', the GNU assembler; `ld', the GNU linker; and their docs)

djdev201.zip

(C header files and libraries, library reference, minimal development environment, DJGPP-specific utilities and their documentation)

gcc2721b.zip

(The GNU C Compiler binaries and docs - including the docs for the C++ compiler)

txi390b.zip

(Info, a stand-alone program to read GNU hypertext documentation, and an environment to produce such files. Without `info', you cannot read the C library reference and the docs included with the ported GNU software packages)

Install all this in an aptly named directory, working in a DOS box, and you have a bare-bones C learning setup. Of course, if you already have a Net Yaroze, then you will have received Sony's C/C++ compiler (which is another port of the GNU software)! If you are currently Yaroze-less (which you probably should be if you don't know any C), then the DJGPP solution is a good way to dip your toes into the murky waters of amateur C programming.

My experience of downloading DJGPP was fairly traumatic. Being the donkey I am, I downloaded the UNIX port of GCC from the Free Software Foundation's homepage before I realised that I actually needed to get DJGPP. Doh! Anyway, after spanning the files over several floppies, I arrived home to discover that one of the files was corrupted. So, I downloaded it again from home, at great personal expense. I have to say, I was in such despair at my bad luck and DJGPP ineptitude that I almost gave up, but getting the C compiler installed and working has actually been harder to work out than most of the C programming stuff I've done so far!

Late that night I typed in my first C program (from the opening chapter of James' "A Guide to C"), compiled it and was greatly chuffed to end up with an EXE file that displayed "Hello, world" on the screen. One giant leap for a man, one small step for mankind. At this point I should explain my "learn to program C" strategy, which went something like this:

1) Get C compiler up and running
2) Get "C for Dummies: Volume One"
3) Work through "C for Dummies" to ensure I have what it takes to program C and that I'm not about to waste a huge amount of money.
4) Order Net Yaroze. Perfect my C skills waiting for it to arrive by working through "C for Dummies: Volume Two".
5) Unfuzzy the differences between Yaroze and PC programming, get to work creating the world's best-ever game, take over DMA Design (and, eventually, the world).

I vowed to pick up "C for Dummies: Volume One" the next day, and spend the weekend going through it, hopefully finding out whether I could hack it or not. I was quietly confident, but only time would tell…


Next page?

Or return home?