Top 8 Reasons for using Python instead of REXX for z/OS

Frank J. De Gilio
Theropod
Published in
6 min readDec 17, 2021

🖥 🖥

Lots of great tools in the drawer

If you asked any z/OS person, what scripting language they use on the platform, the majority would say REXX. This makes sense because REXX is an easy to use, flexible language that makes it simple to issue commands, parse the returned data, and perform any compensating actions. Back in the 80s when I started writing scripts for the platform, I loved REXX because it was powerful, easy to pick up, and allowed me to attack complex problems quickly.

Lately, I have been eschewing REXX for Python. While it did take effort to transition from REXX to Python, I believe the transformation is important and something every sysprog should consider doing. Naturally, I don’t expect people to rewrite all their REXX programs, but I do think people should make the effort to write their new code in Python. There are some pretty strong arguments for doing this. Here are the top 8 reasons to use Python instead of REXX:

1. Python programmers are more plentiful

While REXX is easy to learn, it is not easy to find REXX programmers outside of the z/OS world. When bringing new people into the company, it is much easier to find people who understand Python. Job listings with Python as the language will probably be less overlooked than REXX. Sure, those people will have to learn z/OS constructs, but they won’t also have to learn a new language. While REXX is easy to learn, you still must learn it. A tyro trying to pick up the language while they debug or change existing REXX code is challenging. Face it, there are some esoteric ways to use REXX that would confuse a newbie.

2. Python’s structures make it more readable

Python code forces a more readable code pattern. While it would take a bit of work for someone who is new to the Python language to get right all the language intricacies (especially if they are writing their code in ISPF), the rules for coding in Python makes the code more legible. If you are using a workstation editor like VSCode or Atom, they provide formatters to make writing code easier. In addition to the fact that Python code itself tends to be simpler to understand, these editors along with its formatters help enforce Pythonic style. Pythonic is a coding style that makes code concise, clear, and less complex. Overall, the entire Python community drives code that is easier to follow. This is going to be critical for new people trying to learn not only what you are trying to do, but also how the system works.

3. Python is easily extendable

Most of the world relies on C code as its system interface language. Platforms like Linux are mostly written in C. Even the z/OS world can leverage the C language as an access language to Assembler functionality. Python is easily extendable with C. Most of the IBM Z Open Automation Utilities are written in C and provides Python modules that leverage the C infrastructure to make use of lower system capabilities. This will only grow in the future as the open-source community takes advantage of such extensions. It is not hard to foresee a world where Python modules interface to z/OS assembler macros making the system much more approachable to new people interested in the platform.

4. Python has more supporting functions

There is a plethora of packages in Python making it easy to take advantage of functionality that someone else has created. Not only does this allow people to take advantage of cool Python functions, but it also allows us to create packages that abstract some of the particularly esoteric z/OS components to make it easy for future sysprogs to use. There is already work in this space. In addition to packages that support simple connections to the HMC, or 3270 data streams, there is an Open Source repository for Python base building blocks at https://github.com/ambitus/pyzkiln.

Look at the programmers working together instead reading this article!

5. Python vulnerability checking

We live in a time when systems are increasingly under attack. Because of this, many companies are looking for ways to ensure that code being used has been vetted to ensure that it doesn’t pose any hacking risk. While there are no guarantees that code is completely safe, having tooling that checks code for known vulnerabilities is essential for minimizing risk. Python’s popularity and its pervasive use in system automation has driven the creation of a set of tools designed to ensure that known vulnerabilities are absent from code that will be automating management functions on the system.

6. Python is used to manage automated activities on all other systems

Many businesses already rely on Python as the automation language for their non z/OS environments. For many businesses, there is already experience in house automating other platforms in the data center. For many of them, orchestration tools like Ansible, rely on Python routines to perform management tasks. Using Python makes it easier for the system to play in the same environment, giving it the look and feel as every other platform in the business. It also makes it easier for non z/OS people to learn what is happening under the covers.

7. Python has tools to aid in documentation

Everyone hates documenting code. It takes time, effort and let’s face it, once the code is done everyone wants to move on to the next project. Even when people generate documentation, it is often incomplete. Python has tools to provide the start of documentation for both the end users of the code and those responsible for maintaining it. Having a set of tools makes it easier to create documentation that is accurate reflecting what the code is actually doing.

8. Python is the language of AI

Modern workers do not stay with a company as long as they used to. As such, we need to make sure they are productive quicker than ever before. To make this happen, we will need automation that can take advantage of AI to help sysprogs make good decisions about the smooth operation of their z/OS systems. This means that the automation will have to interact with AI Operations models. Since most of that work is done in Python today, having automation that can easily leverage that functionality will be critical.

Not a knock on REXX

None of this says that REXX isn’t a great language, nor does it say that existing REXX programs need to be rewritten into Python. Just as REXX replaced CLIST on the mainframe, it seems likely Python is poised to replace REXX as the language of the future, not because it does things better, rather because everything around it makes the scripting task easier.

Supporting a youthening community

There is a confluence of events that will drive this change. There are a number of sysprogs who are nearing retirement. At the same time, the incoming workforce tends not to commit to a company for their entire career. Because of this, we need sysprogs to be effective with a shorter adoption period. We can’t afford to educate a sysprog over the course of 7 years and hope she/he stays with the company until retirement. We need that person to be productive quickly for as long as they work in the company. Python is a language that will facilitate that productivity requirement.

--

--

Frank J. De Gilio
Theropod

Seasoned mainframer guy with delusions of grandeur