2010 June

An (in)famous astronomer has died

I have no idea how I missed this. English-born astrophysicist Geoffrey Burbidge died earlier this year, on January 26 at the age of 84. He was instrumental in helping to develop the now commonly-accepted theory that all elements heavier than hydrogen, including those in planets and organisms come from ancient stars.

He gained a bit of notoriety and controversy for advocating the alternative cosmological model known as the Quasi-Steady State (QSS). In a steady-state universe, matter is being created, along with space, as the universe expands. QSS is an addition to the steady-state theory that states that miniature Big Bangs, called “minibangs,” are going off constantly, even after the Big Bang 13.8 billion years ago that sparked the creation of our universe. Because these theories directly contradict established observations and these discrepancies have not been properly addressed by QSS or SS proponents, they have yet to gain any real traction in the astronomy community.

In his later years, he gained even further notoriety for proposing that extremely red-shifted quasars were not distant, but were, in fact much closer. Due to the expansion of space, objects appear to accelerate from one another faster at greater distances. Burbidge proposed that these extremely red-shifted objects were really nearby galaxies moving away from us at the relativistic speeds and not moving at those speeds because of the expansion of space.

He came to fame in astronomy by contributing to a 1957 paper that explained how any element can be synthesized from hydrogen within the cores of stars. If a star is sufficiently massive to nova or shed its outer atmosphere, it will then spread these heavier elements throughout its galaxy. This is the commonly-accepted scientific theory to explain how heavier elements came into existence and were distributed throughout the universe.

Quick overview of UIAutomation

UIAutomation is a new plugin, previewed at WWDC, that will be in the version of Instruments shipping with the iOS 4 SDK. Essentially it allows scriptable testing of the UI. This is one of the few (if any) instances of Apple supporting Behavior Driven Development (BDD) in their developer programs and it is very exciting.

If you have spent any amount of time with BDD in Ruby on Rails, this should be familiar to you. If not, here are the basics. As the developer builds out new features or modifies existing ones, he or she can create simple test scripts that will be read and parsed to create a virtual interface for the application that will only be seen by the testing software. Here, it is Instruments. In Ruby on Rails, it is Cucumber.

UIAutomation makes use of JavaScript-based scripts to describe what the test should do and what it should be testing for. Unlike Cucumber, which runs in an invisible, virtual browser, UIAutomation will actually run on a development device and operate the application on the screen, for the developer to see. The team at Apple that created this plugin has come up with a way to describe UI elements and features on the screen in JavaScript.

The script will run through the tests that are specified and, as it runs, it will deliver a running report of what has happened so far. When it is done, the developer can save the results of the test session.

As someone who spent most of his summer in 2009 writing Cucumber scripts and wading neck-deep in BDD, it is a little exciting to see this kind of testing coming to the iPhone. Hopefully, it will be available for Mac development, as well. When I have the new development tools in my hands, I will give you a more detailed tutorial.

Basics of implementing multitasking on the iPhone

One of the most highly anticipated features of Apple’s iOS 4 is the ability to temporarily push an application’s processes to the background while another application is brought to the foreground and used. This was covered in detail at WWDC earlier this month. Fortunately, Apple was generous enough to provide videos from the conference on its iPhone developer site.

Main types of multitasking app

There are three types of multitasking app, detailed in the UIBackgroundModes key.

  • Audio (This would be for an application like Pandora and would allow it continue playing music outside of the application, similar to the iPod app.)
  • Location (This would monitor the phone’s position via CoreLocation and perform tasks according to the developer’s code.)
  • VoIP (This would include applications like Skype and allow them to function like Apple’s “Phone” app.)

Application lifecycle

There are three states in a multitasking app’s lifecycle, Active, Inactive, and Background.

typedef enum {
   UIApplicationStateActive,
   UIApplicationStateInactive,
   UIApplicationStateBackground
} UIApplicationState;

When the application launches, it calls the following methods from the app delegate:

-(void) application:(UIApplication *)application    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
-(void) applicationDidBecomeActive:(UIApplication *)application;

