On 06.07.2022 11:03, Seymour J Metz wrote:
When I select a language for a job, one of the things that I look at is the
ecosystem. I prefer ooRexx to Perl, but I find myself using
Perl for some tasks because CPAN is an awesome resource. Python may not be the
best language for the task at hand, but it pays to check what packages are
available.
Indeed Perl and Python have a great wealth of libraries available to them.
There is one ecosystem that beats Perl, Python and practically any others: Java. For every problem
domain, for new emerging technologies there are Java class libraries which one can take advantage
of. As Java classes get compiled to intermediate byte code, these Java class libraries can be
deployed and used immediately on any hardware and any operating system for which a Java virtual
machine exists.
The Java runtime environment (JRE) already comes with a wealth of professional and tested class
libraries covering practically all aspects of modern programming, covering everything that any
modern application may have a need to exploit and interact with.
Seeing the OpenJDK (open-source Java) community and how vigorously Java gets developed further,
continually updated in critical areas like security, there is no end in sight for this great
ecosystem. Witnessing also OpenJDK distributions (from Java 8 LTS to the latest Java 18) from IBM,
Amazon, SAP, even Microsoft, and many, many more competent and leading IT-related companies, the
support for Java is unique compared to any other software there is.
There is no other language and there is no other software infrastructure that can possibly beat Java
in this regard.
Therefore it is a good idea to use Java strategically in software projects.
Having said all that, you may see the motivation why I wrote an ooRexx [1] function/class library
that bridges ooRexx and Java, which is called BSF4ooRexx [2]. This ooRexx-Java bridge has two main
applications:
* Allow ooRexx programmers to use Java classes and Java objects as if they
were ooRexx classes and
ooRexx objects to which one can send ooRexx messages and the Java objects
will understand them
conceptually. Here a small ooRexx example that demonstrates how to use the
Java class
"java.awt.Dimension" as if it was an ooRexx class:
/* Java class, cf.
<https://docs.oracle.com/javase/8/docs/api/java/awt/Dimension.html> */
dim=.bsf~new("java.awt.Dimension", 111, 222)
say "1)" dim~toString /* every Java object understands "toString" */
dim~setSize(555,222) /* change width Java-like */
say "2)" dim~toString
dim~width=999 /* change width ooRexx-like (attribute) */
say "3)" dim~toString
::requires BSF.CLS /* get ooRexx-Java bridge */
Running the above ooRexx program yields:
1) java.awt.Dimension[width=111,height=222]
2) java.awt.Dimension[width=555,height=222]
3) java.awt.Dimension[width=999,height=222]
* Allow Java programmers to easily run ooRexx scripts/macros, with the
possibility to even supply
arguments that may be even Java objects with which the ooRexx program can
readily interact with.
Here a small Java example that demonstrates how to run an ooRexx script from
Java using the
standard Java scripting framework (cf.
<https://docs.oracle.com/javase/8/docs/api/index.html?javax/script/package-summary.html>):
import javax.script.*;
public class TestRunRexx
{
public static void main (String args[])
{
String rexxCode = "say 'Hello, world, this is Rexx speaking ...'
\n" +
"say 'It is:' .dateTime~new
" ;
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine se = manager.getEngineByName("rexx");
System.out.println("about to execute the Rexx program from
Java...");
try
{
se.eval(rexxCode);
}
catch (Throwable t)
{
System.err.println(t);
System.exit(1);
}
System.out.println("about to end Java.");
System.exit(0);
}
}
Compiling the above Java program with "javac TestRunRexx.java" and running it
with "java
TestRunRexx" yields:
about to execute the Rexx program from Java...
REXXout>Hello, world, this is Rexx speaking ...
REXXout>It is: 2022-07-07T13:43:42.670000
about to end Java.
---
So my advice would be, if you use ooRexx and have a need for functionality that is not available:
install the ooRexx-Java bridge BSF4ooRexx and from that moment on you have access to *all* Java
class libraries on *all* operating systems: this makes a wealth of libraries immediatley available
to ooRexx that does not possibly exist for Perl, Python, Ruby and the like.
So the combination ooRexx+Java is hard to beat when it comes to looking for ubiquitous functionality
that you want to use from ooRexx instantly. And both are free.
---rony
[1] ooRexx 5: <https://sourceforge.net/projects/oorexx/files/oorexx/5.0.0beta/>
[2] BSF4ooRexx:
<https://sourceforge.net/projects/bsf4oorexx/files/GA/BSF4ooRexx-641.20220131-GA/>
[3] ooRexx-Plugin for IntelliJ:
<https://sourceforge.net/projects/bsf4oorexx/files/Sandbox/aseik/ooRexxIDEA/GA/2.1.0/>
________________________________________
From: IBM Mainframe Discussion List<[email protected]> on behalf of Bernd
Oppolzer<[email protected]>
Sent: Wednesday, June 29, 2022 5:52 PM
To:[email protected]
Subject: Re: Some questions on SYSCALL
The only reason why your Python code is shorter is because you use
the builtin os.walk method to walk through the directory recursively.
A similar method could have been used in my REXX example, too,
but I wanted a command to be issued in every subdirectory
when walking through the tree,
so I had to do the recursive directory walk myself, using the recursive
call
to the tree procedure. This is what makes my coding longer,
but this is not due to the REXX language. Be fair.
To call this verbose is simply wrong, and you are missing the point
completely;
please show me how your Python solution looks, if you also walk the
directory tree
by yourself and issue a command given as a parameter at every subdirectory
and not only print the name.
but I don't really want to argue on this ... this seems like a waste ot
time.
I use the tools I have at hand ... and I didn't have Python in 1998 on
my OS/2 boxes.
This has nothing to do with personal favor; I use the tools which make
the most
sense for me, given my knowledge or my personal skills (which can of course
change or improve over time).
Earlier in a similar thread I told you or other posters how easy it is
to append
small pieces of information every 15 minutes to a file using IBM's C
and still having a large blocksize etc. ... and how I would support
the simultaneous update and the reporting. The thread degraded into a
discussion about started tasks and how to implement the operator commands
to control the STCs using REXX or other languages ... again: what a
waste of time.
For appending information to a file every 15 minutes, I would create a
batch job
which is started every 15 minutes, controlled by UC4 or cron or whatever
you have
... and which terminates after some milliseconds. No need for a started
task,
which is idle most of the time.
I miss sometimes a certain cost sensitivity with the discussions here in
IBM-MAIN,
but this should be part of our profession.
Kind regards
Bernd
Am 29.06.2022 um 23:24 schrieb David Crayford:
On 30/06/2022 4:22 am, Bernd Oppolzer wrote:
This is an old OS/2 REXX program (from the 1990s, IIRC),
used to traverse a directory tree recursively and issue a command in
every subdirectory found:
/* rexx */
arg command
call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs"
call SysLoadFuncs
dir = directory()
if right(dir,1) = "\" then
dir = left(dir, length(dir) - 1)
call tree dir, command
x = directory(dir)
exit
tree: procedure
arg dir, command
say "*** Verzeichnis in Bearbeitung: "dir" ***"
x = directory(dir)
command
rc = SysFileTree("*.*", verz, "D")
do i = 1 to verz.0
dir = word(verz.i, 5)
call tree dir, command
end
return
you may notice the recursive call of the procedure "tree".
I don't see any justification for your REXX bashing;
it's just another flavor of scripting language, which allows to do
great things,
once you manage to use it.
Sorry Brend, but I don't consider that snippet to be great! It's a
perfect example of flabby, verbose REXX code. The only justification
for using REXX is that you personally favor the language. Python is
far more succinct.
|for| |root, dirs, files ||in| |os.walk(path_of_the_directory):|
|||for| |i ||in| |files:|
|||print||(os.path.join(root, i))|
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN