No announcement yet.

Why old code is still so good?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Why old code is still so good?

    So, I was looking at some code on the forum from about 2001 and the thought occurred to me - why is code that old, still good?

    The real question is that if the programming industry has continued to progress with new techniques, then I'd have expected the old code to be supplanted with something new? But if there is a new way of doing/programming things, where is the new stuff and what bearing does it have on PowerBASIC?

    I get the impression that all of the newer programming techniques/languages are simply wrappers for the Windows API - along with promoting techniques/procedures for how someone thinks we ought to be programming.

    But here in PowerBASIC land, it seems that the techniques of a decade ago are still as good as gold (yes, DDT has progressed, but SDK is still SDK).

    Anyone have insight in this to share?

  • #2
    Originally posted by Gary Beene View Post
    ...why is code that old, still good?...
    If it ain't broke, don't fix it.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.


    • #3
      One reason I think is that PB is backward compatible. While the same code can be rewritten using PBs new features, making it shorter and more efficient the old code in most cases is running w/o or with minimal adjustments. If you really go to the depth of other programming languages in the Windows OS all of them are wrapping around the Windows API even if that is not as apparent as in PB. I do not think there is anything wrong with that. In fact, I was one of the millions of angry and disappointed VB6 users who were abandoned by Microsoft when they desupported VB6. PB does not do the same. Your investment still works after many years... This is one of the big advantages of using PB!

      Peter Redei
      Last edited by Peter Redei; 13 May 2009, 12:25 AM.


      • #4
        Basically it is because the Windows API is at the core of Window, despite the many new technologies.

        Core API's have not changed much since Windows 95.

        Many of the newer features of the operating system though are based on COM. One example is the many shell API's which use COM. DirectX is primarily COM based. is a GUI engine "on top of" the Windows API, so new languages can access, while many API based applications still run perfectly fine.

        The advantage of accessing the API directly, is that ones app is much smaller and less dependencies.

        For example, VB depended upon a lot of ActiveX controls (OCX's) for many of its features, while with PB you can access these same controls (ie. common controls) directly using the API. This decreases the need for distributing a bunch of OCX's with ones app and problems with versioning.

        You do have to be careful though with the API, because some API's do become obsolete after awhile, but it is not many. Instead Microsoft simply adds features to the API functions, via "tricks" like defining the first member of a structure (TYPE) as a value to store its size. When they add members to the newer structure version, the API checks the first member to see the size defined and acts accordingly. The basic API call does not change much, but new features are added via the change in the structure passed.

        When using the API it is good to read the most current API docs (found online at MSDN) to see if an API has changed on a newer operating system.

        It is also good to define your target operating systems before using any newer API's. If you plan to target Windows 95 to Vista, then you have to be much more careful of the API's you use, than when you target only XP and Vista.
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"


        • #5
          get the impression that all of the newer programming techniques/languages are simply wrappers for the Windows API - along with promoting techniques/procedures for how someone thinks we ought to be programming.
          Why would you think that? You think Microsoft has a monopoly on finding innovative and talented programmers?

          Look at the long-ago story* of the 'decimal print' function (BASIC "STR$())" ... for years the programming community was trying to reduce the number of instructions required... from 80, to 70, to 60, to 58, to 56. to 55... it sure looked like 50 was the 'magic number', the Ultimate, the Nirvana.....

          Then one day some "newbie" took a fresh look at it and came up with a better way. As was common in those days, he posted his code on the bulletin board: all eleven (11) instructions worth.

          *Source: Hackers by Steven Levy
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]


          • #6
            And the reason some of that "old" code is still here, and still used?

            We're waiting on that next 'newbie.'
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]


            • #7
              The core API changed plenty between Windows 95 and 2000. It's settled down and more reliable now that the NT kernel has taken over since Windows XP in 2001. I'm glad Win9X and it's 16-bit kernel is dead.

              The only things that seem to change between each release are the controls (COMCTL32) and occasionally additional libraries (UXTHEME, GDIPLUS) are added. These are now standard.
     | Slam DBMS | PrpT Control | Other Downloads | Contact Me


              • #8
                I think it's because that code was written when resources (memory, speed,..etc.) were scarcer than now.
                I dont know how is phrased in english, but certainly "one hungry man thinks harder than one hundred wise men".


                • #9
                  You are right Manuel,

                  When you had few resource, it did concentrated your mind wonderfully to the most efficient code
                  Old QB45 Programmer


                  • #10
                    • because PB language has always keep strong compatibility with the past (so you can still compile code written many years ago)
                    • because PB language put optimization at high consideration. every new keyword or functionality is not just introduced but introduced after optimized
                    • because PB is always working under the curtains to improve the language and internal libraries so at every release you get for sure speed improvements in many different areas
                    • because if compiler was already doing great optimizations and producing fast executables many years ago on old slow CPUs you can be sure the same application will fly if executed in current CPUs
                    • because when you do not have a 100% Visual Designer environment but just an editor, you concentrate much more on code and how it is written. Code is the source of good or bad programming