Game idea: Spinbot

I plan on learning how to use the Pyglet media library and the Cocos2d game library, along with gaining more experience with Python, by creating a simple video game. Here’s my next idea:

Spinbot is a platform puzzle game. It involves simple puzzles related to changes in perspective and changes in gravity.

Each puzzle takes place in a room. There are platforms scattered throughout the room. The player can move left and right and jump. Any time the player comes in contact with a surface, the screen rotates so that the surface they touches is the new “ground”. Gravity also changes to match the new rotation.

The goal is to guide the player, Spinbot, through the room in order to find and touch a glowing power sphere. Obstacles include surfaces with oil that the player can’t grab on to, and moving platforms.

I hate C++

I hate C++. I will never ever use it by choice to write software again.

C has been my favorite programming language for many years, but I never really did anything with C++.

I’ve decided it’s incredibly wordy, error messages from the STL are really hard to read, there are so many things I need to do myself instead of having the compiler take care of them for me, there are many ways to do everything, it takes an incredibly long amount of time to compile my small application, and the standard library is so small and painful to work with. I could go on and on.

I don’t hate pointers, I don’t need automatic garbage collection, but holy moley it feels like everything that’s been implemented in C++ has been done in the worse way possible.

Why is this language so popular? It has almost an infinite number of features, which can be nice I suppose. If you want a fast, compiled, object oriented capable language then there traditionally aren’t too many options. Some others are Ada and Objective-C.

I may have made a mistake. Before working on my first C++ application, I wrote my first Python application. I think Python spoiled me.

I wish there was a language that was like Python but compiled like C. I’m sure many programmers want the same thing. Maybe one exists, but if it does I don’t think it’s very popular yet.

For now, I think I’m going to start using Python a lot more. Throughout my life as a programmer, I’ve written software in assembly and C. I’ve learned a lot about good programming principles and managing all of the details in the code myself.

But I’m getting of tired of it. Writing code in a language like C++ can be kind of fun, but I never get anywhere. Alternatively, with Python I can have fun and actually finish an application.

Contributing to the FOSS community

In what ways have I contributed to the free and open source software community? And what can you do to help? Here are some thoughts.

I love helping FOSS projects, but it can be difficult to decide what to do.

Keep it simple

Choose a project where you need to learn one thing at a time.

There are languages (examples: Python, C), libraries (examples: GTK, Qt), and programming paradigms. (examples: GUI programming, threaded programming) When you begin working on a project, you will probably need to learn something new. Try to learn only one thing at a time. For example, if you have to learn gstreamer and GTK (two libraries) at the same time then you might become frustrated. Or, if you have to C++ and Qt (a language and a library) at the same time then you might become frustrated.

So, try to learn one thing at a time.

Working with other FOSS developers

I love working online with FOSS developers. When I get to talk to the lead developer of a project, it feels like I’m talking to a celebrity.

Of course, you should join the mailing list and bug tracker for the project you want to work on. I don’t usually introduce myself. Instead, I just start helping, and people will know me soon.

My FOSS experience

Here are some examples from my FOSS experience.

Many years ago, I wanted to write a new FOSS application. I couldn’t think of any new applications to make, so I decided to make a video game. There are never too many video games.

I learned many things by making video games:

Languages: C, Objective-C, Java, Assembly, Ada

Libraries: Allegro, SDL, Java SWING

I’ve submitted many bug reports to many different projects, such as wxWidgets, Allegro, Udiskie, and Haiku. I really like submitting bug reports and working with the developers to fix the problem. It’s easy to do and I get to use better software.

I maintain some AUR packages. (very easy, but it helps FOSS)

I helped write the documentation for some software from the Arch Linux community, such as Packer and Udiskie. I’ve contributed to the Arch Linux wiki.

Recently, my wife and I wanted a new application for budgetting. I decided to write one. I used Python and wxWidgets. It works pretty well. My next goal is to convert it to C++ and wxWidgets, and then make a version for Haiku using C++ and the Haiku API.

Interesting things

You should definitely work on something that you think is interesting. To me, that’s Arch Linux, Haiku, bug reports, and documentation. Try to find things that are interesting to you!

Lastly, don’t make your goal too big and don’t try to do too much. There are many many people helping in FOSS. If everyone does a little bit, then we can make something great.

GNOME 3 pre-release opinions

It was announced on the GNOME developer list that GNOME 3 won’t have minimize or maximize buttons:

