Tuesday, June 30, 2009

Practical Programming: An Introduction to Computer Science Using Python

Authors: Jennifer Campbell, Paul Gries, Jason Montojo, and Greg Wilson Format: Paperback, 350 pages Publisher: Pragmatic Bookshelf; 1st edition (May 28, 2009) ISBN-10: 1934356271 ISBN-13: 978-1934356272 According to wordnetweb.princeton.edu, Computer Science is "the branch of engineering science that studies (with the aid of computers) computable processes and structures". It's the study of computer architectures, languages, and mathematical structures as applied to the process of computing. So what have Campbell, et al produced in this book...a Computer Science textbook that teaches Python? Kind of. Imagine you wanted to learn how the computer is used in the various scientific disciples. Further, you wanted to learn how computer programs and programming is used in this context to construct tools, perform investigations, and to solve problems. You also want to use a single programming language as your example. Welcome to "Practical Programming: An Introduction to Computer Science Using Python". Not a book about learning Python as such, but an introduction to the discipline of Computer Science with Python as your guide. Yes, it is a text book. Page 5 in the Introduction has a For Instructors section which should be a clue. Code samples and installation instructions for the class are available for download at the book's website. New as this book is, there's already entries in the Errata section, and as with other Pragmatic books, there's a discussion forum available for questions and comments, which will come in handy for teacher and student alike. This really is a book that starts at the beginning, even to the point of describing a prompt in a python shell on page 9. Sections in Chapter 2 include Expressions and What is a Type, so the reader isn't presumed to know Python or programming at all. Like any other textbook of worth, there are exercises at the end of each chapter. Also like many textbooks, the information is presented in a rather "dry" manner, so don't expect to be entertained. Please keep in mind that this is a textbook and the target audience is a beginning Computer Science class. Class instructors are the most likely subset of the audience to be commenting about the book at this point, since they are using the book to educate their students in the fundamentals of Computer Science (which leaves me out since I'm not an instructor, but I'll do the review anyway). The book doesn't contain any surprises. Ultimately, it teaches beginning concepts in computer programming and as such, takes the reader along the elements of learning programming. As I mentioned before, Python is the "example" language, but the student is really supposed to be learning programming principles in general, not just Python programming principles. I must admit that Python was a good choice for this task as a language to learn from, plus it has a great deal of power and scalability. Thus the Python skills learned by the student will serve him or her in future classes and in a programming career. If you want to buy this book as an individual to teach yourself the content, it will still work, but you won't have the support of an instructor or a class. You can use the aforementioned discussion group at the Pragmatic site to ask questions and review any issues or shortcomings you discover (such as packages requiring Python 2.5 be installed on your computer in order to work). Many of the programming books I review contain at least a little humor to help break the monotony of the topic being taught, but don't expect to get any laughs out of this book. Campbell and company have written this text to be "all business". If used in the classroom, the instructor or the resident "class clown" will need to provide any required distractions or levity. Perhaps this is because this book is for a beginning Computer Science class and needs to take itself very seriously. I suspect that the publisher imposed this style of writing as part of the requirements for this series. In real life, in sure the authors are very funny. This is a beginner's book, so don't expect to learn everything there is to know about Computer Science or the Python programming language. It's just one class, intended to be taught in semester one of year one of a university student's academic career (though it could also be used in a High School class of similar nature). The later chapters do touch on Object-Oriented Programming, Graphical User Interfaces, and Databases, so by the end of the course, the student should be prepared to move on. Appendix A is the book's Bibliography, so you can see the sources drawn upon and, if you're using this book independently, determine what other books you might want to add to your library. Many of the sources are other traditional textbooks, but a few are more widely used references such as O'Reilly's Learning SQL. If you don't anticipate using this textbook in an Introduction to Computer Science class, but are intending to enter into such a program, this book would fit nicely in your summer reading list, giving you a leg up on the course work. Since a large part of what you are supposed to be learning is the process of computing, exposing yourself to the principles early can only help. That, and as a standard classroom textbook, is the best use I can think to make of "Practical Programming: An Introduction to Computer Science Using Python".

Friday, June 26, 2009

Review: Regular Expressions Cookbook

