Node.js Bridge For COBOL
Node.js Bridge For COBOL
Written by Kay Ewbank   
Friday, 20 May 2016

The developer who came up with a way to run COBOL from within JavaScript has now added a way to run JavaScript in COBOL.

Romanian developer Bizău Ionică has also developed similar modules that let you mix Fortran and JavaScript.

While both projects seem at first glance to be well into the crazy zone, there is method in Bizău's madness. There are still a lot of COBOL legacy applications left running without anyone to maintain or manage them, and the range of Fortran modules covers more or less all scientific areas that people have been interested in since the 1970s. Being able to pull in code from either COBOL or Fortran into Node.js could save a lot of unnecessary recoding. Whether there's a use for running Node.js in Fortran or COBOL is less clear, but Bizău told us it was at least interesting to code it!

 

cobol3

 

The new COBOL-Node.js unit is called node.cobol. It compiles with GNU COBOL, and you need to install Node.js on the same machine you're running the code on. In theory this would let you do things such as run a Web server from in your COBOL code. If you're adventurous enough to try it, this would be how it would look in your COBOL code

 

       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.

The Fortran connector is used with two parameters, input and callback. Input should contain the Fortran code to execute, or a path to a Fortran file, while callback is called with err, stdout and stderr.

 

For example:

const fotran = require("fortran");
// Let's run some Fortran stuff
fotran(`
      program hello
          print *, "Hello World!"
      end program hello
`, (err, data) => {
    console.log(err || data);
    // => Hello World
});

Punched card readers and coding pads are optional for all the modules.

cobol

More Information

Ionica Bizau on Github

Related Articles

Hottest Skills To Get You Hired  

COBOL for Node.js

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter,subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin

 

Banner


Fear And Loathing In The App Store 19 - Apple Rejects Net Neutrality App
18/01/2018

An app that tests to see if your ISP is applying throttling to your data according to its type - aka a net neutrality detector - has been rejected from the App Store for some very strange reasons.



As We Are - A 14-Foot Selfie
27/12/2017

How far we have come from "As We May Think" to "As We Are". The selfie has has transformed from a modern wonder to an irritation and occasionally a danger to life and limb. But the selfie can be art.  [ ... ]


More News

 

 
 

 

blog comments powered by Disqus

Last Updated ( Friday, 20 May 2016 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.