• (cs) in reply to jimlangrunner
    jimlangrunner:
    pink_fairy:
    snip. No -- TRWTF is the choice of language, as always (insert flame here). snip.
    No -- TRWTF is the choice of language, as always (FLAMEFLAMEFLAMEFLAMEFLAME).
    ITYM :
    Call GetFlame(4)
    Line = flame4
    Line = 'No -- TRWTF is the choice of language, as always '
    Line = Line  & '(FLAMEFLAMEFLAMEFLAMEFLAME)'
    
    FTFY HTH !
  • (cs) in reply to Jeremy
    Jeremy:
    Throw some Perl at it:

    $spaces = " " x $num_of_spaces;

    31 chars, including variable names. Done.

    Ruby:

    spaces = " " * num_of_spaces

    28 chars including variable names.

  • Anonymous (unregistered) in reply to derula
    derula:
    Jeremy:
    Throw some Perl at it:

    $spaces = " " x $num_of_spaces;

    31 chars, including variable names. Done.

    Ruby:

    spaces = " " * num_of_spaces

    28 chars including variable names.

    better:

    spaces = ' ' * num_of_spaces

    Still 28 characters, but uses fewer pixels.

  • A Gould (unregistered)

    That's not a WTF - that's job security, right there. Code so gawd-awful that your replacement will run screaming, forcing your employer to hire you back at a substantial increase.

  • Maks Verver (unregistered) in reply to Jeremy

    Python and Ruby do this too.

    But Python's version makes the most sense since is and si (with s a string and i an integer) yield the same result, while the i*s form doesn't work in either Perl or Ruby, even though they suggest commutativity by using a symbol normally used for multiplication.

  • appalled (unregistered) in reply to Daid
    Daid:
    Simple because "space()" was not fancy enough: http://msdn.microsoft.com/en-us/library/k6ethaxs.aspx

    Returns a string consisting of the specified number of spaces.

    http://msdn.microsoft.com/en-us/library/kthanxs.aspx

  • Pepper (unregistered) in reply to Dennis
    Dennis:
    What we need is a language with a compile-time garbage collector!
    I thought VB already collects all the garbage programming-time!
  • ell0bo (unregistered) in reply to Neil

    He also spent that entire week making changes to his code section. So to roll back all the changes would have broken his code, and wasted the entire week he spent on it. Now it's his little section of code, and the entire system. I only managed to contain his code, not destroy it.

  • joe (unregistered)

    Too cool to use the String(n , " ") function?

    Reinvent reinvent reinvent

  • (cs) in reply to Maks Verver
    Maks Verver:
    Python and Ruby do this too.

    But Python's version makes the most sense since is and si (with s a string and i an integer) yield the same result, while the i*s form doesn't work in either Perl or Ruby, even though they suggest commutativity by using a symbol normally used for multiplication.

    Well, that's nice to know.

    Here at TDWTF, we're always up for fresh insight.

    No Soup For You!

  • (cs) in reply to Maks Verver
    Maks Verver:
    But Python's version makes the most sense since i*s and s*i (with s a string and i an integer) yield the same result, while the i*s form doesn't work in either Perl or Ruby, even though they suggest commutativity by using a symbol normally used for multiplication.

    I guess you don't have to deal with quaternions a lot then.

  • Fast Eddie (unregistered) in reply to Code Dependent
    Code Dependent:
    Capt. Kirk:
    As a customer your choices are:
    1. Hire an experienced competent developer who understands the library functions, knows how to write properly structured code with appropriate variable scope and data types, or

    2. Hire someone who will produce what appears to be exactly the same output.

    As a customer who doesn't happen to be a developer himself, the above two options translate as:

    1. Hire an expensive expensive expensive who expensive the expensive expensive, knows how to write expensive expensive code with expensive expensive expensive and expensive expensive, or

    2. Save a bunch of money and get exactly the same thing.

    3. Save a bunch of money and get what looks like exactly the same thing, and spend the next five years constantly hiring cheap consultants to come in and appear to fix what's wrong.
    For the attempt to leverage the humor of Capt. Kirk as a means to make your own funny, I must award you the fail prize. Congratulations. Go pick up your prize at the web-site next door.

  • Maks Verver (unregistered) in reply to derula

    Fair point; an even more common example might be (general) matrix multiplication.

    Still, allowing 3 * 'foo' and 'foo' * 3 to evaluate to the same result seems more sensible to me, since 3 isn't a quaternion or a matrix here, but just a simple integer. This seems more in line with the principle of least astonishment, although I'll admit this is a bit subjective.

    (The problem with Perl of course, is that the language doesn't distinguish between integers and strings but regards both as scalar values, so the interpreter only considers the positions of the arguments to decide which one is a string and which one is a number, and as a result 1x'foo' yields an empty string. Not very obvious at first glance, in my opinion.)

  • Rocco (unregistered) in reply to jimlangrunner
    jimlangrunner:
    Looks like BBx to me. MY EYES! THEY ARE BLEEDING!
    HOLY SMOKES! Yep... both MAI and Basis Intl versions. ick.
  • 01001001011101000010011101110011001000000110110101100101 (unregistered) in reply to Capt. Kirk
    Capt. Kirk:
    As a customer your choices are:
    1. Hire an experienced competent developer who understands the library functions, knows how to write properly structured code with appropriate variable scope and data types, or

    2. Hire someone who will produce what appears to be exactly the same output.

    As a customer who doesn't happen to be a developer himself, the above two options translate as:

    1. Hire an expensive expensive expensive who expensive the expensive expensive, knows how to write expensive expensive code with expensive expensive expensive and expensive expensive, or

    2. Save a bunch of money and get exactly the same thing.

    This reminds me of a story:

    Two penny-pinching executives (we'll call them Bill and Ted) need to drive across the country for a conference (just go with me here...) Bill purchases a new Honda Accord for the drive. It's a nice call, but not too fancy. It cost him $28000. Ted says to Bill, "A new Honda! What a waste, you pay too much for the name, you loose money as soon as you drive it off the lot!" Ted then purchased a 12 year old used car for $2000.

    After the first 200 miles Ted needed new tires. "Part of the maintenance of a car" he said. The tires cost $400. After another 200 miles Ted's car broke down. He needed new water pump. Including the towing charge, the water pump cost $600 and Ted was now a full day behind his driving schedule. After another 600 miles Ted needed brake repairs. Cost, $350. "Part of the maintenance of a car," he said.

    This continued for many days and Ted's driving schedule slipped again and again. Finally Ted arrived at his destination, where he met up with Bill again.

    "So Bill," said Ted, "we're both here, and I only spent a fraction of the cost on my car as you did!"

    "Well, that's true," said Bill. "I estimate between the cost of the car, and the cost of gas, and the oil change I needed, I spent around $30000."

    "Ah-ha!" Said Ted, "I had to do more work on my car than you, and spent more on gas too, but at the end, I spent $25000 on the car, gas and maintenance."

    "That's great for you Ted." Said Bill.

    But what Bill did not tell Ted was that since he was late to the conference four of his customers now signed on with Bill. Also Bill's car was still in great shape and he was able to keep using it for several more years without requiring any major work.

    Ted, on the other hand, had more car trouble on his way home. He finally had to abandon the old car, and purchased another $2000 used car to get him the rest of the way home. That car also required a few trips to the mechanic on the way. "Part of the maintenance of a car," Ted said.

  • Kelly (unregistered)

    There's something with spaces. A few weeks ago, I found this function...


    Public Function Spaces()

    Dim sSpace As String

    sSpace = " " ' 50 spaces 'default 50 spaces

    Return sSpace End Function


    And it was used like this Spaces() + Spaces() + Spaces()

  • Kelly (unregistered) in reply to Kelly

    Silly comments! SSpace is actually a string that's 50 spaces

  • (cs)
    I found this interesting set of global variables.
    Private space1, space2, space3, space4, space5, _
            space6, space7, space8, space9, space10, _
            space100 As String
    

    But um with the private access specifier in front of the variable declarations it's actually a set of private class variables not that this makes this craptastic code any better mind you...

  • (cs) in reply to 01001001011101000010011101110011001000000110110101100101
    01001001011101000010011101110011001000000110110101100101:
    This reminds me of a story:

    Two penny-pinching executives (we'll call them Bill and Ted) need to drive across the country for a conference (just go with me here...) Bill purchases a new Honda Accord for the drive. It's a nice call, but not too fancy. It cost him $28000. Ted says to Bill, "A new Honda! What a waste, you pay too much for the name, you loose money as soon as you drive it off the lot!" Ted then purchased a 12 year old used car for $2000.

    […]

    Meanwhile, a third guy called Rufus (an engineer by training, obviously) takes the time machine, errr, plane at a cost of a few hundred bucks, even allowing for the hire car at the other end. And he saved a lot of time too while those other two losers were stuck on the interstate. (Excellent!)

    The moral of this? While penny-pinching can obviously make things worse, sometimes it is best to take a step back from the immediate task and work out what the actual goal is so that you can go for the right solution.

  • Americium (unregistered) in reply to Max
    Max:
    Even QuickBasic had a function to make spaces...

    Space$(i%)

    6502 Assembler has one too. Just loop through screen memory & write space characters. Memory starts at $4000 in this example.

    2000 LDY #$0A 2002 LDA #$20 2004 STA $4000, Y 2006 DEY 2008 BNE 2000

    Y-register is the loop counter, starting a 10 spaces (hex 0A), counting down. The Accumlator holds SPACE (hex 20) to be written to memory. The SPACES array starts a memory location hex 4000. The built-in SPACES(#) probably does this.

    Storing the spaces as constant arrays is wasteful in any era.

  • (cs) in reply to Maks Verver
    Maks Verver:
    Fair point; an even more common example might be (general) matrix multiplication.

    Still, allowing 3 * 'foo' and 'foo' * 3 to evaluate to the same result seems more sensible to me, since 3 isn't a quaternion or a matrix here, but just a simple integer. This seems more in line with the principle of least astonishment, although I'll admit this is a bit subjective.

    (The problem with Perl of course, is that the language doesn't distinguish between integers and strings but regards both as scalar values, so the interpreter only considers the positions of the arguments to decide which one is a string and which one is a number, and as a result 1x'foo' yields an empty string. Not very obvious at first glance, in my opinion.)

    You're being a bit unfair to Perl there. It's got scalars, it's got lists (with an awful auto-flattening implementation, I grant you), and it's got hashes. I mean, what more could you want?

    Quaternions? They're, like, so Nineteenth Century.

    I'd argue that Perl does precisely what you want here -- "the principle of least astonishment." I believe Larry puts it differently ... something along the lines of "Perl always tries to guess what you actually meant."

    Now. If you're dealing with quaternions, would you rather have an empty string? Or would you rather have the abortion shown in the OP?

    Perl5: Strings are everything. And there's nothing you can't do unless you're incapable of writing a suitable regexp.

    Perl6: Superstrings -- coming to your neighborhood real soon! Superstrings spit on your quaternions! Also, check out the new Norris::Chuck module.

  • (cs) in reply to Code Dependent
    Code Dependent:
    <snip/>C rap
    Hell, yes!.

    The world would be better with background music provided by C-Rap. I can't understand why those '60s guys at Dartmouth didn't get this fairly obvious point.

    But this is 2009. What we need in 2009 is Saran-Rap ... transparency is everything.

  • (cs) in reply to 01001001011101000010011101110011001000000110110101100101
    01001001011101000010011101110011001000000110110101100101:
    <snip>Ted</snip>
    01001001011101000010011101110011001000000110110101100101, I can see you on Google Earth. We really do know where you live. And, believe me, we will use this information.

    What you need, my man, is Base64. Preferably twice.

    Also, I believe you've got the thirteenth nibble wrong. Time to upgrade to VB5.

  • mjc (unregistered) in reply to ell0bo

    sounds like you need a little git ;)

  • ratchetr (unregistered) in reply to Americium
    Americium:
    Max:
    Even QuickBasic had a function to make spaces...

    Space$(i%)

    6502 Assembler has one too. Just loop through screen memory & write space characters. Memory starts at $4000 in this example.

    2000 LDY #$0A 2002 LDA #$20 2004 STA $4000, Y 2006 DEY 2008 BNE 2000

    My 6502 is a bit rusty, but that looks like an infinite loop to me. You probably wanted: 2008 BNE 2004
    Storing the spaces as constant arrays is wasteful in any era.
    Perhaps. But if the choice is squandering 10 bytes of garbage collectible memory, or having to debug a hang caused by an infinite loop, I'll squander the memory every time. An inefficient solution is infinitely faster than an infinite loop.
  • (cs) in reply to Maks Verver
    Maks Verver:
    Fair point; an even more common example might be (general) matrix multiplication.
    Well I was thinking quaternions because if x and y are quaternions, x*y and y*x are both defined. This is not always (well, rarely to be exact) true for matrices.
    Maks Verver:
    Still, allowing 3 * 'foo' and 'foo' * 3 to evaluate to the same result seems more sensible to me, since 3 isn't a quaternion or a matrix here, but just a simple integer.
    While I don't know about Perl, in Ruby i*s doesn't make much sense in an object oriented point of view, seeing that * is a method of Integer here. Integer#* would then perform differently on different kinds of arguments, which seems rather odd. String#* will only have to check if the argument passed is an Integer...

    Edit: Also:

    class Integer
      alias old_mult *
      def *(var)
        if var.is_a? String
          var * self
        else
          old_mult(var)
        end
      end
    end
  • pbean (unregistered) in reply to Maks Verver
    Python and Ruby do this too.

    But Python's version makes the most sense since is and si (with s a string and i an integer) yield the same result, while the i*s form doesn't work in either Perl or Ruby, even though they suggest commutativity by using a symbol normally used for multiplication.

    It's a method of the string class, so basically: s.multiply(i), which makes sense as you are multiplying a certain string i times. However i.multiply(s) doesn't make that much sense (in my eyes). Also, an asterisk isn't normally used 'irl' for multiplication (just in programming and computers) so the commutativity applies less than you might suggest.

    What we need is a language with a compile-time garbage collector!

    VB is the garbage collector: you type in your code and... there you have it, the garbage!

  • ass-laminate (unregistered) in reply to mjc
    mjc:
    sounds like you need a little git ;)
    But I am a little git!
  • (cs) in reply to randomlyVarying
    randomlyVarying:
    Obviously, this guy should learn the mother of all programming languages:

    http://en.wikipedia.org/wiki/Whitespace_(programming_language)

    Now I know why M$ Office includesa function to show all whitespace characters.. it's M$'s editor :P which would also explain the bugs featured in every software they create..

  • Mozzis (unregistered) in reply to Rocco

    A$=A$+Left(Spaces$, Len(A$)-60)) might be better

  • (cs)

    The WTF originator didn't push the concept far enough. It was disappointing to see him give up after defining space1 through space10 and space100 and then rely on GenerateSpaces() for those odd numbers when he could have defined spaces11 through, say, spaces1000.

    That's a lot of typing though. Clearly, dynamic type generation is the way to go:

    Public Shared Function GetSpacesType() As Type
    
        Dim pointlessAssyName As New AssemblyName("PointlessStringLibrary")
        Dim pointlessAssyBldr As AssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(pointlessAssyName, AssemblyBuilderAccess.Run)
        Dim pointlessModBldr As ModuleBuilder = pointlessAssyBldr.DefineDynamicModule(pointlessAssyName.Name)
        Dim spacesTypeBldr As TypeBuilder = pointlessModBldr.DefineType("Spaces", TypeAttributes.Public)
    
        Dim spacesCtorBldr As ConstructorBuilder = spacesTypeBldr.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, Nothing)
        spacesCtorBldr.GetILGenerator().Emit(OpCodes.Ret)
        Dim staticCtorGen As ILGenerator = spacesStaticCtorBldr.GetILGenerator()
    
        Dim spacesStaticCtorBldr As ConstructorBuilder = spacesTypeBldr.DefineConstructor(MethodAttributes.Private Or MethodAttributes.RTSpecialName Or MethodAttributes.HideBySig Or MethodAttributes.Private Or MethodAttributes.Static, CallingConventions.Standard, Nothing)
    
        Dim i As Integer
        Dim fieldValue As String = ""
    
        For i = 0 To 1000
    
            fieldValue += " "
            
            Dim spacesFldBldr As FieldBuilder = spacesTypeBldr.DefineField("Spaces" & i.ToString(), _
                GetType(String), FieldAttributes.Public Or FieldAttributes.Static Or FieldAttributes.InitOnly)
    
            staticCtorGen.Emit(OpCodes.Ldstr, fieldValue)
            staticCtorGen.Emit(OpCodes.Stsfld, spacesFldBldr)
    
        Next
    
        staticCtorGen.Emit(OpCodes.Ret)
        Return spacesTypeBldr.CreateType()
    
    End Function
    

    Now you just create an instance of the dynamic type and then magically start using Spaces.Spaces725 or Spaces.Spaces489 whenever necessary.

    Public Shared Sub Main()
    
        Dim Spaces As Object = Activator.CreateInstance(GetSpacesType())
    
        Console.WriteLine("W" & Spaces.Spaces25 & "T")
        Console.WriteLine("F" & Spaces.Spaces172 & "!")
    
    End Sub
    

    Just remember to set VB.NET's "Option Strict Off" to allow for late-binding and get rid of all that pesky compile-time checking.

  • topcat (unregistered) in reply to Zapp Brannigan

    It is VB.Net. space1 is a string

  • (cs) in reply to Americium

    Clearly it should be (in C) (all wtfs unintentional, like they should be):

    char *spaces; char *end; int maxLength;

    void initSpaces(int maxLength) { spaces = malloc(maxLength+1); memset(spaces, ' ', maxLength); spaces[maxLength] = 0; end = spaces + maxLength; }

    char *spaces(int length) { ASSERT(length <= maxLength, "Spaced Out!"); return end - length; }

  • Stefan W. (unregistered)
    COMMENT intentionally left SPACY
    
  • thatoneguy (unregistered)

    Hey could you color code the spaces or something? Make them blue? I had trouble counting them, thanks!

  • (cs) in reply to Anonymous
    Anonymous:
    derula:
    Jeremy:
    Throw some Perl at it:

    $spaces = " " x $num_of_spaces;

    31 chars, including variable names. Done.

    Ruby:

    spaces = " " * num_of_spaces

    28 chars including variable names.

    better:

    spaces = ' ' * num_of_spaces

    Still 28 characters, but uses fewer pixels.

    even better:

    _=' '*i

    7 chars, including variable names. As a bonus, uses least ink on paper

  • (cs) in reply to smbarbour
    smbarbour:
    L:
    I don't get it : does GenerateSpaces() actually do something ? I don't know VB, so maybe I'm missing something...
    Yes, it wastes a ton of memory and CPU cycles.
    This is VB. Judging by it being called "old code" it is most likely VB6. I really don't think they were that concerned with wasted CPU or memory cycles.
  • courage dog (unregistered)

    How much do such ehm, Experienced Developers, earn on an average?

  • FromCanada (unregistered) in reply to Resistance
    Resistance:
    even better:

    _=' '*i

    7 chars, including variable names. As a bonus, uses least ink on paper

    Oh God

  • Todo: register username (unregistered)

    I just loved the way space10 and Mod 10 was used for... code optimization?

  • (cs) in reply to SpasticWeasel
    SpasticWeasel:
    Zapp Brannigan:
    Private space1, space2, space3, space4, space5, _ space6, space7, space8, space9, space10, _ space100 As String

    If this is vb what data type is space1? It's not string.

    Something doesn't smell right, this code has to be someones idea of a joke.

    Everything except space100 is a variant.

    Unless it's VB.Net in which case they're all strings.

    Incidentally, the String class in .Net has the following constructor:

    Public Sub New (c As Char, count As Integer)

  • D C Ross (unregistered) in reply to FromCanada
    FromCanada:
    Resistance:
    even better:

    _=' '*i

    7 chars, including variable names. As a bonus, uses least ink on paper

    Oh God

    That's only six characters, but you're using a lot of extra pixels and I'm not sure that you'll get the correct output.

  • (cs) in reply to ratchetr
    Americium:
    6502 Assembler has one too. Just loop through screen memory & write space characters. Memory starts at $4000 in this example.

    2000 LDY #$0A 2002 LDA #$20 2004 STA $4000, Y 2006 DEY 2008 BNE 2000

    My 6502 is a bit rusty too, but the DEY instruction would be stored at $2007, not $2006. Also, this stores 10 spaces in $4001 through $400A and leaves $4000 uninitialised. You should have switched the DEY and the STA $4000, Y.
  • BonziBuddy (unregistered)

    One word : HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA

  • Al H. (unregistered) in reply to Zapp Brannigan

    Actually, space100 would be a string since it's explicitly labeled as such; the other variables would be variants (which can contain strings but are less efficient since the compiler/run-time library has to determine what kind of data it contains constantly).

  • Mark (unregistered) in reply to ell0bo
    ell0bo:
    I told him to place all constants in /company_configs/company_name.php .
    All constants in one file? Really?
  • TPD (unregistered)

    The trdegy is that they missed out on a space1999 global variable

  • Great link for WTF source material buried in this article (unregistered) in reply to L
    L:
    I don't get it : does GenerateSpaces() actually do something ? I don't know VB, so maybe I'm missing something...

    It does something, but it is kind of pointless since it doesn't have any outputs or change the system state in any way.

  • Jazzman (unregistered)

    The code looks like Visual Basic, and the logic behind the programmer also indicate Visual Basic =)

  • John (unregistered)

    My ohhhh my. LOL My ohhhh my.

Leave a comment on “Spaced Out”

Log In or post as a guest

Replying to comment #:

« Return to Article