Posts tagged as:

Books

Fundamental theorem of code readability

by John on November 28, 2011

In The Art of Readable Code, the authors call the following the “Fundamental Theorem of Readability”:

Code should be written to minimize the time it would take for someone else to understand it.

They go on to explain

And when we say “understand,” we have a very high bar … they should be able to make changes to it, spot bugs, and understand how it interacts with the rest of your code.

{ 9 comments }

The Tangled Web

by John on November 27, 2011

The Tangled Web is a security book that you may find interesting even if you’re not interested in security. The first half of the book is an excellent explanation of how Web technologies work in theory and especially in practice. This material is included in order to discuss security implications, but it’s interesting on its own. The second half of the book is directly devoted to Web security.

The author, Michal Zalewski, has a colorful writing style. His book is serious and loaded with technical detail, but that doesn’t stop him from turning a nice phrase here and there.

Here’s an excerpt from The Tangled Web that I particularly liked, one that explains why security concerns on the Web differ from previous security concerns.

In the traditional model followed by virtually all personal computers … there are very clear boundaries between high-level data objects (documents), user-level code (applications), and the operating system kernel … These boundaries are well studied and useful for building practical security schemes. A file opened in your text editor is unlikely to be able to steal your email …

In the browser world, this separation is practically nonexistent: Documents and code live as parts of the same intermingled blobs of HTML, isolation between completely unrelated applications is partial at best …

In the end, the seemingly unlikely scenario of a text file stealing your email is, in fact, a frustratingly common pattern on the Web.

{ 1 comment }

Cartoon guide to the uninteresting

by John on November 21, 2011

If you’re not interested in a subject, do cartoons make it more palatable?

My guess is that cartoons may help keep your attention if you’re moderately interested in a subject. If you’re fascinated by something, cartoons get in the way. And if you’re not interested at all, cartoons don’t help. The cartoons may help in the sweet spot in between.

No Starch Press has given me review copies of several of their Manga Guide books. The first three were guides to the universe, physics, and relativity. I’ve reviewed these here and here. Recently they sent a copy of the newest book in the series, The Manga Guide to Biochemistry.

I’m much more interested in physics than biology, so I thought this would be a good test: Would a manga book make it more interesting to read about something I’m not very interested in studying? Apparently not. It didn’t seem that the entertaining format created much of an on-ramp to unfamiliar material.

It seemed like the information density of the book was erratic. Material I was familiar with was discussed in light dialog, then came a slab of chemical equations. Reading the book felt like having a casual conversation with a lawyer who periodically interrupts and asks you to read a contract.

Someone more interested in biochemistry would probably enjoy the book. Please understand that the title of this post refers to the fact that I find biochemistry uninteresting, not the book. If I had to study a biochemistry book, the Manga Guide to Biochemistry might be my first choice. At times I’ve found biochemistry interesting in small doses, describing a specific problem. But it would be nearly impossible for me to read a book on it cover to cover.

O’Reilly’s “Head First” series is similar to the Manga guide series, though the former has more content and less entertainment. I enjoyed the first Head First book I read, Head First HTML with XHTML & CSS. Maybe I enjoyed it because the subject matter was in the sweet spot, a topic I was moderately interested in. The cartoons and humor helped me stick with a dry subject.

When I tried another Head First book, I was hoping for more that same push to keep going through tedious content. The books clearly had the same template though with different content. What was interesting the first time was annoying the second time, like hearing someone tell a joke you just heard. So at least for me, the Head First gimmick lost some of its effectiveness after the first book.

{ 4 comments }

Firsthand knowledge

by John on November 6, 2011

From C. S. Lewis:

It has always therefore been one of my main endeavors as a teacher to persuade the young that firsthand knowledge is not only more worth acquiring than secondhand knowledge, but it usually much easier and more delightful to acquire.

This quote comes from the essay On the Reading of Old Books, part of the collection God in the Dock: Essays on Theology and Ethics. Lewis says here that it is easier to read Plato or St. Paul, for example, than to read books about Plato or St. Paul.  Lewis says that the fear of reading great authors

… springs from humility. The student is half afraid to meet one of the great philosophers face to face. He feels himself inadequate and thinks he will not understand him. But if he only knew, the great man, just because of his greatness, is much more intelligible than his modern commentators.

