Skip to main content
The quickRun() method provides a fast and secure way to execute code directly within your application. It has built-in support for ten popular runtimes: Python, Java, C++, Node.js, etc.
Before using quickRun(), you must first establish a connection to the sandbox by calling create() or fromSnippet(). The sandbox must be connected before executing code.

Supported Languages

The following languages can be executed with the help of the quickRun() method.

C / C++

Java

Python

Node.js

SQLite / MySQL

Go

Rust

.NET (C#)

Method Parameters

The quickRun() method accepts a set of parameters that define how your code will be executed. Some are required to run code successfully, while others let you customize execution behavior, provide input, or validate results.

Required Parameters

These parameters are mandatory for every QuickRun execution. Without them, the method won’t know what language to use or what code to run.

Optional Parameters

Use these optional parameters to provide inputs, verify expected outputs, or include additional files required by your program.

Execution Results

The quickRun() method returns a runResult object that holds detailed information about the execution outcome: whether it succeeded, failed, or encountered runtime or compilation issues.

Validation (if you provided expectedOutput)

If you supplied an expectedOutput when running your code, QuickRun automatically compares the actual output with your expected value. The comparison result is reflected in the runStatus field:
  • If the output matches: runStatus will be "successful"
  • If the output doesn’t match: runStatus will be "wrong-answer"
  • If there’s a compilation error: runStatus will be "compilation-error"
  • If there’s a runtime error: runStatus will be "non-zero-exit-code" or another error status
This allows for quick correctness checks, ideal for grading systems, test runners, or automated assessments.

How to Use QuickRun

Here is a simple example on how you can use the quickRun() to execute code:

Error Handling

Even well-written code can fail, the quickRun() provides clear feedback to help you identify and debug errors efficiently. Common failure types include compilation errors, runtime exceptions, and timeouts. Each is detailed below with example usage.
These occur when the code fails to compile due to syntax issues or missing elements. The runStatus will be set to “compilation-error”, and the compiler output can be found in compilerOutputAfterCompilation.
Runtime errors happen when the program compiles successfully but fails during execution, such as dividing by zero or accessing invalid memory. In such cases, the runStatus will be “non-zero-exit-code” or another error status, and the error message appears in programRunData.stderr.
Timeout errors occur when a program runs beyond the allowed time limit, typically due to infinite loops or heavy computation. The runStatus will be “time-limit-exceeded”.

Best Practices

  • Connect to sandbox first : Always call create() or fromSnippet() before using quickRun()
  • Always check runStatus first : Before looking at output, verify the code ran successfully (runStatus === 'successful')
  • Check programRunData is not null : Ensure programRunData exists before accessing its properties
  • Output is already decoded : The SDK automatically decodes stdout, stderr, and compilerOutputAfterCompilation, so you can use them directly without additional decoding
  • Use expectedOutput for automated testing : The system will set runStatus to "successful" if output matches, or "wrong-answer" if it doesn’t
  • Handle errors gracefully : Show helpful messages when code fails by checking runStatus and accessing stderr directly
  • Validate user input : If users can submit code, validate it before execution

Performance Tips

  • Code execution typically takes 1-3 seconds
  • Compilation languages (C++, Java, Rust) may take slightly longer
  • Interpreted languages (Python, Node.js) start faster
  • Database operations (SQLite, MySQL) depend on query complexity

Frequently Asked Questions

Code execution typically completes within 1–3 seconds, depending on the programming language, code complexity, and whether compilation is required. Interpreted languages like Python or Node.js tend to execute faster, while compiled languages such as Java or Rust may take slightly longer.
You can include any required files by encoding them as a Base64 ZIP and passing them through the additionalFilesAsZip parameter. This allows your program to access external dependencies, data files, or assets during execution.
Yes. Your program can read from files provided through additionalFilesAsZip, or you can simulate user input using the stdin parameter for simpler text-based input.
Each code execution has a time limit to prevent infinite loops or unresponsive code. If your program exceeds this limit, it’s automatically stopped and marked as TimeLimitExceeded in the result object.
Absolutely. All code runs inside a secure, isolated sandbox with strict resource and permission controls. This ensures your application and data remain safe from malicious or runaway code.