From: Steve Richter
( On the .NET vs i5/OS front, the comparison that I am interested in
is languages that garbage collect vs those that dont. C++ used to be
important. Almost overnight, with the adoption of managed code by
MSFT, it is legacy because it does not GC. Garbage collection in RPG
would work really well for its many business oriented programmers. )
Okay, I'll relax the restriction for just a moment and answer this question
even though you again are talking about a technical issue that really
doesn't matter to application programmers.
Why do you think RPG needs garbage collection? The only reason you need GC
is when the programmer dynamically allocates memory outside of the OS and
doesn't give it back. In OO languages this is an absolute requirement
because of the creation of millions of transient objects which are never
explicitly destroyed, but in procedural languages it's unnecessary. The
only reason you need GC is if you start adding a bunch of dynamic memory
allocation, and frankly that's why I don't want RPG to start looking like
Java - I don't need all that extraneous crap. If I need objects, I'll use
Java. If I don't, I'll use RPG.
Now, in order to make OO virtual machines work outside their sandbox, there
are GC issues, which is why most folks don't do it. At the most, they might
let Java call their native non-Java functions (through JNI), but rarely vice
versa. In a rather stunning architectural achievement unlike any other
operating system that I'm aware of, the i5/OS interface between RPG and Java
has support to directly invoke Java methods, and thus there is a need to
directly invoke the GC functions -- which IBM has provided and which Barbara
has kindly shown in specific detail in other posts.
So, again, the question is simple: why does RPG need GC? If it doesn't have
OO and you occasionally allocate your own data structures, then you can
clean up after yourself. And if I'm not mistaken, you can even use
activation group boundaries to clean up for you -- I believe (but I'm not
sure) that any memory allocations done by a job are released when the
activation group ends. Maybe someone more knowledgeable like Scott, Bruce
or Barbara can chime in.
Joe
As an Amazon Associate we earn from qualifying purchases.