- 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
These calculator articles are really boring :P
(fist)
Admin
Very boring indeed. (seocnd)
Admin
I still think PolyCalc was a much clever (and WTF) implementation than my other entries... but I still don't know if someone actually understood how it works, so maybe that's the reason it isn't mentioned here ;-)
Admin
bored bored bored bored bored.
did I mention I was bored?
Admin
Oooh, ASCII-based logic gates, enthralling.
Admin
...so instead of this masterpiece, the half-finished transistor netlist emulator gets into the finalists? Yeesh!
Admin
Sad to see mine didn't make it to any of the highlights even. If not for the implementation of nested functions in C++, at least the art should be worth it.
[image]Admin
this is generally hilarious. i love that OMGWTF thing :D
Admin
Can't believe goplatcalc is not among the finalists. Did it fail some test cases?
Admin
Ummm, it works by using state objects (based on the last operator used) and using placement-new on this to change states (i.e. "new(this) Sum()"). A less-WTF way to do this is to have a state variable which is a pointer to the operator function or a pointer to an object with a virtual method for the operator.
The comments give away the whole thing really.
A nice WTF touch is the ChooseOperation method in the base class Operator, which contains a switch statement that must list every class that ever derives from Operator.
The ChooseOperation method calls the destructor on this before calling placement new on this, which is of course totally unnecessary for classes where the destructor code is "return;" and there are no data members.
Am I the only one who understands C++ vptr table abuse, or did I completely miss something? ;-)
Admin
omfg these are brilliant.
To all of you saying these articles are boring: Pah!
Admin
OK, maybe I've led a sheltered life but I've never seen Unicode art before, only ASCII...
Admin
Is anyone else completly horrified by the idea that some Brillant "programmer" is going to see some snippets of any of this code and think "That's the way I should be doing it."?
Captcha: tastey. He must've just eaten at the Colonel's.
Admin
Ummm, maybe it's because we can't tell if that's a fish with a beak or a bird with fins atop the body of your superhero.
Captcha: doom. Yes, yes it was.
Admin
That one was originally Shift-JIS art, straight from 2ch.
Show me. Show you. Kikkoman!
Admin
These comments that say these articles are non-boring are boring.
Admin
don't any of these sumbitters have a job?
Admin
Admin
Java has toString() and trim(), but it makes everything else too complicated. Give me C++ any day!
Admin
Just so that no one misses out on the Paula Bean stuff: http://worsethanfailure.com/Articles/The_Brillant_Paula_Bean.aspx
Admin
goplatcalc is... beautiful.
Admin
Of course, those would be the non-WTF ways of using state objects. But the idea of an object which self-destroys and then replaces itself with a new one totaly struck me, when I first saw it in a C++ newsgroup. The Real WTF(TM) is that the ide appeared in a post where a programmer (well, sort of...) was asking if that could have been a good way to implement state objects; the "WTF!" reaction was unanimous.
Of course, but a proper implementation (if there's anything that's actually "proper" in this techinque) would have data members and so would really need this, along with copy constructors and something else.
No, you got it right. People on that newsgroup also argued something should have been declared as "volatile", because the compiler could optimize the vtable, assuming it never changes during an object's lifetime... I don't know is this can be an issue with different compilers, but VC++ just doesn't seem to do that.
Admin
I know! Holy cow! That would easily be in contention for one of my top couple.
Admin
Admin
Java makes things complicated? Seriously, you can blame it for just about any generic language flaw, like half-arsed OOP, bloated APIs, slowness and memory hogging.
But the language is probably the simplest generic mainstream language in existence; automatic garbage collection, single inheritance, huge standard library (aka batteries included) and incredibly little syntax to learn.
C++ is much more complicated with it's arcane module system (if you can call it that), manual memory management, template metaprogramming, multiple inheritance and what not.
Admin
And then I saw the goplatcalc. My lord ... I want to have its children. This is so impossibly beautiful and stupid at the same time.
Definitely time for democracy to prevail over the menshevik/kropotkinist clique running this contest.
Admin
Passing swiftly by the ignorant misuse of the apostrophe, we come almost instantly to a straw-man argument. C++ does not have a "module system." Damn it, it barely even has a concept of "linkage." By design. And for good reason, originally.
Proceeding on through the treacle of presumably second-hand prejudice, we come to "manual memory management." (I liked that Calc, too.) C++ has a style. It's called RAII. It works with constructors and destructors, and is quite powerful when used correctly. Java, Python, Ruby etc prefer garbage collection, which is fine in its own way, but you have to make a trade-off between molly-coddling and determinism. I'm not arguing either way. I'm just saying it's a trade-off.
Template meta-programming? I'd be tempted to say that at least C++ has offered this possibility for ten years, which is more than Java could have said before generics arrived in 1.5. But I won't. Have you ever met anyone who does template meta-programming? I haven't.
Multiple inheritance? Is this the worst you can throw at C++? It's probably a mistake, and on the whole I'd rather have Java's "implements" interface, or aggregation, but you have to remember that C++ had inheritance long before it had a usable template system. I've only ever used multiple inheritance under protest over the last ten years. I can count the instances on the fingers of one hand, and it only took me a fifty-foot petri dish to grow the extra twenty three thousand fingers for counting ...
Seriously. Java's fine for some things. I would say, less than you might think, but that's just personal preference and not prejudice. C++ works as well. Try not to throw pointy little rocks at a target that doesn't exist.
Admin
Jake asked for it, so...
It was bad enough when student's class code ended up here. And then we were asked to MAKE UP WTF code!!! How STUPID can you get. Talking about WORSE THAN FAILURE.
The thing that was brillant about thedailywtf was we got to see got that was IN PRODUCTION. Someone somewhere paid someone (or maybe they didn't if the person focked up bad enough) to write some code, that I'm sure the writer thought was brillant, that clients are using. Or were using before our hero swooped in and saved the day.
Its not as funny when you intentionally make it that way.
While I think some interesting programs were written for the contest, it seems to me the winner of the contest will actually be a cool program, and not WTF code (as my impression of what the contest was about)
Its just not the same when its staged. If you guys are running out of material, then tell us. I'm sure we can find some good REAL WTF material for you.
Admin
If you think they need better material then start submitting WTFs instead of making stupid comments here. Yeesh.
Admin
Nobody noticed the add routine in entry 100197? It's not obfuscated - just really unusual.
Oh well, it's probably because 100190 seems to have had the same entry name. Just my luck.
Admin
goplatcalc FTW! That scares me. Scares me so much I want to run away and cry.
But I can't help but love it.
Admin
YAY! Honovrable mention. :D
Admin
The real WTFs are obviously a) "All Rights Reserved under the GPL", which strikes me as a "Someone said I should use GPL for this so I did! (without actually reading the license text and understanding what it means)" kind of licensing deal and b) I get Google ads for G-strings, which has probably (an educated guess) happened quite a few times in the history of this site, so I guess it doesn't count.
Admin
I call BS. It's used, with good results, in Qt 4 (www.troll.no), and actually makes life easier in a couple selected spots in the toolkit. Qt has become reasonably significant business AFAIK, and it really gives C++ some beating.
I wouldn't call it "probably a mistake". Don't like it, don't use it, it's not like MI is forced upon us.
Cheers, Kuba
Admin
Still angry with the site name change, man.
Admin
Wow. goplatcalc is supremely cool and would definitely have my vote if it were a finalist.
Even the idea of doing that is simultaneously awesome and terrifying.
I guess the next step is writing a compiler to compile code for the ASCII CPU...
Admin
Unbelievable, this time non of the highlights are boring :)
Admin
I'd agree with you on two of the three:
GUIs were already appearing when C++ was developed, and the language definitely should have included a standard windowing library. The lack of this has spawned a whole clusterfuck of different APIs and wrappers, making GUI development a tower of Babel. [the reason I did not even consider entering the contest].
C++ was actually a great language before the STL and anal-retentive namespace designation became integrated with the ANSI '97 standard. It was very flexible, the facilities for templates in general added to that flexibility, and it also allowed for clear, uncluttered code that focused on the job to be accomplished. With the STL, it became a low-level nightmare, requiring the constant feeding of the type-specification beast, and making the code look like line noise. What a fucking shame!
Low-level memory access really isn't a big problem in my view. As long as one avoids too-clever hacks such as casting between pointer and integral types, pointers can be incredibly useful, and make for very effective programming. Along with strong data types, pointers make for the most precise control of data in the context of high-level language.
Admin
Please tell me you eschewed Unicode for one of the Japanese-specific (and usually not autodetected) mutlibyte character encodings like Shift-JIS? It's just not a proper WTF otherwise...
Admin
I do, he! :-)
I agree that Java makes some simple things simpler. And it's easier to support Java on the tool level than C++. But the simplicity comes a price: Java makes hard things even harder. Manual memory management is almost never used in modern C++, RAII solving almost any resource management problem. I have a 10,000 line C++ plugin right here. The new and delete keywords are used 3 times each, mostly for allowing .NET classes to access C++ classes using "impl pointers" (where Boost's smart pointers don't work). The rest of all memory management is automatic, objects being placed directly on the stack or within other objects.
Multiple inheritance - I rarely ever need it, but when I do, I'm glad that it's possible. Unlike in Java where you would be forced to write lots and lots of adapter code.
Template metaprogramming - not easy for those who provide libraries that use it, but a boon for the users of those libraries.
Standard library - the C++ standard library is a lot smaller than Java's, but what made it in the C++ library is actually good, the well thought out, fast and flexible STL containers and algorithms vs. the ad-hoc-designed hode-podge java.util.* being a nice example. Plus, there are a lot of excellent open source cross-platform C++ add-on libraries for almost any purpose. Boost, wxwidgets, Ogre3D, Xerces-C++ and Xalan-C++ just to name a few, plus C libraries like libxml2 and libsdl of course. If you're hardcore, you can embed a Perl interpreter. ;-) Or access C++ code from a Perl program.
Some things are needlessly complicated in C++ like the historically grown text #inclusion (not that Java's lack of separation between interface and implementation at the class source level is so much better). But for the most part, C++ is more complex, and not more complicated than Java.
In Java, some of the complexity just shows up elsewhere - in redundant, convoluted source code. Think of the casting insanity when using containers before generics were introduced, and the debugging problems when you and your coworker couldn't agree on which kind of object to put in that Vector. Where the complexity can be removed, on the other hand, this often results in inferior performance. And Java generics, while being so much better than no generic programming constructs as all (i.e. before "Java 5"), are no match for C++ templates in terms of expressivity.
Admin
Being a bit too serious...
Not that using lexical_cast in this way makes any sense, of course. cout << 42 works fine.
And what about Java? AWT, Swing, SWT... which is the right one? .NET started out with Windows.Forms, but this is already considered obsolescent in favor of WPF. And neither of those are truly cross-platform.
If you are using C++, why not just settle for one (e.g. wxWidgets) and go with it? Or QT, if you prefer, it's free unless you prefer to keep your WTFs secret. ;-)
Admin
I'm in two minds here. On the Stroustrup principle that you only add to a language if that addition provides genuinely worthwhile gains, I think I'd rather work around the perceived need in the few cases where it appears. It just doesn't seem that great a tool to me. The latest argument I saw from Mr S. was that the alternative, of using forwarding functions, would be "less elegant." Still workable, though, and whoever claimed that C++ is "elegant?"
Bottom line, "guns don't kill people; people kill people." Substitute MI for guns and "confuse the shit out of" for kill, and that seems to be the gist of your argument. I don't know about Qt, but if you've ever looked at the ATL, you'll realise quite what a nightmare multiple inheritance can be for the library consumer, rather than for the producer. And it's not like you have a choice as a consumer, except to switch to a saner library (assuming your PHB will let you).
That's a hell of a lot more hardcore than I'd ever envisage being. Have you tried calling into Perl code using that XS rubbish? Let alone making pthreads and ithreads peacefully co-exist? (I know, I know, you can use pthread keys, but it's not fun.) SWIG where necessary; it's saner.And anyway, at the end of the day you only get Perl. Real hardcore would be to embed Python...
Admin
fredsafety:
int dummy = 0; dummy *= dummy; dummy * dummy * dummy; // division is said to be slow dummy = dummy / dummy / dummy;
I'm guessing it won't crash only because dummy operations were optimized out? -O0 == KABOOM?
Admin
No. I've used SWIG which is better for one's mental health.
Admin
The last virtualization example looks just like LabView. Labview is programming language used mainly by electrical engenders that looks like bunch of wires and boxes-- For some reason its popular in the electronics industry...
Admin
Jesus christ, can we stop with the stupid calculator posts and get back to some real WTF articles?
Admin
Jesus christ, can we have a way to vote ban idiots who seem to think that their opinion is in any way important?
Admin
I just love comments like these. Why is it that most programmers think they know best and cannot fathom the tiny possibility that maybe, just maybe, the API/system/whatever is acting wrong because they used it in the wrong fashion... :-)
Don't get me wrong. I am as guilty as the next guy. Except you. You are perfect!
Admin
Isn't there enough unintentionally retarded code in the world already that we don't need to add to it intentionally?
Just saying...
Admin
I never had the guts to actually use ATL; after cursory inspection of the ATL code (both library and generated) in early VC6 times, I've decided to do it the old-fashioned C way. For what little COM I did use back then, the C way was enough.
As far as Qt goes, IIRC the multiple inheritance actually let them implement some core technology (the meta object system) in a more efficient manner. Again, IIRC, because it's long since I looked that deep into Qt4's innards.