Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

    ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
    ** This thread discusses the Content article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)0

  • #2
    TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

    ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
    I think the rush to extoll Free-Form RPG as the paradigm of new coding methodology has been overdone. I think the introduction of Free-Form RPG was primarly done to attract the new generation of programmers who are used to working in script-based languages. The "old" RPG (with its very structured syntax) was seen as unpalatable to the "modern" script-based programming methodologies in other languages. The reasoning is that, unless RPG also becomes a "script" language, it will pass out of existence, because the new generation of programmers will refuse to work in it. Maybe I'm stone-aged in my mentality, but I always thought that the "old" RPG's structure was one of its greatest strengths, and that when used properly, it lended clarity to the coding. On the other hand, I have frequently found script-based coding to often be an exercise in creating "spaghetti", which is cumbersome to decipher --- especially when one has to unravel someone else's program code. From my perspective, the whole point of modern programming should be to be structured in form, and to emphasize clarity and economy over any debate about "new" versus "old". Telling me that something is "better" because it is "new" doesn't impress me. Showing me that it is clearer, more structured, does. Call me "stone-aged", but I'm not impressed with "spaghetti", unless it has marinara on it. I don't care how "new" it is.

    Comment


    • #3
      TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

      ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
      Interesting choice to use %REPLACE. I would have never thought of that. I use %SUBST, as follows:
       C EvalR %SUBST(Long:%Len(Long)- C (%len(Short)-1)) = Short 
      Obviously this yields about the same "readable" code as %REPALCE, yet replace feels better to me. But, I believe replace uses many more CPU cycles to get the data into the result, whereas %SUBST is more efficient. But we're probably talking nanoseconds so who cares?

      Comment


      • #4
        TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

        ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
        I am yet to find anything that I could do in fixed format that I am unable to accomplish in /FREE. Sure in a few cases it has required an extra line or two of code, but in the vast majority of cases, it takes less code. In my experiences I have found that people who consistently used BIF's in fixed format can make the transition to /FREE in a matter of days. People who never bothered to learn and use BIF's have a tough time making the switch. But that is IMHO.

        Comment


        • #5
          TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

          ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
          I think the intent of this comment is good. However, I see the problem as having been one of inertia. "Nobody" will use anything except RPG on AS/400/iSeries/System i. So, eventhough we've had perfectly good C/C++ compilers, PL/I compilers, and others on the system for a while, RPG is still the champ. However, in order to give people (i.e., software vendors) a way to leverage things coming down the pipe (at least at the time) the only solution was to invest in a hybrid syntax that gave people something to use in they, for example, needed to interface with C, C++, and now Java. Would IBM have introduced the EVAL opcode an the hybrid syntax today? Probably not. They probably would have gone straight to /FREE by introducing yet another RPG language (RPG V?) that included only the /free Calc specs (hence no /FREE required). I suppose they could still do that via a compiler switch on the Header spec:
           H OPTION(*RPGV) 
          Then the "C" in column 6 would cause a compiler error. Let's hope if and when they ever do something like this, they also eliminate that B.S. feature of allowing "comments" to be specified in columns 1 to 5; which in my opinion should have been sacked with the "C" in column 6.

          Comment


          • #6
            TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

            ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
            Brian, I think the lack of date opcodes and MOVEx opcodes in /FREE (initially) were a show-stopper to a lot of people. The dislike of the semicolon was just icing on the cake. But now with %DIFF, %DATE, etc. the "only" show-stopper is MOVE not being there. Ironically, with those date built-ins being introduced, a lot of what MOVE/MOVEL did is now posible in /FREE with a little imagination--but not a lot of work. One, the ability to move between numeric and character is easily solved with the %EDITC(numVar:'X') built-in; and the other-way-round with %DEC or %INT. but for all of these short-comings, the one big issue for me in moving to /FREE was not the semi-colon, it was not the goofy "FOR" opcode syntax, it was not the requirement to code /FREE and /END-FREE. Instead it was the fact that (at the time) "nobody" was on V5.1 of OS/400. Therefore, advocating something that nobody would use was to me, so reminisent of the IBM of the 1970s and 1980s ("Look how great its going to be next year!") that I just would do it. Today "everybody" is on V5.1 or later so /FREE is finally available to everyone. Even I'm using /FREE in a limited way!

            Comment


            • #7
              TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

              ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
              As an old fart who started writing RPG II on the IBM System/32, I have to say that I'm convinced that free form RPG is a much more productive and readable language. Maybe a lot of that has to do with putting indicators on the scrap heap of history but I think many of the opcodes are more intuitive. And it's a bonus when I can show a piece of freeform RPG code to a young whippersnapper who has never coded RPG and he thinks it's the bees knees. And script-like code doesn't have a monopoly on spaghetti code. Whether it's RPG or BASIC or Java, clarity of code is a matter of giving priority to readability over cuteness. My one beef with IBMs introduction of free form RPG is that the reference manual is so poorly done. More USEABLE examples of the new syntax would go a long ways to better understanding and creating a few more champions of the language.

              Comment


              • #8
                TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                Bob wrote: "I think the lack of date opcodes and MOVEx opcodes in /FREE (initially) were a show-stopper to a lot of people." I may be mistaken, but I believe date operations within expressions were implemented in V5R1 already. Furthermore, they could be used in the fixed-form Extended-Factor-2 operations, and not just in /FREE calcs. (Actually, way back during initial RPG IV development, I argued for date operations in expressions. But at the time, EVAL and expressions were still considered a bit too risky. And so those goofy date op-codes were implemented instead. :-( Cheers! Hans

                Comment


                • #9
                  TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                  ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                  Bob, I can understand your situation. In providing code and examples for many different people, I can see not using free format for compatibility reasons. It makes good sense. As for me, in an IT department for a single company, that was not an issue. As for the shortcomings early on, I found that the QC2LE binding directory opened up the doors needed to overcome some of the hurdles (the "atoll" function especially). In fact, I still use some of the C functions for various situations. The most recent being parsing pipe delimited data over a socket connection using "strtok", which I recommend to anyone in that situation.

                  Comment


                  • #10
                    TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                    ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                    "They probably would have gone straight to /FREE by introducing yet another RPG language (RPG V?) that included only the /free Calc specs (hence no /FREE required). I suppose they could still do that via a compiler switch on the Header spec: H OPTION(*RPGV)" After failing to convince IBM compiler team (or for that matter to any guru), I had diverted to praying for it (last night was the night of acceptance of prayers for Sufi Muslims). It seems atleast one guru thinks this way

                    Comment


                    • #11
                      TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                      ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                      Stone age wrote: "I think the introduction of Free-Form RPG was primarily done to attract the new generation of programmers who are used to working in script-based languages. The "old" RPG (with its very structured syntax) was seen as unpalatable to the "modern" script-based programming methodologies in other languages." I don't think that you're espousing a "stone age" message, I think you're espousing a "narrow view" message. I learned RPG in 1975. It was, if I can remember properly, about the 19th language I had learned. (I was a computer science major at UCLA.) Even at that time RPG was an outlier with it's fixed format syntax. It was also one of my least favorites. I learned PL/1 at UCLA and found free format much more to my liking than the fixed format RPG that I learned later. I had been pounding on IBM for years that RPG needed to be free format so that programmers that came from other languages could learn RPG easier. Conversly, fixed format RPG has pidgeon holed RPG programmers into a corner as knowing only a fixed format has made it hard for them to fit themselves into the mainstream. So you can see, free format languages have been around just as long, if not longer, than RPG. It's not a new fangled "fad" thing to appease the younger crowd as you make it out to be.

                      Comment


                      • #12
                        TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                        ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                        Don't discount the scripting languages. My current contract is writing Javascript and PHP for a small company setting up an extranet. In reality, I'm not just writing the scripts. I'm setting up the database, writing the HTML, etc. This is a far cry from RPG and DB2. I will return to the RPG fold in a couple of weeks and will program the way the client wants me to. I suspect they're not using /free. RPG shops, even small ones, seem to have much more control over the coding style. RPG's strength lies not in its format, whether fixed or free. A readable or unreadable program can be written regardless of the format. I don't understand, though, the religious-like evangelism to get everyone to write in free format. It's just another tool in my toolbox. Tom.

                        Comment


                        • #13
                          TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                          ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                          "It's just another tool in my toolbox." Amen!

                          Comment


                          • #14
                            TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                            ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                            For me, %subst is more readable as subst or substr is more of a universal name, thanks to SQL.

                            Comment


                            • #15
                              TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits)

                              ** This thread discusses the article: TechTip: Coding Free-Format RPG IV (and Overcoming Old Habits) **
                              Why not program in RPG II? It is time to advance our programming. Maybe one of the reasons the System i is perceived to be outdated technology is that the RPG programmers don't want to update their skill set. Free format RPG is a step in the modern world.

                              Comment

                              Working...
                              X