I’ve been looking for projects to test various methods of work-distrubtion, without being yet-another-Fibonacci-series that has been done to death already, and I stumbled on the idea of finding all the reversible words and palindromes within a given range of lengths (3-7 letters).

It immediately seemed like a fun challenge: the simplest approach would be to load an entire dictionary in from one of the open-source resources someplace, and simply iterate over each word and find those which still make a valid word when reversed.

But just as easily, you could start ignorant of the lexicon and use brute (or genetic) force to find it… Remember, this is an exercise, it’s not really so much about finding the results.

One of my variations used ZeroMQ to distribute tasks across 20 free Amazon EC2 servers: there are both Linux and Windows instances available for free (within limits) if you use “c1.micro”.

Searching for palindromes and reversible words (“Elle”, “tuba” => “abut”) provides a number of sub-tasks which you can compartmentalize in a variety of different ways. For example: combine letters to generate a word, match word against a dictionary, reverse the word and match that against a dictionary.

C++11 is the now ratified and gradually being implemented C++ standard that finally solidifed last year after far far too many years in design. The process by which C++11 was finally settled on leaves me thinking that the people on the committee are far, far too divorced from day-to-day C++ usage and the needs of the average software developer. I’m not talking about what they finally gave us, but how they reached the decision on what would be included, how it would be phrased, and so forth.

Some of the features, especially lambdas, are going to be a real pain in the ass when they begin being commonly deployed, introducing write-once-scratch-head-forever crap into the language, and half-assed fixing solutions with copious obfuscation for lesser issues of the same source problem (virtual ‘override’).

But somehow, someway, somefolks got some good stuff into C++11 that I think I will personally benefit from.

auto

While I may not be happy about the word itself, the “auto” feature is very nice.

One of the big concerns of the C++ standards committee was breaking pre-existing code. As a result, awful choices like naming auto “auto” were made. range-based for is another case of “I’d rather teach people visual basic than explain C++11 range-based for to them”, but in practice it’s really nice:

One thing I’m not clear on, with range-based-for is whether it copes with iterator validity, e.g. what happens (yeah, I know, I could try it, duh) if you do

for ( auto it : myMap )
{
if ( it.first == 0 )
myMap.erase(it) ;
}

extended enum definitions

In the beginning, there were names. And the Stroustrop said, Let there be name spaces, that separate the code from the library. And he named the standard library “std::” and the rest “::”. And it was about bloody time.

Unfortunately, “enum”s slipped thru the cracks. In C and C++ I find to enums be something of a red-headed stepchild, lacking a few really, really important features that programmers always end up resorting to sloppy bad practices to work around.

In C++3 (before C++0x/C++11) there was no way to pre-declare them. If you wanted to declare a function prototype that accepted a LocalizationStringID enumeration, that mean’t including the whole bloody list of LocalizationStringIDs too.

Compounding this issue is the fact that enums are exposed in the scope they are declared in, so they generally pollute namespaces, so being forced to continually include is a real pain in the butt.

It also means you have to remember the special prefix that every enum list uses, because in order to hide stuff, people tend to make their enum names long.

But the compiler couldn’t, otherwise, tell what sort of variable was going to be needed for the enum, and there was no way to specify it. Especially when you’re dealing with networking, this is an abject pain in the ass because it’s a variable who’s type you don’t control in a language without reflection there is no way to find out what it has been given, in a situation where you care a great deal about exactly how the data is stored.

I’ll get to my other enum issues after I touch on what C++11 did do for enums.

C++11 cleans up on enums big time. Firstly with enum class, and here, I think hats off to the committee for coming up with a rather nice syntax although they had to fudge it to avoid what I find a dumb caveat of the C++ class definition :)

An enum class is a class-like namespace, complete with type safety, that contains an enumeration. Borrowing further from the class definition, it allows you to specify a base class which will be the underlying type used for the enumeration. If omitted, though, it’ll use the good old I-dunno-wtf-type-that-is enum type.

enum class LSTRING_ID : short ; // VS11 Beta doesn't support this as of 2012-03-03, though it says it does.

GCC 4.6 supports this, and it reduced game-server compilation time by about 8%. RAR!

We can also use nice names for the LString IDs now without worrying about naming clashes.

I would like to point out that anyone who knows C++ should have spotted that there is no access type specification,

enum class Foo : public unsigned char { public: Fred ... } ;

It makes no sense that the names in an enum class be private. But then it also makes no sense that the stuff in a class be private by default.

Note: There is also “enum struct” … which as far as I understand is exactly the same, it’s just less likely to make you forget to put “public” at the top of your next real class declaration :)

I’m going to write a separate post about my other gripes with enums :)

time

Not many people know this, but computers are utterly shit at keeping track of time. The hardware involved is a joke, and because of various historical bugs in each operating systems’ time keeping routines, it’s really bloody messy and expensive to get time in meaningful terms, never mind portable.

C++11 doesn’t fix that, but it helps by providing functions to deal with a lot of this stuff in the standard library via the <chrono> header. Yay! The template origamists really came out and did their thing, there are some really nice features involved there, including the ability to create timing variables that include their quanta in their compile-time type information so that the compiler can do smart stuff like working out that you’re comparing seconds with minutes and what it needs to do to handle that situation…

Languages

Visual Studio 11 includes support in the box for the following languages: C#, Visual Basic, F#, C++ and JavaScript. The Microsoft implementation of JavaScript in Visual Studio 11 is compliant with the ECMAScript 5th Edition language specification. The C++ support in Visual Studio 11 includes the full C++ 11 standard library as well as new language features: stateless lambdas, SCARY iterators, range-based for loops, and scoped enumerations support. Visual C++ 11 also adds seamless access to Windows Runtime components through C++/CX as well as C++ Accelerated Massive Parallelism (C++ AMP), which enables hardware acceleration for the execution of your data parallel C++ code.