On 07.07.2022 14:54, Seymour J Metz wrote:
Which of these has Java equivalents?
use charnames qw(:short);
use File::Spec;
use Getopt::Long 2.3203 qw(:config auto_help auto_version);
use IO::File;
use Net::DNS;
use MIME::Parser;
use MIME::QuotedPrint;
use MIME::Tools;
use Regexp::Common qw /net URI/;
use Regexp::Common::URI::RFC2396 qw /$host $port $path_segments $query/;
use Socket;
use URI::Escape;
These are Perl-specific libraries, which is fine of course.
There are Java equivalents for all of them, one would need to research them first before being able
to put them to work.
An example for "use URI::Escape;": search on the Internet e.g. with "java encode url" and you would
get many hits, here a few from the top hits:
* Java tutorial: <https://www.baeldung.com/java-url-encoding-decoding>,
* Stackoverflow:
<https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters>
* the Javadoc (Java documentation) of the respective Java class:
<https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html>; if you
wanted the Javadoc
of a specific Java version, let us say Java 8, then you could use the
following search string:
"javadoc 8 urlencoder"
You get the idea, I am sure. This way you are able to fish (research the Java equivalent) for
yourself and are not dependent on others to fish for you! ;)
Java has the advantage of always being there, at least for z/OS. JIT doesn't
hurt.
BSF has been available for a long time; why doesn't every Rexx programmer know
about it and PCRE? Thanks for putting in the work.
You are welcome!
---rony
________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of
Rony G. Flatscher [[email protected]]
Sent: Thursday, July 7, 2022 7:53 AM
To:[email protected]
Subject: Java (Re: Some questions on SYSCALL
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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.oracle.com%2Fjavase%2F8%2Fdocs%2Fapi%2Fjava%2Fawt%2FDimension.html&data=05%7C01%7Csmetz3%40gmu.edu%7C3c202325a69b418f044508da600f6e1f%7C9e857255df574c47a0c00546460380cb%7C0%7C0%7C637927916636331741%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0Etc155I%2FyB6VDmsHqh%2FTkMftp4RSjkD3mttR9Ix%2BgQ%3D&reserved=0>
*/
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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.oracle.com%2Fjavase%2F8%2Fdocs%2Fapi%2Findex.html%3Fjavax%2Fscript%2Fpackage-summary.html&data=05%7C01%7Csmetz3%40gmu.edu%7C3c202325a69b418f044508da600f6e1f%7C9e857255df574c47a0c00546460380cb%7C0%7C0%7C637927916636331741%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4YYnTzNMfjS5AwWEmYl7v0Eww2WJK%2BkCUmDIBmJm7WY%3D&reserved=0>):
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://secure-web.cisco.com/1lUrSAn_ZK-cWwPhYsTEVm2ApxzONuo8RzKt98gpKOYRxuvFVP0pDpP0DKHyUWAXRYwhsib_1L72SupPP-ekUligeqVee7p0DH4XrX6EjgZIMcebDy_oJnJ-dz31js2pe2d-_g5Qwi313FfBITMP0SbOVQaj5_xpQ_m90SniFmEEewdYmQ6cYRePii9qXG1B5OkXzffK77e-US0qFZcazvtIIScycQXWEB0OQckOuohHDtlBLcycwytsLrsZy3zpQIInNlADfk6IeAgA-rAIwJmiSaX4JUl-n6B1pRxv7W83cdQLmU3OutWXtU_02izs_Rs86j2VXs-1e3n-Q-WYUMC8mqcvP6gdGivZqsRptwan8aMO6c_Ru9xhny0mYkJiJUx7I-lTeLyL3s4-C1gklBvcR2Xn31g65O6TI1lQHJW08VoqoHciFyruV5z9jfNXVP9VQ6_BufbLC6T23eKUqFg/https%3A%2F%2Fsourceforge.net%2Fprojects%2Foorexx%2Ffiles%2Foorexx%2F5.0.0beta%2F>
[2]
BSF4ooRexx:<https://secure-web.cisco.com/1HFuMFoQ3y7skDqz2gVws_E0EskxO3z6FKD6oQPpKYMMWeYqV-qXZK-syIHs8kLE1wMV0mBu2Qr4n5ivn1Eptn5PG6ozjl7i1RvEhdODVpP13zVdqDMorp8k-knV5aa6_yO-vDnFZvn2Ij3kAQbf-ar0-LgAIq-MdemMOCSQak7RpS_5gE2ETmWTZEN67OZS4YSaArfx40z9gfifEbHb4aYv8F_QG9eG7v6ZYZUpoVocJL44i7RO6Zz3txUI22CKpiBZXac8S7YSQD-kgfU-v6SHEXOjqXsqxhZPNJmxKHraprOeIWbDPODE1ZJ60T2N--zxjI9UtBpyKAV9qCRa03crJBiuKlc-Vi4YdmtaQzompUvDNuz8oVVwgSreRUXoocqa5qlooScRdQ2qRyfgAw8PNpRglrV09Z0crggk0_vvxbC4Gfx9OIkttSSSpO7qQt9XlyRYXhjqsUi4TguHOSQ/https%3A%2F%2Fsourceforge.net%2Fprojects%2Fbsf4oorexx%2Ffiles%2FGA%2FBSF4ooRexx-641.20220131-GA%2F>
[3] ooRexx-Plugin for IntelliJ:
<https://secure-web.cisco.com/16nJUPpQxyTq0BBmyNLHHbAD4_MC-J88zwUinc6q4ED75hiTAmvc9O1TRcL93c5ewsEPkonPPPxOeLUJpv8__VBGJy73b2u0I1X8nmKPRApvRiJ8SzhhlI5iKJjft4RTfTC7l2mBAVht3ODPsqDugRzcWdvqdv9HS7V9Pm48Lm7ZJp8cgEP6BSX8CiPXgGGqNs0VJQDo2Msg85BzmZzyfkynBq2M6aw48fQcfkvQRQxZrfjYQ34TEQKI_cud6FvZIDdnPEO-MlBv7Yp56nKGOHRYcWzXmj_moi__iyEVfQhJ0uAenoCViLnC6T31dbKtfZ0cMSLUtDb-Tt2-d1zYRz7c5YOBM62z7a8Ve5frU9-h5Z5XBAom157ajxmR1sPnVGWyR00jn4xPy6kk8k_0SPq_-eir_AVPSc0vec2BYv5ugyltLx5schUe7V7X4nTsW28Et1RT5PBr-MK416P_4yw/https%3A%2F%2Fsourceforge.net%2Fprojects%2Fbsf4oorexx%2Ffiles%2FSandbox%2Faseik%2FooRexxIDEA%2FGA%2F2.1.0%2F>
________________________________________
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