Evolve a Solution

Implementing a genetic algorithm has been on my coding bucket list for quite a while now, but I hadn’t the time and motivation to actually get started, until recently. Genetic algorithm is an iterative approach to finding an optimal solution to a problem by emulating natural selection processes (sorta). In my case, I implemented a simple one to “optimally” schedule tasks between two hypothetical machines.

Continue reading “Evolve a Solution”

Smart Pointers

Smart pointers have been around for quite awhile, but it is a concept I am only beginning to appreciate (wish I have learned about it earlier). Pointers are inescapable, especially when you want to utilise the full extent of the object-orientedness of C++; and when performance is key. However, using them opens up a Pandora’s box of memory management issues.

Continue reading “Smart Pointers”

Plug It In

Plug ins. Many applications nowadays support the use of plug ins. It is one way for the users of an application to customise and extend its functionalities without the need to access the underlying source code of the application. Take, for example, the Eclipse IDE which is best known for its great extent of componentization – almost everything in the IDE is a plugin. As someone who loves to bodge up random things, I’m always interested to find out how an application is made to support plug ins.

Continue reading “Plug It In”

What They Don’t Teach In C++ Classes

So I was happily coding away for my final year project, until I ran into an unexpected “Access Violation” bug. That got me scratching my head. I checked everywhere, looking for use-after-free pointers or buffer overflows, but I just couldn’t find one. I know I am very meticulous in making sure that I do not reuse freed pointers so this took me awhile to tackle. It is a subtle issue that arises from the C++ type-casting and I hope this one serves as a good reminder to learn the different type-casting available in the language.

Continue reading “What They Don’t Teach In C++ Classes”

SimpleVM has a multi-threaded display

What’s a machine if it can’t output anything useful. Building on that virtual machine I made a couple of weeks back, I put in support for virtual IO devices. By the way, everything is “virtual” here cause nothing’s physical. I hope that is how the terminology works.

Continue reading “SimpleVM has a multi-threaded display”

A Simple Virtual Machine

Haven’t been doing much around here lately… until now. So recently I have botched up something that I have been dying to make for a long time now – my own virtual machine. A disclaimer: it’s not going to be like of those sandbox machines that can hold an OS, or anything like the Java Virtual Machine (okay, slightly similar). Even so, I believe it’s working pretty well.

Continue reading “A Simple Virtual Machine”

Want a better window frame?

If you’ve toyed with Visual Studio, you’ll mostly have come across the term “Windows Forms Applications”, which is just some fancy words to describe a .NET wrapper over the underlying ‘windowing’ system use in… well… Microsoft Windows. To you and me, a window is just something that pops up when you double click an executable. Visual Studio has in it very good tools to aid in designing a windows app very quickly, but sometimes, the default look and feel of a window is not pleasing enough.

Continue reading “Want a better window frame?”

Alignment Matters

Us humans have been counting in the decimal system for a very long time already. It makes sense cause we have ten digits on our hands. To a computer, the decimal system is counter-intuitive. It’s ‘hands’ are basically switches, and a switch can only be either ‘on’ or ‘off’. So it makes more sense for it to count in binary. This has repercussions in the way data is arranged in a computer’s memory.

Continue reading “Alignment Matters”

Bridging the Divide – Part 2

Garbage collectors, be it a human or a machine, deserve some love as without them, we will be living in our own pile of rubbish. Even when developing applications, humans still leave their trail of trash along the memory lane (ain’t being figurative here). We aren’t perfect creatures, and sometimes people forget to release the block of memory that they previous requested. However, we cannot rely on the garbage collectors all the time to clean up after our own mess.

Continue reading “Bridging the Divide – Part 2”

Bridging the Divide – Part 1

It’s about 6 weeks into my internship now, and my goodness, the rate of learning is so much higher than one whole semester worth of lectures. So recently, I forced myself to pick up C++/CLI. It’s basically your usual C++, … but with the .NET toppings. Mmm mm, if that doesn’t sound delicious… I dunno what will. Think about it: you get the performance boost from native code, and the memory management from … the managed code. Of course, wielding such a powerful tool is not easy, as I found out the hard way.

Continue reading “Bridging the Divide – Part 1”