Johnny Cai



Recreation of the game Factorio.

It uses OpenGL for rendering and loads runtime data using Python. It is written in C++17, built via CMake, with automated builds running on Microsoft Azure.

I spent a significant amount of time optimizing the renderer, making use of threading to reduce frame times. When that was insufficient, I tuned the assembly in hot paths by assessing the compiler generated assembly and restructured code to convince the compiler to emit better assembly and redesigned data structures to take advantage of cache locality.

C Compiler

A C99 compiler I wrote, in C.

It currently supports all the basic language constructs: conditionals, loops, expressions, arrays, pointers, function calls, and so on.

It uses top-down recursive descent with backtracking to build nodes of language productions. The nodes are translated to a custom intermediate language, which are then converted into assembly via macro expansion and register allocation with graph coloring.

Vim LaTeX Equation Editor

Edit LaTeX equations in a vim style editor.

I find a vim style editor much faster to use for writing equations. As none of the existing websites supported a vim style editor, I made my own.