• Robot (unregistered) in reply to Synonymous Coward
    Synonymous Coward:
    The Corporation shall have exclusive right to use the name "United States Olympic Committee"; the symbol described in subsection (a)(1) of this section; the emblem described in subsection (a)(2) of this section; and the words "Olympic", "Olympiad", "Citius Altius Fortius" or any combination thereof subject to the preexisting rights described in subsection (a) of this section.

    Cheers.

    United States Code 17, Statute 107. Limitations on exclusive rights: Fair Use

    Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright. In determining whether the use made of a work in any particular case is a fair use the factors to be considered shall include -

    1. the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;
    2. the nature of the copyrighted work;
    3. the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
    4. the effect of the use upon the potential market for or value of the copyrighted work.
  • Andy Janata (unregistered) in reply to anonymous
    anonymous:
    WTF is C/C++?

    C or C++, pick one or the other.

    C/C++ = 1, C != 0. Of course, the value of C has been increased by one (barring overflow).

  • wtf (unregistered) in reply to th0mas
    th0mas:
    Zylon:
    WTF.

    What's worse than failure?

    Worserer than failure!

  • (cs) in reply to Aaron Griffin
    Aaron Griffin:
    th0mas:
    Can our entry use a database, like mysql for example?

    Web services!

    By the way, here is my submission, I'm done. I worked real hard.

    package test;

    public class paulaBean {

    private String paula = "Brillant";

    public String getPaula() { return paula; } }

    Fired...

    You did that TODAY? What? It ONLY took you a few hours? What will you do for the next few weeks?

  • (cs) in reply to Chris
    Chris:
    Will my new laptop come with award winning calculator software pre-installed?

    I bet Alex will be happy to preinstall the winning submission.

  • (cs) in reply to th0mas
    th0mas:
    Can our entry use a database, like mysql for example?
    Hell, you have C, write your own into it and include the data files as giant C structures. (The second or third thing I do when I pick up a new languages is try to write an SQL database in it. So far the only thing that beat me was XSLT; truly, that was the mother of WTFDB. =D)
  • Steve (unregistered) in reply to Sigivald

    From the sounds of this you also need a wood table.

  • sir_flexalot (unregistered)

    I'm just going to upload the exact same template back. The WTF is that I didn't code anything, it's still all TODO's! Now that's dysfunctional.

    devin (sir_flexalot - the WTF of this post is I'm registered but not signed in!)

  • (cs)

    All you have to do is write it in bad APL, then write a bad APL interpreter in C or C++ and hardcode the code to be interpreted into it. I'm not entering as I'm tired of C and C++.

  • (cs) in reply to Shinobu

    As for the contest, man, I have so many good ideas...

    Shinobu:
    The whole UI thing scares me away. I don't have Visual Studio and getting the skeleton to work in MINGW or coLinux is probably going to be too much of a bother.

    So download it. It's free as in, uh, drugs.

    anonymous:
    WTF is C/C++?

    C or C++, pick one or the other.

    Welcome to English. We sometimes use the '/' character, or 'slash', to abbreviate either 'and' or 'or'.

  • mabinogi (unregistered) in reply to EvanED
    Welcome to English. We sometimes use the '/' character, or 'slash', to abbreviate either 'and' or 'or'.

    But saying C/C++ is like saying Apple/Elephant

    They're completely different. Might as well say Perl/COBOL.

    So which is it? C? or C++?

    If it's either, then use "or" which more correctly implies that you have a choice of two different languages, rather than implying that C and C++ are so similar as to be indistinguishable.

    Java and C# are far more similar than C and C++

  • (cs) in reply to mabinogi
    mabinogi:
    Welcome to English. We sometimes use the '/' character, or 'slash', to abbreviate either 'and' or 'or'.

    But saying C/C++ is like saying Apple/Elephant

    I suppose your analogy is not completely worthless... provided the elephant has just eaten the apple in question.

  • (cs) in reply to mabinogi
    mabinogi:
    Welcome to English. We sometimes use the '/' character, or 'slash', to abbreviate either 'and' or 'or'.

    But saying C/C++ is like saying Apple/Elephant

    They're completely different. Might as well say Perl/COBOL.

    No they're NOT completely different! Almost all valid C code is valid C++ code. You can't say that about your Perl/COBOL example in either direction.

    It's true that they are diverging, but they will remain very tightly related for some time.

    Java and C# are far more similar than C and C++

    I'll agree about that, but I've also seen stuff like C++/Java, which I still think is perfectly fine and yet in some sense far more egregious than C/C++.

  • (cs)

    For the testing machine, what is the minimum spec (particularly RAM) that it should run on to test?

    Even though compile time may be easy and short, what is the cut off for load time?

  • Foobar (unregistered) in reply to EvanED
    EvanED:
    mabinogi:
    But saying C/C++ is like saying Apple/Elephant

    They're completely different. Might as well say Perl/COBOL.

    No they're NOT completely different! Almost all valid C code is valid C++ code. You can't say that about your Perl/COBOL example in either direction.

    Show me just one single non-trivial C program which is also a C++ program and which hasn't been created specifically for the exercise of creating something compilable both as C and C++. C++ breaks the most fundamental parts of C.

    IMO writing "C/C++" is a sign that the person who wrotes it knows neither C nor C++ well enough to know that they're not the same language.

    But yeah, maybe I should start writing Java/C#. While I don't really know either of those two languages, I once read someone (just a few comments ago) claiming they were similar, so that makes it OK, right?

  • (cs) in reply to Foobar
    Foobar:
    EvanED:
    mabinogi:
    But saying C/C++ is like saying Apple/Elephant

    They're completely different. Might as well say Perl/COBOL.

    No they're NOT completely different! Almost all valid C code is valid C++ code. You can't say that about your Perl/COBOL example in either direction.

    Show me just one single non-trivial C program which is also a C++ program and which hasn't been created specifically for the exercise of creating something compilable both as C and C++. C++ breaks the most fundamental parts of C.

    This is true, but largely because of malloc. I bet that if C++ allowed implicit conversions from void* to other pointer types, a third to a half of existing, non-trivial C programs would compile fine. Add in allowance for implicit declarations and half of the rest would compile. Almost no one uses C99 features that aren't already in C++ (e.g. // comments or for(int i=0;...)) or most compiler extensions (long long).

    When the language differences can nearly be counted on your fingers, saying that C and C++ are "completely different" is a vast overstatement.

    But yeah, maybe I should start writing Java/C#. While I don't really know either of those two languages, I once read someone (just a few comments ago) claiming they were similar, so that makes it OK, right?

    If you could substitute "or" or "and" in for the slash, sure.

  • (cs) in reply to sir_flexalot
    sir_flexalot:
    I'm just going to upload the exact same template back. The WTF is that I didn't code anything, it's still all TODO's! Now that's dysfunctional.

    devin (sir_flexalot - the WTF of this post is I'm registered but not signed in!)

    I beat you to it, only I wasn't able to get to the template- it was 404ed - so I submitted the 404 with a .zip extension. I'll claim that "the archive was corrupted, let me resend" and get back to Alex with a real version several months after the contest is over.

  • Foobar (unregistered) in reply to EvanED
    EvanED:
    Foobar:
    EvanED:
    mabinogi:
    But saying C/C++ is like saying Apple/Elephant

    They're completely different. Might as well say Perl/COBOL.

    No they're NOT completely different! Almost all valid C code is valid C++ code. You can't say that about your Perl/COBOL example in either direction.

    Show me just one single non-trivial C program which is also a C++ program and which hasn't been created specifically for the exercise of creating something compilable both as C and C++. C++ breaks the most fundamental parts of C.

    This is true, but largely because of malloc. I bet that if C++ allowed implicit conversions from void* to other pointer types, a third to a half of existing, non-trivial C programs would compile fine.

    A bet I'd be more than happy to take.

    EvanED:
    Add in allowance for implicit declarations and half of the rest would compile.

    I take it you pulled that statistic right out of your lower rear? :)

    EvanED:
    Almost no one uses C99 features that aren't already in C++ (e.g. // comments or for(int i=0;...)) or most compiler extensions (long long).

    Hopefully noone is using "for(int i=0;;)" because that's just plain poor programming. C99 added a few things from C++ which tend to make source code a mess and/or unreadable, but luckily not many use it (and those who do are mostly C++ programmers who refer to themselves as C/C++ programmers).

    I tried taking a non-trivial C application and compiling it with a C++ compiler. Not one single file compiled, and I gave up after C++-ifying a handful of files.

    Some of the problems I encountered:

    signed char *foo;
    unsigned char *bar;
    
    foo = bar;
    

    Implicit casts between different pointer types are not allowed in C++. Any reasonable C compiler will warn about unrelated types, though.

    void foo(char *bar);
    
    foo("Hello, world\n");
    

    Doesn't work in C++. String literals are const in C++.

    int foo;
    int foo;
    

    Doesn't work in C++ either.

    And that's without even trying.

    EvanED:
    When the language differences can nearly be counted on your fingers, saying that C and C++ are "_completely_ different" is a vast overstatement.

    Please note that I am not the person who claimed they were "completely different", however I do not think they're the same language either, not by a far stretch. Just because they share a part of the syntax does NOT make them the same, or compatible, languages.

    I don't agree with Bjarne Stroustrup often. In fact, the first time I've even partiall agreed with him was when I found this quote of his:

    Bjarne Stroustrup:
    There is no language called "C/C++". The phrase is usually used by people who don't have a clue about programming (e.g. HR personnel and poor managers). Alternatively, it's used by people who simple do not know C++ (and often not C either). When used by programmers, it typically indicates a "C++ is C with a few useful and a lot of useless complicated features added" attitude. Often, that is the point of view of people who like to write their own strings and hash tables with little knowledge of the standard library beyond printf and memcpy. There are people who stick to a restricted subset of C++ for perfectly good reasons, but they (as far as I have noticed) are not the people who say "C/C++".

    I agree that writing "C/C++" is braindead. Most people do it in this way: "Languages I know: Visual Basic, Java, C/C++." That's just wrong.

    Where I don't agree with Bjarne is that he thinks it is mostly C programmers who write "C/C++." In my experience, it is mostly C++ programmers who never learned C and just once got told that "a C++ compiler will compile any C++ program. C++ is a superset of C." Thus they think that since they learned C++, they also know C, so they know C/C++!

    EvanED:
    But yeah, maybe I should start writing Java/C#. While I don't really know either of those two languages, I once read someone (just a few comments ago) claiming they were similar, so that makes it OK, right?

    If you could substitute "or" or "and" in for the slash, sure.

    So why is it that so many people can figure out how to write "or" or "and" between any other language, but not C and C++? I'd say it's because most of them simply don't know what they're talking about.

  • (cs) in reply to Foobar
    Foobar:
    EvanED:
    Add in allowance for implicit declarations and half of the rest would compile.

    I take it you pulled that statistic right out of your lower rear? :)

    Yep

    EvanED:
    Almost no one uses C99 features that aren't already in C++ (e.g. // comments or for(int i=0;...)) or most compiler extensions (long long).

    Hopefully noone is using "for(int i=0;;)" because that's just plain poor programming. C99 added a few things from C++ which tend to make source code a mess and/or unreadable, but luckily not many use it (and those who do are mostly C++ programmers who refer to themselves as C/C++ programmers).

    I would argue exactly the opposite.

    Perhaps its because my background (if you can't tell...) is mostly C++, but I think that declaring your variable in the loop like that when you can is both better practice than outside of the loop and more readable.

    I can support the first statement with actual reasons (it limits the scope of variables and puts them near their use), but I suspect the latter is just personal preference. (For that matter, the former reasons are probably largely preference.)

    the first couple code examples you posted

    Okay, so I didn't think that those sorts of pointer casts would be used that much. I probably should have loosened my statement before to say that if C++ allowed unrelated pointer casts to the degree that C does, instead of just from void*. Though I guess that still probably wouldn't have given me a wide enough girth to make me correct, so I concede that point.

    EvanED:
    When the language differences can nearly be counted on your fingers, saying that C and C++ are "_completely_ different" is a vast overstatement.

    Please note that I am not the person who claimed they were "completely different", however I do not think they're the same language either, not by a far stretch. Just because they share a part of the syntax does NOT make them the same, or compatible, languages.

    Ah, sorry about the misquote. I have a habit of not really looking at who says things, which has both good and bad consequences. (Probably mostly bad...)

    I do not think they're the same language either, not by a far stretch. Just because they share a part of the syntax does _NOT_ make them the same, or compatible, languages.

    I will make one last argument to try to support my position, which is that if you are somewhat but not terribly careful (probably the biggest concession would be the need to cast out of malloc), it should be possible to write non-trivial code that sticks to the intersection of the languages while losing almost nothing from C. (Though I guess I am a bit more wary about making this statement than I would have been a couple hours ago, as I wonder if there are reasons why people use what I would consider unsafe practices like random pointer casts regularly enough that it would cause a noticeable problem compiling existing code as C++...)

    In that sense, C and C++ ARE a lot more related than any two other language I can think of off the top of my head.

    I agree that writing "C/C++" is braindead. Most people do it in this way: "Languages I know: Visual Basic, Java, C/C++." That's just wrong.

    I would agree that there it would be better separated, at least if the person didn't deliberately mean that they have used the limited part of C++ that largely overlaps with C, in the sense that Stroustrup meant.

    But I do think that there are plenty of places that C/C++ would be fine. This article is borderline IMO, more because of the "the language" than the C/C++.

  • (cs)

    BTW, for the record, I just looked and my resume says "C and C++" ;-)

  • Sarni (unregistered) in reply to Tom Ritchford's Boyfriend
    Tom Ritchford's Boyfriend:
    Tom Ritchford:
    What a shame it requires Windows... after being a professional programmer for 25 years, I still don't own a Windows machine (and I've written hundreds of thousands of lines of C++ too...)

    I don't exactly understand why you did this, either. Seems like there's absolutely no need for it as the code is pure C++. Care to explain?

    What happened did you run out of tampons today?

    You must be a pretty crappy coder if you can't afford a $300 windows box. And you must be extremely retarded if you can't figure out how to dual boot.

    What kind of failed abortion are you? Could you imagine that it is a blessing to work as a programmer for 25 years, bringing food on the table and never having to touch the clusterfuck called Windows? Why the fuck should someone taint his clean soul for a crappy contest?

    Go back to licking Bills arse and stop annoying the real programmers.

  • Raw (unregistered) in reply to Sigivald
    I'm not going to make an entry, but if I did, it would require the following things:

    A physical four-function calculator.

    A webcam.

    A robotic arm.

    OCR and robotic arm-control software.

    The rest is left as an exercise for the reader.

    Sorry, that's not enough to solve the problem. Once you got the result, you also need a printer to print the result, have the robot arm place it on a wooden table, take a snapshot with the webcam, post it on a web server, download the image from the web server, preferably using web services, OCR the image to get the result and then return the result.

    You have to think enterprisey.

  • (cs) in reply to anonymous
    anonymous:
    WTF is C/C++?

    C or C++, pick one or the other.

    No, oh no no no, it's definitely < 1 provided C > 0.

  • yetihehe (unregistered)

    Yeah, but for prize there is macbook or sony, I don't want to have any of them. I don't like mac's and sony is "teh evil corporation".

  • (cs) in reply to yetihehe
    yetihehe:
    Yeah, but for prize there is macbook or sony, I don't want to have any of them. I don't like mac's and sony is "teh evil corporation".

    If you win, I'll give you a ThinkPad in exchange for one of them.

    Hopes he doesn't ask how old it is

  • Clusterfuck (unregistered) in reply to Raw

    I had a buddy that wrote his own calculator. It didnt compile (HAving more errors than LOC, about 3-4 times as many errors as it had lines actually) so, what did he do? He picks up the phone and calls me to come and "look at some code". My hair DIDNT go white, but I am pretty sure I am gonna go bald a full 10 years earlier because of that code.

    It did a lot of wonderfully fucked up things, and once I actually got it to compile (Beating on it with a sledgehammer more or less until the compile errors went away and there were only like 70 or so serious warnings left). It miscalculated stuff if you put numbers in in "the wrong way", it used strings to do calculation, and well, it had indentation, but uhm. Not like you'd expect. ;) It was a real mess, and I still remember it fondly, and I have been planning to make my own version of it just to do something horrendous. This might be a good time. ;)

  • C++ Coder (unregistered)

    -Passes all of Test Cases

    Okay, it looked all fine until this point. But what's the point of a WTF contest if the program has to pass all test cases? I thought it should be buggy.

    I thought about making a program that runs C:\WINDOWS\system32\calc.exe (assumes an absolute path of course), then takes a screenshot and scans for the result. But if it has to pass test cases then I guess that idea is out the window.

  • (cs) in reply to Anonymous

    I don't see a requirement that the program must give the calculation results within the judges' lifetime.

    How do the judges determine whether the calculator actually completes the testcases, in the case the program actually performs quadratically or worse?

  • Anony mouse (unregistered) in reply to JOHN
    JOHN:
    Hey Joel, there's a bigass "FIND" button right on the toolbar. Click it, enter what you want, hit enter. DONE. 2,450 emails in my inbox right now, searched in under 10 seconds. Outlook 2003, SP2.

    His point being that said search was slow to the point of uselessness, if you'd read the full article...

  • Anony mouse (unregistered) in reply to Anony mouse
    Anony mouse:
    JOHN:
    Hey Joel, there's a bigass "FIND" button right on the toolbar. Click it, enter what you want, hit enter. DONE. 2,450 emails in my inbox right now, searched in under 10 seconds. Outlook 2003, SP2.

    His point being that said search was slow to the point of uselessness, if you'd read the full article...

    And the specifics being: (To add to this)

    I have a lot of big PST files, which, I'm told, is why search was so slow for me
  • Chris (unregistered) in reply to Tom Ritchford's Boyfriend
    Tom Ritchford's Boyfriend:
    Tom Ritchford:
    What a shame it requires Windows... after being a professional programmer for 25 years, I still don't own a Windows machine (and I've written hundreds of thousands of lines of C++ too...)

    I don't exactly understand why you did this, either. Seems like there's absolutely no need for it as the code is pure C++. Care to explain?

    What happened did you run out of tampons today?

    You must be a pretty crappy coder if you can't afford a $300 windows box. And you must be extremely retarded if you can't figure out how to dual boot.

    Obviously the original posters are complete numptys for not reading the whole article, as there's a GTK equivalent to the Win32 code. However, on the dual booting front, can you tell me how to dual boot Windows on my Sun workstation as I don't feel the need to blow several hundred quid on a PeeCee?

  • Asd (unregistered)

    Why no Java/C#? They would be the easiest languages to do a simple GUI in, and the tools are much more straightforward to set up.

  • ok (unregistered) in reply to joe.edwards

    Re: The Worse Than Failure Programming Contest 2007-04-24 15:36 • by [email protected] Come on, let me do it in C#. Pretty please?

    An idea for WTF: Implement the CLR and C# compiler in C/C++, and then implement the solution in C#. I reckon this counts as a "clever" solution.

    ok.

  • J (unregistered) in reply to Chris
    Chris:
    However, on the dual booting front, can you tell me how to dual boot Windows on my Sun workstation as I don't feel the need to blow several hundred quid on a PeeCee?

    It seems to me you might get a head start on some excellently WTF code by writing Windows code without a Windows machine available.

  • (cs) in reply to Tom Ritchford
    Tom Ritchford:
    What a shame it requires Windows... after being a professional programmer for 25 years, I still don't own a Windows machine (and I've written hundreds of thousands of lines of C++ too...)

    I don't exactly understand why you did this, either. Seems like there's absolutely no need for it as the code is pure C++. Care to explain?

    He probably wants to guarantee that the code submitted won't contain malicious malware components such as virii, trojans and adware which could potentially steal intellectual property from his machine.

    Restricting the competition to a windows codebase - ie a commercially verified codebase - eliminates the possibility of open source code being used which is well known to be rife with the above concerns.

  • dkf (unregistered) in reply to Cthulhu
    Cthulhu:
    Restricting the competition to a windows codebase - ie a commercially verified codebase - eliminates the possibility of open source code being used which is well known to be rife with the above concerns.
    The Real WTF! is that you didn't read this part of the article:
    Alex Papadimoulis:
    For the Linux folks out there, you may use the mostly equivalent GTK skeleton solution.
    If you can't use Win32 or GTK, then this contest is probably not for you. Either that or you should enter some untested code...
  • cardboard box (unregistered)

    Well :D Ive wasted some time now to get this to compile under VS2005 express with no luck :D It kompiles but wont link so I think Ill sit out until the GTK one arrives and do it in my cozy linux :)

  • (cs)

    I figure that my being one the the 15% who don't use C/C++ is a real advantage here...

    My bugs will be authentic! =)

  • cardboard box (unregistered)

    Hee! Dumat nada ne brõgat. Read the manual and what ya know, to compile this with VS 2005 express you will need to add kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib to linkers aditional deps for the skeleton project. the gude tells you to add this to the default project template but that does nothing for an existing prject...

  • RON (unregistered) in reply to Wierenfest
    Wierenfest:
    anonymous:
    WTF is C/C++?

    C or C++, pick one or the other.

    No, oh no no no, it's definitely < 1 provided C > 0.

    Wrong.

    C++ is a postincrement, meaning that it's evaluated and then incremented.

    So therefore C/C++ is equal to 1, except when C is 0.

  • natron (unregistered)

    You think you could get Joel Spolsky to call the winner and give their code review on the phone using harsh language?

  • Foobar (unregistered) in reply to EvanED
    EvanED:
    EvanED:
    Almost no one uses C99 features that aren't already in C++ (e.g. // comments or for(int i=0;...)) or most compiler extensions (long long).

    Hopefully noone is using "for(int i=0;;)" because that's just plain poor programming. C99 added a few things from C++ which tend to make source code a mess and/or unreadable, but luckily not many use it (and those who do are mostly C++ programmers who refer to themselves as C/C++ programmers).

    I would argue exactly the opposite.

    Perhaps its because my background (if you can't tell...) is mostly C++, but I think that declaring your variable in the loop like that when you can is both better practice than outside of the loop and more readable.

    I can support the first statement with actual reasons (it limits the scope of variables and puts them near their use), but I suspect the latter is just personal preference. (For that matter, the former reasons are probably largely preference.)

    My point of view is that variables should only be declared at the beginning of a scope and before any statements. This IMO makes it much easier to read through code you don't know. Uncertain of what type something is? Well, just scroll up to the beginning of the scope and you will find the declaration. Also if you use more than one loop, declaring i multiple times is just silly.

    I do realise that C99 considers "for(" the beginning of a new scope, but I completely disagree with C99 here. C99 allows declaration of variables anywhere anyway, which I also completely diagree with. It's just promoting sloppy programming.

    EvanED:
    the first couple code examples you posted

    Okay, so I didn't think that those sorts of pointer casts would be used that much. I probably should have loosened my statement before to say that if C++ allowed unrelated pointer casts to the degree that C does, instead of just from void*. Though I guess that still probably wouldn't have given me a wide enough girth to make me correct, so I concede that point.

    To be fair, the thing I tried to compile was Quake, which is very far from being the most beautiful code. In fact the Quake source code is fairly ugly if you ask me.

    Another problem I forgot to mention is that Quake has a "typedef enum { false, true } qboolean;" definition which also clashes with C++ ;)

    Code I write does not do unrelated implicit pointer casts since I consider it bad style. Indeed if C code compiles with -Wall without warnings, there's a good chance the code won't need too many changes to compile with a C++ compiler.

    EvanED:
    I do not think they're the same language either, not by a far stretch. Just because they share a part of the syntax does _NOT_ make them the same, or compatible, languages.

    I will make one last argument to try to support my position, which is that if you are somewhat but not terribly careful (probably the biggest concession would be the need to cast out of malloc), it should be possible to write non-trivial code that sticks to the intersection of the languages while losing almost nothing from C. (Though I guess I am a bit more wary about making this statement than I would have been a couple hours ago, as I wonder if there are reasons why people use what I would consider unsafe practices like random pointer casts regularly enough that it would cause a noticeable problem compiling existing code as C++...)

    In that sense, C and C++ ARE a lot more related than any two other language I can think of off the top of my head.

    Related? Yes. But not enough to write "C/C++."

    One of my biggest problems with writing it like this is that many (most?) C++ programmers make awful C programmers. Looking at C code written by someone knowing C++, you don't have to look for many seconds to find the first memory leak or lack of error checking.

    Especially bad is error checking. The typical C++ programmer does absolutely no error checking at all, which is just proven again and again every time I start working on a new project at work (which usually means I end up working with new people). Another thing I see scaringly often by C++-programmers-turned-C is something like:

    x = new char[strlen(y)];
    strcpy(x, y);
    

    And then after a while, someone taps me on the shoulder, asks me if I know why the new operator would be crashing and if it is a bug in the operating system. Of course the new that's crashing is the one after the code I wrote.

    EvanED:
    I agree that writing "C/C++" is braindead. Most people do it in this way: "Languages I know: Visual Basic, Java, C/C++." That's just wrong.

    I would agree that there it would be better separated, at least if the person didn't deliberately mean that they have used the limited part of C++ that largely overlaps with C, in the sense that Stroustrup meant.

    But I do think that there are plenty of places that C/C++ would be fine. This article is borderline IMO, more because of the "the language" than the C/C++.

    I'm still trying to think of a single place where writing "C/C++" would be OK... Unless you were trying to unify the two languages into a new language, that is.

  • Anonymous Guy (unregistered)

    What everybody really wants to know, but doesn't want to say out loud, is: what does OMGWTF stand for? Sure we want to know, but only in a perverse "after I find out I'll be sorry" kind of way. I'm guessing it's something like:

    Ooops Me Goof it's Worse Than a Failure

    Maybe somebody else knows for sure.

  • (cs) in reply to Anonymous Guy
    Anonymous Guy:
    What everybody really wants to know, but doesn't want to say out loud, is: what does OMGWTF stand for? Sure we want to know, but only in a perverse "after I find out I'll be sorry" kind of way. I'm guessing it's something like:

    Ooops Me Goof it's Worse Than a Failure

    Maybe somebody else knows for sure.

    That'd be "Oh My God, What the F---??"

  • (cs) in reply to Sarni

    awwwwwww yeah.... use the GUI for basic I/O only (user enters digits, reads result). The calculations are done in a console window however, instead of passing the variables back through to the GUI class, the GUI runs a screen scrape method on the console window to get the results.

    or better yet,instructs the user to take a screenshot of the results window, print it, put the printout on a wooden table....

  • (cs) in reply to Foobar
    Foobar:
    signed char *foo; unsigned char *bar;

    foo = bar;

    Implicit casts between different pointer types are not allowed in C++. Any reasonable C compiler will warn about unrelated types, though.

    There's a reason the warning is there... It's telling you that you should have written it as: foo = (signed char*) bar;

    And, it you had, it would have compiled under C & C++.

    Foobar:
    void foo(char *bar); foo("Hello, world\n"); Doesn't work in C++. String literals are const in C++.

    No, actually that does. The Standard committee had to hold their nose as they hacked the Standard to get it to work, but that is allowable.

    Foobar:
    int foo; int foo;

    Doesn't work in C++ either. And that's without even trying.

    So, basically, you're saying that C is a different langauge from C++ because C++ won't let you get away with incredibly bad programming practices you shouldn't be doing in the first place.

    So, let's re-phrase the original statement -- "Most WELL-WRITTEN C code is compilable be a C++ compiler."

  • (cs) in reply to Foobar
    Foobar:

    My point of view is that variables should only be declared at the beginning of a scope and before any statements. This IMO makes it much easier to read through code you don't know. Uncertain of what type something is? Well, just scroll up to the beginning of the scope and you will find the declaration. Also if you use more than one loop, declaring i multiple times is just silly.

    I do realise that C99 considers "for(" the beginning of a new scope, but I completely disagree with C99 here. C99 allows declaration of variables anywhere anyway, which I also completely diagree with. It's just promoting sloppy programming.

    See, I think personal preference. I think it's easier to find things if they are near their uses. If the function is short, it doesn't make much difference; if the function is long, it means that you have less chance of scrolling and also that the block of declarations is likely pretty sizable. In either case, if you're using an IDE then there's no issue figuring out where the declaration is, as there's a "go to declaration" action. Heck, Visual Studio will show you the type of the variable the mouse is over in a tool tip.

    In addition, "declare anywhere" also often/usually allows you to initialize the variable at the point of declaration, something you can rarely do in C, which reduces the chance of using an uninitialized or improperly initialized variable. And this doesn't affect C, but it also makes RAII a lot more useful by letting you use it at any block level.

    I'm still trying to think of a single place where writing "C/C++" would be OK... Unless you were trying to unify the two languages into a new language, that is.

    Eh, I guess we disagree.

    Does remind me of like a, by now, probably third-hand anecdote though. This one guy my friend knows was interviewing for faculty positions probably about a decade ago, and one of the places was at UT Austin. He gets to the department, and some of the profs start essentially apologizing to him for what was apparently fairly unpleasant behavior on the part of Edsger Dijkstra. For instance, they warned him that Dijkstra didn't like people anthropomorphizing programs, so at one point during his talk he said "the program wants to do this.... sorry, the programmer wants the program to do this".

    But on one of his slides he had something like "x/y" (not as a division). Dijkstra raised his hand and asked "what does x slash y mean"? And this guy says "it means x or y, but if I had written that out then it would have wrapped to the next line, and I hate that!"

  • (cs) in reply to Robot
    Synonymous Coward:
    The Corporation shall have exclusive right to use the name "United States Olympic Committee";
    Robot:
    United States Code 17, Statute 107. Limitations on exclusive rights: Fair Use

    Let's try to pay attention here --- The first refers to a trademark; the second, to copyrights. They are incompatible.

    And while we are pointing out problems with the name of the contest, I guess I should get nit=-picky and point out that it should be "The Olympics of Misguided Geeks at Worse Than Failure Programming Contest."

    "Olympiad" actually refers to a period of time, specifically 4 years, during which there is one Olympics.

  • AC (unregistered) in reply to Sigivald
    Sigivald:
    I'm not going to make an entry, but if I did, it would require the following things:

    A physical four-function calculator.

    A webcam.

    A robotic arm.

    OCR and robotic arm-control software.

    The rest is left as an exercise for the reader.

    And a wooden table, don't forget the wooden table.

  • Foobar (unregistered) in reply to JamesCurran
    JamesCurran:
    Foobar:
    signed char *foo; unsigned char *bar;

    foo = bar;

    Implicit casts between different pointer types are not allowed in C++. Any reasonable C compiler will warn about unrelated types, though.

    There's a reason the warning is there... It's telling you that you should have written it as: foo = (signed char*) bar;

    At least the last non-broken version of GCC doesn't warn about implicit signed/unsigned casts.

    JamesCurran:
    And, it you had, it would have compiled under C & C++.

    Bingo, and if I didn't, it wouldn't. And that was (part of) my original point.

    JamesCurran:
    Foobar:
    void foo(char *bar); foo("Hello, world\n"); Doesn't work in C++. String literals are const in C++.

    No, actually that does. The Standard committee had to hold their nose as they hacked the Standard to get it to work, but that is allowable.

    Right, it actually does compile. The code that had the problem looked like this:

    extern int blah;
    
    void foo(char *);
    
    void bar()
    {
            foo(blah?"foo":"bar");
    }
    

    Now I don't know if that's a compiler bug or really intended in C++

    JamesCurran:
    So, basically, you're saying that C is a different langauge from C++ because C++ won't let you get away with incredibly bad programming practices you shouldn't be doing in the first place.

    No, I'm saying that C is a different language from C++ because while they're syntactically similar (though not identical), the way the two languages are used, especially when it comes to allocation, error handling and standard libraries, means that C knowledge can't just be transferred into C++ knowledge and C++ knowledge can't just be transferred into C knowledge. You need to learn both languages, and thus they're distinct.

    JamesCurran:
    So, let's re-phrase the original statement -- "Most WELL-WRITTEN C code is compilable be a C++ compiler."

    Well, I can extend that. Any well written C++ program will be compilable with a C compiler.

    When your definition of a well written C program is something that compiles with a C++ compiler, well, then the argument is lost before it even started.

    C++ has a lot of "features" over C which makes code much harder to read, much harder to maintain and overall puts the code in a lot worse condition. Though I don't expect you to agree.

Leave a comment on “The Worse Than Failure Programming Contest”

Log In or post as a guest

Replying to comment #133472:

« Return to Article