How to Create a Language Evaluator

Add support for new programming languages in BonitoBook by creating a custom language evaluator.

Implementation

Create an extension module that defines:

  1. Evaluator struct inheriting from LanguageEval

  2. eval_code method that executes code

  3. get languageevaluator function that returns the evaluator

Example: Shell Evaluator

Register Language

Add your language to ALL_LANGUAGES in src/BonitoBook.jl:

Real Example: Python

The Python evaluator shows the full pattern:

Key Points

  • Extension loading: BonitoBook uses Base.get_extension() to load evaluators

  • Thread safety: Code runs in spawnat(1) for thread safety (e.g. for PythonCall)

  • Variable sharing: Transfer variables between language and Julia using the mod parameter

  • Error handling: Wrap execution in try-catch, BonitoBook handles display

That's it! The AsyncRunner handles the rest automatically.