Tags

The stars at night

2:49pm on Jan 11, 2012

I've been working on an Android program which uses 2D graphics over the past few days, and since it's always nice to have sample code to start from, I dug up my old Android starfield simulation.

I wrote this thing back in 2008, not that long after Android first came out, as an introduction to doing 2D graphics. I've written starfields before, first in C (and modeX) back in 1996, then in Flash's ActionScript around 2002.

I just compiled the Android version, and discovered that nothing has changed in the API since 2008 - a very good thing. I did speed up the animation a little and add more stars, since modern phones are a lot faster, and there were odd gaps in the animation.

You can find all of these versions, with source code, right over here.

Naturally, all source is copyright (c) me, and released under the Creative Commons by-nc-sa license.

building blocks

9:21pm on Dec 21, 2011

I was reading an article today, a comparison of application life-cycles in Windows Phone 7 and Android, and while the article is for the most part correct, many of the statements are made in a slightly misleading manner. After a bit of pondering, I realized why this is.

Imagine that we have two children, Alice and Bob, who have a bag of 100 LEGO blocks. They're building small houses.

Logical process

Initially, Alice and Bob each take half of the blocks and build a house. A bit later, Alice decides to rebuild her house with half as many, so now she has 25 blocks in her house, and in a spare pile. No problems so far.

Bob discovers he needs a bit more blocks, so he asks mom to help him out. Mom notices that Alice has 25 spare blocks, so she puts them back into the group pool. Bob then takes another 10 blocks and finishes his house.

A Windows user's perspective

Okay, let's restart. Alice and Bob build houses of 50 blocks each, then Bob takes his apart, and rebuilds with 25. He now has 25 in his spare pile.

This is where a Windows user would say to Bob, "Hey! You aren't using those! Put them back!" Have you noticed this happen? Even though Bob wasn't using the blocks, they're still in his pool. But this isn't a problem, since so far, nobody else has asked for more blocks.

The average Windows user immediately complains when they don't have "free memory." But if you think about this, "free memory" is really just "wasted memory" because it's not in use. Why did you pay for that extra gigabyte anyway?

Android

A common "complaint" about Android, usually from users of other phones is that you can't close applications in Android. For the most part, this is correct, there's no simple way to "close" an application - but why did you want to? Unless the application is specifically written to run things in the background, once it's no longer the foreground application, it's not running. "But wait!" you say. "It's still using up memory!" Yes, yes it is - but until you need that memory, why do you care what else is using it? Android will happily shoot that other app in the head and steal its memory for you - but only if you actually need it.

But if you don't, and you want to switch back to that previous application, you don't have to restart it from the beginning, it'll just pick up where it left off. This is GOOD, it's an advantage.

cool

5:57pm on Oct 06, 2011

I finally quit being lazy and updated my first Android app, calCOOLator. It was semi-broken because it was using standard java.lang.Double numbers, now I'm using java.math.BigDecimal and dealing with precision much better.

Maintaining old applications, especially when it's been years since you even looked at the code, is a little annoying.

I'm sure I'll still get comments about how it doesn't handle percentages correctly. "50 + 10% = 55" - wtf kind of math is that?

Tags