Why REXX does not need to be compiled?

Time Sharing Option, Interactive System Productivity Facility and REstructured eXtended eXecutor

Moderator: mickeydusaor

Post Reply
Geetu
Registered Member
Posts: 24
Joined: Tue Oct 21, 2014 5:31 pm

Why REXX does not need to be compiled?

Post by Geetu »

Hi,

I have started working with REXX. I am reading about it more and learned that it's true that scripting languages don't require compilation and so does REXX. But how does a computer understand a program then:: I mean is not it a first step to convert the program to some kind of machine code to become understandable to machines?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why REXX does not need to be compiled?

Post by Robert Sample »

is not it a first step to convert the program to some kind of machine code to become understandable to machines
Not necessarily -- research interpreters and p-code machines. REXX is generally an interpreted language, although (for z/OS at least) there is a REXX compiler available.
Geetu
Registered Member
Posts: 24
Joined: Tue Oct 21, 2014 5:31 pm

Re: Why REXX does not need to be compiled?

Post by Geetu »

Thanks Robert. I read the article on p-code machines at https://en.wikipedia.org/wiki/P-code_machine though I am still trying to understand it.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why REXX does not need to be compiled?

Post by Robert Sample »

Programs are either compiled or interpreted. Compiled programs can run quickly (and often are optimized for the hardware) but the cost is that changes to the source have to be recompiled which introduces a delay. Interpreted programs can be changed very quickly since the code is read when the program is executed but the cost is that interpreted programs run MUCH slower than compiled programs -- usually a minimum of one order of magnitude slower; it is not unusual for them to run 2 orders of magnitude slower. Optimization also tends to be problematic for interpreted programs since the final machine code isn't known until the program is executing. Also, compiled programs are closely tied to the hardware since they are using the machine's instructions; interpreted programs don't need the machine's instructions until the code is being executed.

Bytecode (p-code) is an attempt to combine these approaches. An ideal p-code machine is conceived and programs are compiled into p-code; for any given platform a p-code translator converts the p-code into machine code. This preserves code portability since the p-code will be the same for all platforms.
Geetu
Registered Member
Posts: 24
Joined: Tue Oct 21, 2014 5:31 pm

Re: Why REXX does not need to be compiled?

Post by Geetu »

Thanks Robert. That's a great a explanation. I read it 3 times.

I have another question, does that mean all the languages which are called compiled languages are actually generating p-code, to make them platform independent?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Why REXX does not need to be compiled?

Post by Robert Sample »

Actually bytecode (or p-code) is much more recent than mainframes (I think it dates to the late 1970's but I don't have any specific references to its age) whereas the IBM S/360 and its COBOL compiler dates back to 1964. COBOL and FORTRAN, both extensively used in the 1960's and early to mid 1970's, compiled to the machine instructions and still do -- you can use the LIST option of COBOL to generate in the compile listing the pseudo-assembler code generated by the compiler. That code will match the opcodes and instructions you learn in an IBM Assembler class.

You have to look at the language specification (and sometimes the implementation) to determine if it compiles to p-code or not. Java compiles to p-code and I'm not sure if it is possible to use it any other way. Wikipedia has an article on bytecode and lists a number of languages that compile to p-code.

There are other options, of course. GnuCOBOL (formerly OpenCOBOL) translates COBOL into C and then compiles the C code; I don't think it uses bytecode but I've never delved that deep into what it does. Their Wikipedia article says that the C code is compiled into machine code.
Geetu
Registered Member
Posts: 24
Joined: Tue Oct 21, 2014 5:31 pm

Re: Why REXX does not need to be compiled?

Post by Geetu »

Robert Sample wrote: Tue Sep 14, 2021 4:34 am Actually bytecode (or p-code) is much more recent than mainframes (I think it dates to the late 1970's but I don't have any specific references to its age) whereas the IBM S/360 and its COBOL compiler dates back to 1964. COBOL and FORTRAN, both extensively used in the 1960's and early to mid 1970's, compiled to the machine instructions and still do -- you can use the LIST option of COBOL to generate in the compile listing the pseudo-assembler code generated by the compiler. That code will match the opcodes and instructions you learn in an IBM Assembler class.

You have to look at the language specification (and sometimes the implementation) to determine if it compiles to p-code or not. Java compiles to p-code and I'm not sure if it is possible to use it any other way. Wikipedia has an article on bytecode and lists a number of languages that compile to p-code.

There are other options, of course. GnuCOBOL (formerly OpenCOBOL) translates COBOL into C and then compiles the C code; I don't think it uses bytecode but I've never delved that deep into what it does. Their Wikipedia article says that the C code is compiled into machine code.
Thank you Robert, this did help.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “TSO, ISPF & REXX (Do you still do CLIST?!).”