Tuesday, August 9, 2011

A New Computer





I spent the afternoon assembling the hardware I bought three months ago. Why the delay? It was a near-fatal combination of being busy, ill, and a terrible procrastinator. But there was nothing on the schedule today, so I decided that it was time to tackle it.

It went far better than I thought it would. I would put it right up there with IKEA. The instructions were pretty good, and almost everything fit together nicely. I started just after one o'clock this afternoon, and all the pieces were assembled before four o'clock.

I was worried about the CPU and cooler, but they slid right into place.

It wasn't clear at first where the solid-state disk drive would go, but the case was as ready as promised.

Everything is in the case, ready to go. Here's a shot with the side panel removed:



I have a few questions I'd like to review with some friends who are more experienced than I am. But once I have those resolved it'll be time to power up, set up the BIOS, and install the OS and software.

It's going to be a terrific machine once it comes on line. I'll wonder why it took me so long to get around to it.

Thanks to Will, Steve, John, Karim, and Matt for their encouragement and inspiration.






profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers

Tuesday, July 26, 2011

Keynote




I'm going to speak at my next Toastmasters meeting on Thu. It's the sixth out of ten speeches required to earn the Advanced Communicator Bronze designation. I'm working out of a manual entitled "The Professional Speaker." The first assignment is to deliver a 15-20 keynote address. It's easily the longest speech I've ever been asked to give.

I'm looking forward to it.

Here's the text of the speech. I thought I'd post it here for the hell of it. Plus if I lose the text before I speak I can always come here and fetch it.

“The Professional Speaker”
Assignment 1: The Keynote Speech

Target organization: young professionals at the start of their career.

Mr. Toastmaster, fellow Toastmasters, and welcome guests:

Opening: One of the things that I love about working for a company like Travelers is seeing so many young people joining the firm. You see them walking through The Link, well-dressed, clutching a Travelers red umbrella like it’s a lost-and-found family heirloom. Eyes wide, ears open, frantically trying to remember the names in this maze of buildings so they’ll have a hope of appearing at their first meetings on time.

For some, this is their first job after earning a college degree. They’re walking with ten league boots: separating themselves from their parents, living on their own, paying bills, being adults. What a huge change! If we view life as a series of decades, each its own transition, this is the foundation for adulthood. This is when you start your career trajectory, think about marriage, and decide how you feel about children. It’s the basis for our entire society.

I remember my first day on the job very well, but my gray hair gives me away. It’s a distant memory: it’s been a long time since then. Let’s inject some humor into this keynote, shall we?

• There was no cable; no CNN or Fox or ESPN.
• There was no Internet; no Facebook or Twitter.
• There were no cell phones; no iPhone, Android, or BlackBerry.
• There was no e-mail.
• Computers were kept in a separate room, with its own air-conditioning under the floor, and shared by an entire department.
• Communicating with that computer meant some interactive terminals, but it also included punched paper cards.
• There was a vault in which vellum blueprints were stored for each component. Computer aided design and manufacturing was in its infancy.

Compared to today’s office, those early state-of-the-art facilities felt like a scene out of Dicken’s “A Christmas Carol.” More coal for the fire?

The scope and scale of technological change is breathtaking, but the human elements are unchanged. As I look back on my career, I thought about what I might have wanted to tell that younger version of myself. Here are a few nuggets of wisdom that I offer for your consideration.

Story 1: Figure out what’s important to you.

What’s your goal? Is it money? Climbing to the top of a corporate ladder? Being an effective individual contributor with deep technical knowledge? Whatever that goal is, spend some time figuring out what is important to you. You can’t reach a goal unless you know what it is and the steps you’ll need to execute to get there.

There is a price to pay for everything. Positions of high reward come with great responsibility. No one will ask about your child’s upcoming weekend activity when they send the limo to your house to whisk you off for a business trip.

