Archive for January, 2009

Refactoring the GUI for an Xcode App

Friday, January 30th, 2009

xcode.jpg

I have been having a blast refactoring the GUI of my Poission Equation solver - Potentials, using Xcode. I had a very simplistic interface in the beginning because I wanted to focus on the math involved, and then never really took the time to mess with the GUI as I realized that I didn't have access to a really good graphing package with which to display the results.

With CorePlot on the horizon, I got interested in it again and decided that the simplistic view of the app needed an update. I had a simple text field for the input file name, a "Go" button, a status label and a text field for log messages. Problem is that the solution is so fast, there's no need for the log text area as the status line will be fine for user feedback.

So I decided to make the app an editor of the source file and headed in that direction. I was very happy to see that I had already really laid down about 80% of the necessary code for this, and there were only a few things I needed to change. When I started to edit the MrBig.h header to include more outlets and actions I was stunned to see that InterfaceBuilder automatically re-parsed that header and added in the actions and outlets to it's representation.

That was a real treat. In the past, you had to manually ask for that to be done and it was always a touchy process that could get you into trouble if you didn't format the actions and outlets properly. Now, with the IDOutlet and IBAction descriptors, it's easier for IB to figure all this out.

Amazing tools, and lots of fun to work with.

Google’s GDrive Replacing PCs? Can’t Believe It

Friday, January 30th, 2009

NetworkedWorld.jpg

I was watching diggnation today and heard (again) about the rumored GDrive, so I decided to do a little reading to see what it's about. I found this article about it and while I can see Google opening up the storage and making a desktop client for something like the MacFUSE, I can't see this being what is being portrayed in the article:

As the latest rumors surfaced, The Guardian told the world that Google was planning to "make PCs history." This was promptly echoed by the likes of FoxNews.

"The Google Drive, or 'GDrive,' could kill off the desktop computer, which relies on a powerful hard drive," The Guardian burbled. "Instead a user's personal files and operating system could be stored on Google's own servers and accessed via the internet."

Apparently, this is part of a Google-grab scheme to put a Googlephone into every hand. "The PC would be a simpler, cheaper device acting as a portal to the web," the paper went on, "perhaps via an adaptation of Google's operating system for mobile phones, Android."

On diggnation, Kevin pointed out why he (and about a billion other people) would never store all their information on a server they don't physically control: security. When it first gets cracked, and it will, it's only a matter of time and energy, then the crackers are going to go after the people with the most to loose - celebrities. Understandable. But there's more to it than that. Everyone probably has something they don't want others to mess with, and if GDrive isn't backed-up in my house, then if GDrive gets nuked, all my stuff is gone.

Unacceptable.

For under $300 I can get a drive that backs up all my data and does it safely. I'll never loose my photos, the sounds of my kids, my docs, my code. No way. So why hand it over to anyone?

And as for the 'PCs are a thing of the past'... yeah, right... Sun tried that with the JavaStation and it failed just as badly as this will. There's no way a phone will replace a computer. The phone is nice, but it's not something you're going to type a sales report on, or do work for your employer. Employers are never going to use it, do the PC industry will survive, and if they are being built, there are going to be reasons to have one at home.

No, it's an interesting idea, and I might very well throw some stuff up there, but I'll use it like a public or semi-private file repository and that's it. No way I'm trusting it to the most important things I have.

Xcode is Amazing, and Sometimes Quite Confusing

Thursday, January 29th, 2009

xcode.jpg

OK, today I decided to get the latest Static Analyzer as I have really enjoyed the reports in the past, and I knew from the mailing list I'm on, that there have been a ton of changes. Well... I had no idea.

The first thing was that there were some old plist definitions in the Potentials project and I had to root around to find out where they were defined and then remove the bad names and let the defaults be used. That was slightly frustrating, but I really did enjoy the fact that the navigation of the compile-time parameters has become so easy in Xcode 3 that it's really not that bad a chore.

Once I had that, I needed to make an alias to make it simple to run the analyzer. I added:

  alias checkit '/usr/local/checker/scan-build -k -V xcodebuild
                              -configuration Development

(all on one line) to my .tcshrc and I was ready to hit it again and again. I like that they have incorporated the viewing right off the command-line, very nice.

