• (cs)

    Blink.

  • Vollhorst (unregistered)

    public static final char[] FILENOTFOUND = {'F','i','l','e',' ','n','o','t',' ','f','o','u','n','d'}; is missing!

  • (cs)

    I see the WTF. public static final char[] NaN = {'N','a','N'}; should be: public static final byte[] NaN = {'N','a','N'};

  • SlyEcho (unregistered)
    switch(pstring.length)
            {
                case 1:
                    return pstring[]PSTRING_SIZE_OFFSET] == 0;
                case 16 < 0:
    

    How does it even compile, can you switch on booleans and ints at the same time? It would work in C but in Java?

    Or is it just a typo?

  • (cs)

    Oh My Lack Of God...

  • (cs) in reply to SlyEcho
    SlyEcho:
    Or is it just a typo?

    Yes, it is; look at the other cases. It's probably meant to be 16 << 0, though why anyone would type such a thing is beyond me.

  • wtf (unregistered)

    WTF?

  • Ben Blok (unregistered) in reply to wtf
    wtf:
    WTF?
    QFT
  • J. Walter Weatherman (unregistered)

    That's brilliant as I drop a massive shit.

  • Christian Vogel (unregistered) in reply to Vollhorst
    Vollhorst:
    public static final char[] FILENOTFOUND = {'F','i','l','e',' ','n','o','t',' ','f','o','u','n','d'};

    No, that would be {14,'F','i','l','e',' ','n','o','t',' ','f','o','u','n','d'}.

  • {'M','y',' ','N','a','m','e'} (unregistered)

    So how often do they convert the MIN_INT_VALUE string to a number in a typical application, so they could compare other numbers to it?

  • (cs)

    My brain hurts! (Mmmm Braaains)

  • M (unregistered) in reply to SlyEcho
    SlyEcho:
    How does it even compile, can you switch on booleans and ints at the same time? It would work in C but in Java? Or is it just a typo?
    You're right, the implicit boolean to integer conversion does not work in Java. And that "pstring[]PSTRING_SIZE_OFFSET]" part is also great.
  • Zied (unregistered)

    WTF ?

  • anonymous (unregistered)

    Why are chars [a-z] in in the char array intDigits? Is this being used for Base36?

    The rest of the WTFs just look like someone having no idea how to code... at least in Java (or probably any newer-generation languages). This has the earmarks of an old-school mainframe coder.

  • M.L. (unregistered)

    It would be nice to know the context of this code.

    It may be a part of some kind simulation of abstract machine or processor where those constructs make much more sense.

  • Proko (unregistered)

    It hurts, it physically hurts. Why, why would anyone do THAT???

  • Martin (unregistered) in reply to M.L.
    M.L.:
    It would be nice to know the context of this code.

    It may be a part of some kind simulation of abstract machine or processor where those constructs make much more sense.

    Simulation of Brillant Paula's brain? Now it makes sense!

  • SlyEcho (unregistered)

    Well if it had been written in C#, it would look much simpler because instead of

    private final static char[] intDigits =
       {'0' , '1' , '2' , '3' , '4' , '5' ,
       '6' , '7' , '8' , '9' , 'a' , 'b' ,
       'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
       'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
       'o' , 'p' , 'q' , 'r' , 's' , 't' ,
       'u' , 'v' , 'w' , 'x' , 'y' , 'z' };
    

    you can just write:

    private const string intDigits = "0123456789abcdefghijklmnopqrstuvwxyz";
    
    </Troll>
  • Ilya Ehrenburg (unregistered)

    My eyes! The goggles do nothing! Really, that hurts.

  • Steve (unregistered) in reply to anonymous
    anonymous:
    The rest of the WTFs just look like someone having no idea how to code... at least in Java (or probably any newer-generation languages). This has the earmarks of an old-school mainframe coder.
    Hey! I resemble that remark! (Started in the middle 1960s when punched cards were all the rage and we didn't need any newfangled text editors, green screens, or operating systems -- just put the compiler deck in the hopper, slap the source code deck on top, and press "START".)

    But, yeah, seriously, WTF? I'd really like to know the context of this project. Maybe it was a class assignment of some sort.

  • (cs)

    I don't suppose anyone could tell me what the hell this is supposed to do?

  • abigo (unregistered) in reply to SlyEcho
    SlyEcho:
    Well if it had been written in C#, it would look much simpler because instead of
    private final static char[] intDigits =
       {'0' , '1' , '2' , '3' , '4' , '5' ,
       '6' , '7' , '8' , '9' , 'a' , 'b' ,
       'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
       'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
       'o' , 'p' , 'q' , 'r' , 's' , 't' ,
       'u' , 'v' , 'w' , 'x' , 'y' , 'z' };
    
    you can just write:
    private const string intDigits = "0123456789abcdefghijklmnopqrstuvwxyz";
    
    </Troll>
    could have been char[] thingie = "string".toCharArray();
  • diaphanein (unregistered)

    This is purely an experiment in entropy.

  • (cs)

    I'd really like to comment something witty and intelligent, but clearly I lack the cerebral capabilities to fully appreciate and comprehend the genius at work here. Someday.. someday..

  • Mark (unregistered)

    Even my code isn't that f*cked up.

    Seriously, as somebody who left programming eight years ago for a systems analyst role, I'd forgotten this simple truth about development in many corporate environments: Incompetence is immortal.

    What I mean by that is that in most other functions, when something is built/done by somebody who is truly incompetent it will usually be replaced or repaired. But when it happens in development (and bad code makes it into production) it takes on a life of its own because nobody wants to touch the code (and rightly so).

  • Reuben (unregistered) in reply to SlyEcho

    In java you could write:

    private final static char[] intDigits = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
  • Easter Bunny (unregistered)

    Hmmm.

    I think this is the 14th Sign of the Apocalypse.

  • Tom Woolf (unregistered)

    I wonder how many weeks he/she got off for worker's comp after their carpal tunnel surgery...

  • Fraggle My Rock (unregistered) in reply to SlyEcho
    SlyEcho:
    Well if it had been written in C#, it would look much simpler because instead of
    private final static char[] intDigits =
       {'0' , '1' , '2' , '3' , '4' , '5' ,
       '6' , '7' , '8' , '9' , 'a' , 'b' ,
       'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
       'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
       'o' , 'p' , 'q' , 'r' , 's' , 't' ,
       'u' , 'v' , 'w' , 'x' , 'y' , 'z' };
    
    you can just write:
    private const string intDigits = "0123456789abcdefghijklmnopqrstuvwxyz";
    
    </Troll>

    Pffft. You're being silly.

  • SomeCoder (unregistered) in reply to Ilya Ehrenburg
    Ilya Ehrenburg:
    My eyes! The goggles do nothing! Really, that hurts.

    2nd.

    This is just... GAH!

  • Konrads (unregistered)

    Just brilliant. This has got to be the best WTF: Programmer gave it a thought and dedicated considerable effort just to do something utterly wrong.

  • (cs)

    But why? Oh my! Why? WTF?!? Please, someone slap this person out of programming. I mean, this person and ALL of his team mates, because someone had to read THAT on a CVS/SVN changes email.

  • MeRp (unregistered) in reply to DOA
    DOA:
    I don't suppose anyone could tell me what the hell this is supposed to do?

    Ok, keep in mind that I'm only going to give a brief description of what this is supposed to do, not a) what it actually does nor b) why they did it.

    In Pascal strings, instead of being null terminated (like in C e.g. c-strings), instead always have the length of the string as the first element of the array. This collection of what can only (and loosely at that) be referred to as "java statements" appears to be an attempt to implement this in java, perhaps so as to somehow interact with Pascal... for some reason.

  • Maks Verver (unregistered) in reply to MeRp
    In Pascal strings, instead of being null terminated (like in C e.g. c-strings), instead always have the length of the string as the first element of the array.
    The irony of course, is that in Java an array of characters is the same thing.
    This collection of what can only (and loosely at that) be referred to as "java statements" appears to be an attempt to implement this in java, perhaps so as to somehow interact with Pascal...
    That almost make sense. Doesn't really explain the huge look-up tables though, and why the switch isn't just implemented like this:
    switch(pstring.length)
    {
    case 1:
    case 16 << 0:
    case 16 << 1:
    case 16 << 2:
    case 16 << 3:
    case 16 << 4:
    case 16 << 5:
    case 16 << 6:
    case 16 << 7:
    case 16 << 8:
    case 16 << 9:
    case 16 << 10:
    case 16 << 11:
    case 16 << 12:
        return pstring[PSTRING_SIZE_OFFSET] < pstring.length;
    default:
        return false;
    }

    Or even shorter (although a bit more complicated):

    int n = pstring.length;
    return (n == 1 || (n >= 16 && n <= 65536 && (n&(n-1)) == 0)) && pstring[0] < n;

    I don't see the point of making PSTRING_SIZE_OFFSET a constant if your code will only ever work if it is set to zero (the empty-string case).

  • FluffGrrl (unregistered) in reply to SlyEcho

    Yo' C-pound ain't no array like tha Java be. Go home.

  • Smash (unregistered)

    public static final char[] SMART_COMMENT = {'S','m','a','r','t',' ','C','o','m','m','e','n','t'};

  • (cs) in reply to Someone You Know
    Someone You Know:
    Oh My Lack Of God...
    Congrats, you're the theological version of this guy.
  • (cs) in reply to Steve
    Steve:
    anonymous:
    The rest of the WTFs just look like someone having no idea how to code... at least in Java (or probably any newer-generation languages). This has the earmarks of an old-school mainframe coder.
    Hey! I resemble that remark! (Started in the middle 1960s when punched cards were all the rage and we didn't need any newfangled text editors, green screens, or operating systems -- just put the compiler deck in the hopper, slap the source code deck on top, and press "START".)
    So they not only looked like washing machines, but worked like them?
  • Smash (unregistered)

    On regard to the DigitTens and DigitOnes arrays, the bloke obviously wanted to do something like this (I'll do it in C because it's been a while since I last touched any java):

    //current value of n = 73
    int n1 = DigitOnes[n]; // n1 = 3
    int n10 = DigitTens[n];// n10 = 7
    I wonder what will happen when the need to check for hundreds or even thousands arise. It probably will result in tendinitis

  • (cs) in reply to Mark
    Mark:
    Even my code isn't that f*cked up.

    Seriously, as somebody who left programming eight years ago for a systems analyst role, I'd forgotten this simple truth about development in many corporate environments: Incompetence is immortal.

    What I mean by that is that in most other functions, when something is built/done by somebody who is truly incompetent it will usually be replaced or repaired. But when it happens in development (and bad code makes it into production) it takes on a life of its own because nobody wants to touch the code (and rightly so).

    More to the point, this is a work of art. Would you re-shape the smile on the Mona Lisa? Would you paint a smiley face on Munch's "The Scream?" Would you edit the captions for Mandatory Fun Day?

    If I came across this in production code, I would refuse to edit it on aesthetic grounds (well, maybe retouch it so that it compiles, but that's it). I'd rather refactor all the other code that depends on it, to make inferior stuff work.

  • Nigel (unregistered)

    I'm glad to see that MIN_INT_VALUE goes to ELEVEN!

    final static char[] MIN_INT_VALUE =
       { 11, '-', '2', '1', '4', '7', '4', '8', '3', '6', '4', '8' };
    Nigel: You see, most blokes will be playing at 10. You’re on 10, all the way up, all the way up...Where can you go from there? Nowhere. What we do, is if we need that extra push over the cliff...Eleven. One louder.

    DiBergi: Why don’t you just make 10 louder and make 10 be the top number, and make that a little louder?

    Nigel: These go to 11

    If I had to maintain this code I would definitely be looking for a cliff...

  • iddJoe (unregistered) in reply to DOA
    I don't suppose anyone could tell me what the hell this is supposed to do?

    Who cares? It's Pretty :)

  • (cs) in reply to operagost
    operagost:
    <bait tempting="false"> Congrats, you're the theological version of this guy. </bait>

    Fixed that for you. ;)

  • Anthony (unregistered)

    I like how each function is bracketed with }; because that's the face I make when I'm reading this WTF.

  • (cs)

    Oh.

    My.

    I tried gouging out mine eyes, and it didn't work. They still burn.

    Wait. No. Mace. Mace'll do that to you.

    Heed well, young Jedi: not even Mace can take away the pain of bad code.

  • DiBergi (unregistered) in reply to Nigel

    Actually, the MIN_INT_VALUE doesn't go up to anything. They're using the 11 to tell you how many characters in the string '-2147483648', which is the minimum signed number in a 4 byte representation. That is why the other solutions about just initializing to a string won't work as this appears to have a requirement that the first 'char' actually be a number indicating how many more characters are in the string.

    That being said, my amp goes to 12...

  • Gumby (unregistered)

    I hate it when I have to write code like that. I wish someone would invent a computer that could do arithmetic.

  • 0xbaadf00d (unregistered)

    What kills me is that DigitTens and DigitOnes are only useful if indexed mod 100.

    If the table is only useful if indexed mod 100, can I assume the author's knowledge of mod 100?

    If the author knows how to mod 100, can I assume the author's knowledge of div 100?

    If the author knows how to mod and div, then why, oh, why the arrays of digits?

  • foo (unregistered) in reply to operagost
    operagost:
    Steve:
    anonymous:
    The rest of the WTFs just look like someone having no idea how to code... at least in Java (or probably any newer-generation languages). This has the earmarks of an old-school mainframe coder.
    Hey! I resemble that remark! (Started in the middle 1960s when punched cards were all the rage and we didn't need any newfangled text editors, green screens, or operating systems -- just put the compiler deck in the hopper, slap the source code deck on top, and press "START".)
    So they not only looked like washing machines, but worked like them?

    Not only that, but when your code didn't work you could literally shuffle it around until it did.

    In FORTRAN we always used the same variable names. That way, when you needed to add a line of code, you might already have it in one of your other programs so you could just dig through your old decks and find it. Saved waiting for a free 029.

    We could put a lot of FORTRAN WTFs up here, but it would be shooting fish in a barrel.

Leave a comment on “Pascal Strings”

Log In or post as a guest

Replying to comment #:

« Return to Article