I wonder what this function does?



  • I work at a small company that makes a very large enterprise-class Delphi program.  It weighs in at close to 4 million lines of code, and in any project that size, there's bound to be plenty of minor WTFs scattered here and there throughout the codebase.  A lot of it is from some of the earlier coders who are no longer with us, whose work makes it very clear that they were C/C++/Java coders with no idea how to do things in Delphi.  Earlier today I ran across this little gem, which reminded me of today's post:

      // disable all controls
      self.DisableAllControls;

    ...ya think?



  • If that function were in the codebase I'm working on right now, it would take a dozen parameters, ignore half of them, and use the other half to decide if the controls should be disabled or enabled, or half-and-half. It would also change a few global variables, and have at least one undocumented side effect (say, validating the input in one of the controls). Occasionally, it would be called exclusively to trigger the side effect. The presence of the comment would be essential to figuring out what this particular invocation does.



  •  I don't get it.



  • @AngelSL said:

    I don't get it.

    ... It's a redundant comment for a self-documenting function name. That is the entirety of the WTF.



  • @Lingerance said:

    @AngelSL said:
    I don't get it.

    ... It's a redundant comment for a self-documenting function name. That is the entirety of the WTF.

    No. TRWTF is Delphi. I mean, nothing against Delphi. I love it (btw, does it have Macros now?). But it keeps getting more and more expensive for no particular reason, and while in the past there were some cut-down low-cost Standard versions, there are none of those for new releases any more. I get the impression that Borland... eer, CodeGear.... I mean Embarcadero solely rely on big vendors that have always been using Delphi and can't afford to write everything again in a real language. Seriously... they would be better off to make cheap versions that everyone can afford. Eventually their large customers will all bankrupt, or switch to a different language (I'm not sure about other colleges, but here, no-one teaches Pascal any more. In the long run it will be cheaper for companies to switch to a more... common language)



  • @derula said:

    No. TRWTF is Delphi. I mean, nothing against Delphi. I love it (btw, does it have Macros now?). But it keeps getting more and more expensive for no particular reason, and while in the past there were some cut-down low-cost Standard versions, there are none of those for new releases any more. I get the impression that Borland... eer, CodeGear.... I mean Embarcadero solely rely on big vendors that have always been using Delphi and can't afford to write everything again in a real language. Seriously... they would be better off to make cheap versions that everyone can afford. Eventually their large customers will all bankrupt, or switch to a different language (I'm not sure about other colleges, but here, no-one teaches Pascal any more. In the long run it will be cheaper for companies to switch to a more... common language)

    Yeah, TRWTF was Borland, and that's a pretty accurate description of their marketing strategy.  They ended up selling off Delphi to Embarcadero, and soon after that they were quietly bought out by some other company after their stock plummetted to below $1.  The people at Embarcadero have acknowledged the need for hobbyists and students to continue to keep the language alive, and they're working on a better marketing strategy, including a low-cost (or hopefully free) personal edition.

     



  • @Mason Wheeler said:

    Yeah, TRWTF was Borland, and that's a pretty accurate description of their marketing strategy.  They ended up selling off Delphi to Embarcadero, and soon after that they were quietly bought out by some other company after their stock plummetted to below $1.  The people at Embarcadero have acknowledged the need for hobbyists and students to continue to keep the language alive, and they're working on a better marketing strategy, including a low-cost (or hopefully free) personal edition.

     

    Let's be honest here, it wasn't just a marketing and business failure - their port to .NET was a trainwreck, and every single version of the Delphi (sorry, "BDS") IDE from then on was buggy as hell and full of bizarre namespace conflicts and other annoyances.

    The original Visual Studio .NET was a bit of a disaster as well, but Microsoft fixed almost all of the problems in VS 2005.  Borland had what, 4 versions to get it right?  And they still couldn't do it.  The last version of Delphi to not totally suck was Delphi 7, and while it was a pretty good option back in 2002, I can't imagine trying to develop any software of significance today without generics, garbage collection, anonymous methods, and so on.

    I have a long history with Delphi and was as sad as anyone about what happened, but it's in the same retirement home as COBOL now, relegated to legacy applications because no sane individual would use it in a new project.  Any organizations that still have live Delphi code sitting around are putting themselves at major risk.



  • You'd be surprised.  The last two versions (ever since they sold Delphi to more competent management) have had generics, anonymous methods, and a very stable IDE.  No garbage collection, but that's not something most of us want in the first place, since it tends to create more problems than it solves.  But following that line of reasoning too far would just lead to a language war, which would be rather counterproductive.  Suffice it to say that Borland turned Delphi into a newt, but it got better, and the language is alive and well today and being used in new projects.



  • @Aaron said:

    I have a long history with Delphi and was as sad as anyone about what happened, but it's in the same retirement home as COBOL now, relegated to legacy applications because no sane individual would use it in a new project.  Any organizations that still have live Delphi code sitting around are putting themselves at major risk.
    COBOL is still very much in use if you're in any financial establishment appropriate size and age.  New projects are done in COBOL, more than you think, but only in these very large, old financial corporations.  They can build as much on top of the mainframe as they want, but that mainframe is still running COBOL (and PL/1) to do the real work.



  • @Mason Wheeler said:

    The people at Embarcadero have acknowledged the need for hobbyists and students to continue to keep the language alive, and they're working on a better marketing strategy, including a low-cost (or hopefully free) personal edition.

    Really? That would be great. Maybe that will finally make me upgrade from Delphi 7.



  • @Mason Wheeler said:

      // disable all controls
      self.DisableAllControls;

    ...ya think?

    Haha, reminded me of this ruby code:

      # Loop
      loop do
    


  • @Aaron said:

    I have a long history with Delphi and was as sad as anyone about what happened, but it's in the same retirement home as COBOL now, relegated to legacy applications because no sane individual would use it in a new project.  Any organizations that still have live Delphi code sitting around are putting themselves at major risk.

    Funny you should mention COBOL - the company that purchased Borland calls themselves the world leading COBOL IDE developers.



  • @Kyanar said:

    @Aaron said:

    I have a long history with Delphi and was as sad as anyone about what happened, but it's in the same retirement home as COBOL now, relegated to legacy applications because no sane individual would use it in a new project.  Any organizations that still have live Delphi code sitting around are putting themselves at major risk.

    Funny you should mention COBOL - the company that purchased Borland calls themselves the world leading COBOL IDE developers.

    Good god people still use COBOL? What has this world come to?



  • More like: What has this world NOT come to? IE: the realization that there are more effecient languages, but since cobol works damned well when done right, you can just chuck more HW at it and poof.



  • @Indrora said:

    @Kyanar said:
    @Aaron said:

    I have a long history with Delphi and was as sad as anyone about what happened, but it's in the same retirement home as COBOL now, relegated to legacy applications because no sane individual would use it in a new project.  Any organizations that still have live Delphi code sitting around are putting themselves at major risk.

    Funny you should mention COBOL - the company that purchased Borland calls themselves the world leading COBOL IDE developers.

    Good god people still use COBOL? What has this world come to?

    Oh yes, yes they do. And yes, it is a trouble. Especially to people that has been living for less than a half of what this damn' language had. Or has.



  • @Mason Wheeler said:

    No garbage collection, but that's not something most of us want in the first place, since it tends to create more problems than it solves.

     

    Yeah, I used to tout the same chestnut back when I was in the Delphi swamp.  You'll get over it some day.  Nothing like having to nest 12 try/finally blocks just to make sure you "Free" a bunch of locals.



  •  @Aaron said:


    Yeah, I used to tout the same chestnut back when I was in the Delphi swamp.  You'll get over it some day.  Nothing like having to nest 12 try/finally blocks just to make sure you "Free" a bunch of locals.

    OK, that's a genuine WTF right there.  First off, having 12 locals that you need to free in the same function, and second, not knowing how to avoid nested try/finally blocks for freeing multiple objects.  (There are about half a dozen ways to do it.)



  • @Mason Wheeler said:

     @Aaron said:


    Yeah, I used to tout the same chestnut back when I was in the Delphi swamp.  You'll get over it some day.  Nothing like having to nest 12 try/finally blocks just to make sure you "Free" a bunch of locals.

    OK, that's a genuine WTF right there.  First off, having 12 locals that you need to free in the same function, and second, not knowing how to avoid nested try/finally blocks for freeing multiple objects.  (There are about half a dozen ways to do it.)

    Soooo...  to be clear, you don't think having to free locals in the first place is a massive WTF.  What the hell has this language done to your brain?  It sounds worse than dropping acid on a daily basis...



  • @morbiuswilters said:

    @Mason Wheeler said:

     @Aaron said:


    Yeah, I used to tout the same chestnut back when I was in the Delphi swamp.  You'll get over it some day.  Nothing like having to nest 12 try/finally blocks just to make sure you "Free" a bunch of locals.

    OK, that's a genuine WTF right there.  First off, having 12 locals that you need to free in the same function, and second, not knowing how to avoid nested try/finally blocks for freeing multiple objects.  (There are about half a dozen ways to do it.)

    Soooo...  to be clear, you don't think having to free locals in the first place is a massive WTF.  What the hell has this language done to your brain?  It sounds worse than dropping acid on a daily basis...

     

    Well, that only applies to local object instances.  Anything else does get cleaned up by the compiler.  And there are really only two alternatives to freeing locally-instantiated objects yourself.  Your language could allocate them on the stack and use RAII, one of the biggest WTFs in the long, sad, WTF-filled history of C++, which has thankfully not been picked up by practically anyone else at all.  Or you could use garbage collection, which causes its own special varieties of headaches, which tend to be harder to trace down and debug.  So personally, I'm fine with the way Delphi handles it.



  • I just love

    with TSomeObject.new do try
    // Do something with self
    finally
    Free;
    end;

    Also: I'm still wondering whether Delphi has Macros now.



  • @derula said:

    I just love

    with TSomeObject.new do try
      // Do something with self
    finally
      Free;
    end;

    Oh wow!  I don't think I've ever seen that particular "pattern" before.  Where'd you run across that?

    Also: I'm still wondering whether Delphi has Macros now.

    Not sure.  What exactly do you mean by "Macros"?  That tends to mean very different things in different languages.


Log in to reply