compilex
compilex is a node.js library which is used to build online code compiler/interpreter websites and webservices.
You can compile and respond back outputs for all the languages that can be compiled by the server.
Some of the online code compiling/judging websites are
Using compilex , you can built sites and services like the above said examples.Why compilex ?
- compilex can detect infinite loops in the users program .
- It can compile programs by getting input from STDIN.
- Generates statistics for the administrator.
Supported Languages
compilex is currently in initial development stage . As the library grows , so does the list here .
Language | Support |
---|---|
C | ✔ |
C++ | ✔ |
Java | ✔ |
Python | ✔ |
C# | ✔ |
Visual Basic | ✔ |
Work Flow
- Get the program as input from the client as a request
- Use compilex modules to compile the program
- Get the output and errors in json and string formats
- Respond the output to the client
Setting Up Compilers
Inorder to compile any programming language , you need to first have the compiler for that programming language in the server machine.
C and C++
- Installation :You need GCC compiler that can compile programs from your cmd/terminal
- Windows - You can get MinGw .
- Linux - Most of the linux versions are installed with gcc by default. If you haven't got , Take a look at Installing GCC .
- Testing the Environment :After installing , set your environment variables for accessing the GCC command lines from any directory
- Windows - create a c file in a directory , execute
g++ filename.c -o output.exe
output.exe
then you will get the output of the program - Linux - create a c file in a directory , execute
gcc filename.c -o output.out
./output.out
then you will get the output of the program
- Windows - create a c file in a directory , execute
Java
- Installion : You need JDK ( Java Development Kit ) to compile Java programs.Click here to download JDK for various platforms.
- Testing the Environment :After installing , set your environment variables for accessing the javac command lines from any directory
- Create a Java file named Main.java with main function
javac Main.java
java Main
then you will get the output of the program.
- Create a Java file named Main.java with main function
Python
- Installation : You can get and install Python from here
- Testing the Environment :After installing , set your environment variables for accessing python command lines from any directory
- Create a python file hello.py and execute
python hello.py
then you will get the output of the program.
- Create a python file hello.py and execute
C# and VB
- Installation : You can have the idea of accessing C# compiler from here . This step also adds VB compiler to the scope automatically as csc and vbc are located in the same directory
- Testing the Environment :After installing , set your environment variables for accessing C# and VB command lines from any directory
- Create a C# or VB file Hello.cs or Hello.vb and execute
csc Hello.cs
Hello.exe
or
vbc Hello.vb
Hello.exe
then you will get the output of the program.
- Create a C# or VB file Hello.cs or Hello.vb and execute
NOTE : Video demos for setting up the compilers and using compilex will be availble soon.
Documentation
1)Require compilex
var compiler = ;var options = stats : true; //prints stats on console compiler;
init() creates a folder named temp in your project directory which is used for storage purpose. Before using other methods , make sure to call init() method.
2)C and C++
//if windows var envData = OS : "windows" cmd : "g++"; // (uses g++ command to compile ) //else var envData = OS : "linux" cmd : "gcc" ; // ( uses gcc command to compile ) compiler; //res is the response object
3)C and C++ with inputs
//if windows var envData = OS : "windows" cmd : "g++"; // (uses g++ command to compile ) //else var envData = OS : "linux" cmd : "gcc" ; // ( uses gcc command to compile ) compiler;
4)Java
//if windows var envData = OS : "windows"; //else var envData = OS : "linux" ; // (Support for Linux in Next version) compiler;
5)Java with inputs
//if windows var envData = OS : "windows"; //else var envData = OS : "linux" ; // (Support for Linux in Next version) compiler;
6)Python
//if windows var envData = OS : "windows"; //else var envData = OS : "linux" ; compiler;
7)Python with inputs
//if windows var envData = OS : "windows"; //else var envData = OS : "linux" ; compiler;
8)C#
var envData = OS : "windows"; //mono modules for linux is not included till now compiler;
9)C# with inputs
var envData = OS : "windows"; //mono modules for linux is not included till now compiler;
10)Visual Basic
var envData = OS : "windows"; compiler;
11)Visual Basic with inputs
var envData = OS : "windows"; compiler;
12)Memory Management
All the temporary files ( source code and executables ) are created in your temp directory. flush and flushSync helps you to free the memory by deleting the temporary files.
compiler;
Synchronous version of flush
compiler;
13)Statistical Data
Getting statistics about your compilex server has been taken care. fullStat returns json data about your server.
compiler;