This does not only apply to literature. I see the same theme in math. Sometimes early math papers are easier to read because they are more concrete. When I was a postdoc at Vanderbilt I asked Richard Arenstorf about a theorem attributed to him in a book I was reading. He scoffed that he didn’t recognize it. He had done his work in a relatively concrete setting and did not approve of the fancy window dressing the author had placed around his theorem. I sat in on a few lectures by Arenstorf and found them amazingly clear.

The same theme appears in software development. Sometimes you can dive to the bottom of an abstraction hierarchy and find that things are simpler there than you would have supposed. The intervening layers obscure the substance of the program, making its core seem unduly mysterious. Like a mediocre mind commenting on the work of a great mind, developers who build layers of software around core functionality intend to make things easier but may do the opposite.

Related posts:

Endless preparation
Opening black boxes
Why Shakespeare is hard to read
C. S. Lewis on reading old books

{ 5 comments }

You ought to give the kid a chance

by John on November 2, 2011

Martin Gardner (1914 – 2010) was best known for his articles on recreational mathematics, especially his column in Scientific American which he wrote from 1956 to 1981. Once Gardner wrote a letter of recommendation for a young man applying to graduate school at Harvard.

I don’t know a lot about mathematics, but this kid invented two of the best card tricks of the last ten years. You ought to give him a chance.

The kid was Persi Diaconis. At the time, Diaconis, like Gardner, was something of a mathematical outsider, someone with more creativity than credentials. Diaconis went on to become a mathematics professor at Harvard and won two MacArthur genius awards. He is now a professor at Stanford.

Source: Magical Mathematics

{ 9 comments }

Moby Dick and the tautochrone

by John on October 15, 2011

The tautochrone is a curve such that a ball rolling down the curve takes the same amount of time to reach the bottom, no matter where along the curve it starts. (The name comes from the Greek tauto for same and chrono for time.) It doesn’t sound like such a curve should be possible because balls starting further up the curve have longer to travel. However, balls starting higher also have more potential energy, and so they travel further but faster. See the video below for a demonstration.

[The video is entitled "brachistochrone race" rather than "tautochrone race." The brachistochrone problem is to find the curve of fastest descent. But its solution is the same curve as the tautochrone. So different problems, same solution.]

I first heard of the tautochrone as a differential equation problem to find its equation. But someone could run into it in an American literature class.

Clifford Pickover’s new book The Physics Book has a chapter on the tautochrone. (In this book, “chapters” are only two pages: one page of prose and one full-page illustration.) Pickover points out a passage in Moby Dick that discusses a bowl called a try-pot that is shaped like a tautochrone in the radial direction.

[The try-pot] is a place also for profound mathematical meditation. It was in the left hand try-pot of the Pequod, with the soapstone diligently circling round me, that I was first indirectly struck by the remarkable fact, that in geometry all bodies gliding along the cycloid, my soapstone for example, will descend from any point in precisely the same time.

{ 5 comments }

The Art of R Programming

by John on October 10, 2011

Here are my first impressions of The Art of R Programming. I haven’t had time to read it thoroughly, and I doubt I will any time soon. Rather than sitting on it, I wanted to get something out quickly. I may say more about the book later.

The book’s author, Norman Matloff, began his career as a statistics professor and later moved into computer science. That may explain why his book seems to be more programmer-friendly than other books I’ve seen on R.

My impression is that few people actually sit down and learn R the way they’d learn, say, Java. Most learn R in the context of learning statistics. Here’s a statistical chore, and here’s a snippet of R to carry it out. Books on R tend to follow that pattern, organized more by statistical task than by language feature. That serves statisticians well, but it’s daunting to outsiders.

Matloff’s book is organized more like a typical programming book and may be more accessible to a programmer needing to learn R. He explains some things that might require no explanation if you were learning R in the context of a statistics class.

The last four chapters would be interesting even for an experienced R programmer:

  • Debugging
  • Performance enhancement: memory and speed
  • Interfacing R to other languages
  • Parallel R

No one would be surprised to see the same chapters in a Java textbook if you replaced “R” with “Java” in the titles. But these topics are not typical in a book on R. They wouldn’t come up in a statistics class because they don’t provide any statistical functionality per se. As long as you don’t make mistakes, don’t care how long your code takes to run, and don’t need to interact with anything else, these chapters are unnecessary. But of course these chapters are quite necessary in practice.

