Last August, we told you about a project posted on GitHub by Romanian software developer Bizău Ionică that makes it possible for snips of legacy COBOL code to run within the JavaScript code of the popular Node.js interpreter. There's more than a little irony in this project. COBOL, the mother of all cross-platform programming languages, is still in use after 62 years, mostly in legacy applications that no one cares or dares to retire. Grabbing snippets of code to run in Node.js—one of the most popular languages to develop networked software today—could be seen as a way to pull old code into the 21st century.
Ionică has now completed the circle with a software bridge that can execute Node.js script from within COBOL programs. It’s called node.cobol, and it compiles with GNU COBOL, though it still requires Node.js be installed on the same machine the code runs on. This is really helpful if you want to, say, run a Web server from within COBOL code.
Would you really want to run a Web server within COBOL? I don't know. But now you can:
* Compile this file together with the node.cobol * modules: * * $ cobc -x example/main.cbl lib/node-exec-* * * Then execute the binary file: * * $ ./main IDENTIFICATION DIVISION. PROGRAM-ID. MAIN. DATA DIVISION. WORKING-STORAGE SECTION. 01 NODEJS-CODE PIC X(100) value "console.log('Hello World!')". PROCEDURE DIVISION. * Execute a short Node.js snippet CALL 'EXEC_NODEJS' USING NODEJS-CODE DISPLAY "Starting an HTTP server on port 8000". * Convert an image into ASCII/ANSI art CALL 'EXEC_NODEJS_FILE' USING "example/grace-hopper.js" DISPLAY "Starting an HTTP server on port 8000". * Starting an HTTP server in Node.js CALL 'EXEC_NODEJS_FILE' USING "example/server.js". STOP RUN.
For those with a fondness for Inception, that means, as Ionică tweeted to me this morning:
@thepacketrat Now we can run COBOL in Node.js in COBOL in Node.js etc! :-)
— IonicaBizau (@IonicaBizau) May 17, 2016
There's also good news for FORTRAN lovers—Ionică has built a FORTRAN connecter for Node.js and a Node.js bridge for FORTRAN. So dust off those punch cards and your Fortran 77 textbook and crank up a Web server, people.
reader comments
35