The next thing I realized was that I was getting a lot of warnings of the form:

  warning: dereferencing type-punned pointer will break strict-aliasing rules

After quite a bit of Googling, I found that it's related to the use of the -fstrict-aliasing optimization option that is put in place (by default) by the -Os optimization (size and speed). So... that's not great. But it shouldn't have been there - so says the Googling. There had to be something else.

And there was... in the GUI if you turn on the "Auto-Vectorization" optimization, then that's the trigger point and there's nothing you can do about it.

Project 201CPotentials201D Info

If you have this checked, then every time you reference super as in:

  if (self = [super init]) {

in your initialization code you're going to get this kind of warning. I tried and tried to use the -Wno-strict-aliasing, but there was nothing I could do to turn off these warnings other than to build as 'Development' (where the optimizations are turned off) or turn off the Auto-vectorization. Shucks.

I read through the man page on gcc and I think the only thing I'm missing out on is the automatic vectorization of loops. It's not to say that it won't be done, but it's going to assume it can't and then see if it can. Not great, but I'm not about to re-write my init methods to skip this, and there's no amount of casting or forcing that removes this error. Calls to super are just not "OK".

I'm not the kind of guy that likes seeing 75 warnings on the build, either. So I have to settle for skipping the auto-vectorization. In the end, I added a few things to the code and cleaned up the build and I'm really rather happy about it. I do believe that Xcode is one of the best development environments that I've ever worked in. It's really quite wonderful.

Twitterrific 3.2 is Finally Out

Thursday, January 29th, 2009

Twitterrific.jpg

Today I got a tweet that Twitterrific 3.2 for the Mac is finally out. They have been working on the iPhone version for quite some time now, and the desktop (Mac) version had been sitting a little idle (but usable) while they did the iPhone development.

The release from beta is not a major thing, but I'm sure they fixed a few things. I've been using the beta for 3.2 for quite some time and not run into a single problem. I've seen many other Twitter clients, but this is by far the best for me - small, lightweight, clean and it works. Can't ask for more than that.

Being Surprised and Amazed by Your Kids

Thursday, January 29th, 2009

trophy.jpg

Last night was my 10 yr old daughter's Winter Concert - rescheduled because of the blizzards we had on the originally scheduled week. Act of Nature - what can you do? Well... I knew she had tried out for a solo in one of the musical numbers - I just didn't know much else about it. I was pretty sure that it was singing, but I don't even think that was clearly laid out for me before-hand.

So we go, and listen to the 3rd and 4th graders, and then a little into the 5th graders, Liza leans over and tells me that the solo is in the final part - where they brought out all the kids that performed and they do a final singing number. OK... nice to know. So we listen to the last number for the 5th graders and then they start to bring out everyone.

Once everyone is ready they give the microphone to Nina, and the music starts. We were pretty far away, so I couldn't really tell when she started to sing - at least I didn't think so... because I was convinced that this was a recording of someone else.

I was blown away.. She'd never done a lot of singing around the house, and that voice... standing all alone in front of 600+ people at the beginning of the song... I was blown away. I had no idea she had that kind of voice. I could see Liza tearing up because of the incredible courage it took to do this. Let's face it - kids in grade school can be downright vicious to one another over the littlest of things.

Yet there she was, singing this song with the most incredible voice I've ever heard from a 10 yr old. OK, so it's not time to ship her to a record studio, but still... there she was, and her courage and talent so exceeded my expectations I was speechless. I have watched her skateboard, play football, play softball, basketball, do schoolwork, draw, play on the computer - I thought I knew her. I didn't.

It's amazing when your kids totally blow your expectations away. I can't say that I had a lot to do with that, but I had a little, and even a little bit of credit for that makes me feel pretty amazing. She is one amazing kid.

Making an App Fault-Tolerant with Intolerant Components

Wednesday, January 28th, 2009

SwissJupiter.jpg

I noticed this morning that one of my price injectors was hung up in a poor, sick little infinite loop when the service (vendor provided) had died and then I restarted it. I had not coded up the library to close and re-open the connection. In an attempt to make my application fault-tolerant to this service's restarts, I decided to dig in and add in all the pieces I needed to properly reconnect when the service was restarted.

If only it were easy.

The first thing I had to do was to unroll where I was in the processing so that I'd pause what I was doing (or trying to do) when an error with the service was detected. That didn't take too long, but I wanted to make sure I didn't put in the logical equivalent of the goto statement, so it took a little bit of work to handle it properly.

Once that was done I needed to have the main thread detect this condition and then close/re-open the connection. Here's where I really started to run into problems. While the code appeared to be what I needed, I would get just a few attempts and then a double free core dump. Every time. And it was always in the vendor's API code. It seemed that no matter what I did there was no way to avoid this problem. Crud.

So what if I tried to "go around the horn" and exit the app with an error condition and then have the guardian script that started the app, and restarts it in the case of a core dump would see this and restart the app. That's OK, but what if it fails right away? Well... that's the problem. So what I tried next was to put a retry loop on the creation of the connection to the service. Maybe that would work.

Better. It seems that so long as the connection isn't ever really made, you can call the open() call as many times as you need to get the job done. I'm getting a lot closer. Now that I have a way to exit the app with an error and restart it with a retry loop all I had to do was to make sure we didn't litter the directory with core files. The final problem was that trying to close a troubled connection lead to the same double frees that I was getting in the first place.

So I had to put in even more logic to the wrapper classes on the vendor's API so that I could be assured that the application could exit cleanly and then the restart would take care of waiting until the service was up again.

Finally I had something. It took a few hours, but in the end I have a system that's fault-tolerant to the vendor's service restarts and that's what I wanted to build today. It's going to make it much stronger a system. Good news.

Interesting C++ Matrix Library: Eigen

Wednesday, January 28th, 2009

cplusplus.jpg

I was reading the RSS feeds this morning when I ran across this interview of two lead developers on a C++ templated matrix library. Very interesting stuff. Their project is called Eigen and has some very interesting capabilities. First, it's self-contained. Secondly, it's all C++ and templated, so it supports both fixed and variable sized arrays and matrices.

I'm not sure I'll do anything with it, but if I get into a situation when I need matrix algebra, I'm going to give this a go. It's probably not the highest performance library in the book - face it, it's all generic templates. But for that there's a universe of decent performance at a very marginal cost. Sounds very nice.

So I'll keep it in mind. Useful if I need something like this.

iPod Touch 2.2.1 Firmware on iTunes

Wednesday, January 28th, 2009

iPodTouch.jpg

This morning I got the iPod Touch 2.2.1 Firmware off iTunes. Yesterday, I read a tweet from John Gruber about the iPhone SDK being out, and didn't make the connection until this morning when I read about the update. It doesn't take as long as it used to, but it's still not like downloading a song.

Worth it as it updates Safari and Mail and adds the same kinds of patches and updates as Apple does for OS X.

New Kindle to Arrive in February?

Wednesday, January 28th, 2009

Kindle.jpg

There's a story out that Amazon has invited the press to an 'event' at a library on February 9th and the speculation is they will be announcing the new Kindle. I was ready to buy the new version this past fall, but with all that's happening lately - the new MacBook Pro, iLife '09, and Comcast's Extreme 50, there's almost too much going on to take it all in.

Also, my Kindle is still working great and not a scratch on it. I use it every day, can't imagine a simple, better way to get and read books. So I'll probably watch (or read about) the announcement, but don't plan on getting a new Kindle right away.

Fission 1.6.2 is Out

Wednesday, January 28th, 2009

Fission.png

Today the Rogue Amoeba team released Fission 1.6.2 with a few important bugs fixed and a few other updates. I have recently started playing with Fission a lot more as I've been going through the sound clips I recorded of Joseph when he was little. I appreciate that Fission is a lossless editor - by design, but I'd really like to have a tool that can reduce/remove hum and popping from sample.

A plugin interface with some decent way to access the data would work - I could write a quick FFT (or use FFTW) and then apply some of the simple filters I learned back in college. It's not rocket science, and it might even be possible with a really selective equalizer that I could base on a spectrum plot of the sample. That would be a neat addition too, come to think of it.

Anyway, it's out, and a free update.

UPDATE: I sent a support request to the Rogue Amoeba team in hopes that they will see the value in a Spectrum Analyzer heads-up view of the data, as well as a plug-in architecture for filtering the data. I'm not hopeful, as Fission is lossless by design, but maybe.