• (disco)

    Wow. I have seen error handlers doing things like

    if err.message == "Unable to connect to srv1.something: Connection timed out":
        […]
    

    but that’s definitely one level higher. Must be fun for maintenance, too. “Add a confirmation dialog here? OK, that will take one or two weeks…”

  • getmeaguiness (unregistered)

    I wonder who is going to be the frist person to comment that the real WTF is the use of VB?

  • (disco)

    fri- ah fuck, every damn time

  • (disco) in reply to algorythmics

    I liked before you guys posted~


    Filed under: Wer reitet so spät durch Nacht und Wind?

  • (disco) in reply to aliceif
    aliceif:
    Filed under: [Wer reitet so spät durch Nacht und Wind?]()
    +1!
  • Don Blackton (unregistered)

    All the fun of keeping track of addresses, without the assembler.

  • anonymous (unregistered)

    Got to the line with OR ERL=... and the realisation of horror hit me suddenly, just like a slowly-dawning realisation of horror, except quicker.

  • (cs)

    Remy, thank you for a write-up which presents the WTF clearly and presents the additional material as a link for those who want to follow it. This article has my nomination for the best-of-2014 shortlist.

  • (disco)

    In seinen Armen der Code war tot.

  • (disco) in reply to dbenzhuser

    [quote=dbenzhuser] In seinen ArmenZeilen der Code war tot. [/quote] FTFY

    Filed Under: 49,46,44,244,39.... clearly the Illuminati are at work here!

  • (disco)

    I once had to write vb in a country local version of Office where all the vb-syntax had been converted to Norwegian.. With no reference manual.. It took me two hours to figure out the name of the rand() function!

  • (disco)

    That's an impressively serious level of fail even by VB6 standards. And On Error Resume... is failtastic before you start.

    I have written VB6. I have never written VB6 that badly. Not even on my first day with the language.

    Still it could be worse. It could be my stepdad who steadfastly continues to use QBASIC. GO SUB everywhere. Labels. Not even DEF SUB or DEF FUNCTION to make sense of the code. Everything's global as a result. Using DEF SUB is 'too complicated'.

  • (disco)

    The only thing that can be said in mitigation is that at least the error-line is displayed in the message box so you can fix it. (Well, assuming you can work out which existing Erlvalue needs to be fixed...)

    But it is only mitigation, not absolution. The original coder is still ARWTF. (There are plenty of other RWTFs, so he is only A RWTF.)

  • (disco)

    I see nothing wrong here. The original programmer obviously knew the code was perfect and never ever had to be changed and therefore could safely rely on line numbers. The RWTF was of course Ryan forcing a change in that masterpiece.

  • (disco)

    Visual Basic doesn't actually put line numbers in unless you tell it to, and in fact the numbers don't have any meaning other than the Erl() function. So if you have something like

    Sub blah doSomething 1 doSomeOtherThing End Sub

    and add a call to doYourMother in the middle, the doSomeOtherThing line will still be line 1 and still work exactly the same.

    Sorry. Someone had to be the killjoy.

  • (disco)

    Erl doesn't show the line number that most of us are familiar with. It shows the BASIC line number, not the position of the error within the source code. See [this example][1]. So, in order for this WTF to have actually happened, several things would have had to have happened:

    1. The original code would have to have been line numbered, with no gaps left for inserting new code.
    2. Ryan would have had to have renumbered several lines without thinking "I wonder if changing these labels will break anything".

    Regardless of how screwed up VB6's error handling is, the original coder's line numbering is a bigger WTF, and Ryan's WTF is even bigger. [1]: http://msdn.microsoft.com/en-us/library/97sx19w1%28v=vs.90%29.aspx

  • (disco) in reply to Arantor
    For example, On Error Resume Next, is a delightful statement that tells Visual Basic to simply ignore errors, and continue execution. A good programmer will know to check errors with conditional statements.
    It's actually not that bad. After On Error Resume Next, you pretty much have C-like error handling; after every call, you have to check if the call failed. Given that the alternative is On Error Goto <<label>>, it's actually the better option.

    Good thing VB added exception handling fifteen years ago.

  • (disco) in reply to Jaime

    after every call, you have to check if the call failed

    The problem with most VB programs with On Error Resume Next is that the programmer never bothers to check if there really was an error.

  • (disco) in reply to Jaime

    I didn't see exceptions in VB, but then again I was doing it about that many years ago with VB5 at home and VB6 at school, and I gave it up shortly after that when I realised I didn't want to be writing desktop apps.

    I didn't discover exceptions until much later, sadly.

  • (disco) in reply to lcrawford
    lcrawford:
    The problem with most VB programs with On Error Resume Next is that the programmer never bothers to check if there really was an error.
    ... exactly like C ...

    That makes it a programmer WTF, not a VB6 WTF.

  • (disco) in reply to Jaime

    Ryan's fix can not be characterized as "adding a single line of code", since he obviously did some sort of RENUMber operation.

  • (disco)

    I inherited a 25,000 line VB6 application and a bunch of smaller ones back in 2006 and I had to deal with the question "How do I get decent error messages out of this thing?". About the only viable option was to run the source code through a preprocessor that added line numbers before compiling so that Erl actually worked. This was especially fun since there are a number of places that line numbers can't be put, so the preprocessor had to parse the VB code in order to avoid introducing errors.

    Fortunately, in less than two years, we moved the code to .Net and had a manageable error handling syntax.

    For added fun, a lot of the smaller VB6 programs were run as services. They were just regular forms-based desktop applications with a timer control that were run as a service with SRVANY. Man did that suck.

  • (disco) in reply to Jaime

    If the programmer is willing to use a language that requires you to check for errors after every call, like C or VB, then yes, it's his fault.

  • (disco)

    Here I was thinking it was the loopctr wasn't being initialized properly and at some point initialized over 100.

  • (disco) in reply to chreng
    chreng:
    I see nothing wrong here. The original programmer obviously knew the code was perfect and never ever had to be changed and therefore could safely rely on line numbers. The RWTF was of course Ryan forcing a change in that masterpiece.

    Guys, we still need the Front Page Troll badge!

    Also, what happened to the cornify script?

    You guessed right- Ryan’s predecessor, the Erl-king, used line numbers as magic numbers to determine what the exact source of the error was.

    The evil ideas thread is :arrows_counterclockwise: :arrow_right: :arrow_left: over there.

  • (disco) in reply to Jaime
    Jaime:
    1. The original code would have to have been line numbered, with no gaps left for inserting new code.

    In that case TRWTF is still VB6 for having a discrete numbering scheme.

  • (disco) in reply to Planar

    The WTF is the programmer that numbered his lines. The bit you quoted is from my list of WTFs, not a list of good ideas. VB only supports line numbers for backwards compatibility with pre-VB BASIC; anyone who used them is a retard.

    Contrast this with JavaScript's Automatic Semicolon Insertion. When you encounter an ASI bug, it's because the feature bit you in the ass by its very existence. You don't have to intentionally use ASI to be bit by ASI. At least VB6 allowed you to simply not number your lines and you could pretend the feature wasn't there.

  • (disco) in reply to Zowayix

    yeah, but... VB macros in Excel sure depend on the user not only leaving cell positions alone, but not even hide/unhiding rows or columns. Otherwise, similar fail.

  • (disco) in reply to cellocgw
    More common, is the On Error Goto ErrHandler approach. As the code implies, when an error occurs, this simply executes a goto to jump to a specific label, with all of the fun that goto statements normally include.
    As opposed to a Try/Catch block... which for all practical purposes executes a goto jump to a specific label.

    Oh, Remy...

  • (disco)

    Talk about Shades of the COME FROM Statement...

    Probably the worst thing was he obviously didn't even use the statement labels.

  • (disco) in reply to Arantor
    Arantor:
    I didn't see exceptions in VB, but then again I was doing it about that many years ago with VB5 at home and VB6 at school, and I gave it up shortly after that when I realised I didn't want to be writing desktop apps.

    I didn't discover exceptions until much later, sadly.

    Yeah, exceptions didn't come around until VB .NET

    More common, is the On Error Goto ErrHandler approach.

    In my experience, that's not the case.

  • (disco) in reply to antiquarian
    antiquarian:
    Also, what happened to the cornify script?

    Right? Especially on an article called "King of the Faeries"? I guess he really wanted to cornify "Erl-King" but wanted to link it even more.

    On the other hand, they're rather different kinds of fairies. On the other other hand, maybe the Cornify unicorns are sinister too. AFAIK no one has ever survived a unicorn attack...

  • (disco) in reply to Zylon
    Zylon:
    As opposed to a Try/Catch block... which for all practical purposes executes a goto jump to a specific label.

    Oh, Remy...

    Try/Catch has better locality because execution resumes with the code after the block. On Error Goto either requires the error handler be at the bottom of the procedure or that you manually jump around the section with another Goto. Try/Catch may not compile to better code, but it is a significant syntax improvement.

    Here's something to think about: C has no error handling syntax. All it has is a convention that return values will be used to convey the status of the operation back to the caller. On Error Goto is arguably worse than C-style error handling, which means this syntax is worse than no syntax at all.

  • (disco) in reply to antiquarian
    antiquarian:
    Also, what happened to the cornify script?

    [spoiler]Remy doesn't usually cornify CodeSOD articles.[/spoiler] No idea why.

  • (disco) in reply to antiquarian
    antiquarian:
    we still need the Front Page Troll badge

    Huh. I thought we just needed the < fe> markup < /fe>

  • (disco) in reply to VinDuv
    VinDuv:
    Wow. I have seen error handlers doing things like ``` if err.message == "Unable to connect to srv1.something: Connection timed out": […] ``` but that’s definitely one level higher. Must be fun for maintenance, too. “Add a confirmation dialog here? OK, that will take one or two weeks…”

    Literally, in my company's code base:

    if (!e.Message.Equals("Thread was being aborted."))

  • (disco) in reply to chubertdev

    @CodingHorrorBot

  • (disco)

    Obligatory Der Erlkönig German Lieder by the late and great William Warfield and Sylvia Olden Lee, IMO one of the best recitals of the song in the post war era. https://www.youtube.com/watch?v=aapUdJSvf0M

    Translation: http://german.about.com/library/blerlking.htm

  • (disco)

    From the linked wiki page: http://en.wikipedia.org/wiki/Erlking#The_Erlking.27s_Daughter

    Looks like The President's Daughter has a rival

  • (disco) in reply to chubertdev

    @chubertdev Is Doing It Wrong™<t3220p36>

  • the beholder (unregistered)

    There's something wrong with this article.

    Where are the unicorns?

  • (disco) in reply to MRAholeDBA

    I think this deserves more than a simple "like." Thank you for posting that. I haven't watched it yet (bookmarked for later, after work), but "Der Erlkönig" was the first thing I thought of when I saw the article title.

  • (disco) in reply to Spencer
    Spencer:
    Looks like The President's Daughter has a rival

    I somehow think she'd probably get her rear end kicked from here to next week by the (half-)elf maidens I know...

    *cues horrific stabby fight scene*

    EDIT: *summons @accalia and @presidentsdaughter*

  • (disco) in reply to tarunik

    I don't actually know any elf maidens, but I definitely got the impression from reading about them that they are a lot less nice than @presidentsdaughter.

  • eric bloedow (unregistered)

    an old Basic game i messed with came to mind: "sink the ship". a simple game where you had an airplane with 10 bombs, and you dropped them to try to sink a ship. you scored 1 point for hitting the lower deck, 2 points for the upper deck, and 3 points for a perfect bomb down the smokestack! just for fun, i decided to make a modified version that would also give you an extra bomb for a smokestack hit. BUT when i scored over 30 points, the game crashed! why? because the game used a "goto line (sc*100)" function to decide what message to display at the end of a game! (sc being the score)

Leave a comment on “The Erlking”

Log In or post as a guest

Replying to comment #:

« Return to Article