As I mentioned up front, I haven’t read the book carefully. So I’m going out on a limb a little here, but I think this may be the book I’d recommend for someone wanting to learn R, especially for someone with more experience in programming than statistics.

Related post:

R: The Good Parts

{ 8 comments }

Sed one-liners

by John on September 27, 2011

A few weeks ago I reviewed Peteris Krumins’ book Awk One-Liners Explained. This post looks at his sequel, Sed One-Liners Explained.

The format of both books is the same: one-line scripts followed by detailed commentary. However, the sed book takes more effort to read because the content is more subtle. The awk book covers the most basic features of awk, but the sed book goes into the more advanced features of sed.

Sed One-Liners Explained provides clear explanations of features I found hard to understand from reading the sed documentation. If you want to learn sed in depth, this is a great book. But you may not want to learn sed in depth; the oldest and simplest parts of sed offer the greatest return on time invested. Since the book is organized by task — line numbering, selective printing, etc — rather than by language feature, the advanced and basic features are mingled.

On the other hand, there are two appendices  organized by language feature. Depending on your learning style, you may want to read the appendices first or jump into the examples and refer to the appendices only as needed.

For a sample of the book, see the table of contents, preface, and first chapter here.

Related links:

Learn one sed command
Daily tips on sed and awk

{ 6 comments }

“The difference between science fiction and fantasy … is simply this: science fiction has rivets and fantasy has trees.” — Orson Scott Card

{ 5 comments }

Thomas Hardy and Harry Potter

by John on September 22, 2011

Emily Willingham mentioned on Twitter that the names of the Harry Potter characters Dumbledore and Hagrid come from Thomas Hardy’s 1886 novel The Mayor of Casterbridge. Both appear in this passage:

One grievous failing of Elizabeth’s was her occasional pretty and picturesque use of dialect words …

… in time it came to pass that for “fay” she said “succeed”; that she no longer spoke of “dumbledores” but of “humble bees”; no longer said of young men and women that they “walked together,” but that they were “engaged”; that she grew to talk of “greggles” as “wild hyacinths”; that when she had not slept she did not quaintly tell the servants next morning that she had been “hag-rid,” but that she had “suffered from indigestion.”

Apparently dumbledore is a dialect variation on bumblebee and hagrid is a variation on haggard. I don’t know whether this is actually where Rowling drew her character names but it seems plausible.

{ 3 comments }

Awk one-liners

by John on August 31, 2011

Peteris Krumins has written a fine little book Awk One-Liners Explained. It’s just 58 pages, and it’s an easy read.

As I commented here, I typically try to master the languages I use. But for some languages, like awk and sed, it makes sense to learn just a small, powerful subset. (The larger a language is, the harder it can be to just learn part of it because the features intertwine.) Krumins’ book would be good for someone looking to learn just a little awk rather than wanting to explore every dark corner of the language.

Awk One-Liners Explained is exactly what title would lead you to expect. It has 70 awk one-liners along with a commentary on each. Some of the one-liners solve common specific problems, such as converting between Windows and Unix line endings. Most of the one-liners are solutions to general types of problems rather than code anyone is likely to run verbatim. For example, one of the one-liners is

Change “scarlet” or “ruby” or “puce” to “red.”

I doubt anybody has ever had to solve that exact problem, but it’s not hard to imagine wanting to do something similar.

Because the book is entirely about one-line programs, it doesn’t cover how to write complex programs in awk. That’s perfect for me. If something takes more than one line of awk, I probably don’t want to use awk. I use awk for quick file filtering. If a task requires writing several lines of code, I’d use Python.

You can get an idea of the style of the book by reading the author’s blog post Famous Awk One-Liners Explained, Part I: File Spacing, Numbering and Calculations.

***

If you’d like to learn the basics sed and awk by receiving one tip per day, you can follow @SedAwkTip on Twitter. If you don’t use Twitter, you can subscribe via RSS.

{ 3 comments }

Odd little bookshops

by John on August 17, 2011

From Tristan Gylberd:

The smaller, the odder, the more out of the way, and the more specialized, the better. That is my philosophy on bookshops. Come to think of it, that is my philosophy on everything else too — it makes for a very interesting life unconstrained by the smothering expectations of the tyranny of fashion or popularity.

Related post:

Small, local, old, and particular

{ 2 comments }

Book review queue

by John on July 16, 2011

