All Projects → smeup → jariko

smeup / jariko

Licence: Apache-2.0 license
a JAva virtual machine Rpg Interpreter written in KOtlin

Programming Languages

RPGLE
3 projects
kotlin
9241 projects
ANTLR
299 projects
java
68154 projects - #9 most used programming language
ruby
36898 projects - #4 most used programming language
powershell
5483 projects

JaRIKo: a JAva virtual machine Rpg Interpreter written in KOtlin

jariko Logo

License Build Status CircleCI codebeat badge jitpack GitHub commit activity

⚡️ Cross-platform RPG Code in a polyglot environment ⚡️

Introduction

JaRIKo is an interpreter for the RPG programming language. It runs on the JVM since it's written in Kotlin.

It is part of a bigger project named Sme.UP Open Architecture, by the italian software company Sme.UP.

Sme.UP Open Architecture aims to build a software platform for business applications (also mistakenly known as ERP systems) and it is the core of Sme.UP Data Platform.

How might this work in the real world

JaRIKo can definitely be used as a library: you push RPG code in, you have it executed, you get results out. And it works, as you can see in this animated gif of a simple on-the-fly online rpg-running application.

rpgweb

This application is running completely on Linux

  • recieves the RPG code via HTTP
  • uses Jariko as a jar
  • overwrites the DSPLY opcode, redirecting the output to the http-response. Pretty slick!

rpgweb

But, for an enterprise-grade application, there'll be a runtime environment running RPG and JVM code altogether, and it will likely work as in the following picture

smeup_data_platform

Once a request comes into the system, it's recognized as a "program" (a unit of execution) and redirected towards the right program handler: RPG is handled by JaRIKo (interpreter), the others by different executors. So JaRIKo is one (important) part of the whole architecture

Why are we doing that?

Why building something that runs RPG, such an old and niche programming language? RPG is widely common in the business and financial industry. There are tons of super-stable, higly-tested, mission-critical lines of RPG code running a big amount of businesses since tens of years. Big companies still rely on this programming language.

This is for at least a couple of reasons.

First, RPG was designed for business, it is very simple, powerful for data manipulation, but extremely inadequate to solving technology issue (like threads, async, http calls, cryptography, and so forth). The developer doesn't need to be aware of the technical details. The system provides all this technology, making code run on top of a platform that solves those issues.

This helped to create a generation of RPG programmers that are closer to business consultants than to developers, and this is very good for business applications development.

The second is that RPG only runs on IBMi, best known as AS/400, that was also designed for business, is very reliable, fast, well-supported, and stable. RPG leverages AS/400 architecture, they are the perfect couple.

Focus on:

1- Doping your code

One of the core features of Jariko is the doping mechanism: once the code is taken over by the interpreter, every single program can be replaced at runtime. This allows to write a very flexible and polyglot software, choosing the right tool for the right job and having all the java (and jvm) power and ecosystem available.

doping

Through doping, it's also much simpler to make the architectural design needed to deal with things like SPOOLS, DATAQUEUES, JOBS, DATAAREA, etc, typical of the OS/400 operating system, where the RPG code used to run.

2- DSL

If you know how programming languages work, you also know that once you have a syntax three in your hands, you can do almost whatever you want. So, since RPG is best used for business applications, why don't add new high-level features to make the life of the RPG programmer easier? This is a step towards a Domain Specific Language

 C                   PARM                    §§METO
 C                   PARM                    §§SVAR
 C                   EVAL      PRICE=§§SVAR
 C                   CALC_VAT(PRICE)    

In this example CALC_VAT, standing for "calculate vat" does not exist in RPG, but the interpreter can handle it as a language keyword, with type check, syntax highlighting, code suggenstions, intellisense, errors an so on.

Some questions

1.So it sounds like you are developing an interpreter to run an application on multiple other platforms.

Right

2.What language is the interpreter being developed in?

Mostly Kotlin, but the overall resulting system will be µ-service-based and we're going to use jvm languages.

3.How do you transfer the database to another platform? SQL scripts?

We have ETLs. We've already been doing that since years. SQL must not have dialect-specific statements, or it has to be re-arranged, but we're thinking about that.

4.Do you handle multiple member files, DDM files, multiple physical logical files

No. We're also not implementing DDS, SUBFILE, CLP. And absolutely none of the os/400 system apis.

5.Data areas and user spaces?

Yes. Also QTEMP, RLA (read, write, chain, setll, etc...), SQLRPGLE (maybe...), /COPY

Development

All information for developers is to be found in the Development guide.

Features

The following list shows all the implemented features:

Logging

The project supports configurable logging, described in a separate document.

RPG Unit tests: the MUTE mechanism

We support special annotations to be used to write unit tests in RPG. For details see this document.

MUTEs and Visual Studio Code

You can run MUTE tests in Visual Studio Code: see the documentation

How the repository is organized

  • generated-src contains the code generated from the grammar
  • gradle, gradlew, and gradlew.bat contain the gradle wrapper
  • src contains the source code for the project and the tests
  • out, and build contain temporary files
  • misc contains utilities for downloading sources from AS400 (for example this ruby script)
  • misc/docker: support for Docker, see instructions
  • docs contains documentation

Are there any presentations about your work?

Yes, of course: see the presentation list

How to use this code in your project

At the moment, we use Jitpack to publish the project. See more details here.

Maven

If you use Maven, add these lines to your pom.xml in order to add the repository

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Then add the following dependencies for the core library:

<dependency>
    <groupId>com.github.smeup.jariko</groupId>
    <artifactId>rpgJavaInterpreter-core</artifactId>
    <version>-SNAPSHOT</version>
</dependency>

And this if you want to include the examples too:

<dependency>
    <groupId>com.github.smeup.jariko</groupId>
    <artifactId>examples</artifactId>
    <version>-SNAPSHOT</version>
</dependency>

Side note for maven users who use mirrors: remember to change your .m2/settings.xml with settings like this:

<mirrors>
    <mirror>
        <id>myNexus</id>
        <mirrorOf>!jitpack.io,*</mirrorOf>

Gradle

Here are the configurationd to add to your build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    ...
    implementation 'com.github.smeup:jariko:-SNAPSHOT'
}

Samples

Here is a sample project that uses the interpreter as a library, and here is another one.

Contributing

Every kind of contribution to this project is really welcome. See our contributing guide for more details.

Credits

The grammar used in this project is based on the work from Ryan Eberly. It is derived from his project rpgleparser.

Some RPG Examples are from Claudio Neroni

Another source for good examples is go4as400

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].