Flux RSS

Code Rant

Where we rant about programming failures.

Entries feed - Comments feed

Sunday, January 20 2013

C++ Streams suck

This one is a short one (and actually, more an excuse to test highlight.js), but C++ Streams really, really suck. You can say whatever you want, they are the spawn of the devil. Case in point:
#include <iostream>
#include <iomanip>

void hexDump(
    const unsigned char * data,
    size_t size,
    std::ostream & str)
    size_t addr = 0;
    str << std::hex
        << std::setfill('0')
        << std::nouppercase
        << std::noshowbase;
    while (addr < size) {
        str << std::setw(8)
            << addr
            << ":   ";
        for (int i = 0; i < 16 && addr < size; i++) {
            str << std::setw(2)
                << static_cast<unsigned int>(data[addr++])
                << " ";
        str << std::endl;
    str << std::resetiosflags;

Sunday, September 2 2012

20 years later...

A bit more than 20 years ago was when I started programming. I was a kid back then, about 12 years old. My first computer was a 286 running at 12Mhz with 640KB of memory, 40MB of harddrive, and MS-Dos 3.30. I was programming in GWBasic, mostly. My very first big program was a small game. I decided to re-write the game today. Here is the result: Daedalus. There is very minimal explanation, let's see how you guys will fare.

Follow me after the break for some discussion about it, and the state of programming in general.

Continue reading...

Saturday, April 14 2012

Redeeming C++ (or not)

A few days ago, I was talking with Yazoo about Lua, and I realized it'd be cool to statically hash strings in order to export hashes of function names to Lua, and not plain names. Then we discussed about the feasibility to of this, and how there was already a few articles on the web talking about this, but I realized that with C++11, it should be possible to do something easier than most solutions presented, and I wanted to do some researches anyway.

So I set up into trying to achieve the goal of hashing strings at compilation time in C++, using C++11. I have to say I'm unimpressed by the results. That's going to be a pretty long read, but I've tried to describe all the steps I've taken in order to show exactly what I mean.

Continue reading...

Friday, March 2 2012

Why C is a good language - or why you're wrong thinking C++ is better

I've recently had a discussion with some friends over at Google+ which finally made me understand why there's so many people out there who don't understand why C is superior to C++, even though there's so many people who say so. So let me share this epiphany with you.

The reason why some programmers think C++ is superior to C is because they're bad programmers. Alright, let me rephrase this so you don't immediately start flaming me. The reason why some programmers think C++ is superior to C is because they (most of the time) don't have the same mindset. And if they do have the same mindset as pro-C people, then they are not aware that there's people out there who don't. But allow me to develop.

Continue reading...

Thursday, March 3 2011

Why "open source" is good

Not so long ago, I made a post explaining Why open source is bad. I'll try to redeem a bit myself and try to explain why there are some very good aspects of it, and why closed source is sometime excessively bad. As I mentioned in my previous post, I don't think open source should be used as a selling point in the "it's open source so it has to be good" way. Instead, it should be used as a selling point in the "we're transparent" way.

Continue reading...

- page 1 of 4