Authors: Jan Goyvaerts and Steven Levithan Format: Paperback, 510 pages Publisher: O'Reilly Media, Inc.; 1st edition (June 4, 2009) ISBN-10: 0596520689 ISBN-13: 978-0596520687 According to Wikipedia, "In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters". If you even dabble in open source, shell scripts, and writing code, you are likely at least somewhat aware of regular expressions. Some people are even really good at using regular expressions, but this method can be a struggle for others. O'Reilly's Cookbook series offers over 100 "recipes" using regular expressions to solve common tasks. The question is, will this cookbook help you whip up the dish you need to serve? I hate to cave in to the consensus of reviews on the web, but this book is hot! That said, there is a caveat. Despite the fact that the Intended Audience section of the book's front matter states the book is written for anyone who "regularly work(s) with text on a computer, whether that's searching through a pile of documents, manipulating text in a text editor, or developing software...", many of the people who are editing articles, books, or a web page source won't need or want to access the power regular expressions have to offer. Also, a large number of the book's recipes are written for programming languages or for web development, so to make the most out of this book, you'll need to be doing work in those areas. I was a little surprised that the book didn't require any prior experience with regular expressions at all. It offers the reader a complete introduction from the first chapter on what regular expressions are, then proceeds to teach the basic skills in chapter two. I doubt it will replace O'Reilly's Mastering Regular Expressions but it might be a way in the "side door" of using regular expressions for someone who doesn't need to "master" this process. For those of you who are programmers (which is most likely the majority of people reading this review), the content that will interest you starts in Chapter 3. Languages covered in the recipes includes .NET Java, JavaScript, Perl, PHP, Python, and Ruby. Regardless of your level of expertise, there's bound to be a recipe or two in this book that will make your life easier. A regular expressions cookbook doesn't require that you be able to use this method "from scratch", any more than a food-related cookbook expects you to create a cheese soufflé from scratch. The "ingredients" are all listed, how they are to be mixed, the temperature of the oven, how long to bake, all the little details should be included. Of course, you'll need to know the difference between a cup and a tablespoon, and how to use all the tools typically found in a kitchen. The regular expressions cookbook is no different, except the ingredients and process aren't designed around food but rather text. You also have to know what task you want to perform and the cookbook must contain information on that task. If you want to make an omelet and your cookbook doesn't contain that recipe, you're out of luck. That's the limit of the Regular Expressions Cookbook. At least some of the recipes contained within its pages must apply to the tasks you need to perform. A random (I just flipped to a page) example is as follows. In recipe 3.5 Test Whether a Match Can Be Found Within a Subject String, the problem is presented in summary and then the solutions are offered. In this case, the solutions presented are for C#, VB.NET, Java, JavaScript, PHP, Perl, Python, and Ruby. The discussion section talks about any additional information or special cases involved in any of the languages. In this example, discussion sections are available for each of the aforementioned languages. The reader is also referred to Recipes 3.6 and 3.7 for more information. I just described the general formatting of recipes in any of O'Reilly's Cookbook texts and this is what you can expect when you use this specific book. If you want (and this is the way the common cookbook is used), just thumb through the table of contents or index to find the particular recipe you require and then have at it. Occasionally, a novice cook will consult the beginning sections of a cookbook to familiarize themselves with food preparation basics. If that's describes you relative to regular expressions, you'll find the early parts of the book quite handy. Bottom line, I'd have to say that the Regular Expressions Cookbook is best used by someone who doesn't use regular expressions regularly (sorry), but whose work efficiency would be enhanced by using a regex engine. The types of recipes that are accessible through this book are also correctly "biased" to the audience, so you won't find that only one or two bits are useful while the rest are impractical or unrealistic for typical coding and text manipulation tasks. I'd have to say that authors Goyvaerts and Levithan and O'Reilly have hit a home run with this book.

Tuesday, June 23, 2009

Book Review: The Manga Guide to Physics

