Skip to content

Compiler backend

andigena edited this page Feb 19, 2018 · 8 revisions

You may want to test your generated code after the OneLang compiler compiles it to various target languages. To make this possible you need a backend server which has the appropriate compilers and/or runtime environment installed and served via

Source repo & Docker image

The source code of the Compiler backend can be found in the CompilerBackend repository.

The pre-built Docker image is available as onelang/compilerbackend on Docker Hub. This was automatically generated from the source repo.

How to setup the compiler backend

Currently the compiler backend is tested on Ubuntu 16.04 via WSL (Windows Subsystem for Linux) and macOS 10.13.

The easiest way is to install the backend as a Docker container, but if you want to install it natively to your machines then please follow the instructions in the Dockerfile in the source repo.

How to run the compiler backend

This depends on your use-case (see the Security section for explanation):

  • running the backend on the same (desktop) machine from which you browse and you're the only user of the machine: ./ --localOnly (requires Python 2)
  • running the backend on the same machine, but the machine is also used by others: ./ --localOnly --requireToken
  • installing it on a server: ./

Without the --localOnly parameter, it will listen on instead of, but will also turn on authentication (see below).

This will provide a HTTP server on the TCP port 11111.

You can now use the backend by passing the address of your server as the server parameter to Eg.

In-memory compilation

To make compilation faster, C#, Java, PHP, Python, Ruby, JavaScript and TypeScript use in-memory compilation (provided by a continuously running process) which may cause unexpected result. You can disable this behavior by passing --noInMemoryCompilation to the script as command line argument.

The implementation of these servers can be found in the InMemoryCompilers subfolder of the CompilerBackend repo.

Authentication & security

Running the compiler backend comes with severe security risks as anybody who can access its interface (thus able to compile and run code on the machine), can hijack your whole machine and steal all your data, credentials, etc.

Although the compiler backend contains various techniques to minimize the chance of such attacks, no guarantees are provided and it's your call whether you run it or not.

So here are a few recommendations security-wise:

  • use Docker or a VM to run the backend: if something goes wrong, only your container / VM will be hijacked
  • if you make the backend publicly available: put a HTTPS reverse-proxy in front of the backend and make sure it requires authentication (if you use the --localOnly parameter, then make sure you also use --requireToken parameter too). If you don't want to use HTTPS, then please make sure you don't use your server on a public network (free WiFi, etc) as the credentials travel in plaintext if you don't use HTTPS
  • if you use the backend only locally, but you are in a multi-user environment (the machine is used by others) then use the --requireToken parameter