Erik McClure
ID picture
Age/Gender: 19, Male
Location: Washington, USA
Position: Lead Programmer
Lead Composer
Web Developer
Projects: Axion

The world depends on unreasonable people, for they are the only ones crazy enough to change it.
July 13, 2009 [16:50:30 PDT] Stupid Features A dictionary of stupid things in programming languages Episode 1: Predicates [C#]
One would think that figuring out whether or not type T exists in an array of type T would be a fairly straightforward thing to do. But wait, C# manages to make it completely fucking ridiculous!. If you want to see if something exists in an array, you need a predicate function - something that returns true or false to help the poor, stupid function know if its hit the right value. But then, if you wanted check if a specific string value exists, that would mean you'd have to make a function specifically for that string!. Obviously if your iterating through a bunch of them, creating a function for every single goddamn string is completely ridiculous. It turns out that there is a way to do this:

Array.Exists<string>(allfiles, s => s.ToLower().Contains(allrecentfiles[i]));


The weird '=>' in that turns out to be a lambda expression, which means this is basically shorthand for doing the exact same thing that I was trying to avoid - It's generating a function for each and every single string that you have to compare. What the fuck?!

This is why I hate the .net framework. 700 megabytes of code, and I can't even search a fucking array for a string without using lambda expressions In the amount of time it took me to go on google and find the answer, I could have coded my own in C++ from scratch. That's completely fucking ridiculous.
Blog Entries
July 13, 2009
July 09, 2009
July 09, 2009