• (cs)

    These calculator articles are really boring :P

    (fist)

  • (cs) in reply to freelancer

    Very boring indeed. (seocnd)

  • (cs)

    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 ;-)

  • (cs)

    bored bored bored bored bored.

    did I mention I was bored?

  • T$ (unregistered)

    Oooh, ASCII-based logic gates, enthralling.

  • Zygo (unregistered)
    We received several hardware emulation entries, all of which were fantastic. Goplat's, though, would parse through an ASCII representation of a series of logic gates.

    ...so instead of this masterpiece, the half-finished transistor netlist emulator gets into the finalists? Yeesh!

  • Name (unregistered)

    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]
  • fin (unregistered)

    this is generally hilarious. i love that OMGWTF thing :D

  • (cs)

    Can't believe goplatcalc is not among the finalists. Did it fail some test cases?

  • Zygo (unregistered) in reply to Massimo
    Massimo:
    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 ;-)

    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? ;-)

  • pstatic (unregistered)

    omfg these are brilliant.

    To all of you saying these articles are boring: Pah!

  • Zygo (unregistered) in reply to Name
    Name:
    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]

    OK, maybe I've led a sheltered life but I've never seen Unicode art before, only ASCII...

  • Ash (unregistered)

    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.

  • Ash (unregistered) in reply to Zygo

    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.

  • (cs) in reply to Zygo
    Zygo:
    Name:
    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]

    OK, maybe I've led a sheltered life but I've never seen Unicode art before, only ASCII...

    That one was originally Shift-JIS art, straight from 2ch.

    Show me. Show you. Kikkoman!

  • Zygo (unregistered) in reply to pstatic
    pstatic:
    omfg these are brilliant.

    To all of you saying these articles are boring: Pah!

    These comments that say these articles are non-boring are boring.

    Captcha:  muhahahahaha (That's not it)   :(
    Captcha:  muhaha       (That's not it)  wtf
    Captcha:  muhahahah    (That's not it)  >:|
    Captcha:  muhahaha                       :D
    
  • Sigh (unregistered)

    don't any of these sumbitters have a job?

  • Kyle Söze (unregistered) in reply to Sigh
    Sigh:
    don't any of these sumbitters have a job?
    Yes, making code just like the submitted examples.
  • (cs)

    Java has toString() and trim(), but it makes everything else too complicated. Give me C++ any day!

  • bsander (unregistered)

    Just so that no one misses out on the Paula Bean stuff: http://worsethanfailure.com/Articles/The_Brillant_Paula_Bean.aspx

  • dbomp (unregistered)

    goplatcalc is... beautiful.

  • (cs) in reply to Zygo
    Zygo:
    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.

    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.

    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.

    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.

    Am I the only one who understands C++ vptr table abuse, or did I completely miss something? ;-)

    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.

  • (cs) in reply to IMil
    IMil:
    Can't believe goplatcalc is not among the finalists. Did it fail some test cases?

    I know! Holy cow! That would easily be in contention for one of my top couple.

  • (cs) in reply to EvanED
    EvanED:
    IMil:
    Can't believe goplatcalc is not among the finalists. Did it fail some test cases?

    I know! Holy cow! That would easily be in contention for one of my top couple.

    Voice recount! goplatcalc kicks some serious ass!

  • (cs) in reply to mkb

    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.

  • (cs) in reply to viraptor
    viraptor:
    EvanED:
    IMil:
    Can't believe goplatcalc is not among the finalists. Did it fail some test cases?

    I know! Holy cow! That would easily be in contention for one of my top couple.

    Voice recount! goplatcalc kicks some serious ass!
    I would've voted for any one of three of the finalists, until I saw the 24-depth kiddie calculator that inexpicably didn't make it.

    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.

  • (cs) in reply to ahnfelt
    ahnfelt:
    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.

    Sigh. And now, back to earth.

    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.

  • (cs)

    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.

  • sjs (unregistered) in reply to chrismcb
    chrismcb:
    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.

    If you think they need better material then start submitting WTFs instead of making stupid comments here. Yeesh.

  • Anonymouse (unregistered)

    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.

  • (cs) in reply to real_aardvark

    goplatcalc FTW! That scares me. Scares me so much I want to run away and cry.

    But I can't help but love it.

  • (cs)

    YAY! Honovrable mention. :D

  • (cs)

    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.

  • Kuba Ober (unregistered) in reply to real_aardvark
    real_aardvark:
    Multiple inheritance? Is this the worst you can throw at C++? It's probably a mistake

    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

  • W & T & F (unregistered)

    Still angry with the site name change, man.

  • vote goplatcalc as write-in candidate (unregistered)

    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...

  • FDF (unregistered)

    Unbelievable, this time non of the highlights are boring :)

  • (cs) in reply to ahnfelt
    ahnfelt:
    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.

    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.

  • (cs) in reply to Quietust
    Quietust:
    Zygo:
    Name:
    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]

    OK, maybe I've led a sheltered life but I've never seen Unicode art before, only ASCII...

    That one was originally Shift-JIS art, straight from 2ch.

    Show me. Show you. Kikkoman!

    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...

  • AdT (unregistered) in reply to ahnfelt
    ahnfelt:
    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.

    I do, he! :-)

    ahnfelt:
    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.

    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.

  • AdT (unregistered)
    //WHAT KIND OF PROGRAMMING LANGUAGE DOESN'T EVEN HAVE TOSTRING()?!?!
    // OR EVEN TRIM()?!  GOOD GOD... WTF WERE THEY THINKING?!
    

    Being a bit too serious...

    #include <iostream>
    #include <string>
    
    #include <boost/algorithm/string.hpp>
    #include <boost/lexical_cast.hpp>
    
    int main() {
    	using namespace std;
    
    	string bla("Foo bar   ");
    	string trimmed = boost::trim_right_copy(bla);
    	cout << trimmed << "!\n";
    
    	bla = boost::lexical_cast<string>(42);
    	cout << bla << '\n';
    }
    

    Not that using lexical_cast in this way makes any sense, of course. cout << 42 works fine.

    rjnewton:
    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].

    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. ;-)

  • (cs) in reply to AdT
    Kuba Ober:
    real_aardvark:
    Multiple inheritance? Is this the worst you can throw at C++? It's probably a mistake

    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.

    Youu missed out the bit of my quote when I admitted that I have used MI, more often that I would perhaps judge sane.

    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).

    AdT:
    ahnfelt:
    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.

    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.

    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...

  • (cs)

    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?

  • AdT (unregistered) in reply to real_aardvark
    real_aardvark:
    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?

    No. I've used SWIG which is better for one's mental health.

  • (cs)

    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...

  • Calculator posts suck (unregistered)

    Jesus christ, can we stop with the stupid calculator posts and get back to some real WTF articles?

  • (cs) in reply to Calculator posts suck
    Calculator posts suck:
    Jesus christ, can we stop with the stupid calculator posts and get back to some real WTF articles?

    Jesus christ, can we have a way to vote ban idiots who seem to think that their opinion is in any way important?

  • (cs)
    ////////////////////////////////////////////////////////// // Class: Mutex // For some reason, the stupid Windows threads cause the CPU to max out in the mutex, // so I made my own cooperative multitasking system. ////////////////////////////////////////////////////////////

    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!

  • Tony (unregistered)

    Isn't there enough unintentionally retarded code in the world already that we don't need to add to it intentionally?

    Just saying...

  • Kuba (unregistered) in reply to real_aardvark
    real_aardvark:
    Kuba Ober:
    real_aardvark:
    Multiple inheritance? Is this the worst you can throw at C++? It's probably a mistake

    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.

    Youu missed out the bit of my quote when I admitted that I have used MI, more often that I would perhaps judge sane.

    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).

    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.

Leave a comment on “OMGWTF Highlights #3: Code”

Log In or post as a guest

Replying to comment #:

« Return to Article