Life SlashBoot The Internet Unices Web Development
This article last updated: Sunday, 23 April 2006

Learning to program in C on BSD and UNIX-like systems

Introduction

I have been involved with computers for nearly 25 years and yet am not particularly proficient, as a programmer, with anything but scripted, interpreted languages. Although I have previously dabbled with C/C++ on Windows based systems, a good few years ago now and in my teens I spent around a year or so, learning 680x0 assembly language, I have never really taken my talents into the field of programming in a compiled language. Since switching to BSD based systems, I have become more and more exposed to C source code and have realised that if I want to get up to the desired levels, similar to those reached in my career in IT (mainly in a Microsoft Windows based environment), I am going to have to expand my skillset into C programming. My former reluctance, using Windows, is no longer applicable. With Windows, to give yourself a reasonably well supported development environment is going to cost you some money. Actually, quite a lot of money. My past purchases in this area have been Borland's C++ development suites, first a fairly basic IDE and later I upgraded to a bigger package from the same vendor. I think these two cost me about GB£ 230, between them! Then the cost of the books took that up to I think GB£ 400-500. When I started looking into the various licensing conditions at the time, I was really put off the whole idea, even after about 6 months of learning. I was not a happy bunny!

This was almost a decade ago and the memories (and some bitterness) are now vague and distant. I've spent a couple of months, on and off, reading up about the gcc compiler and the BSD development environment, in general terms rather than getting down to the nitty-gritty of comiler flags etc. No point in trying to hop, skip and jump, before I can really even crawl, is there? What I have found, has been very encouraging and now that my Internet use isn't governed by telephone bills, as it was back then, I feel that there will always be somebody, somewhere, willing and able to assist, should I end up completely stuck. The amount of tutorials on the Internet, to assist new C programmers in learning the language, is also something that I didn't really have available to me back then. Well, they probably were available, but things were different back then and I was still learning how to make the most of the web, let alone how to use the web to help in my learning of C, as well as the online costs consideration.

I'm starting the ball rolling by working my way through some basic tutorials, in particular an excellent course that is hosted at the University of Strathclyde Computer Centre and thanks to their generosity and good nature, is now mirrored on this site, here should you have trouble getting through to their site for any reason. I fully intend to buy a copy of The C Programming Language (2nd Edition) By Brian W. Kernighan, which I understand is THE book to get on the subject. I think that I will be best prepared to make good use of the book, once I've (re)acquainted myself with the fundamentals of the language, via the online material I find, including the tutorial I mentioned above. The purchase of 'Programming in C', I hope will take me on to the point where Kernighan's book will be of most use. I also feel that I now have an advantage, in that I have been programming in PHP and the shell for a while now and that has helped me to get used to some of the conventions of C, like syntax and structure, as there are more than a few similarities between them. PHP was created by Rasmus Lerdorf, who modelled it on his experience of C, so I guess I have to thank the guy for that. Not only has he created a great rapid development, web scripting language but his work has also helped me to be better suited to C programming. I'm convinced that my previous experience with PHP and other scripted languages, have helped me become familiar with the C syntax. I recommend this route, as PHP has also forced me to pay very close attention to the security of my code. If you have access to a web server running PHP I recommend learning some PHP, if you haven't already, as I see it as a good primer for C which, if you are going along the right route, will also teach you something about programming with security in mind.

It'll be quite some time before I feel confident enough to pass on any of my own knowledge of C, but I will document my journey into it, some of the less embarrassing gotchas that I fall victim to and plenty of source, in the hope that if I am getting it wrong to some degree, then somebody might be gracious enough to give me a word to the wise. Should I be given any advice of this kind, I will be sure ot pass it on, as it might help somebody else to avoid the same pitfalls. What I do hope, is that this whole mini-project, whilst not being full of technical data and such like, might become a good primer for other people taking their first tentative steps into learning the language. It's all good fun, isn't it?

I've been asking about on the OpenBSD misc list, regarding getting the ball rolling and have been offered what I see as good, solid advice. I've had a good book suggested to start me off and break me in a little gentler than perhaps the Kernighan & Ritchie might, in Programming in C by Stephen Kochan - ISBN: 0672326663. After reading about the book and seeing some customer reviews, I think I might well have found what I'm looking for, to complete my C toolkit of books. I've also been reminded that in a BSD environment, the man pages will also be invaluable and should negate the need for too many books on the subject. It's been pointed out to me, that the K & R book has an excellent reference in it, which has saved me buying a separate C Reference Manual, as I had originally planned to do.

I've included the books mentioned here, in my book listing. This lists books that I own, books I would like to own and books that I have no longer have a reason to own, other than to help prop things up.

Summary

If you are looking to start programming in the C language, you may want to start with some online primers. The Strathclyde University C course I link to above, would be a good place to start. This should give you a reasonable feel for the language.

University of Strathclyde Computer Centre

SlashBoot mirror of the above course

If after that you are still keen, then from my own research, I would advise you look into these books, in the appropriate order:

The books mentioned here are the result of advice given on the misc mailing list for OpenBSD. Although others were also suggested, I combined the responses with the relevant customer reviews at Amazon.co.uk and settled on these three. I will, at some future point, add more titles as I find out about the good ones. As always, suggestions are welcome. Here is a feedback form to use for the purpose.

C course downloadable archives:

c.zip (163,915 bytes)
SHA1 (c.zip) = 0f99937f30f6a974bb6f13267546932d06c6362e
MD5 (c.zip) = caca5e222e5c266341ce6630c7543e6b
c.tar.gz (109,122 bytes)
SHA1 (c.tar.gz) = ca37e15af62f3905556740fb9c3c242f3f7adcb3
MD5 (c.tar.gz) = 6ed5297a0731850eeafc213ef9b82b85

Post a comment:




No HTML allowed except for plain <b>, <i>, <s>, <u> & <p> tags. NO uBB code ([b] ... [/b] style tags) are allowed and comments containing [URL] ... [/URL] tags are automatically rejected as spam.
|
URL and email address are optional, email address is never displayed.
Like this page? Furl it | del.icio.us | Spurl it
GeoLocator Contact Sitemap
Standards for a better web Valid XHTML Strict CSS inside Valid RSS2.0 feeds used on this site
Hosted by BristolGeek