Categories
Business Politics Programming

Optimize the Most Significant Parts

There’s a general principle to optimization that many people miss, but seems so simple once you know it. I’m sure I first read about it in The Practice of Programming from Kernighan and Pike. You should optimize the most significant part of a program to get the most reward for your effort. The procedure is simple. Measure how much time the computer spends in each part of your program. There’s likely a loop that takes up a significant portion of the time. Optimize that part first. If you don’t follow this formula, you’ll probably spend a bunch of time optimizing what you intuitively think is slow, but it may not matter at all.

I’ve found that this approach applies equally well to optimizing money. For example, when you’re running a business, you have a range of expenses. Some of them are for tangible goods, some of them are for outside services and some of them are for salaries. Imagine an office with a fancy coffee maker. Everyone might think it’s a waste of money and a luxury, but the cost of that expense is likely minuscule compared to salaries. You’re usually better off figuring out how to improve efficiencies in your work process than going with cheapo amenities.

Of course, once you know how this work, you can use it deceptively. Politicians do it all the time. Watch how they talk about earmarks, or the apocryphal $100 hammer. You might agree that it’s not a good idea for a congressman to request a $1mil earmark for his wife’s employer, but even $1mil is nothing compared to the most significant costs to the U.S. budget: Social Security and Medicare. If you check the measurements, you’ll find that all the earmarks together total about 1% of the budget, which Social Security and Medicare are about a third. (Total federal spending is about $2.9tril, and Social Security plus Medicare is about $900mil).

I’m a relatively young person in my late 30s. I wonder if I’m not alone in counting on getting absolutely nothing from Social Security by the time I might need it. I’m not taking that chance. I’m saving money in a 401K plus whatever else I can beyond the annual limit of a 401K. I really wouldn’t mind if my taxes were 30% lower and I had to take responsibility for my own retirement.

Categories
News

Iraqis Liberated From Bad Ideas

Last week, the New York Times ran a story on Iraq with the premise that the religious ideas of Islam are being tested and rejected. The author, Sabrina Tavernese, used the phrase, “the American liberation”, which is only remarkable because the reputation of the NYT is that of promoting the idea of the war as a failure. While the war has a definite strategic purpose for the USA, I cannot think of a better achievement of the Iraqi people than for them to move past the outdated ideas of religion.

Here are a people who truly are liberated from a religious or military dictator, finally able to decide for themselves what to think. The laws of Islam have been dramatically exercised in Iraq. To a free man, the idea of screaming “God is great” as you chop off someone’s head is not appealing. In fact, the ideas of the clerics lead only to your own destruction.

When Bush talks about a forward strategy of freedom, I’m not sure he totally understands it. But a disillusionment of religion is exactly the kind of freedom I was hoping for.

Categories
PHP

March 2008 PHP Meetup

At the suggestion of my buddy Lee Springer, I hung out with the PHP geeks at the SF PHP Meetup in the CNET building last Thursday night. A couple of Zend guys talked about version 1.5 of Zend Framework. It was good to get a view into what they are up to, although in many ways they are making a super robust version of the techniques I was implementing about 10 years ago.

Oh man! It just hit me that it was about 10 years ago that I started writing the first edition of Core PHP Programming! Yikes!

There were about 50 people who showed up. That’s impressive based on my experience from years ago with the old PHP users group that dwindled into nothing. A guy named Mariano Peterson came up to me and recognized me as the author of Core PHP. That was cool! Michael Tougeron also made a point to say hello to me. He’s looking to get me to talk at some point, but I’m not feeling like a something significant to talk about.

The most remarkable part of the session was when someone asked if the new Zend Forms code filtered input for SQL injection attacks. Terry Chay spoke up about this, saying quite correctly that you should prepare data with escaping at the moment you send the data out. If it’s going to the browser, convert special characters to entities. If it’s going to the database, escape the special characters right before you assemble the query. You don’t want the mess we had many years ago with magic quotes.

Then, Terry made what seemed like a nonsequitur. After explaining how you would protect you Zend Framework app from SQL injection, he declared “I hate Zend Framework, but that’s how you’d do it.” That made me smile. He later clarified that he hates all frameworks. I can appreciate that attitude. I know I sometimes feel like frameworks are a solution looking for a problem. I’m not even sure if FreeEnergy is a true framework or just a set of idioms.

Anyway, I’m sure I’ll be showing up to the meetups now. Next time I’ll plan on staying later and chatting with more people.

Categories
News

Gary Gygax Died

Basic D&DI spent a lot of time in my youth with the worlds Gygax helped create. Some of my fondest memories are related to all night D&D games with my friends. So, it’s sad to hear that Gygax passed away recently.

Roleplaying games and programming are intertwined for me. I experienced both when I was about nine years old. My father encouraged both hobbies. My entire family actually played D&D for a while! Reading through the rules is not unlike reading through a computer manual.

C64 Programmer’s Reference

In fact, I’m sure I spent equal time trying to understand the AD&D Dungeon Master’s Guide and that spiralbound Commodore 64 Programmer’s Reference Guide. There were many numbers to memorize,w whether they were RAM addresses to call with POKE, or the armor class numbers for various suits of armor.

Of course, D&D inspired many, many computer games. My friends and I were so excited when the origional Pool of Radiance came out in the late 80s. For the first time, the actual rules of D&D were implemented in computer form. That was a second renaissance of D&D for me during my early college years. I had the money to buy all the 2nd Edition books, no significant other and the time to waste playing all weekend long.

I know a lot of dads look forward to teaching their sons to play baseball or fish (and I do, too), but I also look forward to my sons being old enough to play D&D. It was such a wonderful excuse to imagine great things and argue with my friends. It’s hard to imagine a world where D&D doesn’t exist. I’d like to think Gygax is somewhere chatting with Bahamut and plotting a raid on Orcus.

Categories
Objectivism

How to Learn More About Ayn Rand for Free

Facets of Ayn RandI’m always happy to see an organization I admire, in this case the Ayn Rand Institute, demonstrate the power of letting information be free. So, I’m happy to pass on news that Facets of Ayn Rand, a personal memoir about Ms. Rand is now available for no cost. Of course, the text isn’t licensed under creative commons, but the implication is that if it’s readable on the Web, it’s easy to redistribute.

I own the hardcopy of this book and it’s been sitting my to-read stack for a while. I consider any money spent on books about or by Ms. Rand to be an investment, but I like the idea of skeptical people being able to get more information for no obligation. Perhaps the ARI would consider offering some of Ms. Rand’s works under a creative commons license. The decision is hard to make since the novels continue to provide a great amount of revenue for the organization. In the balance, the money probably helps spread the ideas better than if there were no marketing and only free copies.

If you have never read Atlas Shrugged or The Fountainhead, I cannot recommend to you strongly enough that you do. It likely will begin a new chapter in your life.