Archive for the ‘Programming’ Category.

Why I started using Haiku

I have dual boot setup on my computer with Arch Linux and Haiku. Arch Linux is my primary operating system, but when I want to relax or have a little more fun I boot into Haiku.

I started using Haiku about six months ago, and for a pretty simple reason. It’s an entire operating system made by one group of people.

GNU/Linux is made of different pieces of software written by different people from different places at different times. It’s a collection of multiple options for kernels, window managers, desktop environments, libraries, sound systems, boot managers, and on and on.

GNU/Linux works, and works very well in my opinion, but I was looking for something different, something with more of a complete design in mind. I wanted something that had the consistency of Mac OS X with the freedom of a free and open source license. FreeBSD meets that criteria if I exclude a graphical user interface.

I looked into alternative operating systems and Haiku fit my criteria well. It’s a complete and unified operating system from boot to GUI, including an API for everything I need. It has very active development, and a nice, yet small, set of applications to use, including a native WebKit web browser.

Haiku is a remake of BeOS. I have never used BeOS before, but found out I really like using my computer the “BeOS way”. Compared to other operating systems and user interfaces, I prefer to use Haiku. I like the consistency between applications. I like the responsiveness of the user interface. I like the clean look and nice default settings. I like the simplicity of installing and uninstalling applications. I find that the user interface better fits my work flow.

I’m excited about Haiku having a stable release some day, whenever that is. I’m also excited about writing some applications for it, but I can’t really think of what to make. I’ll probably start by just converting my video game to native Haiku code.

Objective-C in Linux

I am a big fan of the Objective-C programming language. Since I love it so much, it makes me frustrated to see people spread misinformation about it that isn’t true.

First of all, what is Objective-C? It is a programming language that allows a programmer to use objects in C.

How does it compare to C++? C++ and Objective-C were both created to allow for easier object oriented design. Even so, they are very different: C++ is a new language based on C, and is mostly compatible with C. Objective-C is C, but with objects.

Let me restate that. A program written in C might compile and run fine with a C++ compiler. With an Objective-C compiler, a C program will compile. It’s guaranteed, otherwise it’s not an Objective-C compiler.

So, what libraries are available for Objective-C? GTK+, Allegro, OpenGL, SDL, glibc, the Linux API… Any library written in C is by default an Objective-C library, and there are a lot of libraries written in C. A programming language may be considered as good as the libraries available for it, and as you can see, it would be silly for anyone to suggest that there are no libraries for Objective-C.

What about GNUstep? GNUstep is a toolkit, including GUI widgets, written in Objective-C. I haven’t used it.

Is Objective-C tied to Apple? Objective-C is a well defined language that is well supported by GCC. Realistically, Objective-C doesn’t seem to be used much nowadays except for Mac OS X and iOS applications. I have never written an application for an Apple product. Also, I don’t have any comments about Objective-C 2.0 or Objective-C++, because I haven’t used them.

Is Objective-C slow? It might be slower that C and C++, but not to the point where I think it matters, nor do I think anyone would be able to tell the difference. In my opinion, the ease of use more than make up for any loss in speed there might be.

Isn’t the syntax for calling a method in Objective-C is obnoxious? Nope. It’s just different, and certainly has its own benefits and drawbacks.

C++:
window->addButton(okButton, 50, 75);

Objective-C:
[window addButton:okButton x:50 y:75];

Why would someone choose to use Objective-C? Objective-C can be compiled for all major operating systems. (for example, anything that supports GCC) It is a compiled language that produces executable files, just like C. It can natively use all C libraries. It is as “simple” as C, but with objects.

Software design lessons

I’ve decided to convert the video game I am making to C.

My hobby is making video games. I’d like to point out that my hobby is not finishing making video games, just making them.

I’ve had a lot of fun working on my current game and game engine. It’s in Objective-C and uses the Allegro Game Library. It was my second project in Objective-C. I decided I really like the language.

A few months ago I finished my first graduate course in Software Engineering. The main theme of the course was “favor aggregation over inheritance, and code to an interface”. It caused me to rethink the design of my code. I decided my design was not very good. It was object oriented, but not the best type of object oriented. I struggled with deciding how to redesign it and the option of converting it to another language. It was during that struggle that I learned an important lesson:

A programming language or programming paradigm will not help a bad design.

I stopped thinking about “making it object oriented” and converting it to different languages, and instead just thought about design. I used the application Dia to write out my ideas. It has helped a lot. And since which language to use it not so important, I decided to use the language I love the most: C.

I’m going back to my original plan from years ago, which was to make a 2D video game in C. And I decided not just any C, but ANSI C. Why? To make it more challenging / fun, and to see if I can do it. As I work on it I’m quickly reminded just how much I like C. It feels like such a pure and simple language.

Even so, I’m also excited for my next project: to make something in Python!