Monday, 24 July, 2006

ActionScript 3: No pass by reference

When you first start learning a new development platform, the learning curve looks more like a learning cliff:  you have to assimilate a huge amount of information up front in order to become even marginally productive.  My current knowledge of ActionScript 3 is about where my knowledge of .NET was four years ago.  I'm just barely able to put together a working program.

Today I was wondering how to pass parameters by reference in ActionScript 3, and came across an odd design decision: all parameters are passed by value.  I know that the documentation says that objects are passed by reference and primitives are passed by value, but in reality everything's passed by value.  An object is a reference, so what you're really passing to a function is a pointer.  In this respect, ActionScript is like C except that in C you can pass a pointer to a value type.

Nomenclature notwithstanding, the odd design decision here is that it's impossible for a function to change the value of a primitive type (Boolean, Number, int, uint, and String) that's passed as a parameter.  The function can change the value locally, but the global copy of the parameter is not affected.  Ever.

Exceptions to rules make for confusion, and this is one thing that's going to confuse a whole lot of programmers.

Sunday, 23 July, 2006

Cabinet Files Revisited

Two years ago I developed some code to access Microsoft CAB files from .NET programs.  Due to some limitations in writing managed C# callbacks, the implementation was kind of messy.  Still, I was able to get the code running and I published a series of three articles about the code on DevSource.  Since October of 2004, the source code for those articles has been among the most popular downloads from my site.

Microsoft released .NET 2.0 last fall, and since then I've received many requests for a .NET 2.0 version of the code.  The addition of the UnmanagedFunctionPointerAttribute in .NET 2.0 completely eliminates the C# callbacks restriction and made the implementation much cleaner.  I finally finished the conversion to .NET 2.0, including a full Visual Basic version and some bug fixes to the original .NET 1.1 code.  DevSource published my new article, Cabinet Files Revisited, today.

You can download the .NET 1.1 source from my web site at  That file includes fixes for all reported bugs.  The .NET 2.0 code, which includes the C# and Visual Basic implementations, is available at

Thursday, 20 July, 2006

And things keep piling up

While my education on the new Flash platform proceeds, things keep piling up.  Let's see if I can clear the stack a bit.

  • I've decided to cancel or seriously cut down my birthday challenge because I simply don't have the time to train for it.  My injured shoulder won't let me swim, and I'm spending a lot of time trying to come up to speed with Flex 2.  There will be time for a birthday challenge one of these years.
  • Last month, David and I rented an office about 7 miles from the house.  Since July 5, I've ridden my bike to the office every day but one.  It takes at most 30 minutes to make the ride, which is faster than I can make the trip in the car during rush hour.  So far I'm much more productive at the office than I was at home.  I have a theory about that, but it'll have to wait for another time.
  • The office is actually a two bedroom apartment, which means that we have a private kitchen and our own bathroom.  Very handy, and a lot less expensive than trying to find office space that includes use of a shower.  Most apartment complexes don't allow using their units for office space, but this outfit doesn't have a problem with it.
  • I had the bike in the shop last month for some major work.  It came back with new tires, wheels, cassette (rear cog set), chain, headset, and saddle.  I never considered that I'd wear out a set of wheels, but after over 14,000 miles the rims were getting a little thin.  The saddle had been on three different bikes since about 1999, and was due for a replacement.  The other parts are normal wear items that have to be replaced periodically.
  • Time Magazine has published an article about Vova (Vladimir) and Olga Galchenko, a Russian brother-sister juggling team who are being called the best technical jugglers ever.   They hold the world record for two people juggling 10 clubs--378 catches.  They also hold the record for 11 clubs (152 catches) and 12 clubs (54 catches).  Don't miss the home movies of them juggling over the years.  The kids are amazing.
  • The keyword "u3" has been used in 67 searches of my web site so far this month.  The term "u3 uninstall" has been used 17 times.  My entry about removing U3 is the 12th most viewed page on the site right now.  I wonder if SanDisk and U3 know that they're annoying folks.
  • Meanwhile, a helpful reader dropped me a note suggesting that I just plug the Cruzer into a Linux box and delete the files.  I suspect it'd work to pop it into a Mac, too.  Or maybe I could tell Windows not to autorun when something gets plugged into my USB port.  If so, then I could probably delete the U3 stuff from the Cruzer without having to download the removal tool.  That's worth exploring.