Pausing on the advancement ladder has a price as well. Choosing to be an individual contributor might mean enduring the frustration of Cassandra: a prophetess whose advice was ignored when she told the Trojans to leave that wooden horse left by the Greeks outside the city gates.

Know what you want.

Be prepared for the consequences of every decision you make.

Make your own measure of success. Take an alternate path.

Story 2: Consider alternative paths to success.

I grew up in a different time. The prevailing wisdom went like this: “Get a job with a well-regarded company. Work your way up the ladder as high as you can, then retire on the terrific benefits they provided.” There was an implied contract: be loyal to a company, and they’d repay you in kind.

That contract is long gone. Companies require greater labor flexibility, so employees need to take on more of the burden of managing and directing their careers.

Alternative paths are on everyone’s radar now. Your choice depends on your appetite for risk. Perhaps you’d prefer being a contractor to full employee status. Or maybe you’d rather go all in and start your own business. This is not for the faint of heart. There are no off days; all the success or failure will be yours to own. You have to learn how to do the work and all the marketing, too. It’s a balancing act: keeping just enough work coming in to make it possible to build your brand and deliver without working every waking moment or waiting for the phone to ring.

Each of the past three decades has seen defining technologies and companies that drove them: personal computers and Microsoft in the 80s; the Internet and companies like Sun, Cisco, and Amazon in the 90s; search and Google at the start of this century; mobile and Apple going on right now. All these sea changes produce opportunities that a smart person can capitalize on.

Story 3: Keep an eye on market forces.

This leads to my next bit of advice: stay informed about your field and those that affect it. You don’t want to be caught unprepared when the world changes. No matter how comfortable and successful you might be, it pays to keep an eye on world events and extrapolate. Have you noticed that every person in this room is likely to have an iPhone, Android, or Blackberry mobile device? If you’re a software developer, and you aren’t writing for one of these mobile devices, you might be doing your future prospects a disservice.

I went to a wedding recently. One young man, whose first job out of school is sales for Microsoft, was rhapsodizing about a recent company meeting he attended. As excited as he was about hearing Steve Ballmer speak, I hope he’s kept his eye on the rise of the mobile computer and the cloud, and the decline of the desktop. His company may not figure out how to replace their desktop operating system and Office monopolies, but I’m sure he’ll have to soon.

Story 4: Keep learning.

The people who were most expert in those technologies that predominated at the start of my career had to change and learn new things or be pushed aside. The cruel truth is that this situation is only getting worse every day. The pace at which new information is added to the world is only increasing.

I resisted the temptation to insert a statistic stating how many terabytes of information are added to the Internet every day, translating it into Library of Congress equivalents to make it meaningful to the audience. But for ever page of fundamental new knowledge there are probably tens or hundreds of pages of celebrity gossip and other meaningless chaff to sift through. I’ll summarize by saying that there are 6.8 billion people living on earth today, and those who are actively adding their bricks to the wall of knowledge are doing it at a rate that is increasing exponentially.

Chances are good that all of us will have several careers during our working lives. I can speak from personal experience: I’ve had two, and I’m expecting that I might have a third act in me. I would not have had that second opportunity if I hadn’t kept learning.

Story 5: Enjoy what you do.

“Choose a job you love, and you will never have to work a day in your life.” This quote is attributed to Confucius and others; it’s still just as true today. You’ll see a lot of stuff written about following your bliss, your passion. The implication is that you just might be able to turn doing something you love into that custom fit career. Whether it is photography or cooking or programming or speaking or something else, your chances of finding happiness pursuing a beloved activity are good. If you’re lucky, financial success and fame might even accompany it.

Story 6: Remember your co-workers.

I was laid off from the first job I got out of school. The economy was not very good at that time; in some ways it was worse off than it is now. Interest rates, inflation, oil prices, and unemployment were all high. A friend of mine recommended that I contact the Navy research lab in New London, CT. It was a department loaded with Ph.D.s; I saw no good reason why they would want a young man without a graduate degree.

