Archive

Posts Tagged ‘c++’

MinGW

January 7th, 2010 No comments

After needing a copy of MinGW to compile some C code, I was somewhat annoyed to find that their all in one installer is now considered “deprecated”. That meant I had to download and extract 15 packages manually (two of them were even compressed as .lzma).

Why anyone would compress a package designed for Windows in .lzma format? The only way to extract it is with a command line sdk tool. Even on Linux, distributing archives in .lzma format is a little strange.

Anyhow, to save everyone the trouble, here’s a package (includes C, C++ and all necessary tools) in .7z format (which can be extracted by 7-Zip, the best file archiver for Windows) -> MinGW Compiler Package (202).

Categories: Uncategorized Tags: , ,

C++ Good, bad or worse?

October 23rd, 2009 No comments

I’ve used many different programming languages, each with their own set of benefits and flaws. C++ was the first one I learned, and every class that I’ve taken has used it (with the exception of two language classes).

Before we discuss the pros and cons of  C++, here’s a factoid: C++ is based on C, which was written in 1972 (approximately 37 years ago) at Bell Labs for use with the UNIX operating system.
Read more…

Categories: Uncategorized Tags: , ,

Amusing mistakes in C++

October 9th, 2009 No comments

I was writing some complicated inherited classes in C++, and made a few amusing mistakes, which resulted in some strange errors.

Firstly, the concept of method hiding is when you declare a method with the same name of a method that exists in a parent class. This doesn’t override the method (unless it was marked as virtual), but any calls to that method will go to the method defined in the child class. This can lead to really strange results if you were expecting a method override, but forgot to put virtual in the parent class, as I did.

class Parent
{
   public:
        void foo();
};

class Child
{
    public:
        void foo();
};

Now mistakes like this are obvious in small classes, but in large classes, while on six hours sleep, they can be harder to pinpoint.

The other mistake was when I didn’t realize I already had a protected method, we’ll call it bar, declared in the parent class. I then defined a private method called bar in the child class, in which I was trying to call the parent class. Guess what? Infinite recursion.

Lesson of the day? Don’t code while tired. It doesn’t work very well.

Categories: Uncategorized Tags:

Grid computing with Linux, Game engines

September 6th, 2009 No comments

If you have several old PCs lying around, you could turn them into a grid, a single computer that uses all their resources together.

I haven’t found a good use for a grid personally, but I found a nice piece software to setup a SSI (Single System Image, basically means one OS running on multiple machines) grid, and a nice tutorial.

If I had a grid running MySQL, the 35 million row DB table I use would probably search pretty fast.

In other news, Panda3D (a game engine, usable from C++ or Python) looks like it has excellent documentation, something that a lot of engines are lacking. I’m also wondering if I should buy a Mac now that Snow Leopard is out (that’s when I said I’d buy one)… I wonder if I’d really use the Mac applications…

OOP in different languages

August 26th, 2009 No comments

OOP is different in each programming language. Some languages like Python and C# don’t offer all the OOP features that you can get from C++.

Python doesn’t really support traditional access modifiers, and C# doesn’t offer true multiple inheritance (you can inherit from one class and multiple interfaces).

While C++ offers the most OOP features of the three languages, it has some disadvantages. If you compare C++ to modern languages like Python, Ruby or C#, C++ starts to show it’s age. Further more, given a small application, it’s usually much faster to write it in Python than in any C language.

The question ultimately becomes, are all the OOP features in C++ really needed in every day development? For small projects, most likely, no. For large projects with a team of developers, maybe.

Categories: Uncategorized Tags: ,