January 2012
1 post
2 tags
Kindle Fire experience by iPad owner
I have had a Kindle Fire now for a few days. I am an Apple guy and an iPad owner but that doesn’t stop me from liking this little device. Lets first start of with some of the things I like about it. Size. It is so easy to hold in the hand and carry around. Typing on it is in many ways easier than iPad if you don’t have it on your lap. You can type with two thumbs which isn’t...
Jan 9th
September 2011
2 posts
Finding a string in a string list O(N) or O(N^2) ?
This ought to be simple right?  My very first thought is that we are potentially looking at every string to find the right one. So it is O(N). But wait. For each string we loop through each character of that string. We got two loops. So maybe it is O(N^2) ? But lets think about this more carefully. Each loop is looping over different kinds of data. The outer loop are strings while the inner...
Sep 16th
The old struggle: native vs cross platform
Today there is a lot of talk about iPhone and Android apps. They were not supposed to have happened because the future belonged to the web. It happened anyway. At a Java conference today I talked to some software managers at different consulting companies. They all seemed convinced that the app was a fad and HTML5 would take over. I think they are going to be wrong again. It is understandable why...
Sep 7th
August 2011
2 posts
Managing coupling in a data oriented way
When your code is tightly coupled it is hard to change one part of the code without affecting other parts. When your modules are loosely coupled they can be modified or removed independently with ease.  I just came across a blog run by the guys behind BitSquid, a new high end game engine. They have some great entries about numerous things related to game development. But today I thought I’d...
Aug 17th
4 tags
Wrapping Lua/C++
Hey I was looking at your wrapping c++ classes in lua article, I must say its been the biggest help in understanding some of the details to me. The first part I got working no problem, the second part gets me a little stuck. Basically the extra argument isn’t getting passed (I think) Calling Sprite.new(..) only seems to pass the 4 arguments and not the table, what have I missed. Thanks, ...
Aug 17th
5 notes
July 2011
1 post
devbug asked: Hey,

I was using "Wrapping C++ classes in Lua" article, as a guide to expose my C++ classes to Lua but I've encountered an error. I can't seem to get Lua -> C++ calls working. Checking the self argument isn't working; the check function failed. It expects the 'global' metatable (as in the registration of the class) but, gets a table. I know you...
Jul 12th
2 notes
February 2011
1 post
Some thoughts on Clojure vs Go
Neither Go nor Clojure are object oriented in the sense that they provide implementation inheritance. With Go you can create what it essentially classes without inheritance. Created with keyword “struct” in Go. These “classes” can used wherever an interface is required if a subset of the classes methods match all the methods defined in the interface. In similar fashion...
Feb 10th
2 notes
November 2010
1 post
4 tags
When pointers are better than iterators
The STL is a very well designed library, and iterators is a powerful concept. Unfortunately you can not fully utilize the power of iterators unless you write generic code: template<typename Iterator> myfunc(Iterator begin, Iterator end) { // Do stuff } Now the function does not depend on the type of the iterator being used in the call. However C++, being a multi-paradigm language means...
Nov 10th
4 notes
July 2010
2 posts
5 tags
Nu, Clojure and the future of Mac Development
Clojure is a lisp like language built on top of the Java virtual machine. It lets you interact with and use existing Java libraries. Nu is a lisp like language built on top of the Objective-C runtime, which gives easy interaction with the Cocoa libraries. On the surface it then seem very similar. However they are radically different. Mostly because their goal and reason for existance is radically...
Jul 22nd
2 tags
How a C program naturally scales better than a C++...
I am currently in the process of rewriting a simple 2D game engine from C++ to C. Having always been a C++ programmer I am used to think in terms of classes. So I have done this in C as well. So here is an excerpt from how I originally wrote my header file for dealing with 2D vectors. typedef struct _Vec { real x, y; } Vec; //- Constructors Vec vec(real x, real y); //- Calculations Vec ...
Jul 10th
2 notes
April 2010
2 posts
What iPad means for the future of PC's
Some say that iPad spells the end of the personal computer while others say that it could never replace it because it lacks too much. I am willing to say that both are right. Regular desktop OS’s like OS X and Windows 7 will be around for years to come. However I am convinced that over the years they will become increasingly marginalized. Main main reason for believing this is looking at...
Apr 5th
2 notes
4 tags
Why iPad will succeed when Tablet PC's didn't
There has been a lot of musing about why Tablet PC’s failed and why it might be different for iPad. A lot of the comments are in my opinion almost metaphysical or full of vapor. We get suggestions like the Apple advertisement machine or Steve Jobs reality distortion field etc will make it all different now. I think iPad will succeed where Tablet PC failed and the reasons for the success...
Apr 5th
March 2010
1 post
Weakness of STL over plain C types
One of the joys of working with Google’s Go programming language is that it is kind of like writing C/C++ but without the extreme verbosity of C++. For various reasons I have used pure C lately, and just as with Go I get struck by how much less verbose your code ends up being. Okay to be fair, C is fairly primitive. A lot of stuff requires you to pretty much give up type safety completely. ...
Mar 19th
2 notes
February 2010
4 posts
6 tags
Performance of STL vector vs plain C arrays
Inserting and retrieving elements in an STL vector is just as fast as doing it in a regular plain C array. This of course requires that you have turn on optimization. However a STL vector has a number of attributes which potentially makes it slower than a C array: A vector does not store its data in a continuous chunk of memory. Pointers to the start and end of the vector will be stored in a...
Feb 25th
3 notes
8 tags
Cache misses with Valgrind and KCachegrind
KCachegrind is a KDE program that reads profiling files produced by profiling tools. One of the tools it can read the results from is called Valgrind which lets you run your code in a simulator. The benefit of this is that you don’t have to modify your executable to profile it. To create profiling information for KCachegrind to use we run Valgrind like this: valgrind --tool=cachegrind...
Feb 24th
4 notes
How cache and memory layout affects performance
This will be my first post in a series exploring how the memory layout of your data affects performance. Why should you care to understand this? Because of the ever widening gap between CPU performance and memory speed how you should code and design your programs changes radically. Well my background for getting into this is actuall from a software engineering point of view. With the article...
Feb 24th
6 tags
Gray Hat Python
About a week ago I came across a book called Gray Hat Python. It is one of the more interesting programming books I have read in a while. It is fundamentally about reverse engineering and how software is cracked or exploited. But in explaining this the book takes you step by step through building your own windows debugger in python. To make that clear because it seems like everybody I talk to...
Feb 23rd
1 note