Art Carlson, the man who headed Code 44, took pity on me and offered me a job. The two years that I spent there made all the difference in the world. I completed a Masters degree, learned a skill that I loved, and – most important of all – got my confidence back. I moved on from that job and managed to earn a Ph.D. of my own. After graduation I wrote a letter to Art Carlson to thank him for giving me that chance. I said that everything that happened to me subsequent to that interview was because of him.

I was told later by people I worked with that Art showed that letter to everyone he encountered at the lab. It might have meant as much to him as it did to me.

Work is a team sport. All of us are dependent on the good will of fellow contributors to meet our goals. Remember to be the kind of person that co-workers can recall with respect at minimum and fondness at best. You never know when you’ll encounter them again as you progress through your career.

Story 7: Don’t sell yourself short.

My father was an immigrant who came to America from Ireland. He didn’t want to be a farmer, so he left home to find economic opportunity in America. When he landed in New York and came to CT, he thought he’d died and gone to heaven. He worked at the utility company that maintained the water system in town. He was a backhoe operator; a union guy, through and through.

I grew up imbued with his work ethic. I worked for that water company during the summer between semesters in college, so I had a taste of what manual labor was like. I was grateful to study something that made brain work possible for me.

I’ve always loved the details of technical work, but I think I also absorbed the lesson that managing and directing work wasn’t for me. Underneath it all, I’m also a union guy, a laborer.

Part of me knows that this was a good thing, because I’m an emotional person with a thin skin.

But there’s another part of me that wonders why I never aspired to be the person who directed the activities of others. The people I’ve observed who have been in charge of things where I worked have been a mixed bag. A few have been inspirational, brilliant leaders, but when I think of the majority of them I can’t help but look back and wonder if I couldn’t have done at least as well.

The first step in becoming a leader is believing in your heart that you’re someone worth following; the second is persuading others that they ought to believe it, too. Work hard to have an idea of your own, a vision for how things could be, and then get to work persuading others that you’re right. Don’t hesitate to put yourself forward. You might surprise yourself.

Conclusion:

If I could choose one message that my younger self could have heard and taken to heart, I think it would have been the one about alternative paths to success. Oh, and maybe something like “Bill Gates will become the world’s richest man by writing a Quick Basic compiler and having the nerve to call IBM’s bluff over DOS” or “Page and Brin will make themselves the kings of search by solving an eigenvalue problem; you know what that is.”. All of us are limited by what we don’t know. People who prepare themselves well, are attuned to the opportunities that come along are the ones, and are bold enough to act on them are the ones who have the greatest career success.

If you’re one of those well-dressed, wide-eyed young people that I see walking through The Link, I hope that you’ll profit by taking my lessons that still apply to heart, that you are astute enough to spot the changes in the world that will invalidate some of my dogma, and that you derive as much pleasure from your life’s work as I have. Thank you.






profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers

Sunday, June 26, 2011

Running








It's almost halfway through 2011. We've passed the summer solstice, the happiest day of the year. This was what I was longing for back in January when there were ice dams on my roof that wouldn't yield to repeated blows from a steel hammer.

2010 was far and away my best swimming year ever - an absolute blow-out in yardage totals, attendance, and every other measure you can think of.

2011 will not top it. By the end of Jun 2010 I had 318,100 yards under my belt. Right now, my total for the year is only 158,100 yards. Half the total!

The reason is easy to see: poorer attendance and effort. Five of the first six months in 2010 were "best monthly yardage totals." This year I fell short in January and never caught up. I haven't been regular about making it to Masters workouts. My standard morning workout was 2500 yards last year. This year I've put in 2000-2400 yards a day, rarely reaching that 2500 yard mark. Those small differences accumulate over time.

I had two bouts of poor health. There was a feverish weekend back in March that left me flat on my back. But I went back to my swimming regimen as soon as I finished the course of antibiotics and recovered sufficient strength. I don't think I was fully recovered. When the trees popped in May, spewing pollen everywhere, my health collapsed. I couldn't breathe, couldn't stop coughing. I was able to recover thanks to extreme measures, a smart doctor and wonderful health coverage.

