How to get started in computer programming for Linux

I’m going to be spending three months in Kyiv this summer, getting a lot of rest and occupying my time with only my hobbies, and I’d like to learn something about computer programming while I have so much free time. I’m a Linux user, and it seems that most of the source code floating around is in C or C++, so C is what I’d like to learn.

So, how do I get started in programming? Linux seems to have all the necessary software for working with C and Perl built in, so what books or website will teach me the language? There’s a book out there specifically on C++ for Linux. Sams Teach Yourself C++ for LINUX in 21 Days, is that good? I’m really looking for something which assumes no prior experience with programming, it seems most books believe “Hey, you’re learning C++? Well, you certainly have already been coding for years in C/Perl/BASIC/whatever, right?”

I have no visions of immediately turning out awesome code, I’m just hoping to learn more and improve my computer literacy. I used to be a Windows user, but since I switched to Linux I’ve learned a lot more about how computers function (buggy software and imperfect installers which raze your system force you to get educated). However, it would be nice to eventually pay back the programming teams who have made the free software I use (Gnome, Mozilla, GPG), because those teams are often very undermanned and like having new people on board.

UnuMondo

Yep, you’ve got all the necessary software you’ll need in Linux already. Pick up a copy of Practical C Programming and do the lessons contained therein. That book will give you an excellent grounding in the basic principles of C, after which you should be able to learn how to tinker with various graphics toolkits and so forth by looking through the code and figuring out how it works. (Most things I’ve learned about programming are by looking at other people’s code.)

Oops - forgot the link: Practical C Programming.

The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie is probably the best programming book ever written. Every C programmer should own a copy.

If only every textbook was like this one.

I you really want to end up knowing C++, I would recommend learning C, Perl and Java first. C, because that’s the language C++ is built around. Kernighan and Ritchie is a good book, although a little terse in places. If you need another one, just go to the bookstore and flip through books until you find one that seems clearly written to you.

You should learn Perl for two reasons. It is very, very useful for automating routine tasks in Unix. And reading input/writing output, which is one of the more difficult parts of learning C, is very easy in Perl, so you can get a program working quickly, and then learn to do more complicated things gradually. The O’Reilly Perl books are excellent (“Programming Perl” and “Perl Cookbook”).

You should learn Java as a warm-up for C++. Java is really just a simplified version of C++. All the objects for making windows, buttons, etc. are in the standard distribution, so you can start building a simple GUI application right away. You’ll learn how to write an object-oriented code by connecting these applications up, without having to write the objects from scratch or use a system-specific set (e.g. Windows). The compilers and everything are free from Sun’s web site (http://java.sun.com), and there is an excellent in-depth tutorial on the site as well, which was all I needed to learn the basics of the language.

Once you know Java, C++ (which is much more flexible, but unstructured) will be much easier to get the hang of. And you’ll be amazed by how similar they are.

Good luck!

I’m going to go against the grain, here, for a moment… What you need to learn first is not how to program in C. What you need to learn is how to program. After you’ve got a couple of languages under your belt, they all start to look the same, and there are a lot of principles of good programming that are universal to all languages.

C might or might not be the best first language for you. It’s designed to be closer to the machine’s level than to the human’s… This is a very good thing, once you’ve learned it well, but it does lead to a rather slow learning curve. You may be better off starting with, say, BASIC, and then moving to C.

I checked “Programming Perl” out of the library, but it assumes a great deal of prior experience with programming and software architecture. The book says its companion “Learning Perl” is for newbies, but according to the Amazon reviews, “Learning Perl” is also for programmers coming from another language and goes right over the heads of total beginners.

Thanks for the suggestion to learn Java, I wish I had thought of that before I posted. Java has a ton of online tutorials, so I wouldn’t have to immediately buy an expensive book. Working with Java on Linux isn’t as easy as C, however. You say that all of my experience with Java will be applicable to C++ in the future?

UnuMondo

I recommend Java, and this is coming from someone who has been a C/C++ programmer for 20 years. The current versions of C/C++ are too tied to fairly arcane and difficult architecture issues. Linux isn’t as bad as windows in that regard, but it’s plenty hard enough. You’ll be facing a steep learning curve.

Java, on the other hand, is more abstracted from all the hardware and intricacies of plumbing. Creating a class in Java means just writing a class. In C++, there are a whole swack of ‘plumbing’ requirements you have to learn that really have nothing to do with programming per se.

If you have access to a windows machine to work on, I highly recommend downloading the free personal copy of Borland’s JBuilder. Just go to www.borland.com and follow the links. JBuilder is probably the best Java development environment for Windows right now. And you can’t beat the price.

Another advantage Java has going for it is that there are a ton of learning resources on the web, and the entire language is well documented. Sun’s Java site is a massive reference work. You can find answers to almost any questions you might have there.

I agree, since you’ve never programmed, I think starting with C would be quite frustrating. Java is very easy to learn and there’s lots of free advice, sample code, etc. available all over the web.

Java is good, since you get to learn OOP in nice small bites. Learn the basics, then look at some real programs to see how things are done. There should be lots of sources on Sun’s site.

The Kernighan and Ritchie book is an excellent reference since, well, they invented the language. But if you are new to programming it can be hard to understand, and C is not the easiest language.

I like the Sims Teach Yourself series a lot, and I have several of them. For a more comprehensive treatment, get C++ From The Ground Up by Herbert Schildt. Once you feel comfortable programming, try Beginning Linux Programming, 2nd Edition by Richard Stones and Neil Matthew. It’s somewhat dense, but it has lots of good material and code examples.