Mastering NGINX

Nginx is an http server intended for high traffic websites with a mind toward network scalability. I used NGINX as my primary web server for about 3 years. At the time, I hosted my sites on under-powered hardware that had little memory and had trouble keeping up with demand when I used Apache, but was able to keep this web site up and running the day one of my posts hit the front page of Digg (back when dinosaurs roamed the Earth and Digg was a really cool website). Back then, NGINX was still pretty new and most of the documentation was either in Russian, sporadic, or consisted of random posts on people’s blogs. It has been a couple of years since I upgraded my server to something beefier. At that time, I switched back to Apache, since I have used it for years and know it very well. That could change again, especially now that the official documentation for NGINX is much better, and because of today’s review book.

Mastering NGINX is by Dimitri Aivaliotis, a systems architect for a hosting provider and someone who uses NGINX daily. His experience shows in the quality and depth of the material. Unlike a different book on NGINX from the same publisher that I reviewed in 2010, Nginx HTTP Server, this book is well written and does not suffer from what I have come to call “The Packt Problem.” I hope this is a sign that Packt’s copy editing process has improved and that there is now a stronger commitment to offer titles that are worthy of being read because of the quality of the writing as well as the quality and uniqueness of the technical content.

Mastering NGINX is intended for experienced systems administrators and systems engineers, people who are familiar with using and administering *nix machines and configuring servers. This is not a beginner book. For me, that is a plus. It allows the author to get right down to business with NGINX.

We start with a short and typical installation chapter, complete with a discussion of modules that includes third-party modules and their benefits and risks. Installing using the package managers of several types of Linux distributions is covered along with compiling from source and the various flags and configure options available.

The next chapter jumps right in to the good stuff. Most of the NGINX materials I once used tell you what to change, but not why to change it. For a long time I was left wondering how to tell when to use specific configuration options, which files to find them in, and what the parameters are that I can use. The goal of this book is not to tell you what to do, but to describe these very things, so that in the end, you should be able to find and open an NGINX configuration file and edit it to fit your situation. Well done.

I was a little concerned when I realized that I was nearing the end of the chapter and still had some questions in my mind about some of the parameters and settings. Then I read this on page 40 in the chapter summary:

What we did not cover in this chapter are the configuration options provided by the various modules that may be compiled into your nginx binary. These additional directives will be touched upon through the book, as that particular module is used to solve a problem. Also absent was an explanation of the variables that NGINX makes available for its configuration. These too will be discussed later in this book. This chapter’s focus was on the basics of configuring NGINX.

Bravo! The author was thinking ahead, anticipated my concerns, and addressed them immediately at the point I had them.