But I found myself back at square one when it came to fitness. I've always been lung-limited while swimming. Now I had to figure out how to get it back. I had to do something different.

Swimming and biking are great, but there's nothing like running to tax the lungs and expand capacity. I decided that I had to learn how to run again.

I started swimming back when I was 21 because I wanted to avoid the toll that pounding the roads would take on my ankles, shins, knees, and hips. That was prescient - no replacement surgery for me. I ran every day then, but I haven't since. I'm lucky if I run the Manchester Race on Thanksgiving Day and hit the road half a dozen other times in a year.

There's a speed limit sign exactly a half mile from my driveway. I started running half-mile repeats, with a two-minute rest in-between. The key is to be regular and focused. I want to run four times a week. Don't take days off. Don't be shy about two workouts in a day. Keep working my lungs, getting a sweat on, and building my metabolism and lung capacity up.

It's worked out well this week. I swam at noon on Monday, squeezing in 1500 yards that included some nice 100 repeats. I had a yoga class at the grammar school just up the street after work. I measured the distance from my driveway to the school: 1.3 miles. A run to yoga would be doable. I persuaded my youngest daughter to join me. It was fun to have a running partner.

We had a 90 minute yoga class that felt great. I felt strong and loose. Wouldn't a run home complete the day? My daughter was game, so we ran home in the dusk followed by clouds of fireflies. It was a beautiful experience.

I'm not trying to run marathons. I don't want to race or be competitive. I just want to get my lungs back and feel fit again. I've learned the hard way that running is the only way. I've neglected this activity for too long. If this week is any indication, it's like seeing an old friend again after many years.


profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers

Wednesday, April 27, 2011

The Power Of Music







I mentioned in my last blog that I've been on a reading roll for the past month.

One of the books I picked up at the library during one fruitful visit was "Thus Spoke Zarathustra" by Nietzsche. I've never read anything by the great philosopher. I thought this might be a good time to remedy my ignorance.

I know nothing about his life either, so I also found "Nietzsche: A Philosophical Biography" by RĂ¼diger Safranski. I hoped it would give me context and let me fill in the gaps before I started on the main event.

It used to be that when I started a book I felt a moral obligation to finish it, all the way to the last page. But that's fallen by the wayside. Sometimes you know early on that something's not working for you. Time is precious. Why not take an economist's view, forget about sunk costs, and cease with further investment?

I tried, I really tried, with Joyce's "Ulysses". I got halfway through. I found Leopold Bloom in a bar spouting gibberish and waded right into pages of nonsense syllables. That's where I got stuck. I couldn't push through.

The Nietzsche biography was the same. I read about a quarter of it. It's not that the author didn't do a fine job. It was meticulous and well-researched. I just didn't care about Nietzsche. The book went back to the library last weekend, along "Zarathustra". I'll have to try again someday when I'm feeling more inspired. There were others in the pile that I was anxious to get to, and I only had three weeks.

One feature of Nietzsche's life struck me: his passion for music. Here's a paragraph from the overture that sums it up:


Over the course of many years, Nietzsche used the music of Wagner to gauge his aesthetic pleasure. After hearing the overture to the 'Meistersinger' for the first time, before his personal encounter with Wagner, he wrote to Rohde: 'Every fiber and nerve of my being is tingling. It has been a long time since I experienced such a sustained feeling of rapture.'


And this:


In 'The Birth of Tragedy', Nietzsche called this ecstatic life in music the 'rapture of the Dionysian state, which eradicates the ordinary bounds and limits of existence.'


Does that kind of passion still exist today? Has the ubiquity of music diminished its power to move us?

Music was rare back in those days. If you wanted to hear a musician or composer you either had to go where they lived or hope that a tour brought them to your town. Performances were live. There was no radio, no albums, no cassette tapes, no CDs, no Internet, no .mp3 downloads, no iPods.

