Skip to main content

Overview

Wecode supports multiple programming languages for code submission. Each language is configured with default execution limits and file extensions.

Supported languages

Out of the box, Wecode supports:
  • C (gcc compiler)
  • C++ (g++ compiler)
  • Java (OpenJDK with security policies)
  • Python (2.x and 3.x)
  • JavaScript (Node.js)
  • Pascal (Free Pascal Compiler)

Language configuration

Each language has the following settings:
name
string
required
Display name of the language (e.g., “Python 3”, “Java”)
extension
string
required
File extension for submissions (e.g., “py”, “java”, “cpp”)
default_time_limit
integer
required
Default time limit in seconds for code execution
default_memory_limit
integer
required
Default memory limit in megabytes
sorting
integer
Display order in language selection dropdowns

Managing languages

Adding a new language

As an admin:
  1. Navigate to SettingsLanguages
  2. Click Add Language
  3. Configure the language settings
  4. Create compilation script in tester/ directory
  5. Test with a sample submission
Adding a new language requires creating Docker images and compilation scripts. See the Docker sandboxing documentation for details.

Editing language settings

To modify time or memory limits:
  1. Go to Languages list
  2. Click Edit on the language
  3. Update default limits
  4. Save changes
These defaults apply to new problems. Existing problems retain their configured limits.

Per-problem language configuration

When creating a problem, you can:
  1. Select which languages are allowed
  2. Override default time/memory limits per language
  3. Set different limits for different languages
Example: Allow 1 second for C++ but 3 seconds for Python.

Compilation and execution

Compilation scripts

Each language has a compilation script in tester/:
tester/
├── compile_c.sh       # C compilation
├── compile_java.sh    # Java compilation with security
├── compile_python.sh  # Python syntax check
├── compile_pascal.sh  # Pascal compilation
└── compile_javascript.sh  # JavaScript validation

Execution flow

1

Upload

Student submits code file
2

Queue

Submission added to processing queue
3

Compile

Language-specific compilation script runs
4

Execute

Compiled code runs in Docker container with limits
5

Grade

Output compared against test cases

Resource limits

Time limits

  • Purpose: Prevent infinite loops and excessive runtime
  • Measurement: Wall-clock time with perl timing script
  • Typical values: 1-10 seconds depending on problem complexity

Memory limits

  • Purpose: Prevent memory exhaustion attacks
  • Measurement: Peak memory usage in the Docker container
  • Typical values: 64-512 MB depending on problem requirements

Output limits

  • Purpose: Prevent disk fill attacks
  • Default: Configured in tester/runcode.sh
  • Effect: Output truncated if exceeded

Language-specific considerations

Python

  • Both Python 2 and Python 3 supported
  • Slower execution time → higher time limits recommended
  • NumPy and common libraries available
# Sample: Using NumPy in Wecode
import numpy as np

def solve():
    arr = np.array([1, 2, 3, 4, 5])
    return np.sum(arr)

Java

  • Security manager enforced (java.policy)
  • Class name must match filename
  • Higher memory requirements
  • Main class auto-detected
// Sample: Wecode Java submission
public class Solution {
    public static void main(String[] args) {
        // Your code here
    }
}

C/C++

  • GCC compiler with standard flags
  • Fastest execution times
  • Can use standard library
// Sample: Wecode C++ submission
#include <iostream>
using namespace std;

int main() {
    // Your code here
    return 0;
}

API reference

Model: Language

Location: app/Models/Language.php

Relationships

// Get problems that support this language
$language->get_id()

// Get ordered list of all languages
Language::order_languages()  // Sorted by 'sorting' field

Routes

MethodURIActionPermission
GET/languagesList all languagesAdmin
GET/languages/createShow create formAdmin
POST/languagesStore new languageAdmin
GET/languages/{language}Show language detailsAdmin
GET/languages/{language}/editShow edit formAdmin
PUT/PATCH/languages/{language}Update languageAdmin
DELETE/languages/{language}Delete languageAdmin
Deleting a language affects existing problems and submissions. Problems using only that language will become unsubmittable.

Docker configuration

Each language requires:
  1. Docker image with compiler/interpreter
  2. Compilation script in tester/
  3. Security policies (especially for Java)
See the complete setup in Docker sandboxing.

Best practices

Conservative limits

Start with conservative time/memory limits and increase only if needed. This prevents resource abuse.

Language fairness

Set time limits proportional to language speed (e.g., Python gets 3x C++ time) to ensure fairness.

Test thoroughly

Always test new language configurations with known-good sample code before using in assignments.

Document requirements

If you add non-standard libraries, document them in problem descriptions so students know what’s available.

Troubleshooting

Compilation errors

If all submissions fail to compile:
  1. Check compilation script syntax
  2. Verify Docker image is available
  3. Test script manually in the tester/ directory

Time limit exceeded

If valid solutions hit time limits:
  1. Run solution locally to measure actual time
  2. Consider language-specific multipliers
  3. Optimize test cases to avoid unnecessary overhead

Memory issues

If submissions crash with memory errors:
  1. Check if problem actually requires more memory
  2. Verify limits are set correctly in language config
  3. Look for memory leaks in student code

Build docs developers (and LLMs) love