Simplifying Code Execution Across Platforms
With PolyglotCoder, you can run code snippets in Java, Python, C++, C, JavaScript, Go, C#, and soon, Ruby too!.
If you need to execute code in child processes using other programming languages, this API can assist you.
Here's a what you can do with this polyglot api:
// Java Example
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
# Python Example
print("Hello, world!")
// C++ Example
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world!" << endl;
return 0;
}
// Go Example
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
// JavaScript Example
console.log("Hello, world!");
And this is an api call and response example.
fetch('http://localhost:3000/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: 'console.log("Hello, world!")', // here can be any other js code(and the code now only returns the things that inside in console.log , printf or cout in cpp)
language: 'js',
input: ''
})
})
.then(response => response.json())
.then(data => {
console.log('Output:', data.output);
})
.catch(error => {
console.error('Error:', error);
});
Response includes the version of language too.
{
"timeStamp": 1708197809394,
"status": 200,
"output": "Hello world\n",
"error": "",
"language": "js",
"info": "v20.9.0\r\n"
}
Furthermore, polyglotCode api offers the flexibility to execute your code independently of your main project, ensuring uninterrupted workflow. Once execution is complete, child process triggers an event, providing you with real-time feedback on the execution process. This enables you to swiftly identify and resolve any errors. You can run polyglot api with docker which supports execution even if you don't have the language installed on your local machine which is the main purpose of this, simply write your code and let polyglot api handle the execution!
Kindly note: This project is a work in progress and not finalized yet.
Check it out in my LinkedIn projects