Now it's hard to find silence. You can have music everywhere you go. Pop in some ear buds and you can have a hand-picked soundtrack for your life, excluding all other sounds. You can see any artist, alive or dead, who has a performance posted on the Internet. I've seen more of Stevie Ray Vaughn, one of my favorite guitar players, since he passed away in 1990 than I ever saw during his lifetime.

What we might perceive as a superior musical past, when giants walked the earth, is survivor bias. The dross musicians that were The Archies of their day had their music die off. There were a lot of bands and performers in the golden ages of classical music, jazz, rock and roll, and every decade since I've been alive that were terrible. They inspired little more than groans from all but their most devoted, die hard fans. We don't hear much about them anymore.

I asked my oldest daughter her opinion. She says that live performance, and the experience of seeing an artist with a large group, can still evoke that feeling of ecstacy. She assures me that an opportunity to see Daft Punk live, especially in their native Paris, would evoke a response that Nietzsche would both identify with and approve of.



profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers


Wednesday, April 20, 2011

The Power Of Reading





I've been on a nice roll reading books lately. I always have two stacks in play at once: non-technical and technical. The latter backlog is always longer, because I've allowed the right side of my brain to atrophy a bit as I've gotten older. I used to be more balanced, but I've had to devote more care and feeding to my technical side to keep up.

It started when I fell ill in the beginning of March and was confined to bed for several days to overcome a fever. I had a lot of time on my hands. A friend at work was kind enough to loan me a paperback copy of "In the Heart of the Sea: The Tragedy of the Whaleship Essex" by Nathaniel Philbrick. It was one of those recommendations that I feared would be returned without being opened. I'd have to embarrass myself and explain why I hadn't bothered to give it a look if I didn't try, so I started reading it.

Was I wrong. I was engrossed in the first few pages and quickly fell into a reading trance.

The story of the Essex was well known at the start of the 20th century. It was the inspiration for Herman Melville's "Moby Dick". That name was on the tip of the tongue of every schoolchild back then. This book brought it back for me.

The Essex was a whaling boat that left Nantucket in 1819, at its height of economic power, in search of sperm whales. Whales were harder to find by that time, so captains headed around the tip of South America and into the Pacific in search of their prey. A whaling ship would be away for two or three years at a time. It was not a journey for the faint of heart: nothing in common with Princess Cruise Lines. I don't recall any mention of a midnight dessert buffet, but I might have missed it in my feverish state.

The descriptions of life on the boat were harrowing. I would imagine that the young men taken along to learn the trade suffered from some variant of post-traumatic stress syndrome. Killing a whale with harpoons, stripping the carcass with knives, boiling the blubber for oil, and storing it in the bowels of the boat sounds like one of the worst jobs ever invented.

The ship had only a quarter of its hold filled with oil when it was attacked by an unusually large whale and sunk off the coast of South America. It must have been a rebel that finally took the systematic murder of his pod personally. He rammed the ship, damaged the hull, and forced the crew into three whaling boats to survive.

The really hair-raising part of the story was just beginning.

They made poorly informed choices and ended up spending three months in open water on the Pacific. If only they'd known that a westerly tack towards Polynesia would have ended their troubles! The irony was that they feared Pacific atolls populated with cannibals. Instead they turned south and east, trying to make their way back to the South American coast.

Their only relief in those three months was a brief stop on a small, rocky, uninhabited island that provided some fresh water for drinking and tortoises for protein. Their food situation became dire enough to force the crew to resort to cannibalism. The captain shot his sister's son, along for the journey as a cabin boy, after he drew the short straw. They ate him with neither chianti nor fava beans.

Even worse, that man survived the journey and had to go home and tell his sister what had happened to her son.