When the app goes to the background, we will execute the following the app delegate:

-(void) applicationWillResignActive:(UIApplication *)application;
-(void) applicationDidEnterBackground:(UIApplication *)application;

When an app is pushed to the background, it operations are suspended, save for the the functions that are desired to run in the background. For example, you would want Pandora to keep playing music and occasionally retrieve more music. You would want Skype to continue taking input from the microphone, sending output to the speaker, and remaining in contact with Skype’s servers. It is primarily the GUI-related functionality that is suspended when an app is pushed to the background.

Killing apps

Now, the iOS is not merciless when it comes to killing app processes. An app is given some time to clean up any processes that are not intended to run in the background. There, its state is sitting in volatile memory.

Because paging memory to the disk is not allowed, if system resources are needed for an active application, any background application can be killed by the OS. When it is killed, it is again given some time to clean up. For example, an app might need to finish a download or safely disconnect from a server. This can be done with the following methods:

-(UIBackgroundTaskIdentifier)
   beginBackgroundTaskWithExpirationHandler:(void(^)(void))handler;
-(void) endBackgroundTask:(UIBackgroundTaskIdentifier)identifier;

The first line of that code will tell the application delegate to move the app to background status along with some instructions on how to handle being terminated while there. The method endBackgroundTask: essentially kills the background task it is given as an argument.

Closing remarks

So, that’s about it. Apple seems to have come up with a system for background processes that is pretty straightforward. The OS will decide for you if and when a background app is to be terminated. It takes only a few lines of code to get started with this stuff. Apple has posted the video of this talk, along with the slides. (It is in the video “Session 101 – What’s New in Cocoa Touch.”) All of the code that you see here came from that talk. I hope all this was helpful.

Depression

Is there any indication we shouldn’t be depressed? Are you living on the same planet that I am? Do you ever think that depression might be the reasonable human response to the crap we’re going through as a species, meant to propel us into the next evolutionary step or, at least, into taking some different course of action, so that we might survive? Do you ever think that maybe it’s the happy people that are really screwed up in the head?

-Marc Maron

Check out Maron’s original routine on having a manic depressive father. It’s actually really funny.

Absence of open source at IUPUI

Indiana University-Purdue University at Indianapolis is an urban campus shared by Indiana University and Purdue University, two large, well-funded public education institutions. There are Schools of Computer Science, Computer Information Technology, and Informatics. IU’s University Information Technology Services does an excellent job of supporting students on all of IU’s campuses. (I am not just saying that because I work for UITS.)

However, despite all the up-to-date computer labs with dozens of computers, free software deals from Microsoft and Adobe, and 24/7 technical support, IU seems to be lacking one thing: open source. There is some Linux/UNIX software available through IU’s software site, IUWare. However, the amount of Linux software there is far outmatched by the software available for Mac and Windows.

Indiana University has deals with several software vendors, in particular Microsoft and Adobe. These corporations provide free software to faculty and students in the hopes that they will continue to use their respective software after graduation. A copy of Adobe CS5 Design Premium can cost as much $1,900. A Microsoft Office 2008 license can cost at least $150. OpenOffice may not be as feature-rich as Microsoft Office, but it would certainly get the job done for 99% of users and it’s free.

Unless it is detailed in IU’s agreement with Microsoft and Adobe that it not push open-source options too hard, I do not see why it should not become a bit more open about open source. At the very least, it is free software that the University will not have to haggle over every few years.

There. That was my first rant over open source. I will get hate mail.

No more back scratches!

I had to write about this. This may piss off some iPhone case makers. Apple’s newly-announced iPhone 4 is using the same scratch-resistant tempered glass on the back as it is on the front.

Any iPod or iPhone owner could tell you that the polished backs of all of these devices have had a difficult time with tiny scratches. These devices always look so shiny and beautiful when they come out of the box for the first time, but then they are tarnished by life in the real world, (just like people).

I do not think this blog post exists for any reason beyond my excitement that I may own an iPhone 4 (or possibly iPhone 5) and that it will not need a case the way my 3GS does now.