Learn to Program by Chris Pine is a concise introduction to the world of programming using an interpreted scripting language called Ruby. An initial “cool point” goes to Pine for writing Learn to Program around Ruby, which is totally free to use, copy, modify, and distribute. The examples start from the basics of getting Ruby correctly installed and configured for your particular operating system. Although Ruby is mostly used to develop applications on Linux, it is a cross-platform language that is supported on many types of UNIX, DOS, Windows 95/98/Me/NT/2000/XP, MacOS, BeOS, and OS/2. I ran the examples on my Windows XP laptop without any problems, using a simple, free text editor called Textpad for some of the examples and the command line to round out my experience. The best part of it all: all of the programming tools were free! Gotta love it.
Pine aptly starts out with the essentials for most newbies to programming: data types, arithmetic operations, variables, and variable assignments. I found the overall approach and programming examples to be fun, detailed, and loaded with little tidbits of information, which gave great insight into the “how” and “why” of things. Pine’s examples and explanations throughout Learn to Program were great at illustrating the power of Ruby and programming in general, without having the overtly silly and annoying tone typically found in the Dummies series of books.
Learn to Program progressively and painlessly takes the reader through increasingly complex (for most newbies) programming concepts such as methods, classes, objects, recursion, and flow control. To reinforce the concepts in each chapter there are sections called “A Few Things to Try”, which were both interesting and amusing. One of the more interesting topics involved writing simple programs to read, write, save, and load files using YAML. (YAML is a format for representing objects as strings).
It’s always fun to learn how to dig around in various files to extract and manipulate information. This should also come in handy when managing log files on several OpenVMS servers I manage. Yes, there is a tested version of Ruby (version X1.8-1X014) for OpenVMS Alpha V7.3-1 and V7.3-2! The final chapter of Learn to Program tied all of the concepts together and introduced the use of blocks and procs as a step beyond using custom methods. The proc examples were an eloquent introduction into the more conceptually challenging topic of passing objects into methods and returning objects from methods. I remember learning the power of passing objects to and from methods in a college Java course (years ago), only after we were taken through the paces of writing programs the “dumb” way without knowing how to do this. I wish I had read this book before I took that class.
Learn to Program is an excellent book for anyone who has an interest in learning to program. It is written for true beginners, who have little or no programming experience. Surprisingly enough, Pine magically manages to go from “What is an integer?” to full-blown object-oriented programming in less than 200 pages. Another bonus is that you will be learning Ruby, one of the newer, (in my opinion) sexier programming languages currently in circulation (i.e. COBOL=not sexy, Ruby=sexy). Decide for yourself:
“Hello World” Program Examples:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLOWORLD.
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
001000 DATA DIVISION.
001100 FILE SECTION.
100000 PROCEDURE DIVISION.
100200 MAIN-LOGIC SECTION.
100400 DISPLAY ” ” LINE 1 POSITION 1 ERASE EOS.
100500 DISPLAY “Hello world!” LINE 15 POSITION 10.
100600 STOP RUN.
puts ‘Hello World!’
Learn to Program is thoroughly engaging and informative and manages to painlessly convey some pretty sophisticated programming concepts that can benefit both novice and more experienced programmers. If you want to learn to program or want a great introduction to Ruby, Learn to Program belongs on your bookshelf.