That’s a huge change. My initial reaction was “Whaaa?”, but then I started thinking about how I use my window manager (currently FluxBox). I almost never use the minimize and maximize buttons, and certainly wouldn’t miss them if they were gone.

The mailing list message talks about helping users learn a new work flow. This reminded me of when I started using Haiku. Haiku has a powerful file manager called Tracker. Tracker is a spatial file manager, which means every folder opens in its own window. The first thing I wanted to do was change it to a navigational file manager. So, I went to the Haiku documentation.

I found the information I was looking for, which included this comment:

Before you switch Tracker to Single Window Navigation mode, because that may feel more familiar to you, we recommend giving the menu based browsing a try first, as that may actually work much faster for you after getting used to.

So, I decided to continue trying Tracker as a spatial file manager, and now I really like it.

Now, in regards to GNOME 3, it’s hard for me to express how I feel about it. Let’s see if I can summarize it:

  • There are too many things that move around the screen. Things go from the window view, which shows almost nothing but the window you’re actively using, to the activities view, which shows everything at once. And I mean everything, every workspace, every window, every running application, every recently used document, directories, and search. And those things were all designed to move and live and grow as you use your computer, which means things are shifting around a lot.
  • It forces a new workflow on users that doesn’t appear to be better than another workflow. This may not be a bad thing. Haiku kind of enforces a new workflow, but I quickly learned to like it. With GNOME 3, I have no idea how the new workflow is supposed to benefit me. Which leads to:
  • How will they train people? When GNOME 3 is released, the new design may be great for many many people, but they need to learn how to use it before they can benefit from it.
  • It requires accelerated graphics.

GNOME 3 hasn’t been released yet, and my opinion will probably change. I hope the GNOME developers know what they’re doing, because I sure don’t know what they’re doing.


I’m very unhappy with the situation of icons in Linux.

When I started using Linux around ten years ago, it seemed like every application had it’s own way of adding an application icon. Nowadays, it seems like most applications use the standard method, but a few don’t, or something. I don’t know. All I know is, I always end up with a few applications that have icons that either look horribly out of place or simply just don’t exist.

Haiku is another open source operating system. It has beautiful icons compared to any other operating system, and I think there are a few reasons for that:

  1. The one and only Haiku API encourages software developers to use the official method of adding an application icon.
  2. All of the other icons in Haiku look so nice that, if you don’t make a beautiful icon for your application, it will stick out like an ugly application icon.
  3. There’s hardly any software for Haiku at the moment.

Anyway, I recently started using the Fluxbox window manager. I chose it because it has a clean and simple user interface, and I can disable all application icons.

The return of malloc

Should you always check the return value of malloc? There’s a heated debate over the answer.

One group insists that, in good software development, you always check the return value of a function, including malloc. It appears that most software developers are in this group.

The other group thinks otherwise. I’m in this group. Here’s why.

I was taught, like many programmers, to always check the return value of malloc. This thread made me think otherwise: Always check malloc’ed memory? The asker raises many interesting points.

When thinking about checking the return value of malloc, it’s important to consider the operating system, hardware, and type of software that you are working on. Linux may behave differently from FreeBSD, a desktop computer may behave differently from a mobile phone, and a GUI application may need different considerations than a shared library. Also remember that it may not even be your application that is causing malloc to fail.

I’m primarily concerned with the case of a GUI application running on Linux on a desktop computer, because that’s what I work on. Even so, it’ll be fun to think of the other cases.

Failure Response

So, let’s say you check the return value every time you use malloc. What do you when a return from malloc fails? You could simply quit your application immediately. You could try to quit your application gracefully. You could cancel the command that caused the fail and display an error message. You could loop until either malloc returned a valid result or the computer catches on fire.

Can You Respond?

Let’s pretend that malloc failed. Imaging the state that the computer is in that caused it to fail. Would it still be able to do any processing at all? I agree that it is extremely important for an application to never lose the user’s data, but would the computer even still be able to recover anything at that point?

Does malloc Fail?

In Linux, malloc may never even fail. On the malloc man page under “Bugs”, it states that just because malloc didn’t fail doesn’t mean it has enough memory.

The Trial

