Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

TechTip: Create Hash Tables in RPG with the Dictionary ADT

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

  • #16
    TechTip: Create Hash Tables in RPG with the Dictionary ADT

    ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
    Craig: I know few people here use Perl or Python. Since the System i is a premium priced platform, compiled languages will always have the edge. That is, if you're spending 6-7 figures on your computing hardware, you want to make sure your CPU's are running at least at 90% (or more), with apps tuned to achieve stringent performance goals. On the other hand, if a shop is spending more money on its programming staff than on its hardware, then programmer productivity becomes more important that machine performance. Interpreted languages like Perl and Python offer IT shops much much higher programmer productivity, as well as much faster response time to change requests. Regarding library functions like Adam's hash table functions, does this really "take RPG where its never been before"? I don't think so. To me it just highlights the sorry lack of functionality in the language. To make best use of the language, you need to be intimately aware of the System i API's and MI built-in's. But in doing so, your apps are also forever tied to that one hardware platform. Now it may well be a fine piece of computing hardware, but your choices will always be limited to this one niche. Cheers! Hans

    Comment


    • #17
      TechTip: Create Hash Tables in RPG with the Dictionary ADT

      ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
      Adam, I downloaded your code. Thanks. It is really excellent programming, not only substance, but style and completeness. I have never had occasion to use functionality like this or other class library type code in my business programming through the years, but when I do there couldn't be a better model of open source support for it than this. regards, rd

      Comment


      • #18
        TechTip: Create Hash Tables in RPG with the Dictionary ADT

        ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
        Hans, I disagree with much of what you said, but the only issue worth discussing that honors Adam's article is that of native support for functionality, functionality such as he has written here. First, let's describe native support. When the PHP authors or addon authors want to add native support for a function, say the function that Adam just wrote, they write a C module to compile in the PHP interpreter. That's significant in that it is now a part of the language to call that runs at native speed, versus functionality provided in PHP script to be interpreted. The C code is compiled, and of course the C compiler for that machine uses native API's. For example, PHP was compiled for i5/OS by Zend. Compiling the C code for the PHP engine that provides native support for PHP language functions makes it no more tied to i5/OS than Linux or Windows. Now, let's add Adam's functionality to RPG as native support. We compile it into a service program. The functionality is callable from RPG with similar syntax to other languages. It runs at machine speed as does compiled C. The MI stuff is such a crappy red herring it is laughable. Just as C library functions and Java library functions are added to the language, RPG library functions are added in exactly the same way. Native support is only an issue with script languages you are so fond of, and even then the script language authors provide add on capability to add compiled library functions for native support, necessary for script languages. So to bash RPG for lack of native function support is to bash C or any language for lack of native support, except guess what, we have native support for all that C has, and can add anything from a script language if we wanted to. Quite frankly, we didn't need it. If it's useful, we'll add it. And it will be just as native as anything added to a script language. rd P.S. I am starting a major project for my web site in PHP, and acquired Zend Studio, so there are places PHP is the right solution, that being running on my web site hosted on a Linux server. Will I develop it faster and better than I do in Java or RPG? Nope.

        Comment


        • #19
          TechTip: Create Hash Tables in RPG with the Dictionary ADT

          ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
          Ralph wrote: "there couldn't be a better model of open source support for it than this." I don't mean to nitpick, but is this really open source code? I am not a lawyer, but anyone wanting to use any code found on the internet really has to consult with a lawyer before using it. Here's my understanding of copyright law: The person who wrote that code owns the copyright to that code. By offering the code as part of an article to MCPressOnline, they now have certain rights to that code. But unless a license is explicitly given, others have no rights to use it. For this to be truly "open", license to use the code must be explicitly stated. Someone needs to consult with a lawyer to see who can grant those usage rights. Can MCPressOnline grant readers those rights? Or can Adam grant those rights? What exactly did Adam sign away when he offered up his code to MCPressOnline for publication? Cheers! Hans

          Comment


          • #20
            TechTip: Create Hash Tables in RPG with the Dictionary ADT

            ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
            Hans, I have plenty of respect for your technical knowledge. I wouldn't debate too many technical aspects of any language with anyone, cause I would probably lose. I would stand on the sidelines and listen sometimes, if I thought I could learn something useful. And useful is the key. You write articles, write an article on it and those interested will read it, and maybe not many people will hijack it back to RPG. I fear that as soon anyone poo poos the solution offered in RPG, then productive conversation takes a back seat. But, I am in need of technical expertise that will help me solve business problems with the hardware and languages provided (approved by management) to me. Hans, we are tied to one niche, as much as possible, and we like it that way. I only apply to jobs that operate in that Zone, and I like it that way. Management here, actually reviews any new ways to do things that can be done by RPG programmers first, to help keep us productive and to help us career wise if we ever leave, imagine that. Because he understands that happy and productive programmers help the 'BUSINESS'. He also, doesn't have to expand his shop to a dozen flavors of programmers either, or dread if that PHP or Perl programmer gets another offer somewhere else, then he has to scramble to find another exotic programmer that also understands 'BUSINESS'. Hans, I would find it refreshing if you took on a challenge. For the next dozen technical articles written, expand upon the RPG or OS/400 technical possibilities of the article to help us enhance our companies 'BUSINESS'. Help us, with your technical knowledge, take RPG where it hasn't been before. Hans, help me work with the tools I have.

            Comment


            • #21
              TechTip: Create Hash Tables in RPG with the Dictionary ADT

              ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
              I'd love to take a look at the code associated with this article - but the only reference to code that I can find is in this discussion thread! Where's the link to the download? I have been over and over the article from top to bottom and can't see it anywhere.

              Comment


              • #22
                TechTip: Create Hash Tables in RPG with the Dictionary ADT

                ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                Hi Jon, the last word in the article "here" is underlined as a link. It's a download link. rd

                Comment


                • #23
                  TechTip: Create Hash Tables in RPG with the Dictionary ADT

                  ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                  Hi Hans, I didn't mean the open source code would be distributed in this fashion. This code of course is for discussion purposes and the author states he welcomes code enhancements. Our open source RPG code would be distributed through a project on SourceForge or the like, or in a change control repository like CVS or Subversion or in an FTP directory on a personal server. Code that we write as infrastructure examples should not be encumbered with a license but done just as Adam did it, perhaps with a "For educational purposes" statement in the header. We should want to disseminate RPG code with best practices examples widely with no restrictions so business can use and incorporate freely without lawyers involved. Of course code that is translated from open source with a license needs to retain the license. We need a lot more good code examples out there so people can use as a base with best practices, such as Adam's displays. rd

                  Comment


                  • #24
                    TechTip: Create Hash Tables in RPG with the Dictionary ADT

                    ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                    Adam, Your hash table service program is an excellent example of how RPG can be extended in ways that many programmers would never think of. I just wish there were a definitive repository for things like this, which encouraged contributions of RPG extensions and open-source development. One that comes to mind is www.easy400.net. Your article spoke of "collision" as something that degraded performance and I wondered if you or one of the other computer scientists here would care to explain the problem in more detail. I gather that collision has something to do with indexing or searching an array. It appeared to me that quite a bit of code in your service program was dedicated to minimizing it. Thanks, Nathan.

                    Comment


                    • #25
                      TechTip: Create Hash Tables in RPG with the Dictionary ADT

                      ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                      Thanks for asking about collisions Nathan. Upon rereading that section of the article, I didn't explicitly say what constitutes a collison. A collision can occur when an item is added to the dictionary. When the program maps the key value to an array index, it may happen that the array already has an item at that location. The article describes in general a couple of approaches to handling these collisions. The nice thing about hash tables is that if there are no collisions, the time taken to add, remove, or retrieve an element stays near constant as the number of elements in the hash table increases. In computer science lingo, we say the time complexity of the operations is O(1). See the Wikipedia article on big-O notation for more info on what that's all about. If you think about it a bit, this is makes sense - you don't need to search through the elements to figure out where to look for a particular element. However, if a collision occurs, you need to do some more processing to figure out where to put the element. Using the linear probing method in the code, we get (comparatively) very bad performance if the array is near full. To illustrate this, suppose you (very unwisely) choose a hash code function that returns 1 for any given key. Let's say we have an array of size 10 for our hash table. The array start out empty: o o o o o o o o o o When we add the first item, the hash code tells us we should put it in position 1. Now the array looks like: x o o o o o o o o o When we add the second element the hash code tells us we should put it in position 1. Since there's already something there, we check the next spot and find it empty, so now the array looks like: x x o o o o o o o o When adding the third element, we'd have check position 1, position 2 position 3 before we can insert the element. If we carry this on, we can see that we have to check 1 extra time each time we add an element to the array. So the time for the add to complete increases linearly with the number of elements in the array. In other words, we now have an add operation with O(n) complexity. I hope that clears things up a bit. Let me know if that made any sense to you.

                      Comment


                      • #26
                        TechTip: Create Hash Tables in RPG with the Dictionary ADT

                        ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                        Copyright RPG source??? In other words writing something in any language for any purpose comes with an implied copyright? As if you could do anything when you see some code you wrote a few years ago for some private or public institution, and the company your with now just purchased a new "package" and while looking at some of the source, you recognize code and even comments you made way back when? Hey it happens all the time! Does it make me mad. Hell no. It's a source of pride that somebody thought your stuff was good enough to copy and now sell it or give it away as part of "packaged" software. Ask the guy who wrote "POP" for the S/36 about that issue. As a rule...If I include something somebody else wrote as-is or even modified, I always give credo's to the author, where I got it, and so forth. It's a matter of honor as well as pride.

                        Comment


                        • #27
                          TechTip: Create Hash Tables in RPG with the Dictionary ADT

                          ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                          If you are an employee, everything you create as an employee is property of your employer? Why? Cause you signed a hiring agreement. Read the fine print. And if you are a contractor, everything you write for the client is property of your client, for the same reason. If you as a contractor state that the code will be your property, you simply don't get the contract. Now, if you work for a very small company, there is a small chance that you own the code you write because they don't mess with the red tape. Chris

                          Comment


                          • #28
                            TechTip: Create Hash Tables in RPG with the Dictio

                            ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                            In other words writing something in any language for any purpose comes with an implied copyright?
                            That's how I understand it. As if you could do anything when you see some code you wrote a few years ago for some private or public institution, and the company your with now just purchased a new "package" and while looking at some of the source, you recognize code and even comments you made way back when? Well, theoretically I think you could. Practically speaking, you're probably right. It would be difficult to take on a a large company on your own. FWIW, there have been cases in which open source projects have been in violation of their licenses, and cases have been pursued. From what I understand, there have been no cases that made it to court in the US. Recently, Monsoon Multimedia was sued by the SFLC on behalf of the developers of BusyBox. I believe they settled out of court. In Europe, it is my understanding that there have been decisions in favour of the GPL. I feel much the same way as you do - I'll be happy if people find my code useful. I agree with Hans that explicitly stating a license is a good idea. I'll have to discuss that with the MCPress folks.

                            Comment


                            • #29
                              TechTip: Create Hash Tables in RPG with the Dictionary ADT

                              ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                              Unless contractors sign away their rights it is normally assumed that they own the intellectual property of their work. I've seen a local instance here where a reasonably large app was written by a single contractor who ended up walking with the product. The irony was that the company thought they would save a fortune by hiring in a contracting slave to build "their" product and didn't bother to get someone in the legal profession to look over the agreement. I know first hand the character of their directors - they used to have an old s36 I used to have to look after. It couldn't have happened to nicer idiots. I do contract work for another company that ended up with this app in one of its subbranches. Interestingly, I have also never signed away any rights to the work I do at that site.

                              Comment


                              • #30
                                TechTip: Create Hash Tables in RPG with the Dictionary ADT

                                ** This thread discusses the article: TechTip: Create Hash Tables in RPG with the Dictionary ADT **
                                I didn't. For a start, I'm haven't gotten in to MI programming at all. I'd certainly be interested in learning more about this in the future. Can you give me a quick overview of what independent indices are all about? I did consider using a user space or something along those lines to facilitate auto-resizing and to avoid limiting the maximum number of elements. I decided it was better to focus on the core concepts, this is a TechTip after all, and then revisit such details if there was any interest.

                                Comment

                                Working...
                                X