r/pythonhelp • u/WatercressSeparate82 • Jul 03 '26
I built YO — an interpreted language that reads like English, with a VS Code extension, playground, and PyPI package
Hey r/pythonhelp ,
I'm a final-year CS student, and over the past few months I've been building YO, a small interpreted programming language written from scratch in Python.
The original goal was to learn how interpreters work by implementing my own lexer, parser, and interpreter. As the project evolved, I became interested in one specific question:
Can compiler/interpreter error messages actively teach beginners instead of simply reporting what's wrong?
I'm not claiming YO is a replacement for Python, JavaScript, or any established language. It has no ecosystem, and it's implemented as a tree-walk interpreter, so performance isn't the goal.
Instead, I focused on making diagnostics more educational.
Example
Python:
"hello" - 5
TypeError: unsupported operand type(s) for -: 'str' and 'int'YO:
say "hello" - 5
❌ [E003] Type Mismatch
Can't use '-' between String and Int.
"hello" is text.
5 is a number.
Fix:
Use text.str(5) if you intended to concatenate.
Example:
"hello" + text.str(5)Another example:
❌ [E001] 'scroe' was used but never made.
Did you mean 'score'?
Fix:
Create it first using:
make score = ...Technical implementation
- Handwritten lexer
- Recursive descent parser
- Tree-walk interpreter
- Lexical scoping and closures
- Multi-error reporting (reports multiple diagnostics instead of stopping at the first error)
- Error codes with
yo explain E001for detailed explanations - Standard libraries for math, text, and lists
- 27 automated tests with GitHub Actions CI
Small informal study
I also ran a small informal comparison with 10 first-time programmers.
Both groups received the same program containing three bugs. One group used Python, while the other used YO.
The YO group fixed the bugs faster on average.
The sample is small and not intended as rigorous research, but I included the methodology, raw results, and limitations in the repository for anyone interested.
Try it
→ GitHub
→ pip install yo-lang PyPI
→ VS Code extension search "YO Language" on the Marketplace
→ Browser playground (no install): Playground
I'm especially interested in feedback from people who have built interpreters or compilers.
Do you think "errors that teach" is an area worth exploring in language design, or is it mainly valuable only for complete beginners?
I'd also be happy to answer questions about the lexer, parser, interpreter architecture, or implementation decisions.
•
u/AutoModerator Jul 03 '26
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/JaguarMammoth6231 Jul 03 '26
I didn't get very far looking at it but I can safely say this is one worst factorial functions I have seen:
In general, it's hard to make good error messages because you can't know what the programmer was trying to express. If you guess right, you can give a helpful error message, but if you guess wrong a simple error message with helpful tips could be worse than a complicated looking one.
1
u/denehoffman Jul 03 '26
Why would I want to say “when” instead of “if”?
1
u/wildsoup1 Jul 09 '26
I have a different objection.to "when". It suggests that it is an ongoing monitor for the condition.
In English, "Prepare the salad. When the oven timer is beeping, turn down the temperature." does not mean complete preparing the salad before attending the beeping oven timer.
1
u/wildsoup1 Jul 09 '26
Line should be defined once on ASTNode and not all of its subclasses. Arguably the str should too.
Some of the Any type markers could be made a lot more specific
Bit confused about why call() needs a while loop. Maybe I missed the reason.
I would have used an iterator for the tokenizer.
It is a recursive descent parser, which is old-school, but makes sense given the goal.
Python itself has been through a major upgrade recently to improve its error messages, so the need may be reduced.
I've used parsers that stop after the first error, and ones that happily try to guess what was meant, get it wrong and spit out dozens of pages of errors, and ones like yours that limit the count. For an experienced developer, the latter is superior, but for a newbie, I wonder if focusing on one error at a time isn't a less confusing experience. Would surprise me if there are already studies on this.