Chapter 2: Why Node.js? Advantages vs RPG, Java, Python and PHP
Node.js is going to replace our existing RPG. Will we need to rewrite our ERP System? A new SQL Database? Is our old RPG system redundant?
Let me get this out of the way, because I can already hear the comments being typed: Node.js is not here to replace RPG.
RPG is brilliant at what it does: high-volume, record-level business processing tightly integrated with Db2 for i. Free-format RPG with embedded SQL is a modern, capable language and it's not going anywhere. I still write it every week.
Where Node.js wins
| Task | RPG | Node.js |
|---|---|---|
| Serve a REST/JSON API | Possible (IWS, YAJL, DATA-INTO, CGI) but fiddly | Natural - it's what Node was born for |
| Parse/produce JSON | DATA-INTO/DATA-GEN + a parser | Built in: JSON.parse / JSON.stringify |
| Call a third-party web API | HTTP_GET / SQL HTTP functions | fetch() built into Node 18+ |
| Web front end | CGI or a separate tier | Same language front and back |
| Packages | Limited | Over two million on npm |
| Hiring | Shrinking (sadly) pool | Huge pool of JavaScript developers |
Where RPG still wins
The sweet spot: use both
The smart move is to put Node.js on the edge - web APIs, integrations, modern UIs - and keep RPG in the core. Node.js calls your RPG programs via itoolkit (we'll do that in Section 4) or calls SQL stored procedures that wrap them. Best of both worlds, and nobody has to fight in the car park.
