Just another WordPress.com site

Archive for the ‘Programming’ Category

Is this the worst program ever made?

Quite possibly.

Ok, so SpectateSwamp has been annoying me with his trolling on Channel9 – and his ludicrous search app – so when he finally challenged the Windows Desktop Search team to a comparison I had to do it. (Note, I’m nothing at all to do with the WDS team, I though it’d be funny.)

Installation experience:

SpectateSwampSuperCrappySearch (SSSCS):

Actually, this is pretty simple, in the same way that "installing" a text file might be simple. It’s a single EXE so put it somewhere and run it.

WDS:

Fairly standard installation process, nothing good nor bad to say really. It did require being restarted when I moved the index files, but that’s just me.

User experience:

SSSCS:

Three little letters – WTF? No, seriously how the hell does it work. Here’s a screenshot of the horrendous thing in action:

Does anyone know how this works? Anyone???

ANYONE?

Ok, no problem it says HELP, so I’m guessing I can type HELP and get some help.

Right…

Well, you can type HELP and you get something – I don’t know what it is, but it’s something.  

Does anyone know what it is?

Right, so I try a few "commands" out – can’t get it to do anything, I do get it to open a text file. Notepad can do that though.

 

WDS:

Simple case (which I failed dismally to achieve on Spectate Search) let’s find a document, any document. Here’s how it’s done in WDS – you see that little box on the taskbar – type something.

And this is what you get:

The immediate differences from SSSCS should be obvious, firstly you have some results. These results contain the words you were looking for.

I’m not even going to go into the advanced search syntax stuff – I’ll leave that to someone who knows something. The second difference is that this program wasn’t written by a loony on acid. Look, it has useful labels on stuff so you know what it does, and you don’t have to type in P to get to a list of god-knows-what (I think it was a list of stuff I typed in, at least some of it looked familiar.)

Conclusion:

Well, SSSCS gets +1 on the installation over WDS, then it promptly loses about a million points for being utterly unusable and clearly written using squirrels.

WDS on the other hand is quite nice, useful and simple to understand.

Well, that was fun – let’s delete the thing now after having awarded it "worst program I have ever seen including the one I wrote which was supposed to print a message but restarted the PC." At least that program was consistent and could have been used for something. 

When Syntax attacks – 2

I found a neatish solution to the problem I was having before. It relies on overriding the () operator – and hence creating a "function object" – of functor if you’re into ridiculous shortened words.
 
Which essentially turns your pointer to your object into a function pointer – without the need to store the object anywhere.
 
Which is marvellous. (Except you can only have one function per object this way.)
 
If you’re into template metaprogramming you can create a template for a Delegate like a .NET delegate this way. Which solves many problems and is lovely.

When Syntax attacks.

Ok, so I’ve got a bizarre situation in C++, whereby two objects on two different threads want to run methods on each other.
 
My solution is to have a public interface which packages up the details of the function call in a struct and sends a message to the thread asking to invoke the function.
 
So I’ve got a nice struct with a function pointer in and all the arguments in. I wanted to have a vector or a queue or some-such so that I could have a generic container and put the function pointer in first and the arguments in in order – but C++ doesn’t like so many different types in an array so I’ve got a struct for each combination of arguments. Fortunately they’re all void func(void) functions so no worries.
 
However, calling the function at the other end is a marvellous example of syntax gone mad. Here’s the call. The pointer to the Invocation object has to be passed as an LPARAM, as windows messages suck.
 
(this->*((Invocation*)pL)->pFunc)();
 
I ended up almost moving brackets and asterisks around at random to get the correct line. I had assumed it would be:
 
(*(this->((Invocation*)pL)->pFunc))();
 
But that didn’t seem to work. Sigh…
 
And for the curious, can you tell me why this won’t work if it’s ported to windows x64 (it’ll work on Win64 as it is though).
Design a site like this with WordPress.com
Get started