So, I wrote some code to try and make malloc fail. When it does, it tries to recover and quit gracefully.

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct NODE
  int data[40000000];
  struct NODE* next;

  NODE* node;
  NODE* first;
  NODE* last;
  int stop;
  int count;

  first = NULL;
  stop = 0;
  count = 0;

  while (!stop) {

    node = (NODE*)malloc(sizeof(NODE));

    if (node == NULL) {
      printf("FAILED! %d \n", count);
      stop = 1;
    } else {
      if (first == NULL) {
        first = node;
        last = node;
      } else {
        last->next = node;
        last = last->next;

  count = 0;
  node = first;

  while (node != NULL) {
    last = node;
    node = node->next;

  printf("FREED %d \n", count);


The Results

Here are the results when running it on three different operating systems.

Arch Linux: After 55 seconds, the message “Killed” was displayed. This was a message from the operating system, not my code. My program never had the opportunity to see a failure from malloc nor try to cleanup after it.

Haiku: Almost immediately the program stopped. The output was “FAILED 10, FREED 9″. That means that after trying to allocate about half a gigabyte of memory, it failed to allocate anymore and was able to clean up the stuff it had.

Windows XP: The results were similar to Haiku: Almost immediately the program stopped. The output was “FAILED 12, FREED 11″.


By using this simple test, it appears that checking the result of malloc can be a worthwhile task. My conclusion is contrary to my feelings from the beginning of this post. I think I just might have to change my programming habits.

What I do in Haiku

This is a growing list of things I do in the Haiku operating system. The purpose of this list is to have an easy reference when people ask, “So, what can you do in Haiku?”.

Also, this is not a list of possible examples of what I could do in Haiku. Instead, it’s specific things I’ve done while sitting down and working with my computer.

  • Update my tech blog. (WordPress, the one you’re currently reading)
  • Browse the Internet with WebPositive.
  • Use Gmail.
  • Use Facebook.
  • Chat with friends on Google Chat, Facebook Chat, and MSN with Caya.
  • Type in Japanese.
  • Download and watch a video using the Transmission bittorrent client.
  • Erase a CD-RW.
  • Download the latest nightly image of Haiku and burn it to a CD.
  • Watch and listen to the lecture video (M4V) from my graduate course.
  • Use SSH to login to my school to work on a graduate lab.
  • Read and write files to my Linux EXT3 drive.
  • Listen to a playlist of my MP3 music files.
  • Video game development using the PE “Programmer’s Editor”, GCC, and the Allegro Game Library.
  • Version control for my software using SourceForge and git.
  • Enjoy the screensavers. This may seem like a small thing, but I believe it’s important. Haiki has at least two screensavers that I think are really nice, namely “Butterfly” and “Icons”.
  • Use multiple desktops to make my workflow easier.
  • Take a screenshot using the Print Screen key and the Screenshot application.
  • Edit an image in WonderBrush.
  • View PDF files using BePDF.


Desktop 1: Programming (PE, Terminal); Desktop 2: Internet (WebPositive, Caya); Desktop 3: Music (MediaPlayer); Desktop 4: Document (StyledEdit)


My new love: Python + wxPython

I have a new love. It’s Python with wxWidgets. Add xwGlade, and I think I’ve found programming nirvana.

I’ve been programming in Python for a couple of weeks now. I find it very easy to learn, writing code is super fast, I don’t have to waste my time writing things that the language already understands, it’s well documented, and it’s pretty to look at and read. That also happens to be pretty much everything I’d read about Python. As an interpreted language, I’d also heard that Python is slower that C, but I certainly haven’t noticed it being slow.

I also started using wxPython about two weeks ago. It was easy to learn and make a GUI with, and the GUI I made looks great on both Linux and Windows.

wxGlade was dead simple to learn. I was able to throw together a GUI really quickly and start adding functionality to it.

Here are some of my favorite sites for learning wxPython:

I have very little time to work on personal programming projects, but working with Python + wxPython + wxGlade has been extremely fast and fun.

Mac OS X 10.7 Lion reactions

Some of the features of the upcoming Mac OS X 10.7 Lion were announced today. I am very disappointed in the changes Apple is making to the OS and the UI.

I used to really like Mac OS X, but in recent years I have been liking it less and less. I don’t actually use Mac OS X, except when I visit my mom and use her iMac with version 10.3 on it. Even so, I like to follow its development.

It’s been hard for me to describe, but I think today’s announcement finally made it clear to me. I think the original idea of Mac OS X is wonderful. There is a windowing UI with lots of drag and drop. It has great default settings and appearances. There is pretty much one way to do everything: UI is Aqua, software installation is drag and drop, and so on.

What I mainly don’t like about recent versions of Mac OS X is the “layers”. Apple keeps adding layers and layers to the UI, and it looks like a mess to me. Spotlight adds search to the desktop which should be in the file manager. Dashboard adds a literal extra layer of tiny applications that run on top of your other applications. Time Machine “takes over” your entire desktop with a space theme. That springy thing in the dock is the “answer” to having too many icons down there, and it isn’t even consistent in appearance with itself all the time. Newly announced features include super-fullscreen mode for some applications that breaks the established window model, a new method of cycling through open applications (while leaving the old methods), and a new screen to store and launch applications from. It all looks very nice and flashy and like a load of crap to me. You see this screenshot from the Mac OS X early public beta? It looks fabulous. I wish it still looked like this.

Another thing I greatly dislike is the tendency for applications to do everything. iTunes, the music player, now plays movies, stores mobile applications, and includes a store. iPhoto, the image viewer, connects to Facebook and can send emails. Garageband, the music writing software, now teaches you how to play an instrument.

Lastly, the “transition” from Aqua to brushed metal is terrible in my opinion. The UI doesn’t look nearly as nice and consistent as it used to.

My general feeling after hearing about the updates was for how grateful I am for Haiku. I started using Haiku because it was free and open source software and it was unified like Mac OS X. Now I’m thinking Haiku is a better Mac OS X than Mac OS X.

Mechanical keyboard

I finally saved up enough money and bought a mechanical keyboard. It arrived yesterday.

I decided to buy the Filco Majestouch Tenkeyless with Cherry MX Brown switches, from It appears to be extremely popular for first time mechanical keyboard buyers.

My reasons for choosing this keyboard include:

  • The small form factor fits on my desk better. It allows me to reach and use my mouse more easily. I never use the number pad.
  • It has a very high build quality and will last a long time.
  • Mechanical keyboard users say that almost any mechanical keyboard is better than the cheap membrane keyboards that come with most computers. I decided to get the Cherry MX Brown switches because they are very quiet but still tactile, meaning you feel a slight “bump” as you press the key down.
  • It is relatively inexpensive. I paid $125 USD. That’s more expensive than a $70 Unicomp buckling spring keyboard, but less expensive than a $265 Happy Hacking keyboard.
  • I bought replacement keycaps for the Windows keys from Das Keyboard. Although they are made for the Das Keyboard, they work very well on a Majestouch keyboard. They fit perfectly. The size difference is unnoticable. The replacements are a bit more shiny than the other keys. If you use one of the replacements that have lettering, the font is different.
  • It has full n-key rollover. I’m not sure I would ever really need this feature, but it’s pretty cool nonetheless.
  • I like the key layout. All of the keys are in the right place and are the correct shape. I can’t decide where I prefer the control key, so the bottom left corner is fine for me.

I’ve only had it for one day and have been too busy to use it a lot, so I don’t really feel like I can give it a “review”. But here are my immediate opinions:

  • I really like the size, although it is taking some time to get used to.
  • The build quality does feel great. It’s kind of heavy.
  • The keys are very light and easy to press. I feel as if I can type quicker without having to worry about missing keys.
  • The replacement keycaps for the Windows keys work fine. They don’t look “perfect”, but they work perfectly, were a relatively cheap solution, and were super easy to install.
  • I now understand why mechanical keyboard users describe cheap membrane keyboards as feeling “mushy”. The Cherry MX Brown switches feel sort of “hollow”, as if there’s nothing under the key. Even so, I can easily press every key even if I don’t hit it “straight on”, I feel a nice “bump” as I press it, and it immediately springs back up when I release it.
  • I am happy with my purchase and feel it was worth the money.

Other notes:

  • I am using it with the included PS/2 adapter.
  • I got the (standard) black model.
  • The cord seemed a little short when I unpacked it, but the length is just fine. I think I’m just used to a super long keyboard cord.
  • I don’t think many people would be convinced that a mechanical keyboard is a whole lot better than a cheap membrane keyboard and worth the extra money IF they only try it for a short test. I get the feeling it’s something a person would have to experience for an extended period of time, and then try going back to a cheap keyboard to really feel the difference, and to feel that it’s worth buying. Of course, there will be people that love it from the beginning, and there will be people that never really like it, but that’s the general feeling I get after purchasing and using my first mechanical keyboard.