Thursday, 13 July, 2006

Flash drive ripoff

Last week, David Stafford bought an 8 gigabyte USB flash drive on eBay for $65--shipping included.  It came in the other day.  When he plugged it in and tested it, it worked.  Up to the point where he tried to write more than 1 gigabyte to it.  It turns out that this is a 1 gigabyte Cruzer that has been very cleverly repackaged, including a new label on the device that says "Cruzer 8.0 GB".  SanDisk doesn't even make an 8 gigabyte Cruzer.

David has asked the seller for his money back and the seller has agreed to a refund.  We'll see if he actually comes through.  (Update 07/25: The seller provided a full refund.  It's likely that he got taken in by the product.)

Oddly, the seller has overwhelmingly positive feedback on these "8 gigabyte" flash drives that he's selling.  David's assumption is that people get the thing, test it by writing a few files, and then provide positive feedback.  It seems not many try to copy more than a gigabyte to the thing before assuming that it works.

Be careful buying these things on eBay or anywhere else online.  The listing for the one David bought showed a picture of the item in its package, but the top part that has the SanDisk logo was cut off in the picture.  The description said, "this is not a SanDisk product."  I would suggest that you avoid these items.

Wednesday, 12 July, 2006

ActionScript 3 Regular Expressions

I've been playing around with the new Flash 9, learning a bit about programming in ActionScript 3.  This new version of ActionScript is a real programming language with a real object model and other things that we've come to expect from environments such as Delphi, Java, and .NET.  I only have a couple days' experience with it, so I don't have a lot to report yet, but we did run into an interesting oddity when splitting a string using regular expressions.

The String class has a function, split(), which will split a string into substrings by dividing it wherever the specified delimiter occurs.  The delimiter parameter is usually a string or a regular expression.  So, these two statements should give the same results:

var words:Array = str.split("\r\n");    // delimiter parameter is a string
var words:Array = str.split(/\r\n/);    // delimiter parameter is a regular expression

We use the above code to split a loaded text file (loaded into a single string) into an array of lines.  The two versions do in fact give the same results, but the regular expression version takes much, much longer.  We loaded a file that contains 400 words and both statements return immediately.  With a file of 10,000 lines, the string version is still instantaneous, but the regular expression version takes about five seconds.  Even with 180,000 lines, the string version is immediate.  We gave up on the regular expression version after over five minutes.

A .NET program that loads a file and splits the lines using regular expressions is instantaneous, so I don't think that I'm expecting too much by wanting the Flash version to perform similarly.

I poked around with the regular expression options for a while and got nowhere.  What concerns me isn't so much the speed, but that the time required does not increase linearly with the number of items in the list.  Somebody at Adobe needs to take a look at their regular expression matching algorithm.

Monday, 10 July, 2006

Demolition goes awry

Last month (June 7), Controlled Demolition, Inc. of Maryland attempted to remove the 1000-foot WFXL-TV broadcast tower in Doerun, GA after it had been struck and damaged by an Army Chinook helicopter.  This would have been a simple exercise except that the WFXL tower had a sister structure--the 1,000-foot WALB tower--nearby.  The guy wires for the two towers overlapped.  But Controlled Demolition was convinced that they could cut the WFXL guy wires and have the tower fall away from the WALB tower.  Sometimes things don't work out as planned.

