• Whiskey Tango Foxtrot? Over. (unregistered)

    Let's start out with this single line from Victor Bilyk, who's predecessor liked the long way of writing "true" ...

    cbfQry.addParameter( <FONT size=+0>"authenticate_required"</FONT>, <FONT size=+0>new Boolean</FONT>(<FONT size=+0>true</FONT>).toString() );

    Err... WTF? Why not just box the bool, why turn it into a string? And if you have to use a string, why toString() a bool, when you can just write "True"?

  • chrismcb (cs) in reply to Whiskey Tango Foxtrot? Over.
    Anonymous:

    Let's start out with this single line from Victor Bilyk, who's predecessor liked the long way of writing "true" ...

    cbfQry.addParameter( <FONT size=+0>"authenticate_required"</FONT>, <FONT size=+0>new Boolean</FONT>(<FONT size=+0>true</FONT>).toString() );

    Err... WTF? Why not just box the bool, why turn it into a string? And if you have to use a string, why toString() a bool, when you can just write "True"?

     

    Uhhh cause someone might have #define true to be false

  • Whiskey Tango Foxtrot? Over. (unregistered)
    The next two lines of code took Christophe Beugnet hours and hours to correct. Who would have guessed that a supplier would have modified a header with this?

    <FONT size=+0>#define</FONT> false 1
    <FONT size=+0>#define</FONT> true 0
    Heh.... I'm guessing evil exiting former-programmer. [:)]
  • BiggBru (cs)
    Alex Papadimoulis:

    <FONT face=Georgia>That's a way to do it, I suppose...</FONT>

    Alex Papadimoulis:

    I love Oracle so much, I would marry it in San Francisco

    <FONT face=Georgia>On a separate note, should we really be allowed to modify other user's quotes? It could lead to embarassing situtations... [<:o)]</FONT>

     

    <FONT face=Georgia></FONT> 

  • meepster (unregistered)

    OMGWTFBBQ first post!! Lol pudding.

    Yeah. Whatever. Just stealing someone else's glory.

  • Whiskey Tango Foxtrot? Over. (unregistered) in reply to chrismcb
    chrismcb:
    Anonymous:

    Let's start out with this single line from Victor Bilyk, who's predecessor liked the long way of writing "true" ...

    cbfQry.addParameter( <FONT size=+0>"authenticate_required"</FONT>, <FONT size=+0>new Boolean</FONT>(<FONT size=+0>true</FONT>).toString() );

    Err... WTF? Why not just box the bool, why turn it into a string? And if you have to use a string, why toString() a bool, when you can just write "True"?

     

    Uhhh cause someone might have #define true to be false

    [:D] I was just reading that as you posted.

  • meepster (unregistered) in reply to meepster

    In other news, I just Totally Owned (TM) myself by receiving the 2nd post. This is America, people: winner takes all!

  • .* (unregistered)
    Alex Papadimoulis:
    Since I know nothing about Linux/Unix, I showed this next snippet of korn script (from Simmoril)to a Linux guy. He thought it was worth posting and said it was one of the more inventive ways to increment a variable. Anyone care to explain why?

    #!/bin/ksh

    [... ommitting unimportant code...]

    export SLEEP_COUNT=`expr $SLEEP_COUNT + 1`


    In C-type code:

    int sleep_count = 0;

    ...

    sleep_count = evalulate_expression(int_to_string(sleep_count) + " + 1")

    Not to mention that it spawns two programs just to do that.
  • Omnifarious (cs)
    Alex Papadimoulis:

    I don't know why it's inventive. AFAIK, that's the way it has to be done in a shell script, unless it supports the $(( ... )) syntax, in which case you can do:

    export SLEEP_COUNT=$(( $SLEEP_COUNT + 1 ))

    Which isn't really that much smaller or more understandable.

  • Colin (unregistered)
    Alex Papadimoulis:

    Since I know nothing about Linux/Unix, I showed this next snippet of korn script (from Simmoril)to a Linux guy. He thought it was worth posting and said it was one of the more inventive ways to increment a variable. Anyone care to explain why?

    #!/bin/ksh 

    [... ommitting unimportant code...]

    export SLEEP_COUNT=`expr $SLEEP_COUNT + 1`
  • DSx (unregistered)
    <font color="#000099">private static final String</font> MBS_PASSWORD = <font color="#990000">"f4rth9fe"</font>.toUpperCase();

    I think what the real WTF is on that one, is that if you're going to hard-code a constant that always gets transformed to upper case, why not just hard-code it in upper case?
  • .* (unregistered) in reply to Omnifarious
    Omnifarious:
    Alex Papadimoulis:
    Since I know nothing about Linux/Unix, I showed this next snippet of korn script (from Simmoril)to a Linux guy. He thought it was worth posting and said it was one of the more inventive ways to increment a variable. Anyone care to explain why?

    #!/bin/ksh 
    

    [... ommitting unimportant code...]

    export SLEEP_COUNT=expr $SLEEP_COUNT + 1

    I don't know why it's inventive. AFAIK, that's the way it has to be done in a shell script, unless it supports the $(( ... )) syntax, in which case you can do:

    export SLEEP_COUNT=$(( $SLEEP_COUNT + 1 ))

    Which isn't really that much smaller or more understandable.

    In KSH, just use ((SLEEP_COUNT = SLEEP_COUNT + 1))

  • mlathe (cs) in reply to .*
    Anonymous:
    Omnifarious:
    Alex Papadimoulis:
    Since I know nothing about Linux/Unix, I showed this next snippet of korn script (from Simmoril)to a Linux guy. He thought it was worth posting and said it was one of the more inventive ways to increment a variable. Anyone care to explain why?

    #!/bin/ksh 
    

    [... ommitting unimportant code...]

    export SLEEP_COUNT=expr $SLEEP_COUNT + 1

    I don't know why it's inventive. AFAIK, that's the way it has to be done in a shell script, unless it supports the $(( ... )) syntax, in which case you can do:

    export SLEEP_COUNT=$(( $SLEEP_COUNT + 1 ))

    Which isn't really that much smaller or more understandable.

    In KSH, just use ((SLEEP_COUNT = SLEEP_COUNT + 1))

    as far as i know using expr is the only way to add two numbers in bourne shell (the most portable shell). anyone have a better way?

  • qu1j0t3 (cs) in reply to mlathe
    mlathe:

    as far as i know using expr is the only way to add two numbers in bourne shell (the most portable shell). anyone have a better way?




    Yes.
       let A=B+C
    or, in this case,
       let ++SLEEP_COUNT
    would do the trick.

    In ksh,
       (( A=$B+$C ))
    works, as does
      (( ++SLEEP_COUNT ))


  • Dave (unregistered)

    > new Boolean(true).toString()

    What programming language is this by chance? If it's VB then the result could be the localized version of truth, such as "waar" or "verdad" so don't assume it comes out "true".

    http://www.codecomments.com/archive293-2005-1-376910.html

    Of course, this makes it even more of a WTF because I doubt that the SQL query expects "waar".

    What's it good for? Absolutely nothing!

     

  • Otto (cs) in reply to .*

    The increment is pretty standard in some shell scripts.

    See http://www.nacse.org/demos/coping-with-unix/coping-with-unix/node161.html

  • qu1j0t3 (cs) in reply to qu1j0t3

    Sorry, read 'Bourne', thought 'bash'. My bad. But the ksh suggestions are still valid :-)

  • VGR (cs) in reply to mlathe
    mlathe:
    as far as i know using expr is the only way to add two numbers in bourne shell (the most portable shell). anyone have a better way?


    No better way in Bourne shell, as far as I know.

    I figure the author just wanted to keep the script as portable as possible.  When I want to write a shell script I expect may need to run on other Unix systems, I stick to basic Bourne shell syntax.

    It's only a WTF if it's certain to only be used on Linux forever.  And not a very big WTF.

    Personally I hate Korn shell anyway.  There's something to be said for the small, straightforward syntax rule set of Bourne shell.
  • Drakonite (cs)

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.

  • Slacker (cs)
    ...who's predecessor seemed to really have some trouble with predicate logic ... and spelling ...

    Probably best not to rag on someone's spelling when you yourself haven't mastered the apostrophe yet :)
  • xcor057 (unregistered)

    #define false 1
    <FONT size=+0>#define</FONT> true 0

    Because we all know FEMALE = 0 and MALE=1.  Women are always right and men are always wrong.

  • Pinguis (unregistered) in reply to Omnifarious

    sh -- notice its sh not bash -- does this:

    echo $((1+1))
    2

    so the portability issues dont matter. that said, the expr version, is the one recomened by the man page. I assume this was a bash programer forced to use ksh? Remember that ksh inst free (beer of freedom).


  • Manni (cs) in reply to Dave
    Anonymous:

    > new Boolean(true).toString()

    What programming language is this by chance? If it's VB then the result could be the localized version of truth, such as "waar" or "verdad" so don't assume it comes out "true".

    http://www.codecomments.com/archive293-2005-1-376910.html

    Of course, this makes it even more of a WTF because I doubt that the SQL query expects "waar".

    What's it good for? Absolutely nothing!

     

    It's not VB. It looks close to VB .Net, but it's not that because the line ends with a semicolon. Maybe C#?

  • Martin (cs) in reply to Dave
    Anonymous:

    > new Boolean(true).toString()

    What programming language is this by chance? If it's VB then the result could be the localized version of truth, such as "waar" or "verdad" so don't assume it comes out "true".

     

    I am guessing from the casing of the toString() method that this would probably be java. In .net, it would be ToString().

  • R.Flowers (cs)

    #define false 1
    <FONT size=+0>#define</FONT> true 0

    AAAHHH!!!

    predecessor seemed to really have some trouble with predicate logic ... and spelling ...

    Which brings up something I often thing about: how can coders, who must master a precise syntax and set of symbols, how can they turn out to be such bad, bad spellers? I mean, do they first code:

    <FONT face="Courier New">SELLECK some_id FRUM some_table WERE cst > 2.5</FONT>

    and then after the usual errors, maybe go back and correct it? Or will most editing environments auto-correct that stuff?

  • sum yung guy (unregistered) in reply to Manni

    It's got to be Java because "toString" starts with a lower case t. According to Sun it's always supposed to return "true" or "false" so you don't have to worry about locale-type stuff.

  • R.Flowers (cs) in reply to R.Flowers
    R.Flowers:

     

    Which brings up something I often thing about...

    Yes, quite hilarious. Even worse, I carefully re-read what I type, given the comment's subject matter.

  • Jon (unregistered) in reply to Martin
    Martin:
    Anonymous:

    > new Boolean(true).toString()

    What programming language is this by chance? If it's VB then the result could be the localized version of truth, such as "waar" or "verdad" so don't assume it comes out "true".

     

    I am guessing from the casing of the toString() method that this would probably be java. In .net, it would be ToString().


    Yes, it is Java.  And it is not outside the realm of possibility that the programmer imagined that they were supporting internationalization or wanted to be ultra-sure they were getting the string representation of the boolean true.  It's a fairly minor WTF.
  • frzx (unregistered) in reply to Pinguis
    Anonymous:
    sh -- notice its sh not bash -- does this:

    echo $((1+1))
    2

    so the portability issues dont matter. that said, the expr version, is the one recomened by the man page. I assume this was a bash programer forced to use ksh? Remember that ksh inst free (beer of freedom).



    Ah, "I tested on one particular implementation of sh and it worked, therefore portability doesn't matter"

    Nice.

    FYI, Solaris 10 /bin/sh:

    $ echo $((1+1))
    syntax error: `(' unexpected

    Some sh implementations have this feature, some (like Solaris -- bringing you tomorrow's kernel technology with the userland of 1982!) don't. And then there are systems where sh *is* bash...
  • J (unregistered) in reply to R.Flowers

    What?  It went through my spell check just fine...

  • Jon (unregistered) in reply to mlathe
    mlathe:
    as far as i know using expr is the only way to add two numbers in bourne shell (the most portable shell). anyone have a better way?


    I have seen it down as follows:

    nUID=`echo $nUID+1 | bc`

  • mthamil (cs) in reply to Manni
    Manni:
    Anonymous:

    > new Boolean(true).toString()

    What programming language is this by chance? If it's VB then the result could be the localized version of truth, such as "waar" or "verdad" so don't assume it comes out "true".

    http://www.codecomments.com/archive293-2005-1-376910.html

    Of course, this makes it even more of a WTF because I doubt that the SQL query expects "waar".

    What's it good for? Absolutely nothing!

     

    It's not VB. It looks close to VB .Net, but it's not that because the line ends with a semicolon. Maybe C#?



    It's Java.
  • RaelShark (unregistered) in reply to Drakonite
    Drakonite:

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.


    I think it's pretty unlikely this was created by hand. More likely it was server-generated code from some backend system. If someone actually wrote this by hand, then yeah - it's much more of a WTF.
  • Felix (unregistered)
    #!/bin/ksh

    export SLEEP_COUNT=expr $SLEEP_COUNT + 1

    It's not really a WTF. Performing arithmetic with expr is actually standard for bourne shell, since it does not support arithmetic expansion. The way "export" is used in front of the variable is korn shell-ish; in bourne shell, this would read "SLEEP_COUNT=...; export SLEEP_COUNT". So I'd guess that this was a bourne shell programmer who'd switched to korn shell and had already learned that you can export variables in one command, but hadn't learned about arithmetic expansion yet.

    In fact, I frequently write scripts in bourne shell, with expr and whatnot. It's the only shell you can rely on if you're packaging Solaris software.

    Regards, Felix.

  • stevekj (cs) in reply to R.Flowers
    R.Flowers:
    R.Flowers:

     

    Which brings up something I often thing about...

    Yes, quite hilarious. Even worse, I carefully re-read what I type, given the comment's subject matter.



    The hardest posts to get correct are the ones complaining about someone else's spelling!

    I'm pretty sure there are no spelling errors in this wun.

  • shatter (cs) in reply to Jon

    A motivation for "new Boolean(true).toString()" might be an attempt for optimization: the toString() may be perceived as more efficient than creating a new "true" String each time. However, because Java uses String interning, the most optimal solution would be to just write "true". :)

  • beinsane (unregistered) in reply to frzx
    Anonymous:
    Anonymous:
    sh -- notice its sh not bash -- does this:

    echo $((1+1))
    2

    so the portability issues dont matter. that said, the expr version, is the one recomened by the man page. I assume this was a bash programer forced to use ksh? Remember that ksh inst free (beer of freedom).



    Ah, "I tested on one particular implementation of sh and it worked, therefore portability doesn't matter"

    Nice.

    FYI, Solaris 10 /bin/sh:

    $ echo $((1+1))
    syntax error: `(' unexpected

    Some sh implementations have this feature, some (like Solaris -- bringing you tomorrow's kernel technology with the userland of 1982!) don't. And then there are systems where sh *is* bash...


    $(()) is part of the POSIX shell standard.  Sun, in their infinite wisdom, ships a perfectly POSIX-compliant shell as /usr/xpg4/bin/sh, keeping the old untouched-since-1982 Bourne shell in /bin/sh apparently for backwards compatibility.

    This is all a moot point, of course, because the script says ksh, and ksh has always had this feature.  (Lack of such a feature in the original Bourne shell was part of the inspiration for writing ksh in the first place.)
  • WTF Batman (cs)
    Alex Papadimoulis:


    This is bad for a couple reasons. First, the programmer doesn't know how to increment variables in shell, which isn't such a big deal in and of itself. Every shell is different, and ksh and the other older shells are WTFs unto themselves, anyway.

    Unfortunately, instead of typing 'man ksh' and looking for the section on arithmetic, he chose to spawn a subprocess to evaluate the expression and store the output of the subshell into the variable.

    I'm not overly familiar with ksh myself, but it took me about 30 seconds to find how to do this from the man page:

    let VAR=1
    echo $VAR  # prints 1
    let VAR=$VAR+1
    echo $VAR # prints 2

    No big deal, and no overhead of spawning subprocesses for silly evaluations.  Sadly, it probably took him longer to figure out this approach than it would have to read the correct way from the man page.


  • ArikTheRed (unregistered) in reply to shatter
    shatter:
    A motivation for "new Boolean(true).toString()" might be an attempt for optimization: the toString() may be perceived as more efficient than creating a new "true" String each time. However, because Java uses String interning, the most optimal solution would be to just write "true". :)
    If the programmer was really doing it to be optimized, then
    why not just do the static Boolean.TRUE.toString() and save yourself an object creation? Oh right, because the programmer obviously doesn't know what s/he's doing.
  • WTF Batman (cs) in reply to Drakonite
    Drakonite:

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.



    It also occurrs to me that this is one way to make sure javascript is turned on. I use NoScript in FireFox, and come across plenty of pages that use links like this to force you to enable JS. That, or they're just idiots.
  • elmegil (unregistered) in reply to frzx

    Hey now, Solaris has ksh and bash, and you should know if you have 10 that it has GNOME too.

    But let's not get into ksh vs ksh93 :-)

  • Russ (unregistered) in reply to Whiskey Tango Foxtrot? Over.
    Anonymous:
    The next two lines of code took Christophe Beugnet hours and hours to correct. Who would have guessed that a supplier would have modified a header with this?

    <font size="-0">#define</font> false 1
    <font size="-0">#define</font> true 0
    Heh.... I'm guessing evil exiting former-programmer. [:)]


    Actually, I reckon this is from code that heavily used the strcmp family of functions - they return 0 if two strings are equal, so you end up with a lot of code like if(strcmp(str1, str2) == 0) all over the place (yes, I know you shouldn't use strcmp anyway, but bear with me). These funky defines would let you write if(strcmp(str1, str2) == true) which is slightly more readable - at the expense of making the rest of your code an impenetrable nightmare.
  • Stevie (unregistered) in reply to WTF Batman

    I'm not sure exactly why this guy/girl decided to use the onclick event to open a link, however there are some differences that may have justified the logic.

    1.) Events can't be cancelled by the user, like links can (e.g. pressing ESC, or the STOP button)
    2.) Developer may have wanted to "hide" the url... although I don't know why
    3.) They may have done all links like this, but with some adding more JS... conditions etc.
    4.) Ditto 3, if it was generated code
    5.) They may have done some link tracking, that isn't apparent now... or was removed...
    6.) Or, yeah, just plain old WTF!?

  • Cowboy Bob (unregistered) in reply to shatter
    shatter:
    A motivation for "new Boolean(true).toString()" might be an attempt for optimization: the toString() may be perceived as more efficient than creating a new "true" String each time. However, because Java uses String interning, the most optimal solution would be to just write "true". :)


    It wouldn't be optimisation as that would be Boolean.TRUE.toString() so you use the global static instance of true and don't create a new Boolean object. However, you're right that "true" would be even better. But then again, I shudder to think how bad a piece of software could be if optimising this kind of thing would make a difference. That or they need to upgrade their 386...
  • Ralph the parrot (unregistered)
    Alex Papadimoulis:

     

    Pure Evil.
    This is so wonderfully evil.
    It reminds me of the time I intentionally hid some code by indenting it into the horizon.

  • cvi (unregistered) in reply to Russ
    Anonymous:
    Anonymous:
    The next two lines of code took Christophe Beugnet hours and hours to correct. Who would have guessed that a supplier would have modified a header with this?

    <font size="+0">#define</font> false 1
    <font size="+0">#define</font> true 0
    Heh.... I'm guessing evil exiting former-programmer. [:)]


    Actually, I reckon this is from code that heavily used the strcmp family of functions - they return 0 if two strings are equal, so you end up with a lot of code like if(strcmp(str1, str2) == 0) all over the place (yes, I know you shouldn't use strcmp anyway, but bear with me). These funky defines would let you write if(strcmp(str1, str2) == true) which is slightly more readable - at the expense of making the rest of your code an impenetrable nightmare.


    On the other hand, writing

    if( strcmp( str1, str2 ) == false )

    is a nice way to shoot yourself in your foot.
  • Russ (unregistered) in reply to cvi
    Anonymous:
    Anonymous:
    Anonymous:
    The next two lines of code took Christophe Beugnet hours and hours to correct. Who would have guessed that a supplier would have modified a header with this?

    <font size="-0">#define</font> false 1
    <font size="-0">#define</font> true 0
    Heh.... I'm guessing evil exiting former-programmer. [:)]


    Actually, I reckon this is from code that heavily used the strcmp family of functions - they return 0 if two strings are equal, so you end up with a lot of code like if(strcmp(str1, str2) == 0) all over the place (yes, I know you shouldn't use strcmp anyway, but bear with me). These funky defines would let you write if(strcmp(str1, str2) == true) which is slightly more readable - at the expense of making the rest of your code an impenetrable nightmare.


    On the other hand, writing

    if( strcmp( str1, str2 ) == false )

    is a nice way to shoot yourself in your foot.


    You're referring, I think, to the fact that srcmp might return -1, so the false test would fail. Good point. Perhaps this is where one of those famous tri-bools that show up so often could be used? Something like if(strcmp(str1, str2) == FILE_NOT_FOUND)
  • ptomblin (cs) in reply to WTF Batman
    WTF Batman:

    Unfortunately, instead of typing 'man ksh' and looking for the section on arithmetic, he chose to spawn a subprocess to evaluate the expression and store the output of the subshell into the variable.


    I don't know if you noticed the variable name?  It was "SLEEP_COUNT".  If you're calculating how many times you've done a sleep(1), or you're calculating how long to sleep(1) the next time, the couple of extra milliseconds that doing the calculation this way hardly matters in the long run.

    WTF Batman:

    Sadly, it probably took him longer to figure out this approach than it would have to read the correct way from the man page.

    Not if he did it that way because that's the way he's been doing it since real live Bourne shell sh was the only shell in the world.  I don't do math in shell scripts much (because if I need to do math, the script probably should be in perl), but when I do, I do increments that same way.
  • makomk (cs) in reply to WTF Batman
    WTF Batman:
    Drakonite:

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.



    It also occurrs to me that this is one way to make sure javascript is turned on. I use NoScript in FireFox, and come across plenty of pages that use links like this to force you to enable JS. That, or they're just idiots.

    I wonder if someone's written a Greasemonkey script to spot the most common forms of this and rewrite them to normal hyperlinks? Probably, I expect. (Unfortunately, being a Konqueror user I have no equivalent to Greasemonkey available).

  • OneFactor (cs) in reply to WTF Batman
    WTF Batman:
    Drakonite:

    &lt;a href="#" onclick="location='http://www.sun.com'; return false;"&gt;


    Ugh, unfortunatly I see that crap all the time. It just goes to show, web monkeys should NOT be considered programmers...
    I feel generous calling them monkeys.




    It also occurrs to me that this is one way to make sure javascript is turned on. I use NoScript in FireFox, and come across plenty of pages that use links like this to force you to enable JS. That, or they're just idiots.

    Very interesting theory about making sure javascript is on. Maybe this isn't a WTF after all...

Leave a comment on “A Friday Mixer”

Log In or post as a guest

Replying to comment #:

« Return to Article