It made me wonder how much of what we think of as our better nature is completely dependent on our ability to secure fundamental needs like sufficient water to drink, a regular supply of food, security from threats, adequate sleep, etc. All of us would be surprised at what we might become and how low we'd stoop given such horrible circumstances. So much of what we think of as civilization is dependent on the illusion that we can meet our needs with no more effort than it takes to walk into a grocery store and swipe a debit card in a reader. We're far more dependent on a fragile web of providers than we'd care to admit.

I enjoyed this book far more than I would have guessed when it was offered to me. It made me think of "The Perfect Storm: A True Story of Men Against the Sea" by Sebastian Junger, a more modern take on the dangers faced by men in boats on the water.

After I finished "Essex", I went to the library in town and trolled for four more books. I'll write more about those soon.


profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers


Sunday, April 17, 2011

Building A Desktop Computer







I bought my first PC back in 1994. I spent a summer as adjunct faculty at the Hartford Graduate Center (now Rensselaer@Hartford, a much more prestigeous name) teaching partial differential equations to first semester masters candidates and earned a cool two grand. That was the going rate for a desktop PC back in those days; it was before Moore's Law kicked into overdrive. I had money in hand. More importantly, I had my wife's approval. After a career spent using Digital Equipment VAX minicomputers and Sun SPARC Unix workstations, I was finally going to have a machine in my own home.

I think I was vaguely aware of the World Wide Web. If my memory is correct, I had a Mosaic browser available to me on my computer at work. It was chicken, meet egg: I could have placed an order for my first PC on the Internet, but I needed a PC and Internet access at home.

I called Gateway 2000 to place my order. '2000' seemed so futuristic, so far away at the time. They were a serious player in the crowded PC market. The person on the other end of the phone was most pleasant and helpful. Windows 3.1? Very good, sir. Would you like two 3.5" floppy drives, or would you prefer one plus a CD ROM drive? Excellent choice, sir. 512MB of RAM? What will you do with all that? It arrived soon after with a monitor that I had to bundle into my arms to pick up.

I couldn't do much with the damn thing. I had to buy a slow modem to access the Internet, which was frustrating as it could be. I couldn't do serious engineering work on it - I could barely do the kind of work that I wanted on the most powerful workstations available to me. The compilers were limited. But I loved having it. I wrote code and prose as best I could. It served me well, but by the time it reached the end of its life I couldn't bear it anymore. I loathed that machine by the time I got rid of it.

I added a second hard drive and maxed out the RAM slots, but those last years weren't kind. I wasn't a hardware guy, so I didn't know how to do anything. I told myself that I was an engineer first, then a software guy. Hardware was someone else's problem. I would have studied electrical engineering if I wanted to know a lot about it.

I don't remember exactly how long I kept it, but it overstayed its welcome. I swore off Gateway, which was in trouble and about to be subsumed in a contraction of the overcrowded market. I went with a proven winner for my second computer: Dell. Their stock had risen and split several times during that period of irrational exuberance. If I'd been smart enough to invest whatever funds I had on hand early in the process I would have been a rich man.

Once again, I placed my order over the phone. The person on the other end of the phone was most pleasant and helpful. I don't remember much about the specs now. I think the operating system was Windows 95. I thought that this machine would last me a very long time, but I was disappointed again. Dell's stock might have been a winner, but their customer service wasn't. I had some long and memorable phone calls with their tech support that were worthy of the comedy series "Outsourced". Once again, I added a second hard drive and maxed out the RAM slots, but those last years weren't kind. I still wasn't a hardware guy; I still didn't know how to do anything.

If I loathed the Gateway, I detested the Dell. I swore I'd never touch another machine of theirs again. Surely HP would be better! I had the Internet at my fingertips in 2005, so I placed this order on line. I didn't need the approval of a salesperson. It was click! click! click! and I had the machine of my dreams: Windows XP! 4GB RAM! Dual core Intel processors! A 220GB hard drive! Surely this one wouldn't disappoint me!

That's the machine that I'm still using now. I'm happy to say that after six years I don't hate this set-up. It's long in the tooth, but Moore's Law gave me something that has weathered the storm better than the others. I can still do what I need to do. I've written a lot of prose, a lot of code, browsed a lot of Internet on this thing.