As the video shows, things went as expected at first.  The guy wires were severed with explosives and the WFXL tower fell away from the WALB tower.  Unfortunately, it appears that one of the severed guy wires wrapped around the WALB tower (or perhaps around one of the WALB tower's guy wires), and the WALB tower came crashing down, too.  As my friend Mark said, "the bigger they are, the bigger the mess when they fall."

I got a good chuckle out of the voice on the video after the second tower came down:  "I...we are all a little stunned. We did not really expect to see both towers come down like that."  Ya think?

For a more detailed description and lots of neat pictures featuring twisted metal, see this writeup.

In 2001 I wrote, "we can store data, but where's the information?"  I was disappointed that, although we have all this computing power, it seemed nobody was taking full advantage of it.  I'm writing this today on a computer very similar to that I described in that article: a Dell notebook with a 2 GHz processor, 2 gigabytes of RAM, and a 60 gigabyte internal hard drive.  I have an external 160 gigabyte USB drive for backups and storage of stuff that I don't have to access every day, and another 250 gigabytes on a NAS that we use for shared data.

It's true that, even with all this fancy hardware, we still haven't solved the big problems.  The Traveling Salesman problem is still intractable, and we're no closer to speech recognition today than we were 20 years ago.  Faster processors and more memory don't make everything easier.  But lots of little problems have been solved.  Computers have made and continue to make our lives better in many different ways, and we do make use of all this computing horsepower.  Perhaps not full use, but not too many people do 100 MPH in their cars, either.

The Internet, even with the spam, phishing, viruses, porn, ugly Web pages, and other assorted junk really is a modern miracle.  With eBay, Craig's List, Amazon Auctions, and similar sites, you can buy or sell just about anything imaginable.  You can get a weather report for anywhere in the world in a matter of seconds, check movie schedules, or research any topic under the sun.  If it's known, you can probably find the answer on the Internet.  Jeff Duntemann's All-Volunteer Virtual Encyclopedia of Absolutely Everything is the Internet.  There's a little indexing problem that we haven't solved yet, but the information is there and with a little persistence you can find it.

The Internet also is the best mass communications medium ever devised.  With any home computer you can send and receive mail instantaneously or chat real-time.  Add a cheap headset and Web cam and you can have a video conference with somebody on the other side of the world.  Free!

It seems like everybody under the age of 30 has an iPod or some kind of MP3 player.  Forget the Sony Walkman or Discman.  For what one of those things used to cost, you can fill your 8 gigabyte MP3 player with 8,000 minutes of music--somewhere between 2,000 and 3,000 songs.  Flash memory and computing cycles are just about good enough today to make portable video reasonable.  Within a year you'll be able to buy a good all-digital video camera (no tape) for under $1,000.  Figure one gigabyte per hour for VCR-quality (perhaps better) video.  (The privacy implications of this are another subject entirely.)  Put all your video and audio on your desktop or notebook hard drive and you have a general-purpose entertainment system.  Goodbye TV and stereo, and good riddance.

My little handheld GPS is a marvel.  With a one gigabyte flash card, I can carry maps of half the U.S. and almost instantly compute directions from where I am to wherever I want to be.  When the 2 GB micro-SD cards are available, I'll have maps of the entire country.  This is invaluable if you're traveling and need to find your way around a strange city.  It's also useful if you get turned around exploring the back country roads on your bicycle.  At home I can plan routes with the software on my computer, and when I get back from a trip I can download the tracks of where I've been.

Sure, I'd like my computer to continually scan the Internet looking for stuff that interests me, and there are times when I'd really like the ability to talk to my computer.  Maybe those things are coming in the future, and maybe not.  Either way, there's no reason to be disappointed by the lack of progress on the big problems or not recognize the many benefits that we gain today.  The power and capacity of home computers will continue to grow and we'll continue to squander most of those cycles, but that's okay because there are some applications that make use of all that power--infrequently, true, but you'd miss it if it wasn't there.

Friday, 07 July, 2006

Mass storage is essentially free

Debra and I were at Office Depot the other day and saw a 500 gigabyte USB hard drive for $299.  Not too long ago, hard disk space was a buck a gigabyte.  Today you can buy a 300 gigabyte internal drive for under $150.  For about buck a gigabyte you can get a ReadyNAS--hardware RAID 5, gigabit ethernet, build-in print server, just attach the device to your network, spend a few minutes setting it up, and off it goes.  A terabyte of disk storage for about $1,000.  Mass storage is essentially free.

(In 1983, two friends and I spent $1,000 for a used 10 megabyte hard disk drive and another $1,000 on the controller.  Dean wired up a board so that we could attach the controller to the Kaypro II, and I spent a number of sleepless nights hacking a BIOS driver for it.  Today I get 100,000 times as much storage for half the price and all I have to do is plug it in.  Less than half the price if you use inflation-adjusted dollars.)

Memory used to be about 100 times the price of hard disk space.  Not any more.  Internal memory still is relatively expensive:  figure $70 to $100 per gigabyte, or about 100 times the price of an internal hard drive.  But flash memory today is about $10 per gigabyte.  People are selling 8 gigabyte flash drives on eBay for $80.  I expect we'll be paying about half that come Christmas.  Maybe mid-Spring.

So if you figure RAID 5 disk drive space at a buck a gigabyte and flash memory at ten bucks, then for $2,000 you could have a terabyte of disk storage with a 100 gigabyte flash memory cache.  That ought to be one screaming storage system, don't you think?  Especially since the flash memory is persistent:  it doesn't go away when somebody shuts off the power.  Things sure ought to boot quite a bit faster.

Almost five years ago, I wrote:

Available RAM, drive space, and processing power have now far outstripped the average computer user's ability to actually use them.  Even power users will have a hard time stressing a 2 GHz machine loaded down with 1 GB of RAM and a 100 GB hard drive.  With cable modems and DSL giving close to 10 mbps download speed, our ability to obtain, store, and process information is well beyond our ability to actually make use of it.  What we need is some innovative applications that will search the Internet for information that we want, cull through all the crap and then actually do something useful with what remains.

Processor speed has about doubled, average available RAM has quadrupled, and available disk space has increased by at least a factor of 10.  And yet I find myself feeling better about it today than I did five years ago.  I'll explain why tomorrow.

Sunday, 02 July, 2006

Give Me a Break

I just finished John Stossel's book, Give Me a Break : How I Exposed Hucksters, Cheats, and Scam Artists and Became the Scourge of the Liberal Media...,, in which he describes how he got started in consumer reporting and how he came to learn that often (perhaps most often) it's government regulation and government programs--rather than "big business"--that are the real scams and cheats.  More than anything, his research confirms my own:  we'd be much better off if government was much smaller and less intrusive.  He also confirms something that I've long suspected:  the Left, for all of its claims of tolerance, is decidedly intolerant of any ideas that contradict theirs.

All in all, I'd say that Give Me a Break is a better book than Myths, Lies, and Downright Stupidity, which I mentioned a few weeks ago.  They're both good books and I'd recommend both, but if you can only read one, read Give Me a Break.

I learned from Stossel's book that Peter McWilliams passed away several years ago.  Peter was an author and a pioneer in the "book on demand" field.  My knowledge of his writing was limited mostly to his book Ain't Nobody's Business If You Do, which I bought in hardcover back in 1993 or so.  It's nice to see that his books live on in traditional print and also in full-text form on the Web.

Sunday, 02 July, 2006

Once more from the In box

  • One of the funniest videos I've seen in a while is the machinima production real life vs internet.  The disturbing part is that it's frighteningly true.
  • The Extreme Diet Coke and Mentos Experiments also is quite entertaining.  But then, I saw the humor in The Flaming Pop-Tart Experiment and Microwave Grape Racing.
  • It's Tour de France time again, and people are hitting my site looking for webcast links.  I'm not following the Tour as closely this year, so the only recommendation I can make is to visit the official site.
  • Speaking of search terms, I got a very large number of hits last month on "liz hurley", and the only time I've mentioned her was in connection with the Aluminium Foil Deflector Beanie.  Weird.
  • In the week since I posted my entry about U3 it's received more than 50 search hits--all variations of "remove U3" or "uninstall U3."  It'll be interesting to see if that continues.
  • My Web site traffic is down quite a bit over the last few months.  In March I had 5,647 unique visitors.  That dropped to 3,961 in April, 3,823 in May, and 3,326 in June.  The numbers for visits, pages, and hits also are down.  I'm not sure to what I should attribute this decrease in traffic.  The referral log spamming stopped a year ago, so that's not it.  Perhaps I need to submit my site to the search engines again.