I’ve got a backlog of books to review. I may not write more about all of them here so I’ll at least mention them briefly.

Packt Publishing sent me copies of Python 3 Web Development Beginners Guide and Python Testing Cookbook. The former may not be what you expect from the title. It focuses on self-contained development with minimal dependencies. It’s not a book on popular Python web development frameworks like Django.

I have a couple books I need to review for the MAA. The first is Validated Numerics: A Short Introduction to Rigorous Computations. This one is less general than title implies. It’s a book about interval arithmetic and frankly it’s dry as dust so far.

The second MAA book is The History and Development of Nomography. Nomography is the lost art of graphical computing. A great deal of ingenuity and artistry went into producing graphics that allowed users to solve equations without numerical computation. For beautiful examples, see Dead Reckonings, Ron Doerfler’s web site.

Eric Sink has a new book in press Version Control by Example. I enjoyed reading through one of the early drafts. I haven’t yet read the final version though I plan to soon. This book shows how to use distributed version control, comparing several popular systems. It does more than tell you which buttons to push or APIs to call; it shows how to solve problems that come up in day-to-day software development.

The final book on my review list is The Physics Book by Cliff Pickover. This book is the physics analog of The Math Book that Pickover published a couple years ago. I look forward to reading this one based on my enjoyment of The Math Book.

Related posts:

Sage Beginner’s Guide
Interview with Cliff Pickover
Calendar of lost mathematical art, sequel
Manga guides to science

{ 1 comment }

Sage Beginner’s Guide

by John on July 12, 2011

I like books. Given a choice, I’d much rather read a book than online documentation. Typically a book speaks with one voice and has been more carefully edited. Unfortunately, it can be hard to find books on specialized software. That’s why I was glad to hear there’s a book on Sage, a project that integrates many Python libraries for mathematical computing into a single context.

Craig Finch’s book Sage Beginner’s Guide provides an easy-to-read overview of Sage. The book is filled with examples. In fact, every topic is introduced by an example. Explanations follow the examples in sections entitled “What just happened?”. Follow-up exercises are provided to solidify the material after the example and explanation.

Someone could begin using Sage without knowing Python. They could think of Sage as an open source Mathematica-like application. But one of the strengths of Sage is that its underlying language is Python. And the Sage Beginner’s Guide has two chapters devoted to the Python language, one basic and one advanced.

Finch’s book is primarily focused on Sage as a whole, not the Python components it integrates. However, it does point out the component libraries that provide certain functionality when either the constituent library conflicts with Sage or can be used to refine Sage functionality.

Sage can be challenging to install. It is not yet directly supported on Windows; the recommended way to use Sage on Windows is to download a Linux virtual machine with Sage installed. I was able to install Sage on Ubuntu but not yet on OS X. However, you can try out Sage without installing it by using Sage online notebooks.

I don’t have as much experience with Sage as with some of its components. As far as I can tell, it’s easy to take your experience from component libraries — say NumPy — and bring it over to Sage. It would be harder to take functionality you discovered while using Sage and use it outside of Sage since, though that is to be expected since part of the value Sage adds is smoothing over the peculiarities of each component library.

{ 7 comments }

Manga guides to physics and the universe

by John on June 15, 2011

I recently received review copies of the Manga Guides to physics and the universe. These made a better impression than the relativity guide that I reviewed earlier. The guide to physics has been out for a while. The guide to the universe comes out June 24.

The Manga Guide to Physics basically covers force, momentum, and energy. The pace is leisurely. There’s not much back story; it cuts to the chase fairly quickly.This guide will not prepare you to solve physics problems, but it does give you a good overview of the basics.

(These books are not entirely manga; all three books I’ve seen in the series have several pages of more traditional textbook content.)

The Manga Guide to the Universe gives a tour of cosmology from the geocentric view to current theories. It contains some very recent material, such as references to the WMAP project.

This book is more rushed than the physics guide. That’s to be expected considering its ambitious scope. It devotes a fairly large amount of space to the back story and this contributes to the book being rushed.

I mentioned in my review of The Manga Guide to Relativity that although Americans associate cartoons with children, that book was not written for children. The physics guide, however, would be appropriate for a wide range of readers. Young readers may not fully appreciate the content, but they would not find anything offensive.

The Manga Guide to the Universe is inoffensive with one exception. There are a couple provocative frames in the prologue that will keep the book off some school library shelves.

{ 1 comment }