Skip to main content

June 2025 (v0.2.10)

This update introduces multi-language code generation improvements, enhanced benchmark automation, and several compiler fixes.

Python Code Generation

Mochi now supports code generation to Python. Programs can be compiled using either the --target python (or py) flag or by specifying a .py output file:

$ mochi build main.mochi --target python -o main.py

The generated Python code preserves the original structure and behavior of the Mochi source. Output is verified using golden file tests to ensure consistent results across releases. This new backend enables Mochi programs to run in Python environments and facilitates integration into Python-based workflows.

Automatic Target Detection

The mochi build command now infers the compilation target from the output file extension or the --target flag. Supported targets include:

  • Go (.go)
  • Python (.py)
  • TypeScript (.ts)

If no target is specified, the compiler defaults to producing a native Go binary. This streamlined behavior simplifies the command-line interface and reduces the need for manual configuration.

Improved Benchmarking Workflow

The benchmarking system has been redesigned for clarity, precision, and ease of use. Notable updates include:

  • Automatic installation of required runtimes: Mochi, Deno, and Python are installed on demand when running benchmarks.
  • Higher-resolution timing: Durations are now measured in microseconds for improved precision in short-running tests.
  • Consolidated test templates: Redundant benchmark definitions have been removed and outputs are labeled more clearly.

These changes improve reproducibility and make it easier to compare performance across languages and implementations.

Compiler and Backend Fixes

A fix has been applied to the Go backend to correctly handle map literals where the values are integers. The compiler now explicitly casts these values to int64, resolving prior type mismatch errors and improving compatibility with the Go type system.