{"id":15445568,"url":"https://github.com/scriptnull/compilex","last_synced_at":"2025-05-12T14:50:32.951Z","repository":{"id":17424650,"uuid":"20197786","full_name":"scriptnull/compilex","owner":"scriptnull","description":"[DEPRECATED] compilex is a node.js library which is used to build online code compiler/interpreter websites and webservices.","archived":false,"fork":false,"pushed_at":"2023-04-17T11:37:52.000Z","size":372,"stargazers_count":68,"open_issues_count":4,"forks_count":48,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T08:58:28.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/compilex","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scriptnull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-26T20:36:11.000Z","updated_at":"2025-03-24T16:17:19.000Z","dependencies_parsed_at":"2024-06-19T05:23:51.020Z","dependency_job_id":null,"html_url":"https://github.com/scriptnull/compilex","commit_stats":{"total_commits":82,"total_committers":3,"mean_commits":"27.333333333333332","dds":"0.46341463414634143","last_synced_commit":"afb74a011b9297087c5446720271bef837325784"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fcompilex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fcompilex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fcompilex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fcompilex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptnull","download_url":"https://codeload.github.com/scriptnull/compilex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253758677,"owners_count":21959643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T19:45:20.721Z","updated_at":"2025-05-12T14:50:32.927Z","avatar_url":"https://github.com/scriptnull.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# compilex \n[![NPM version](https://badge.fury.io/js/compilex.svg)](http://badge.fury.io/js/compilex)\n[![Build Status](https://travis-ci.org/scriptnull/compilex.svg?branch=master)](https://travis-ci.org/scriptnull/compilex)\n[![Dependency Status](https://david-dm.org/scriptnull/compilex.svg)](https://david-dm.org/scriptnull/compilex)\n[![Download Status](http://img.shields.io/npm/dm/compilex.svg)](https://www.npmjs.org/package/compilex)\n[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scriptnull/compilex/blob/master/License.md)\n[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/scriptnull/compilex?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\u003e This package is __DEPRECATED__. Please read the [deprecation notice](https://github.com/scriptnull/compilex/blob/master/README.md#deprecation-notice).\n\ncompilex is a node.js library which is used to build online code compiler/interpreter websites and webservices.\n\nYou can compile and respond back outputs for all the languages that can be compiled by the server.\n\nSome of the online code compiling/judging websites are \n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"http://www.codepad.org\"\u003ecodepad\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://www.ideone.com\"\u003eideone\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://www.hackerrank.com\"\u003eHackerRank\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://www.codechef.com\"\u003eCodeChef\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\nUsing compilex , you can built sites and services like the above said examples.\n\ncompilex is an experimental package , however , if you want to build your site quickly , you can prefer to use the API of the above said services. Node.js Wrapper modules for those API are available. You can try [HackerRank SDK](https://github.com/scriptnull/machinepack-hackerrank) and [HackerEarth SDK](https://github.com/scriptnull/he-sdk-nodejs). \n\nTypical scenarios in which you have to go with wrapper modules instead of compilex are \n- If you don't want to have the pain of configuring compilers on your server. \n- If you don't have the access to the VM on which your site is hosted \n- If you feel tired of configuring compilex over SSH.\n\n# Deprecation Notice\n`compilex` is not under active development. It started as an experiment and served its purpose well. But over the time, new technologies like [docker](https://www.docker.com/) emerged. The existence of such technology and [nature of node.js](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/) prove that compilex would not scale well and be production ready with its current state.\n\nBefore a production ready rewrite of architecture and code, I considered looking at already existing solutions, which seem to be powerful enough to make me not to rewrite compilex. Here are they,\n\n#### APIs\nThere are serveral battle tested APIs, that can help compile code online without the hassle of configuration and infrastructure. Some of them are\n- [Hackerrank API](https://www.hackerrank.com/api)\n- [Hackerearth API](https://www.hackerearth.com/docs/api/developers/code/legacy/)\n- and many more.\n\n#### Container Based Solution\n[Docker containers](https://www.docker.com/) prove to be best fit for running code in an isolated environment ensuring security. Instead of rolling out compilex on the server itself, it would be more sensible to run compilex inside a docker container. For that to happen, we will be needing to build docker images for each language and their versions. \n\nLuckily, there is already a well managed and [open source solution](https://github.com/prasmussen/glot) called [glot.io](https://glot.io/). It seems to be one stop solution which includes web editor, docker based code runner, more language suppport and production ready. So, I highly recommend looking at [glot.io](https://glot.io/), if the intention is to run a code compiling service on your own infrastructure.\n\n#### Steps forward\n- compilex won't be unpublished from npm. This is to ensure that, projects using compilex is not affected.\n- No PRs will be merged, except bug fixes. compilex will never reach 1.x.x version ( how sad :( ). This is to enforce people to use alternate solutions ( right solutions ) mentioned above.\n\n\u003e \"I thank people for their responses and support over mail, gitter, quora etc.\" - [scriptnull](https://twitter.com/scriptnull)\n\nSupported Languages \n===================\ncompilex is currently in initial development stage . As the library grows , so does the list here .\n\n| Language | Support |\n|---------|:-------:|\n|C |\u0026#x2714;|\n|C++ | \u0026#x2714; |\n|Java | \u0026#x2714; |\n|Python | \u0026#x2714; |\n|C# | \u0026#x2714; |\n|Visual Basic | \u0026#x2714; |\n\nWork Flow\n=========\n1) Get the program as input from the client as a request\u003cbr/\u003e\n2) Use compilex modules to compile the program \u003cbr/\u003e\n3) Get the output and errors in json and string formats \u003cbr/\u003e\n4) Respond the output to the client\u003cbr/\u003e\n\nSetting Up Compilers \n====================\nInorder to compile any programming language , you need to first have the compiler for that programming language in the server machine.\n\n\u003ch4\u003eC and C++\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003e\u003cb\u003eInstallation :\u003c/b\u003eYou need GCC compiler that can compile programs from your cmd/terminal\n    \u003cul\u003e\n    \u003cli\u003eWindows - You can get \u003ca href=\"http://www.mingw.org/\"\u003eMinGw\u003c/a\u003e . \u003c/li\u003e\n    \u003cli\u003eLinux - Most of the linux versions are installed with gcc by default. If you haven't got , Take a look at \u003ca href=\"http://gcc.gnu.org/wiki/InstallingGCC\"\u003eInstalling GCC\u003c/a\u003e . \u003c/li\u003e\n    \u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTesting the Environment :\u003c/b\u003eAfter installing , set your environment variables for accessing the GCC command lines from any directory\n    \u003cul\u003e\n    \u003cli\u003eWindows - create a c file in a directory , execute \u003cbr/\u003e \n    \u003ci\u003e\u003cb\u003eg++ filename.c -o output.exe\u003cbr/\u003e\n    output.exe\u003c/b\u003e\u003c/i\u003e\u003cbr/\u003e\n    then you will get the output of the program\u003c/li\u003e\n    \u003cli\u003eLinux - create a c file in a directory , execute \u003cbr/\u003e\n    \u003ci\u003e\u003cb\u003egcc filename.c -o output.out\u003cbr/\u003e\n    ./output.out\u003c/b\u003e\u003c/i\u003e\u003cbr /\u003e\n    then you will get the output of the program\u003c/li\u003e\n    \u003c/ul\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003eJava\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003e\u003cb\u003eInstallion :\u003c/b\u003e You need JDK ( Java Development Kit ) to compile Java programs.Click \u003ca href=\"http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html\"\u003e here \u003c/a\u003e to download JDK for various platforms.\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTesting the Environment :\u003c/b\u003eAfter installing , set your environment variables for accessing the javac command lines from any directory\n\u003cul\u003e\n\u003cli\u003eCreate a Java file named Main.java with main function\u003cbr/\u003e\n\u003ci\u003e\u003cb\u003ejavac Main.java \u003cbr /\u003e\njava Main \u003c/b\u003e\u003c/i\u003e\u003cbr/\u003e\nthen you will get the output of the program.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003ePython\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003e\u003cb\u003eInstallation :\u003c/b\u003e You can get and install Python from \u003ca href=\"https://www.python.org/download/\"\u003e here \u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTesting the Environment :\u003c/b\u003eAfter installing , set your environment variables for accessing python command lines from any directory\n\u003cul\u003e\n\u003cli\u003eCreate a python file hello.py and execute \u003cbr/\u003e\n\u003ci\u003e\u003cb\u003epython hello.py\u003c/b\u003e\u003c/i\u003e\u003cbr/\u003e\nthen you will get the output of the program.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003eC# and VB \u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003e\u003cb\u003eInstallation :\u003c/b\u003e You can have the idea of accessing C# compiler from \u003ca href=\"http://msdn.microsoft.com/en-us/library/ms379563(v=vs.80).aspx\"\u003e here \u003c/a\u003e . This step also adds VB compiler to the scope automatically as csc and vbc are located in the same directory \u003c/li\u003e\n\u003cli\u003e\u003cb\u003eTesting the Environment :\u003c/b\u003eAfter installing , set your environment variables for accessing C# and VB command lines from any directory\n\u003cul\u003e\n\u003cli\u003eCreate a C# or VB file Hello.cs or Hello.vb and execute \u003cbr/\u003e\n\u003ci\u003e\u003cb\u003ecsc Hello.cs \u003cbr/\u003e\n     Hello.exe\n\u003c/b\u003e\u003c/i\u003e\u003cbr/\u003e\nor \u003cbr /\u003e\n\u003ci\u003e\u003cb\u003evbc Hello.vb \u003cbr/\u003e\n     Hello.exe\n\u003c/b\u003e\u003c/i\u003e\u003cbr/\u003e\nthen you will get the output of the program.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/ol\u003e\n\nDocumentation\n=============\n\u003ch5\u003e1)Require compilex \u003c/h5\u003e\n\n```javascript\nvar compiler = require('compilex');\nvar options = {stats : true}; //prints stats on console \ncompiler.init(options);\n```\ninit() creates a folder named temp in your project directory which is used for storage purpose.\nBefore using other methods , make sure to call init() method.\n\n\u003ch5\u003e2)C and C++ \u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\" , cmd : \"g++\"}; // (uses g++ command to compile )\n    //else\n    var envData = { OS : \"linux\" , cmd : \"gcc\" }; // ( uses gcc command to compile )\n    compiler.compileCPP(envData , code , function (data) {\n        res.send(data);\n        //data.error = error message \n        //data.output = output value\n    });\n    \n    //res is the response object\n```\n\n\u003ch5\u003e3)C and C++ with inputs \u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\" , cmd : \"g++\"}; // (uses g++ command to compile )\n    //else\n    var envData = { OS : \"linux\" , cmd : \"gcc\" }; // ( uses gcc command to compile )\n    compiler.compileCPPWithInput(envData , code , input , function (data) {\n        res.send(data);\n    });\n```\n\n\u003ch5\u003e4)Java\u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\"}; \n    //else\n    var envData = { OS : \"linux\" }; // (Support for Linux in Next version)\n    compiler.compileJava( envData , code , function(data){\n        res.send(data);\n    });    \n```\n\n\u003ch5\u003e5)Java with inputs\u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\"}; \n    //else\n    var envData = { OS : \"linux\" }; // (Support for Linux in Next version)\n    compiler.compileJavaWithInput( envData , code , input ,  function(data){\n        res.send(data);\n    });\n```\n\u003ch5\u003e6)Python\u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\"}; \n    //else\n    var envData = { OS : \"linux\" }; \n    compiler.compilePython( envData , code , function(data){\n        res.send(data);\n    });    \n```\n\n\u003ch5\u003e7)Python with inputs\u003c/h5\u003e\n\n```javascript\n    //if windows  \n    var envData = { OS : \"windows\"}; \n    //else\n    var envData = { OS : \"linux\" }; \n    compiler.compilePythonWithInput( envData , code , input ,  function(data){\n        res.send(data);        \n    });\n```\n\u003ch5\u003e8)C#\u003c/h5\u003e\n\n```javascript\n    var envData = { OS : \"windows\"}; \n    //mono modules for linux is not included till now\n    compiler.compileCS( envData , code , function(data){\n        res.send(data);\n    });    \n```\n\n\u003ch5\u003e9)C# with inputs\u003c/h5\u003e\n\n```javascript\n\n    var envData = { OS : \"windows\"}; \n    //mono modules for linux is not included till now\n    compiler.compileCSWithInput( envData , code , input ,  function(data){\n        res.send(data);        \n    });\n```\n\u003ch5\u003e10)Visual Basic\u003c/h5\u003e\n\n```javascript\n    var envData = { OS : \"windows\"}; \n    compiler.compileVB( envData , code , function(data){\n        res.send(data);\n    });    \n```\n\n\u003ch5\u003e11)Visual Basic with inputs\u003c/h5\u003e\n\n```javascript\n\n    var envData = { OS : \"windows\"}; \n    compiler.compileVBWithInput( envData , code , input ,  function(data){\n        res.send(data);        \n    });\n```\n\n\u003ch5\u003e12)Memory Management \u003c/h5\u003e\n\nAll the temporary files ( source code and executables ) are created in your temp directory.\nflush and flushSync helps you to free the memory by deleting the temporary files.\n```javascript\n    compiler.flush(function(){\n    console.log('All temporary files flushed !'); \n    });\n```\nSynchronous version of flush\n```javascript\n    compiler.flushSync();\n```\n\n\u003ch5\u003e13)Statistical Data\u003c/h5\u003e\n\nGetting statistics about your compilex server has been taken care.\nfullStat returns json data about your server.\n```javascript\n    compiler.fullStat(function(data){\n        res.send(data);\n    });\n```\n\u003ch5\u003e1)options : (windows only c/c++ only)\u003c/h5\u003e\ntimeout: number of milliseconds to wait before killing the compiled program\n```javascript\n    //compile and execute the file and kill it after 1 second if it still running\n    var envData = { OS : \"linux\" , cmd : \"gcc\" ,options: {timeout:1000 } };\n    compiler.compileCPP(envData , code , function (data) {\n        res.send(data);\n        //data.error = error message \n        //data.output = output value\n    });\n```\n\nExamples\n========\nYou can find examples \u003ca href=\"examples\"\u003ehere\u003c/a\u003e.The examples are downloaded everytime you download compilex via npm.\nyou can begin with editing CSS and publish your site in minutes.\nHere is the screenshot of the demo.\n\u003cbr /\u003e\n\u003cbr /\u003e\n![alt text](https://github.com/scriptnull/compileX/raw/master/DemoPicture.png \"Screenshot image.\")\n\nLicense\n=======\nAll the contents in this repository are released under the \u003ca href=\"https://github.com/scriptnull/compilex/blob/master/License.md\"\u003eMIT License\u003c/a\u003e .\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptnull%2Fcompilex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptnull%2Fcompilex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptnull%2Fcompilex/lists"}