Authors: Hideo Nitta and Keita Takatsu Format: Paperback, 248 pages Publisher: No Starch Press (May 13, 2009) ISBN-10: 1593271964 ISBN-13: 978-1593271961 "I can't change the laws of physics! I've got to have thirty minutes!" -Scotty The aforementioned quote is from the original Star Trek series episode The Naked Time. As you may (or may not) recall, the Enterprise crew had become infected with a disease that did away with all inhibitions and good judgment, allowing everyone to express their deepest thoughts, feelings, and fantasies. Riley (played by Bruce Hyde) had locked everyone out of engineering so as "Captain", he could control the ship. He also unfortunately, turned off all of the engine power while the Enterprise was orbiting an ancient planet in the process of breaking up. When Scotty and the crew regained control of engineering, the ship was entering the planet's upper atmosphere and was minutes away from fiery destruction. Kirk wants the engines started NOW! but you "can't mix matter and antimatter cold". The "laws of physics" say so. Sure. Kirk, Spock, and Scotty get the engines started, invent the time warp, and all is right again, but just exactly what "laws of physics" was Scotty talking about? For that matter (no pun intended) what are the "laws of Physics"? The answer to that question may not be easy to learn for some of you. Like electricity and databases, technical subjects aren't always effortless to grasp, let alone master. If you are an exceptionally visual learner, a dry textbook may not do you much good, especially if you are required to learn the content and demonstrate your knowledge (take a test) in a high school or university beginning Physics class. Fortunately, once again No Starch Press has come to your rescue by publishing The Manga Guide to Physics (originally published by TREND-PRO Co., Ltd., Japan in 2006). If you're familiar with any of the other books in this series, you know that the lessons are told within the context of a story depicting the adventures of a hero or heroine, presented in "manga" or Japanese comic format. While this may seem amazingly frivolous to some of you, physics (or databases, electricity, statistics, and so forth) taught within the context of manga can be "distracting" in a good way, and there's no "law of physics" that says education can't also be fun. If the idea of learning while reading manga appeals to you or if you're just curious, this book and series could be the way to go. A couple of things to keep in mind. First of all, this is a beginner's book, so you won't know everything there is to know about physics by the last page. It's just to get you started and to familiarize you with what probably are the topics in a "Physics 101" class at the high school or college level. Also, it's unlikely that an instructor of such a class will actually use this book (though I've been wrong before) to teach said-class. As with the other "Manga Guides" I've reviewed, this book seems best suited as a preparation text for a student who is looking forward to attending such a class (in the same way as he or she might look forward to having their fingernails pulled out by a pair of pliers and then crawling five miles naked over ground glass). If there's something that could give such a student a "jump start" on the coursework and ease the pain of transition, that something would be exceedingly welcome. The book is divided into four basic sections or topics: The Law of Action and Reaction, Force and Motion, Momentum, and Energy. Unlike the prior two Manga books I reviewed (electricity and databases), the story isn't set in a mythical kingdom or a fantasy city, but rather in a "typical" (for a manga adventure) school. The authors have you follow the "adventures" of student and tennis ace Megumi who is a "star athlete" but hopeless when it comes to understanding physics (I'm sure you can see where this is going already). Fortunately Megumi befriends "physics geek" Ryota, who helps her leverage her understanding of sports in order to teach her how to pass her physics class. As is consistent with this series, the book presents the "story" or scenario designed to teach specific principles followed by a more "factually" organized review section. As is consistent with traditional manga or anime, there's plenty of drama to be had, this time in the form of Megumi's rival Sayaka. If you are athletic or used to thinking in terms of sports metaphors, the book's storyline is an added bonus. Megumi's athletic performance, particularly on the tennis court, becomes dependent on her understanding of the physics she's learning for class. She has to think of learning physics in terms of the sports she plays. Also, like some students (or some people in general), when one area of her life has problems like her physics class, Megumi can't concentrate on any other area of her life, even tennis. Although there are two authors listed, Hideo Nitta actually wrote the content while Keita Takatsu provided the artwork. As it turns out, Nitta is well qualified to write a book on physics since he's a professor in the Department of Physics at Tokyo Gakugei University and has published numerous papers and books on topics such as quantum dynamics and radiation physics. I don't know how the dynamics of creating this book happened, but I wonder if Nitta really did write the book creating the characters, dialogue, and situations or if he had help from Takatsu? If the former, I'll have to give special kudos to Nitta for not only knowing his topic (and with his qualifications, it's to be expected) but being a creative fiction and manga writer, too. No, you won't learn about the physics of matter and antimatter and how to write a new start-up routine for a vintage 23rd century warp engine, but you will grasp the foundational basics of physics by the last page of this book. As with the occasional movie, there's a little "treat" waiting for you after the credits, or index in this case, just for one last chuckle (did I mention, this book is funny?). If you find yourself in need of a physics primer and traditional textbooks either send you into fits of anxiety or to the depths of boredom, give The Manga Guide to Physics a whirl. You might learn something and have fun doing it. Oh, just a thought. I wish some writers of science fiction including those creative souls responsible for the most recent Star Trek film would read this book occasionally. For instance, in the film, when Chekov beamed Kirk and Sulu up to the Enterprise while they were in free fall, the law of the conservation of momentum says they should still have been falling when the materialized in the transporter chamber (causing a really big bang!). That said, my son theorizes Chekov used an inertial damper field to suppress this law during transport. Gee, aren't the (fictional) physics of the future wonderful...and convenient?

