Introductory Books for Beginning Programmers

I’ve recently started learning progrmming seriously and so I’ve been on the lookout for good books to learn from. So here’s a short list of books that I’ve found useful. They deal with a variety of languages and concepts and the best thing is that they’re all absolutely free. Please note that these books would probably be most useful for someone in the last two years of school, though older people shouldn’t have a problem. I’m personally using them as a sort of prep for studying Computer Science in college and so only time will tell if I’ve been successful.

How to Think Like a Computer Scientist – Python Version

Python by itself is a very good programming language for beginners (unless you’re less than ten years old in which case I would suggest Logo). Combine that with a good book and you get a winning combination. The book’s style is clear and cluttered and the chapters are fairly self-contained. It does a good job of introducing procedural programming first before moving on to object orientation (which can be quite a difficult concept for beginners). My only real gripe is that there seem to be too few exercises, which sort of leaves you on your own to find something to do.

How to Think Like a Computer Scientist – Java Version

This is the original Think Like a Computer Scientist book, and unfortunately it’s one major flaw isn’t really something that can be fixed: the choice of language. Java as a language may be very nice, but it’s certainly not too fascinating for beginners. If your learning programming on your own, like I am, I would recommend starting this book after you’ve come to grips with the object oriented matter in the Python book. That issue aside, it is a very good book and I personally like its style slightly more than I do the Python one’s. One major scoring point is that there are a number of exercises at the end of each chapter which involve both writing and reading/fixing code. This book will also come in handy if you’re studying for the American AP exam, but I’m not quite sure if it covers all the bases. I would suggest combining this with the BlueJ IDE, which’ll let you sidestep many of the practical hurdles involved in using Java as a beginning language.

How to Design Programs

This book is designed from the ground up to make you learn programming that is data-centric, i.e. the program’s very purpose for existence is the data that it manipulates. Unlike other programming books that focus on specific concepts as a path around which to structure your learning, this book focuses on data: you start by using smaller, atomic types of data and then move on to using mroe complex data structures. This book uses the functional programming language Scheme. But this books comes with its own dedicated environment: DrScheme. DrScheme helps beginners tremendously by hiding obscure syntax features until the time is right. It does this by providing not just standard Scheme, but a number of subsets containing only the features that you will need. As you progress through the book you move on to richer and richer subsets until finally you’re ready to use full-fledged Scheme. The book focusses on the ‘why’ of a program rather than the ‘how’.

Structure and Implementation of Computer Programs

Think of this as the last one’s big brother. SICP has been the textbook for MIT’s introductory Computer Science for the better part of two decades. As you can well imagine, this not for the faint of heart. However, once you set your mind to it, you’ll find that the book deserves its reputation as a computer science classic. It’s written in a simple no-nonsense style and like HtDP, it teaches you programming, not a programming language. It uses Scheme, but it makes and effort not to let your attention be drawn to what language you’re using. The book drives home the fact the computer is just a tool and your head is where you have to do the real work. That being said, there is probably no point in reading this book unless you intend to make computers your career. Also, having some amount of programming experience would help you on your way. This book is also rather intensely mathematical, and so make sureyour math skills are well polished before you embark on this journey.

Programming from the Ground Up

This book takes a different approach to programming: it’s basic premise that you can only really learn how to make a program if you understand how the computer ticks inside and what it does when it runs your program. As a result of that philosophy you are required to get up close and personal with the computer and that means assembly language. Yes the book uses assembly language (x86 assembly to be specific), but all the examples are very thoroughly explained and if you have patience in abundance, you shouldn’t have any problems. What sets it apart from SICP, is that while SICP approaches programming from a mostly theoretical aspect, this approach is decidedly practical. Again, probably not worth your time unless you plan on computer science as a career.

Personally, I think all the above are very good books. Of course there is the inevitable question of choice. I’m currently working my way through the How to Think Like A Computer Scientist books (yes, both of them). Once school is over I will try push through How to Design Programs and finally go through SICP and Programming from the Ground Up. All in all, I think all of that should keep me busy for the better part of a year. So in a year’s time, come back and check on my progress. If you’d like an IDE to go with your new book, check out the next post.

