- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
That would be useful if you only like long puppies, like daschunds.
Admin
That's the only way I can think of to give people FOND memories of casting.
Admin
Admin
Admin
If by chance the function actually made the page smaller without screwing up the page contents, then surely he's helped out those people downloading it over a 300 baud modem! I mean that bit of code could easily save several seconds per page, even after acounting for how long the function takes to run...
Admin
Same with our Project Architect. Oh wait, I AM the project architect. What a swell guy!
Admin
This won't compile in C#...
Error The best overloaded method match for 'cast<long>(long)' has some invalid arguments
Admin
So, it's the same thing as
just like in C, C++, and Java. I agree -- a worthless construct. If the compiler can manage to inline and optimize everything (which it should be able to do, in theory), then all's good in performance land. The only WTF, then, is the questionable syntax advantage.
Admin
So for everyone slamming the regex - which takes longer to process: the regex that removes whitespace, or the gzip compression that the webserver will do on the whitespace if the webserver is configured properly? That's an honest question. I'd think it would be best to do whitespace-removal (and other size optimizations, a la Google's toolkit) as a one-time operation (a "build" of the developer-friendly HTML/Javascript/etc. into the bandwidth-friendly pre-compressed version) instead of every time a page loads, but it's going to happen somewhere along the way unless the webserver has been deliberately configured not to gzip HTML content, which is usually a huge performance hit for users.
Admin
No. But this will:
What's wrong? CTRL+C, CTRL+V broken ?
Admin
Uh... No. Do you actually write code? That won't compile, the code in the article will.
Admin
wouldn't the server send the html twice, as the writer isnt cleared?
Admin
Who?
Admin
My code is valid C and C++. Maybe not C#, and Java might have problems with it (I'll check that next). I even ran it through gcc just to make sure.
But even if it weren't valid, it still makes the point about the intent of the code.
Admin
Yep, that's perfectly legal to do. Gotta love people that just assume they know more than you, huh? Do you actually write code, frits?
Admin
Admin
Yep.
Admin
Doesn't work in Java, does work in C/C++.
Admin
Oh, give some benefit of the doubt -- frits probably just missed that I was talking about C/C++, rather than the C# from the original example.
Admin
Since you mentioned four languages in one post, is it any wonder I couldn't follow? Not to mention you were dead wrong about the only language used in the article.
Admin
He still didn't need the "do you actually write code" comment. It's one thing to be condescending, it's another to be condescending when you don't know what you're talking about.
It reminds me of management.
Admin
Yes. Four is a pretty big number, but I think you miscounted.
The only one he was wrong about is Java, no mention of C#.
Admin
There has to be a category of bad code just for the Gedanken Optimizer. "I just KNOW it will run faster!"
Clients and I, we live in real world; please do performance testing sir...
Admin
TRWTF is that Alex doesn't realize <int> needs to have the angle-brackets escaped if it appears in regular HTML.
Admin
Oh, come on. Let's be mature about this. From the very start I have said that I don't know C#. I have never written one line of code in C#, and probably won't in the foreseeable future.
I also clearly marked that line as being an equivalent C/C++/Java construct (although I admit I was wrong about Java) -- there should have been no confusion.
Lastly, four items is not that hard to keep track of. I use up to SEVEN different programming languages every day: C, C++, Java, Perl, Bash, Csh, and an in-house language. I probably even missed one or two. Don't come to me whining about a measly four languages, especially when I was as clean as I was.
To be fair, the parts of the paragraph about optimization can be interpreted as referring to C#, even if not explicitly mentioned by name.
Admin
Admin
Dumb questions. But relevant.
Admin
Admin
Admin
The compression is pretty small in terms of the cpu time you take vs. the bandwidth savings you get and the fact it'll still get to the person faster.
In regards to minifying the HTML/JS/CSS, the algorithms used to minify them are actually a bit intense as it does a bit more than just a quick run through to remove spacing. It looks at variable names, methods and more.
Between a good caching setup for images, css and javascript and enabling gzip, you're cutting the actual total response size alot. I'd be surprised if minifying html on the fly would result in much more savings vs. cpu time.
Speaking of gzip, why isn't thedailywtf.com using it?
Admin
What!? This wouldn't be The Daily WTF then, would it!
BTW, that caching example is the best "maybe I needing later" I have ever seen!
Admin
It's actually C-Octothorpe!
Admin
Wouldn't that be Götterdämmernum?
captcha: secundum - doing the above twice?
Admin
So you're complaining because he's using a monad for rendering? Not the best architectural choice given the platform, but... so what? This is transparent code.
Admin
I've always pronounced # as the "rap" sign, as in "C#".
Admin
Admin
Admin
While I would generally agree with you, if you've ever had to dig down into the guts of C# and/or read any interview with the designer of C#, you'd know this statement isn't entirely accurate The designer of C# basically only made the language because of some sort of vendetta against C/C++. I guess C++ must have murdered his family or something :)
At least that's the impression I get when reading people's interviews with him :)
I'm only joking... sort of...
That said, I'm not defending today's WTF, just strongly implying that the designer of C# is crazy :)
Admin
You clearly don't have a good understanding of C++ style casts then. They can do everything a C style cast can, and only require that you understand the appropriate cast for the job. As not to accidentally change the nature of the data you are manipulating.
Admin
I don't know why you Americans pronounce it Pound. This is a pound sign £, and this is a hash sign # otherwise own as sharp (as in musical notation). At least anytime I phone an automated phone line I'm always asked to push the 'hash' sign after keying in some number.
Admin
Wrong. Sort of.
You cannot reinterpret_cast<float>(int). You need to do the ugly-fugly ((float)(&int)) instead. Well, I suppose you could do reinterpret_cast<float>(&int) , but that is just as ugly.
Ah, the joys of floating point formats not supported by the processor or the compiler...
Admin
Admin
In C++ (type)var is known as a C-Style cast and anyone who's read More Effective C++ knows that static_cast<> is the preferred method in C++. More obvious it's a cast and looks more like the other C++ style casts (const_cast<>, reinterpret_cast<> etc...)
I'm not sure how it works in C# - I've not used it much (in fact I didn't even know it supported templates...)
Admin
Captcha: tego, like lego, but concealed.
Admin
No, but it sure as heck offers "C style" casts. RTFC.
Captcha: jumentum - you're on a roll!
Admin
I LOVE dachshund puppies.
[image]Admin
I was about to make the same point!! (and quite appropriately, the captcha is 'secundum')
Admin
#define CAST int x = (CAST int)2.1;
define CAST as nothing, and you're free to stick it next to any casts without having any effect at all on the compiled code, while making said casts easy to locate.
Or if not using C, of course, use the methods provided by your language.
Admin
Must be the atmosphere here, but when you wrote 'no memory' I assumed for a second that you're talking about embedded systems... ;-)
Admin