Monday, June 8, 2009

Front End Drupal: Designing, Theming, Scripting

Authors: Konstantin Käfer and Emma Hogbin Format: Paperback, 456 pages Publisher: Prentice Hall PTR; 1st edition (April 15, 2009) ISBN-10: 0137136692 ISBN-13: 978-0137136698 The Käfer and Hogbin book isn't just a "how to use Drupal" book. There are a number of books that introduce Drupal in general (I put in the link just in case you need to know what Drupal is), including Using Drupal (O'Reilly) which I previously reviewed. According to this book's back cover blurb, "Drupal is now the world's number one content management system...As Web Designers and developers adopt Drupal, they need ways to quickly customize the visuals and interactivity with their sites." Is Front End Drupal then a book with just a focus on designing and managing themes, or is there more "under the hood"? Let's find out. As always, my first question for a book is "who is it written for?" The back cover invokes "web designers and developers", which presupposes a certain skill set. The authors have backgrounds in both web development and Drupal, so that should also be a clue. That said, I didn't find a section in the front matter of the book saying "this is the book's audience" or similar text. The context of the book will have to do, but who the book is created for should become fairly obvious early on. The first page of the Forward states the basic problem and thus, the reason this book was written. Apparently, Drupal sites "out-of-the-box" are "ugly". Further, Dries Buytaert (Drupal founder and project lead) says "...creating a Drupal theme isn't always easy. It's a crosscutting experience that requires a lot of diverse skills and utilizes expertise in XHTML, CSS, JavaScript, and PHP..." That should be enough to define the target reader of this book, at least as far as what you have to know to utilize this text. Chapter 10 is an introduction to jQuery, further narrowing the focus, at least as far as JavaScript libraries are concerned. Chapter 1 starts out with a lesson on how basic web design integrates with Drupal. No, it's not an XHTML/CSS primer. You are supposed to know that stuff already to be able to utilize this book, but the authors do suggest here that you access those skills when mapping out the design of your future Drupal site. They do include resources such as Zen Garden and W3Schools.com's CSS Tutorial for those who might need to brush up in that area, so it's not like you have to be a total guru. I found this interesting because, as I moved through the book, I found that being a guru helps a lot, but more on that in a minute. Theming tools and strategies are added onto this "gentle introduction" and the more formal introduction to Drupal begins, including JavaScript, PHP, and the Drupal API. The mechanics of creating a Drupal theme are presented as early as Chapter 3, including more online tutorials and code examples in the book. This is where your coding experience starts to be needed. A basic understanding of at least XHTML, CSS, and PHP is required from here on in. I say "at least", because the book will not hold your hand as far as learning these technologies is concerned and even then, I don't think just "basic" skills are quite sufficient. The way the topics are presented doesn't seem to be quite "even" and I really think a lot of prior web design/development, and even some prior Drupal experience helps in having a good reader experience. In fact, if this book was my introduction to Drupal and I had no other experience with this platform or with other Drupal books, (even if I was well versed in the underlying technologies), I can see myself getting lost somewhere in the first third of this text's pages. If I was expecting a "total newbie's" book, I'd probably write a review slamming the authors for getting me in too far over my head. Do not, repeat, do not use this book if you have no experience with Drupal at all. Even more, do not use this book if you have little or no experience in web development. This book is best used by people who are (despite the resources presented in Chapter 1) well versed in how to design websites. If you work in a content management firm, you are probably ideally positioned to use Front End Drupal. The book's Appendix describes how to install Drupal, if you don't know, briefly discusses LAMP/XAMPP, and provides equal time for Windows, Linux, and Mac OS X as OS platforms. A "value added" piece is the book's support website which has the sample code included in the book available for download. There's also an errata page for the first printing of this book, so you can check if any issues or errors you come across have already been dealt with. Contact the authors if you come across something new. I'd suggest downloading and configuring Drupal up front and learning basic Drupal from a book like O'Reilly's Using Drupal before digging into Käfer and Hogbin's Front End Drupal. Save yourself the aggravation (or the temptation of writing a "negative" review on this book) of trying to follow along with this book if you don't have a Drupal background already. Those of you who do know Drupal and know web development, have fun.