Advertisements

The Ackermann Function in Java: Why Computers are Stupid

I’ve started teaching myself Java, right from the basics and as a guide I’m using the Java version of the How to Think Like a Computer Scientist book. One of the exercises at the end of the fifth chaper (called Fruitful Functions) is to implement the Ackermann Function as a recursive method. The Ackermann function is mathematically defined as:


Now, the Ackermann function is quite well suited to computerization, it takes little real intelligence to solve for any two numbers, and is mostly repetitive calculation (which computers are good at). It took me less than a minute to implement the function as a Java method as follows:

public static int ackerman(int ack1, int ack2){

if (ack1 == 0)

	return ack2+1;

else if (ack1 >0 && ack2 == 0)

	return ackerman(ack1-1, 1);
else if (ack1 >0 && ack2>0)

	return  ackerman(ack1-1, ackerman(ack1, ack2-1);
)

I passed it to the compiler and the compiler replied with a cheery: “missing return statement”. Since I already had three return statements, that meant that there was a possible path through the method where the method would end without a value being returned. The Ackermann function doesn’t work with negative numbers, so I had already implemented a check for negatives before the function call. I tried putting in another check for negatives in the function itself, but that didn’t work. By this point I was getting rather frustrated because the above code would catch all non-negative numbers and produce appropriate returns. I ran the code in my mind with a few small numbers and everything seemed to check out as it should, the values of ack1 and ack2 would keep on reducing until ack1 hit zero and the method would end with a proper return.

Finally on a hunch, I decided to remove the last if-else and make the last return statement free-standing. Semantically it was the same thing, because there was only one possible case if the first two conditions were not satisfied. And for some reason the compiler thought that this new version was perfectly passable. I haven’t entirely ruled out the possibility that there was really some path that would have resulted in no return. But I think that it is far more probable that the compiler for some reason couldn’t handle the multiple recursions and simply gave up. Of course, I’m not an expert in these things and if someone knows of a proper explanation please let me know. Until then I’ll stick to the knowledge that a computer is still quite some distance away from what would be common sense to a human (or at least the Java compiler is).

Book Review: Beginning Python

Learning a new language (human or computer) isn’t always easy. But it helps if you have a good teacher, who makes things fun as well as interesting to learn. Sometimes a good book can make things a lot easier. I’ve been wanting to learn Python for a good few months now and being the dedicated netizen that I am I turned to the Internet for tutorials and howtos. Though Python documenatation is fairly complete and quite usable if you are trying to teach yourself, it can be rather bland at times. Luckily for me, Beginning Python: From Novice to Professional from Apress came to my rescue.

Beginning Python is written by Magnus Lie Hetland, author of another Apress book, Practical Python and a number of well-written online tutorials which are available at his website. Beginning Python isn’t meant to teach you everything that there is to know about Python or programming. What it tries to do (and succeeds at) is to give you a good head-start from the basics upwards. The book covers a fair amount of matter, starting from the basics of writing simple, small programs to full-fledged GUI applications. Most importantly however, it does so in a pleasing, conversational style. Each chapter is fairly self-contained, dealing with a particular aspect of Python programming, which means that you can learn at your own pace and even skip a few chapters without too much difficulty. But what makes the book stand out from the crowd is that it not only gives a working knowledge of Python, it helps you figure out what to do with that knowledge. The book includes 10 programming projects including things like an XML converter, and internet messaging system, a file transfer program with a graphical frontend and even an interesting little game. Most chapters also come with a set of suggestions at the end about how you can apply what you’ve learned: a great way to keep yourself busy if you’re bored

While the book is called Beginning Python, there is some amount of more advanced information like network programming (including working with CGI and SQL), using GUI toolkits and other practical things like testing, debugging, optimizing and packaging programs. At the same time, it should be noted that the book does not intend to turn you into a complete master: the advanced material is enough to get you up and running, but do not cover the topics in great depth. All things considered, the book will probably be useful to you even after you have a fair mastery of the basics. It’s clean structure and good formatting allows it to be used as a quick reference as well as a textbook.

The book is definitely worth a buy if you’re interested in learning Python but have been keeping it off for want of a good resource. The $45 price tag is a bit steep, but it’s worth it for a book that will take you a long way and will probably still be useful even after a good few months.

Book Review: Beginning Ubuntu Linux

I’ve come across numerous Linux books since I started using Linux about a year ago. From what I’ve seen Linux books generally fall into two categories: Firstly, books that are about specific distros (Mandrake, Red Hat, SUSE etc.) and books that are about general Linux topics (like BASH scripting, networking, security). For people who are beginning Linux, it’s the first category that is most useful. Most such books are about the popular distros. In the past they have included the likes of Red Hat and SUSE. Recently Ubuntu Linux has joined the ranks of the popular and mass user distros, and Beginning Ubuntu Linux is one of the first books written specifically to give a helping hand to people who are beginning their Linux journey with Ubuntu. And that includes people like me.

This book is different in many ways from other similar books that I’ve come across in the last year; in fact in seems to be as different from other books as Ubuntu is from other major distros. The back of the book says that the book is “Written for newcomers to Linux, yet comprehensive enough to appeal to even seasoned users”. And they are quite right about it. The book does not just cover how to get Ubuntu installed and running, it also takes a good look at the common applications that any computer uses: office and mulitmedia programs, internet software and even some slightly more advanced topics like making backups, networking with other computers, making sense of the Linux filesystem and optimizing your system for better performance.

Most Linux users, especially new users today are exiles from the world of Windows and for them adjusting to the Linux world can sometimes be a challenge. This book accepts the fact that most of it’s readers will be coming from Windows and will need a helping hand figuring things out. The two most important questions asked by any Windows exile are: “Can I use my favourite Windows programs in Linux?” and “Do I have to type in a lot of weird commands?”. This book anticipates these questions and makes a determined and sincere effort to gently introduce the Linux newbie to Linux equivalents of comon Windows programs and also to the weird and wonderful thing that is the command line. I especially liked the chapters devoted to the intricacies of the BASH shell, and even though I’ve spent a good deal of time at the Command Line, I still learnt a new trick or two.

But of course do actually get the most out of the book, you have to have Ubuntu installed on your computer. There is an in depth guide to installing Ubuntu, which holds your hand through the whole process and even helps you through the often confusing process of partitioning and also tells you what to do if you run into one of the common errors. it then goes on to take you on a tour of Ubuntu’s GNOME desktop and helps you set up your hardware and get connected to your home network and the Internet. There are also sections to guide you through conecting scanners and cameras and using USB storage devices and installing graphics card drivers. There is also a section on installing a firewall and securing your computer (which includes an introduction to the user system in Linux).

The book is replete with screenshots, which make sure that the user encounters no confusion while installing and configuring her or his system and the layout is clear and simple. But what impressed most about the book is not how well it guides the new user, but that the book begins with an extensive account of the history of Linux and the free softare movement. And it is one of the few books that I have encountered that give due credit to both Richard M. Stallman and Linuz Torvalds acknowledges the part played by the FSF and GNU software. The book ensures that only will a reader become an adept Linux user, she or he will know about the people and the ideas behind Linux and understand appreciate the differences between Free and proprietary software.

In the end it all boils down to this: is it really worth paying $39.99 for this book? The answer is yes. If you’re a new Linux user, this book will certainly save you a lot of time scouring forums and documentation for solutions to simple problems and answers to common questions. Even if you’re reached the stage when you can manage linux without too much of a fuss (like me) you can still hope to learn a good few things from this book. And thanks to the spirit of humanity and free software, you also save bandwidth charges because this book comes with a complete, no-strings-attached copy of Ubuntu on CD. If you’ve been hearing about Linux, but have been waiting for someone to hold your hand when you take the plunge, just get this book and get wet!