Monthly Archives: September 2005

When Bad Random Functions Go Good?

Most software developers who have even a cursory knowledge of code security know that using the built-in rand() function for anything cryptographic is a bad idea.

Now take the issue of randomness in car CD players, for example. In the last year I replaced my car’s stolen stereo system with a new one. It’s a Kenwood and I’m generally happy with it, but it has got to have the WORST shuffle play I have ever seen…er… heard. Let me explain:

I created a WMA CD with about 80 favorite songs in the root directory. I have this CD in more often than not. Yesterday, as I was driving home it played the exact same set of songs as on the previous day driving home! They were in a different order, however. It was probably a subset of about 20 songs. What are the odds of that?

A second oddity I’ve noticed is that it more often than not plays two Elton John songs in a row (songs are ordered in alpanumerical order and most consist of something like “01 – My Song.wma”, where the number is the track number from the original album). I have maybe 5 on the CD.

But the really weird thing is that every time Trace Adkins’ beautiful tribute Arlington comes on I happen to be passing Arlington Cemetery right at that moment. This has happened each of the 4 times I’ve heard the song in my car. Each instance has been separated by at least a few weeks.

I would be interested in seeing the algorithm they use.


Check out my latest book, the essential, in-depth guide to performance for all .NET developers:

Writing High-Performance.NET Code, 2nd Edition by Ben Watson. Available for pre-order:

Movie Theaters

Much has been said in the media lately regarding the drop in movie theater attendance by the American public. Reasons given include: awful movies; expensive tickets and concessions; competition from DVDs, home theaters, and video games; cell phone users; advertisement and preview glut; rude patron behavior; etc. I bet the list could go on for many people.

Yesterday, we went to see March of the Penguins. It was highly recommended, and some said we had to see it in the theater for the full-scale effect.

The movie was great–but not overly so. Worth a theater ticket? (and the popcorn I have to get?) I’m not so sure. But each time (and they’ve been few) that I’ve gone to the theater here, I’ve understood more and more the reasons people are not going as often.

I think I’d rather watch things at home where I can control the environment–sure I don’t have a cavernous room with a 30-foot screen and 7-channel Dolby Digital, but…

…It still seems more enjoyable. Probably the next big thing to drag me to the theater will be the next Harry Potter movie. After that, the Lion, The Witch, and the Wardrobe. After that? Who knows…the list gets smaller every year.

I wonder if theaters will become the exception, as DVDs become the rule?


Check out my latest book, the essential, in-depth guide to performance for all .NET developers:

Writing High-Performance.NET Code, 2nd Edition by Ben Watson. Available for pre-order:

List<> vs. ArrayList

I read Rico Mariani’s latest quiz, and decided to check out the results for myself in BRayTracer.

I already have some simple performance benchmark tests in my NUnit tests, so I ran some before and after. I changed only the ArrayList’s used in the scene object to hold shapes, materials, and lights.

Before:

25.197 opaque spheres/sec (time: 3.969 )

After:

31.841 opaque spheres/sec (time: 3.141 )

Pretty impressive savings with minimal work! Almost a full second! In an enormous scene, that will add up to a LOT of time saved. I still have to change the implementation for polygons and polygonal meshes–this will greatly speed up those operations, which are currently fairly slow. In fact, the way I have polygonal meshes written at the moment, they’re nearly impossible to render in a decent amount of time.

More exciting things coming to BRayTracer soon…


Check out my latest book, the essential, in-depth guide to performance for all .NET developers:

Writing High-Performance.NET Code, 2nd Edition by Ben Watson. Available for pre-order: