In this post I will discuss the programming languages you find on z/OS, and what they are generally used for.
COBOL
The COBOL programming language was invented 60 years ago to make programs portable across different computers. The language is best usable for business programs (as opposed to scientific programs).
COBOL is a language that must be compiled into executables, load modules.
IDENTIFICATION DIVISION.
PROGRAM-ID.
COBPROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY "HELLO WORLD".
STOP RUN.
PL/I was developed in the mid-1960s with the aim to create a programming language that could be used for business as well as scientific applications.
Like COBOL, PL/I programs must be compiled into load modules.
World: Procedure options(main);
Put List( 'Hello world' );
End World;
Assembler is still around. In the past business applications were developed using Assembler. Nowadays you should not do that anymore. But there are still a lot of legacy assembler programs around on the mainframe.
In the old days, assembler was often used to implement tricks to achieve things that were not possible with the standard operating system, or other programming languages. This practice has created a problematic legacy of very technical programs in many mainframe application portfolios.
The modern stance is that Assembler program should be regarded as severe legacy, because it is no longer maintainable and Assembler program are a risk for operating system and middleware updates.
Furthermore, we find Assembler programs in modifications to the z/OS operating system and middleware.
z/OS offers a number of points where you can customize the behavior of the operating system. These so-called exit-points oftentimes only have interfaces in Assembler. Like application programs in Assembler, z/OS exits in Assembler are a continuity risk. Not only because nobody knows how to program Assembler anymore, but even more so because these exit points make use of interfaces that IBM may (and wishes to) change at any point in the future.
IBM is actively removing Assembler-based exit points and replacing these where needed with configuration parameters.
The bottom line is that you should remove all home-grown Assembler programs from your z/OS installation.
TEST0001 CSECT
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVE+4
LA 13,SAVE
WTO 'HELLO WORLD!'
L 13,SAVE+4
LM 14,12,12(13)
BR 14
SAVE DS 18F
END
The language invented by a team from Sun in the 1990s with the goal to develop a language that could run on any device. Support for Java on the mainframe was introduced somewhere in the beginning of the 21st century.
Java programs do not need to be compiled. They are interpreted by a special layer that must be installed in the runtime environment, called the Java Virtual Machine.
The execution is (therefore) far more inefficient than COBOL and PL/I. So inefficient that running it on the mainframe would be very expensive (see section Understanding the cost of software on z/OS, MLC and OTC). To address this IBM invented the concept of zIIP specialty engines (see section Specialty engines), which makes running Java on the mainframe actually extremely cheap.
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" in the terminal window.
System.out.println("Hello, World");
}
}
The C/C++ programming language was added to z/OS in the 1990s as a more mainstream programming language for mainframe applications and tools.
The process of compiling a C source program into a load module is basically the same as it is for COBOL.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!";
return 0;
}
JCL is the original “scripting” tool for the mainframe. It is hardly a programming language, although it has been enhanced with several features over time.
JCL looks very quirky because it was design for interpretation by punch card reader, which you can still see very clearly. The main purpose of JCL is to start a program or a sequence of programs.
Many of the quirky features of JCL have very little use in today’s z/OS programming but are maintained for compatibility reasons.
I mentioned before that there can be tens of thousands of batch jobs running on the mainframe. You should realize that mean you will easily have thousands of JCL “programs” as well to run these jobs.
Nevertheless, we could do with a more accessible, more modern alternative.
//JOBNME5 JOB AB123,PRGRMR,NOTIFY=MYUSER1,MSGLEVEL=(1,1),
// CLASS=1
//RUN EXEC PGM=COBPROG <- PROGRAM TO RUN
//* PROGRAM WAS PUT IN HERE --v
//STEPLIB DD DISP=SHR,DSN=MYUSER1.LOADLIB
//SYSPRINT DD SYSOUT=*
The story goes that the Rexx programming language was created by an IBM developer, Mike Cowlishaw, who was totally fed up with the only available language for scripting at that time, the CLIST language. In one night he is said to have developed Rexx. When he showed it to his colleges next day, they were immediately very enthusiastic.
On z/OS Rexx fulfils the same role a Unix scripts in Unix environments. It is mostly used by system administrators to automated all kinds of administration tasks.
You can run Rexx interactively under TSO/ISPF, but you can also use it in batch jobs.
Rexx is somewhat similar to PHP, I find. It has the same sort of flexibility (and drawbacks).
/* Main program */
say "Hello World"
z/OS has a Unix part, which is complying to POSIX standards, and hence also support a command shell like any Unix flavor. With the shell scripting language you can automate all kinds of Unix processes.
Shell scripts can also be ran in batch jobs.
#!/bin/bash
echo "Hello World"
Many z/OS users exploit the SAS language from the company with the same name. SAS is used for ad hoc programs and reporting, besides its analytical capabilities.
On the mainframe SAS is often used to process the measurement data that z/OS generates, and create all kinds of usage and performance reports.
proc ds2 libs=work;
data _null_;
/* init() - system method */
method init();
declare varchar(16) message; /* method (local) scope */
message = 'Hello World!';
put message;
end;
enddata;
run;
quit;
The programming language Easytrieve from CA/Broadcom you also find regularly in z/OS environments. This language is used by application support staff to create ad-hoc programs, and by advanced end-users to to create business reports from application data.
There are many other languages available on z/OS. But the ones discussed here are the mainstream languages. Languages like Python and R are emerging for analytical applications, JavaScript for use in in Node.js, PHP for web applications. Rocket Software, the company that supports a ported version of Python for z/OS, also have a supported version of PHP and Perl.