Codemux: a RESTful language interpreter

What is it?

Code Multiplex, written in Python / Django / Django Rest Framework, is an open source RESTful application / RESTful language interpreter. Since it’s a REST application, it allows access to remote scripts without predefined language restrictions: you send JSON and you receive JSON. It’s a “Language as a Service” model, “Interpreter as a Service”, or perhaps most accurately a “RESTful language interpreter”.

So, how does this work? Because Codemux is a separate application with its own interpreter, your application talks to Codemux via HTTP. From there, Codemux talks to its interpreter. Finally, Codemux will ship its results back in a response. Essentially, it’s a wholly separate instance meant to compliment your existing application.

Codemux runs as a service for existing applications. Once setup, an administrator can push scripts to it, and then have those scripts available to their primary application.

A scenario

Imagine you have an existing web application that primarily acts as a CRUD. Sooner or later, you will have clients or users requesting new features. Eventually one of these features will add new requirements to your code and changes to your application’s environment/system as well.

So let’s also imagine that your users have requested a report based on an R script they have. While not exhaustive, there are a couple of ways you can solve this problem. On the one hand, you can try to integrate R into your application. On the other hand, you might attempt a port of the script in your application’s primary or native language.

Being a seasoned engineer and/or dev ops, you know that integrating R will require you to install R and it’s dev dependencies. Not to mention that you will need to make code changes in your application. Now you will need to implement a foreign function interface / language bindings to the R interpreter.

Again, since you’ve seen these problems before, you know that porting the script isn’t always that simple. For example, you might end up with slightly, or entirely, different results than the client’s script yields. Also, no matter how much you fuss with a rewrite, you may not be able to reproduce the script’s results.

A reason for a RESTful language interpreter

So these are some problems that Codemux attempts to solve. Now all you need is to run Codemux and then query it’s RESTful interface from your main application. Ok, so it’s not that simple: you still have to curate the interpreter environment.

That last part is something we are also attempting to solve. And at least for now, we have done this by curating language specific docker images. Since we are using containers, getting an instance up and running and standardizing development environments across teams should be baked in.

This early version of Codemux comes with an example python docker image for the target script resource system. You could just as easily configure your own server instance and run the Codemux application. Either way, containerized instances serve as a practical approach or an example, to solving the decoupling problem.

Future of the project

At this point we are not at a first full release. Because I feel this project has real potential, I wanted to open source it. As a result, Codemux is licensed under the “New BSD License”. We want people to pull down the project, use it, recommend changes.

Please feel free to pull the project down and provide feedback. We are open to feature requests, issues, and pull requests.

Facebook
Twitter
LinkedIn
Pinterest