Skip to content

Translating Oils to Rust

andychu edited this page Jun 16, 2025 · 11 revisions

Why?

Why create liboils?

  • Tools like resholve are built on top of the Oils AST (lossless syntax tree), in Python
    • I'd like somebody to write an auto-formatter for YSH.
    • A formatter based on OSH is also possible, though shfmt exists (in Go)
  • It would be nice to use something besides GNU readline
    • nushell and brush use the reedline create (developed as part of nushell)

Issues

  • mycpp Modules
    • and refactoring to modules: the C++ build should have a pure "liboils" + the Unix I/O
  • Zephyr ASDL subtyping - multiple inheritance, graph-shaped type relationships
  • Python/C++ exceptions - I think every function call ends with ?
  • Garbage Collection
    • Rc<T> is possible, but probably not fast, and would leak cycles
    • I would start out with Arena
    • maybe do OHeap-like "data-oriented design" - Compact AST Representation
    • later: copying collector

Non-issues:

  • mycpp: classes with single inheritance should be easy

Related

Oils for Windows

Rewriting YSH Only in Rust

Oils vs. Other Bash-Compatible Shells

As of 2025, the only bash-compatible shells I know of are Oils, toysh, brush and sush.

brush and sush are much more compatible than toysh, and both are written in Rust.

  • fast edit-run cycle - just start the Python interpreter (~50 ms)
  • precise location info and error messages
  • has YSH too
    • simple word evaluation
    • better handling
  • less binary code than shells in Rust
    • though we dynamically link GNU readline, so that is not a totally fair comparison
Clone this wiki locally