But I'm still not a hardware guy; I still don't know how to do anything. It's time to do something about that.

I've wanted to build my own machine ever since reading Jeff Atwood's Coding Horror blog about building a PC back in 2007. My HP was only two years old at the time, so I didn't think I needed to be in the market for another one so soon.

Now it's four years later, and I could use another machine. Capabilities have gone up and prices have come down. The world of hardware continues to race along. If I was going to buy another OEM PC I would go for an Apple and see what that's like.

But I've decided that I want to try my hand at assembling my own and installing a operating system for the first time. It's almost a professional requirement.

I'll have lots of help: a friend at work has done this in his sleep, so he was kind enough to offer a complete parts recommendation from Newegg.

So I finally pulled the trigger this afternoon: I set up an account at Newegg and placed an order. My federal tax return will more than cover it. I have my wife's blessing.

This won't make me a hardware guy, but it's a start. I hope it'll give me some base experience and enough awareness to do what's needed to keep the machine up as the years go by.

I want to install an operating system - no, make that several operating systems - from scratch. After spending an engineering career working on nothing but Unix hardware, I've been unable to get away from Windows during my second act as a software professional. When I was an engineer I thought like a guy who didn't care about being an admin on his machine. I used what I was given; I didn't install software.

I'd like to get back to Linux and rediscover what I missed. Setting up my own machine to dual boot to Ubuntu would be fabulous. I want to learn why software professionals say Unix/Linux is a great environment in which to write software. I want to learn sed and awk and rediscover tools that could make my software development life better.

Most of all, it's a chance to keep growing and expanding and learning. Stagnation and satisfaction are death; we all need to keep doing new things that we're afraid of, to expand that circle of light where knowledge and comfort live, and erode that ignorant darkness that's all around us.


profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers


Sunday, March 6, 2011

Mandelbrot Set












I just finished a trivial but entertaining programming project: rendering a Mandelbrot set using Java.

Mandelbrot sets are named after Benoit Mandelbrot, the recently deceased mathematician that "discovered" them. He took a simple recursive relationship and mapped it onto the complex plane by counting how many iterations were required to observe the magnitude diverge when repeatedly squaring the value at each point:



I've known about Mandelbrot sets for more than twenty years. Chaos theory was all the rage in the late 80s; James Glieck wrote a terrific, accessible book entitled "Chaos: Making A New Science" that summarizes the history beautifully.

Knowing about Mandelbrot sets and having successfully coded them for oneself are two very different things. I saw a question about an implementation on Stack Overflow. Having not gone through it for myself I had nothing to contribute, so I decided to tackle it.

It took me a little while. It all starts with a good Complex class. I implemented the basic arithmetic operators using a fluent style, because it seemed cleaner to me. I wrote a nice JUnit test and asked IntelliJ to tell me about code coverage.

I haven't done any Swing programming in a very long time. I had the set in black and white displaying quickly, but then I had to get a nice color map. It was a happy moment when I saw the picture that accompanies this posting.

That wasn't enough; I had to be able to use the mouse to select a sub-region and zoom in. Once that was working I wanted to be able to save the lovely images to a file. Adding a "save" button would be nice, but my first try just writes the image to an output file when the window closes:



I checked all my code into my local Subversion. I have 100% code coverage for my two model classes (Complex and Mandelbrot, which implements an IterativeFunction iterface) and two view classes (MandelbrotPanel and PixelMapper).

It's not much more than a nice undergraduate problem, but it made me happy to get through it and get such a satisfying result.

I've created an open source project on SourceForge.net and uploaded the code to their Subversion repository. Anyone with a Subversion client can download the code and give it a look:

svn co https://mandelbrotset.svn.sourceforge.net/svnroot/mandelbrotset mandelbrotset


profile for duffymo at Stack Overflow, Q&A for professional and enthusiast programmers