The rest of the book gives deeper, more detailed information about specific uses for NGINX. Topics covered include using NGINX for serving mail, reverse proxying, setting up security, HTTP serving, including setting up your server for use with PHP (which is much easier now than when I wrote this outdated post), caching, tracking, and various sorts of troubleshooting. I was thrilled to see the appendices, especially the rewrite rule guide, as when I tried to do rewrites, I couldn’t find any good information (see my now-long-outdated post on the topic.

I was pleased to see how complete and clear the book is. Kudos to the author, the reviewers and editors, and the publisher. I recommend this book to anyone who uses NGINX or wants to do so.

Disclosure: I was given my copy of this book by the publisher as a review copy.

Learn You Some Erlang for Great Good!

Functional programming is not new, but it is becoming popular once again. For this reason, in my last book review, I talked about a Lisp book and this review will cover a book on Erlang. Functional programming treats computation differently from other programming languages. Here, computation is done by evaluating mathematical functions. State and mutable data are avoided. Most of this is rooted in lambda calculus, in which everything is a function (yes, I’m simplifying, but this is a short review). Even if you prefer to use a different programming style, learning a functional language is beneficial to expand your skills and your ability to think of a problem in multiple ways, which often leads to more elegant and human-readable solutions. This is vital for long-term maintainability of code.

Learn You Some Erlang for Great Good! is by Fred Hébert. One of the things I really admire and appreciate about the author is that he provides a great example to others. So often, budding programmers and computer scientists feel intimidated by functional programming, somehow believing that they need to study for years and earn a higher level computer science degree before they even make the attempt. Hébert is a self-taught programmer and also the author of one of (perhaps the) most respected and used Erlang tutorials out there, on which this book is based and shares a title. He was named Erlang user of the year for 2012. Hébert proves that really bright people can learn and use and teach complicated things, and you can do so without learning it in a university. So, put aside the intimidation and press on!

This book covers all the basics of language and syntax, as well as the needed functional programming concepts and techniques. It covers the hot Erlang topics of today, too, stuff like concurrency and distributed computing. One thing I love is that as the book discusses these things, it does so without the typical hype and over-zealousness that often accompanies Erlang presentations and discussions. In fact, there is an amusing series of information box notes throughout the book, each titled “Don’t Drink Too Much Kool-Aid,” that give a welcome, balanced view of various features, praises, and criticisms of Erlang. Each of these shows a grounding in reality that comes from real-world use.

This is a serious book filled with quality discussions, clear writing, interesting and useful examples, and an occasional bit of whimsy. The book isn’t playful like Land of Lisp, but it isn’t dry and boring or overly academic, either. It is an accessible, practical book that the real-world programmer who is considering Erlang will find useful.

Disclosure: I was given my copy of this book by the publisher as a review copy.

Land of Lisp

Programming books are not fun. No one uses Lisp anymore, and almost no one ever did. There is no practical reason to read a book about Lisp. These are a few misconceptions that this review aims to correct.

Land of Lisp is by Conrad Barski, M.D. It is a book filled with enjoyable art, clear prose, and an easy to follow structure. The examples used in the book are easy to comprehend and do a very good job of illustrating the concepts being taught while also being interesting.

Let’s step back for a minute. What is Lisp? Lisp is a functional and expressive programming language. It was born out of an attempt to make a programming language that is easily read and understood by humans while also being able to do a lot in a short number of lines. Lisp code is compact and involves a manner of expressing instructions that is different from any other programming language I have experienced. It is with good reason that people describe Lisp as poetry, as elegance, or as “casting spells”. When you really get it, Lisp will affect how you program in any language because it changes how you think. I may be biased, I first encountered Lisp way back in 1987.

Land of Lisp includes within it the same sense of quirky brilliance that you remember in your favorite computer science or physics gurus. All share a different, not-completely-serious way of looking at the world that also allows them to come up with ideas that shatter stereotypes and enable new inventions. The book resides somewhere between the classic The Far Side comics and Richard Feynmann, perhaps with some of the better qualities of Richard Stallman thrown in, without Stallman’s sometimes off-putting traits. The book is a throwback to an era when playful brilliance was the norm in science, including computer science, and I mean that in a good way. This is one of the most fun computer books I have ever read.

So what about the quality of the information, from a technical standpoint? Rest easy, this also receives kudos. Land of Lisp starts with a short history section to give the reader context and then jumps right in to programming. Throughout the book, games are used to illustrate concepts. The first game is identical to the “guess the number” game I programmed on my Casio fx-7200G programmable graphing calculator back in 1986. The game is a simple one, but it provides a launching pad to greater things. The program is used to discuss global and local variables, functions, and basic Lisp etiquette.

From here, we move into syntax, code and data, and lists. Then, in the section titled “Lisp is Symmetry,” we begin the deeper topics like conditionals, paths, objects, reading and printing text, lists, and lambda. The last one, lambda, even gets its own chapter, which is a good thing since so many find it difficult and confusing at first. Before the section ends, Land of Lisp helps you learn important concepts using the classic Hunt the Wumpus and we get into arrays, hash tables, structures, and sequences. Now we are almost halfway through the book.

Land of Lisp includes some atypical examples for Lisp, and I like this. While it teaches the remaining vital programming concepts and Lisp style, we learn not only silly games, but even how to create a web server, really grok functional programming, macros, and more. The book is focused on Common Lisp, but modern variants like Clojure are also discussed.

If you have ever wanted to learn Lisp, but find typical tutorials and resources a bit dry, this is the book for you. Even if you aren’t as excited about the playful bits of the book, the quality of the prose and technical descriptions are such that you should give Land of Lisp a chance.

Disclosure: I was given my copy of this book by the publisher as a review copy.

A Chance Encounter with Mr. Darcy’s Progenitor

(In honor of the 200th anniversary of Pride & Prejudice, a review written in a style which attempts similarity to that of Miss Austin.)

I found myself, through no fault of my own, suffering terribly for several days under a fever. During the course of that time, I exhausted the contents of my reading list and asked my beloved wife if I might read her favorite book, one Pride and Prejudice by a Miss Jane Austin. Here is my opinion.

Miss Austin is a talented writer. She is witty, charming, gifted in her phrasing and descriptive ability, and has a sharp, perhaps wicked, sense of humor. I don’t like her at all. Next to hers, my own prose arrives at the ear uninteresting and plain. Hateful woman. Her ability to make the mundane and silly prattle of Elizabethean women both interesting and delightful gives me cause to doubt my own abilities.

I had the privilege of attending a ball at which Miss Austin was also an attendee. A Mr. Darcy, my longtime friend at whose estate I have often passed enjoyable hours fishing for trout in his stream or listening to his delightful sister play on the piano forte, did the pleasure of introducing us. In person, I found Miss Austin engaging, insightful, and possessed of a savage ability to expose to the world the innermost parts of other attendees with a mere sentence. May I always find myself in her good favor.

During that encounter, Miss Austin enquired as to my opinion of her book, as Mr. Darcy had informed her previously of my reading it. I told her all that I have already described to you. She then asked me to be forthright and direct with her as to my personal opinion. I hesitatingly told her that, while I found her writing gifted and her skills great, I was not enamoured with her subject matter as it falls outside of my personal interests. She gave a frown and replied, “Of course, you are not among my target audience.”

We both stood silently for a moment, regarding one another. Our stern gazes met, softened, and smiles appeared. Soon we found ourselves laughing giddily and causing no small scene. In the end, we embraced and parted as friends.

Python for Kids

I previously reviewed a book intended to teach programming to kids, Super Scratch Programming Adventure. That book used a self-contained editor and language that was easy to understand, easy to use, but confined its usefulness to a very limited set of roles. This is because of how Scratch is run and written.

It is no secret that I like Python. Even though I really don’t write code anymore, at least not very often, for most purposes I am still a big fan of Python over any other programming language I have learned. I’ve reviewed two Python books in the past, Learning Python and Python for Unix and Linux System Administration. While I know people who use Python as a beginner’s language for kids, I had not done any reading nor read any curriculum used for teaching programming to kids using Python that I felt I could recommend freely. Until now.

Python for Kids: A Playful Introduction to Programming is by Jason R. Briggs. It is the book that fills the hole in my Python library. It starts with a nice introduction and installation instructions for Windows 7, Mac OS X, and most importantly to me, Ubuntu (on which you are really only checking to make sure you have Python 3 installed, since Python is installed by default, although Ubuntu releases older than 12.04 may still have Python 2.x installed as default). Perhaps it is because we started in a similar era, but I found Briggs very easy to read and follow; like me, he started out by learning BASIC on a TRS-80. More likely, the clarity and tone are the result of an intentional focus so that kids can comprehend the complexities of the material. In either case, he did a wonderful job.

The book is broken down into logical chapters, each building upon the previous ones. It starts with foundational concepts like variables and calculations, adds types like strings and lists and tuples, then begins with an introduction to graphic interaction using the turtle module. This is much sooner than typical, and I think it is beneficial because it gives kids a quicker jump to that fun moment of power, “Hey! I just made that thing move on the screen.”

Then the book builds understanding with explanations of if and else statements and loops. On top of that are added the concepts of functions, modules, classes, and objects. We are now a mere third of the way through the book.

From here on, the simple explanations given will be expanded upon in easily-absorbed chunks. Built-in Python functions and useful modules each get a chapter. Then, we revisit turtle graphics to play some more. Once the basic graphic concepts are taught with turtle, tkinter is presented.

The last third of the book is focused on games. Specifically, using some fun game examples to flesh out the concepts more completely, developing greater fluency with the concepts, grammar, and vocabulary already presented.

One weakness of many beginning programming books is that once you finish the book you have to do further research on your own to figure out what to do next. I love that Python for Kids does not end this way, but instead includes a useful Appendix titled Where to Go from Here. This Appendix is short, but gives enough information to help the reader learn just a little bit about some Python resources and other programming languages to make those next steps just a little bit easier.

This book is suitable for kids in upper elementary school and older. The only real prerequisites are the ability to read and understand the concepts and a computer that will run Python. While the book is clearly written using suitably simple vocabulary, it is not watered down and never talks down to the reader. For this reason, despite the title, this book could be just as useful for the adult programming novice, too.

Disclosure: I was given my copy of this book by the publisher as a review copy.

LEGO books for all

This time around I have a real treat: three books about LEGO. These bricks were a staple of my childhood. They are well made and foster creativity in ways no other toy does. My LEGO collection has been handed down to my kids (who allow me to play with them sometimes) and added to many times.

These books give interesting insights and ideas that LEGO aficionados may enjoy. Each book is focused on a different segment of this audience. All are from No Starch Press. All the books are nicely printed on quality paper and include amazing color illustrations throughout. I’ll say right up front that, while I really liked all three of these books, I am reviewing them in order of preference. This preference reflects my personal tastes more than my feelings about the quality or content of any of the books, though. I think each deserves a high rating.

The first book is The Unofficial LEGO Builder’s Guide, 2nd Edition by Allan Bedford. This book has a lot of words, but they are not wasted words. It communicates the philosophy behind the engineering of LEGO and then builds on that knowledge the skills necessary to design and create anything you can conceive of using LEGO. That’s an amazing feat! There are some step by step directions to build a few things, but these are used more to illustrate good and useful techniques rather than give examples of what to build. The information given is deep, interesting, and would give a great foundation to anyone wanting to learn to build using other materials later in life. I recommend this book to anyone from older elementary school all the way through adulthood.

The second book is The LEGO Adventure Book, Vol. 1 by Megan Rothrock. This hardcover book includes a series of about 25 step-by-step building guides that are similar to what is provided when you buy a LEGO kit and pictures of about 200 built models for further inspiration. The illustrations in this book are stellar and the models are outstanding. Anyone looking to be inspired to build more interesting and more beautiful things will find this book thrilling. The book follows a loose story line focused on an adventure, a quest to learn how to build interesting and complicated things with LEGO. The story line is neither vital nor distracting, it just gives an fun excuse to move from idea to idea. This is the book that I expect my kids to enjoy most (ages 7, 9, and 10), with the older kids graduating to the book above very soon. This book includes “Vol. 1” in the title. I haven’t seen any other volumes, but will be watching for their appearance.

The third book is The Unofficial LEGO Technic Builder’s Guide by Paweł “Sariel” Kmieć. This is the most technical of the books in this review. Not everyone moves from standard LEGO bricks and kits to the Technic series. Those with a bent toward engineering, toward learning the mechanics of systems, love Technic kits and what can be done with them. I remember building my first car with a working steering wheel that actually turned the front wheels using Technic pieces back when I was in middle school (say 12 or 13 years old). I loved learning how this stuff works and the flexibility that comes from building with the even-more-precise-and-flexible gears, beams, and technical pieces available. I remember building a model of an internal combustion engine and tons of other stuff of this sort. Not everyone finds this interesting, and this smaller audience is the only reason this book is listed last. If you like this sort of thing, this book will expand your palette in ways you never imagined. You will learn about all the types of pieces available, how to use them to even greater effect, and learn some great mechanical science at the same time.

Disclosure: I was given my copy of these books by the publisher as review copies.

Economix: How Our Economy Works

I live in the United States of America. It is an election year. The election is next month. The atmosphere is charged with political conversation and rhetoric. Some of it is based on knowledge. Some of it is based on fancy. Some of it is so obviously false that it is stunning that the speaker/writer believes that anyone will buy in to what is being said/written. On many occasions it is obvious that too many people have no understanding of economics, how an economy works, or even basic history. This book weaves all three together beautifully.

Economix: How Our Economy Works provides an up to date, well researched, well presented, and detailed look at the economy. The book presents multiple economic theories clearly and with a flair that is hard to describe but which will thrill all but the most dry-textbook-loving reader. It is a comic that is also a better textbook than most I have read, especially for people who do not already know the history of Western economic thought. Ever wonder what differentiates a free market from a controlled market? What has historically caused economies to grow or shrink? Why government spending, inflation, and interest rates matter and how each can affect an economy? This is the book to get you started.

As a bonus, you will also learn what differentiates capitalism from socialism from communism and other systems, what has influenced each, and what is driving and influencing the current worldwide and U.S. political and economic climates. Want to understand the basic ideas of the big and influential people in economic theory like Adam Smith, Karl Marx, or John Maynard Keynes or maybe the basic ideas that drive past and present Chairmen of the Federal Reserve Bank like Alan Greenspan or Ben Bernanke? This book will give you enough detail to help you understand the theoretical underpinnings of their policies and recommendations and it does so in a way that my (admittedly really smart) 10 year old can understand most of it.

If you ever mention the economy, but don’t really know with certainty what you are talking about, read this book. If you hear people being called “socialist” or “fascist” and wonder what that means, read this book. If you have heard of oligarchies and monopolies and don’t really know what they are or why they would matter, read this book. If you only read one book on the economy, read this one. Yeah, I’m recommending it that strongly. I got my copy for free, and I’m thinking of giving it away so that I can go pay for one and help support the author so that the book stays in print and finds a wider audience.

Oh, and the comic art is quite good, too, but suddenly that seems anticlimactic. Too bad, because that really isn’t fair to the artist, who is quite talented in his own right.

Disclosure: I was given my copy of this book by the publisher as a review copy.

Are All Book Reviews Positive?

No, not all my reviews are positive, but it has been a while since I have posted even a lukewarm review. That is intentional. I got tired of making half-hearted recommendations for things I wasn’t thrilled about. Especially over the last two years, I have become more and more picky about what I am willing to recommend. So, as a result, all my reviews are pretty positive. If I don’t mention a book that I have been asked to review, I either haven’t read it, or I’m not willing to recommend it strongly.

EDIT, 23 Nov. 2013: Over the last year since this post was written, I have chosen not to publicly review several books. However, I have contacted the publishers directly in those instances where the book was sent to me as a review copy and have submitted my lukewarm or worse comments directly to them, in the hopes of both sparing them public shame and of improving a second edition, should one be created. I thought that was worth sharing.

Super Scratch Programming Adventure!

My parents bought my first computer for me in 1981. I was 11. When my TRS-80 Color Computer was turned on, it booted up into a BASIC editor. What it did afterward was up to me. That computer came with a whopping 4K (not a typo, K) of RAM and no storage. We bought a cable to connect the computer to a cassette tape deck so that I could store programs on cassettes. It took several minutes to load an entire program into memory.

I’m feeling nostalgic, but this article is not about that computer. It is about learning to program as a kid. I learned BASIC because I didn’t know anything else existed. I had this cool machine and I wanted to bend it to my will, to make it do my bidding. It started with simple things like accepting text input and repeating it on the screen. Later I learned how to save a Christmas card list and print it using an early dot matrix printers, the DMP-100, which had a really amazing 5×7 matrix (which meant no true descending characters, those ys and gs and stuff all got moved up and looked weird…sorry, feeling nostalgic again).

Super Scratch Programming Adventure! provides a much easier and extremely fun entry into programming. It doesn’t make the learner focus on the really gritty details, like people in my generation had to do. That’s okay. What it does do is give kids a way to do the parts that I loved about owning a computer in the early 1980s, it gives them a chance to bend it to their will, to make the computer do what they want it to do.

I have three kids, ages 6, 9, and 10. Each of them has read this book. Each of them enjoyed the clever comic narrative that introduces each chapter. Each of them, even the youngest, found the book enjoyable and interesting as well as easy to understand and follow. The software used for programming, Scratch, is freely available from MIT, where it was created, and runs on several platforms including our family’s beloved Ubuntu. I installed it on their computer and off they went. They haven’t finished the book or the exercises yet, but they are doing what I did as a kid, having fun with a powerful toy that they can control.

The meat of the book is impressive. It covers some deep topics but always remains readable and clear for those within its target audience, which according to a note on the back cover is “for ages 8 and up.” I admit it, my 6 year old is advanced <grin>. The book leads the reader through the process of creating games in Scratch. Along the way, you learn about graphics, data flow, sound effects, subroutines, and more. This is done using an interface that is menu driven and easy. The concepts are what are focused upon, not the semantics. This is good, because I’ve known too many programmers who are good at semantics and yet struggle to know when or why certain things are done. I prefer to see the “why” understood first, then the “how” is easily transferred to other languages and contexts.

I’ve given away other programming books to kids, like the time a few years ago when I gave my nephew a book on game programming in Python. Starting now, this will be the book I recommend or give away to kids (to be followed later with Python or other stuff…). If you know a kid or even a young teen who wants to make their computer do stuff, this is a good start.

Disclosure: I was given my copy of this book by the publisher as a review copy.

Think Like a Programmer

I used to write software. I confess, it has been a long time. There are parts about doing so that I loved (problem solving, being creative) and parts I didn’t enjoy (solving problems that I didn’t find interesting, over and over and over again). This book concentrates on the parts I enjoyed most.

Think Like a Programmer came out earlier in 2012. It was published by No Starch Press, which consistently puts out books that impress me. It is one of the more consistent computer-related publishers and when I’m researching a specific topic, I generally look at any they offer, along with O’Reilly, before looking at other publishers’ offerings. I should probably disclose that back in 2009 I talked with No Starch about writing a book about Ubuntu. That didn’t work out and shortly afterward I ended up taking over the Ubuntu Unleashed title for SAMS when the previous author team didn’t want to continue with it, but my email conversations with the head honcho (or as their website says, the “Big Fish”), Bill Pollock, left me with a favorable impression of the company.

This is not a “how to program” book that concentrates on learning the syntax, vocabulary, and grammar of a specific programming language. You will need to learn that elsewhere. In fact, you probably want to learn basic C++ before you read this book. While the concepts in this book will apply across programming languages, examples are given using C++. Those who already know Java or C# and who are flexible will probably be okay, but will need to be experienced enough to translate.

This is a “how to program” book that focuses on figuring out how and when to use the various concepts and tools within a language to creatively solve problems. I have never read another book that covers this topic. The idea is that learning the basics of a language helps you understand what the tools do, but it is usually experience that helps you understand and create strategies for using them. You may know what a pointer is and the mechanics of using one, but seeing when using pointers is most effective only happens after seeing them at work in context. Context is what this book tries to give. The author, V. Anton Spraul, calls the missing skill problem solving, “the ability to take a given problem description and write an original program to solve it.” The cool thing is that the book teaches the sort of problem solving skills that usually require years of experience in a systematic, logical way.

The book starts with a discussion about strategies. Problems almost always have constraints, things that limit the paths you have available for solving them. Good problem solving finds a way to do what must be done while not violating any of these boundaries. This involves creative thinking. This 20-some page discussion is the foundation for the rest of the book.

As the book continues, you will meet up with all your conceptual friends you learned about in your programming class or book. Only this time, the discussion is not about mechanics, but strategy. Why is tracking state important? When should I use scalar variables vs arrays vs multidimensional arrays? What problems are better solved using pointers and dynamic memory? How do I create meaningful classes and objects (and not just “arbitrary bags of leftovers”)? Since C++ is flexible, it affords a nice discussion of when a procedural and when an object-oriented approach may be most suitable. Sequential or recursive? If using recursion, head or tail? What about reusing code?

The book ends with a useful chapter on thinking like a programmer. Yes, that is the topic of the entire book, but whereas each chapter focuses on discrete parts, this chapter brings all the parts together to help the reader learn to synthesize a master plan when solving specific problems.

Bottom line: you probably need a year or two of experience for this book to be really useful. This is because once you have struggled with some of the issues the book discusses you are going to be much better equipped to see how useful the book is. The bare minimum is to either have studied C++ or to have spent enough time programming in another language or two so that you understand what the C++ discussions and samples are illustrating. If you fit here, the book is highly recommended.

Disclosure: I was given my copy of this book by the publisher as a review copy.