Skip to main content
HopX sandboxes support multiple programming languages for code execution. Each language has specific features, pre-installed packages, and capabilities.

Overview

HopX currently supports the following languages:
  • Python - Full-featured Python environment with data science libraries
  • JavaScript/Node.js - Modern JavaScript runtime with npm support
  • Bash - Shell scripting and command execution
  • Go - Go programming language runtime
Language support depends on the template you use. The code-interpreter template includes Python, JavaScript, and Bash. Other templates may support different language combinations.

Python

Python is the most feature-rich language in HopX sandboxes, with extensive pre-installed packages for data science, web development, and automation.

Version

  • Python 3.11+ (varies by template)

Pre-installed Packages

Common packages available in most Python templates:
  • Data Science: pandas, numpy, matplotlib, scipy, scikit-learn
  • Web: requests, httpx, flask, fastapi
  • Utilities: beautifulsoup4, ipykernel, jupyter-client
  • System: git, curl, wget, vim, nano

Features

  • Rich Output Capture: Automatically captures matplotlib plots, pandas DataFrames, and other visualizations
  • IPython Kernel: Interactive Python execution with Jupyter kernel support
  • Package Installation: Install additional packages with pip
  • File Operations: Full filesystem access for reading/writing files
  • Environment Variables: Access via os.getenv() or os.environ

Example

Expected Output:
Rich outputs (plots, DataFrames) are automatically captured in result.rich_outputs.

JavaScript/Node.js

JavaScript execution runs in a Node.js environment with access to npm packages and modern JavaScript features.

Version

  • Node.js 18+ (varies by template)

Pre-installed Packages

  • Runtime: Node.js with npm
  • Kernel: iJavaScript kernel for interactive execution
  • System Tools: Standard Unix utilities

Features

  • npm Support: Install packages with npm install
  • ES Modules: Support for modern ES6+ syntax
  • Rich Output: Can generate HTML, JSON, and text outputs
  • Async/Await: Full support for asynchronous operations
  • File System: Access to Node.js fs module

Example

Expected Output:

JavaScript-Specific Features

The JavaScript SDK includes some unique features:
  • IPython Kernel Support: sandbox.runIpython() method for interactive JavaScript execution
  • TypeScript Types: Full TypeScript support with type definitions
  • Async Generators: WebSocket streaming uses async generators (for await...of)

Bash

Bash provides shell scripting capabilities for system administration, automation, and command execution.

Features

  • Shell Commands: Execute any shell command or script
  • Pipelines: Support for command pipelines and redirection
  • Environment Variables: Access via $VARIABLE_NAME syntax
  • File Operations: Standard Unix file operations (cp, mv, rm, etc.)
  • Process Management: Background processes, job control

Example

Expected Output:

Common Use Cases

  • Installing system packages with apt-get or yum
  • Running build scripts and automation tasks
  • Processing text files with grep, sed, awk
  • Managing files and directories
  • Running system diagnostics

Go

Go (Golang) support enables compilation and execution of Go programs in sandboxes.

Version

  • Go 1.21+ (varies by template)

Features

  • Compilation: Compile Go programs with go build
  • Standard Library: Full access to Go standard library
  • Modules: Support for Go modules and dependency management
  • Concurrency: Full support for goroutines and channels
  • Cross-compilation: Can compile for different platforms

Example

Expected Output:
The timestamp in the output will be the actual execution time, not a fixed value. The format follows RFC3339 (e.g., 2025-01-27T10:30:00Z).

Language-Specific Considerations

Execution Timeouts

Default timeouts vary by language and execution mode:
  • Synchronous execution: 30-60 seconds (configurable)
  • Background execution: Up to 300 seconds (5 minutes)
  • Async execution: Up to 3600 seconds (1 hour) with webhooks

Memory and Resources

  • Each sandbox has allocated CPU, memory, and disk resources
  • Resource limits are defined by the template
  • Monitor resource usage to avoid hitting limits

Package Installation

Or use commands:

Environment Variables

All languages can access environment variables set in the sandbox:

Choosing the Right Language

Data Science & Analytics

Use Python for data analysis, machine learning, and visualization. Pre-installed packages like pandas, numpy, and matplotlib make it ideal for data work.

Web Development

Use JavaScript for Node.js applications, API development, and web scraping. Full npm support enables rapid development.

System Automation

Use Bash for system administration, file processing, and automation scripts. Perfect for DevOps tasks.

High Performance

Use Go for concurrent programs, network services, and performance-critical applications. Excellent for building APIs and microservices.

Language Support by Template

Different templates support different languages. Check template details to see which languages are available:
Expected Output:
The actual templates and their languages may vary. Use Sandbox.list_templates() to see available templates in your account.

Next Steps