Inspiration

Initially, the goal was simple: build a retro-style game as a hackathon project. However, while researching how old games and engines actually worked, I came across the concept of a virtual machine.

That discovery changed everything.

Instead of just asking “How do I make a game?”, the question became:

“What if I build the system that runs the game?”

That curiosity led to CineBrew — a project focused less on visuals and more on understanding how code is parsed, executed, and managed at runtime.


What it does

CineBrew is a custom programming language that compiles into bytecode and runs on a stack-based virtual machine built entirely from scratch.

Using CineBrew, it is possible to:

  • Write programs in a custom language
  • Compile them into a readable bytecode format
  • Execute them on a virtual machine
  • Drive a game loop that outputs real-time state updates

Instead of rendering graphics, the current system outputs render-ready data to the console, proving that the entire execution pipeline works end to end.


How we built it

The project was built in clearly defined stages:

  1. Lexer — converts source code into tokens
  2. Parser — builds an Abstract Syntax Tree (AST) using a recursive-descent approach
  3. Semantic Analyzer — validates variables, functions, and scopes
  4. Code Generator — converts the AST into text-based bytecode
  5. Virtual Machine — interprets bytecode using a stack-based execution model
  6. Runtime Library — provides built-in functions for I/O, math, timing, and stubs
  7. Game Loop — runs as a frame-timed update cycle on top of the VM

All components were written from scratch in C++, without external compiler frameworks.


Challenges we ran into

Some of the biggest challenges included:

  • Designing a language syntax that was simple but expressive
  • Implementing a correct recursive-descent parser
  • Managing function calls and stack frames inside the virtual machine
  • Debugging bytecode execution without advanced tooling
  • Balancing scope creep under strict hackathon time limits

One small mistake in the compiler often caused failures far downstream in the VM, making debugging both difficult and educational.


Accomplishments that we're proud of

  • Building a complete language toolchain end to end
  • Successfully executing custom bytecode on a virtual machine
  • Implementing a working game loop on top of the VM
  • Keeping the architecture clean and inspectable
  • Finishing a systems-level project within hackathon constraints

Most importantly, the system works — source code goes in, behavior comes out.


What we learned

This project reinforced several key lessons:

  • Abstractions hide complexity, but fundamentals explain it
  • Compilers and VMs are approachable when broken into stages
  • Debugging low-level systems builds strong intuition
  • Architectural decisions matter more than features
  • Simpler systems are easier to reason about and extend

Concepts like stacks, instruction dispatch, and execution frames became practical instead of theoretical.


What's next for the VM, custom language, and game loop

Planned next steps include:

  • Adding a graphical renderer (e.g., SDL)
  • Improving error messages with line-level diagnostics
  • Expanding the language with arrays and structured types
  • Optimizing bytecode execution
  • Building a complete playable game on top of CineBrew

The long-term goal is to evolve CineBrew from a learning project into a fully self-hosted runtime capable of running real interactive programs.

Built With

Share this project:

Updates