Brainrot is a meme-inspired programming language that translates common programming keywords into internet slang and meme references. It's built using Flex (lexical analyzer) and Bison (parser generator), making it a fun way to learn about language processing and compiler design.
The TRUE history behind the Brainrot programming language can be found here.
Brainrot is a C-like programming language where traditional keywords are replaced with popular internet slang. For example:
voidโskibidiintโrizzforโflexreturnโbussin
To build and run the Brainrot compiler, you'll need:
- GCC (GNU Compiler Collection)
- Flex (Fast Lexical Analyzer)
- Bison (Parser Generator)
sudo apt-get update
sudo apt-get install gcc flex bison libfl-devsudo pacman -S gcc flex bisonbrew install gcc flex bisonSome macOS users are experiencing an error related to libfl. First, check if libfl is installed at:
/opt/homebrew/lib/libfl.dylib # For Apple Silicon
/usr/local/lib/libfl.dylib # For Intel Macs
And if not, you have to find it and symlink to it. Find it using:
find /opt/homebrew -name "libfl.*" # For Apple Silicon
find /usr/local -name "libfl.*" # For Intel Macs
And link it with:
sudo ln -s /path/to/libfl.dylib /opt/homebrew/lib/libfl.dylib # For Apple Silicon
sudo ln -s /path/to/libfl.dylib /usr/local/lib/libfl.dylib # For Intel Macs
git clone https://github.com/Brainrotlang/brainrot.git
cd brainrot
nix develop
# then create your .brainrot file
./result/bin/brainrot filename.brainrotOr via a flake-based NixOS config (/etc/nixos/flake.nix), which always tracks the latest version:
# /etc/nixos/flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
brainrot.url = "github:Brainrotlang/brainrot";
};
outputs = { nixpkgs, brainrot, ... }: {
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
{
# For a specific user
users.users.username = {
packages = [ brainrot.packages.x86_64-linux.default ];
};
# For system-wide installation
environment.systemPackages = [
brainrot.packages.x86_64-linux.default
];
}
];
};
};
}Run nix flake update whenever you want to pull the latest version, then rebuild with sudo nixos-rebuild switch.
- Clone this repository:
git clone https://github.com/Brainrotlang/brainrot.git
cd brainrot- Generate the parser and lexer:
bison -d -Wcounterexamples lang.y -o lang.tab.c
flex -o lang.lex.c lang.l- Compile the compiler:
makeNOTE: The gcc version we use to test is v13 if you get any warnings remove -Werror flag from the Makefile
sudo make installEach v* GitHub release attaches native archives plus the wasm module:
brainrot-<tag>-linux-amd64.tar.gz,linux-arm64,darwin-amd64,darwin-arm64--brainrotandlibstdrot.so. Extract both files and run./brainrot file.brainrotfrom that directory. At startup the interpreter honorsSTDROT_LIB_PATHif set; otherwise it tries cwd-relative./libstdrot.so, then the dynamic linker'slibstdrot.sosearch path. Release binaries include an rpath ($ORIGIN/@loader_path) so that second lookup can find thelibstdrot.sonext tobrainrotwhen no cwd copy is loaded first.brainrot.wasmandbrainrot.mjs-- same names as previous wasm-only releases, for the in-browser playground.SHA256SUMS.txt-- checksums for every attached file.
Windows is not a native target (dlopen / POSIX stdrot). A release can
also be cut from the Actions UI with a patch/minor/major bump over the
latest stable tag.
sudo make uninstallmake wasm builds brainrot.wasm + brainrot.mjs using Emscripten โ this is what powers the in-browser playground. Requires emcc on your PATH (install via emsdk):
make wasmThe interpreter is statically linked for this target (no libstdrot.so, no dlopen โ see stdrot.c's STDROT_STATIC path), and takes its source file the same way the native binary does, via argv[1] written into Emscripten's in-memory filesystem before calling callMain.
Known platform-specific difference from the native build: sizeof(giga) is 4, not 8 โ wasm32 uses the ILP32 data model (long = 4 bytes) instead of native's LP64 (#177). Everything else, including stderr, matches native exactly.
node tests/run_wasm_tests.mjs runs the same fixtures as the native pytest suite against the wasm build (checking the one difference above against its wasm-correct value instead of native's), and node tests/run_wasm_examples_check.mjs diffs every examples/*.brainrot program's stdout against a real native run. Run both after make && make wasm to sanity-check a build.
chill() calls sleep() under the hood, which blocks the JS thread it runs on rather than yielding โ fine in a short-lived CLI run, but something a browser embedder (e.g. a playground) should account for (run in a Worker, expect the tab to be unresponsive for the duration) rather than assume it behaves like an async delay.
- Create a Brainrot source file (e.g.,
hello.brainrot):
skibidi main {
yapping("Hello, World!");
bussin 0;
}- Run your Brainrot program:
./brainrot hello.brainrotCheck out the examples:
- Hello world
- Fizz Buzz
- Bubble Sort
- One-dimensional Heat Equation Solver
- Fibonacci Sequence
- Modules (
#cooked) - Named modules (
#cooked <name>) - Ohio Engine โ the first cursed game (raylib)
Yes, the joke language runs a real game loop. examples/raylib/ohio_engine.brainrot
calls raylib through the optional brainray native
module (#cooked <raylib>) to bounce an "ABSOLUTE CINEMA" orb around a window.
raylib is an optional dependency (not needed for make/make test), and
#cooked <raylib> loads the brainray/raylib.so wrapper built by make brainray โ not the system libraylib.so directly. First install a system
raylib (on Ubuntu it is not apt-get install libraylib-dev; that package
does not exist there โ use the raylib PPA or a source build), then:
pkg-config --exists raylib # confirm raylib is installed
make # build the interpreter
make brainray # build the raylib binding (brainray/raylib.so)
BRAINROT_PATH=brainray ./brainrot examples/raylib/ohio_engine.brainrotmake play does the last two steps in one. See
docs/brainray.md for the full raylib setup guide (Ubuntu
PPA vs. source build, macOS, the two-library model) and the binding reference.
Join our community on:
| Brainrot | C Equivalent | Implemented? |
|---|---|---|
| skibidi | void | โ |
| rizz | int | โ |
| cap | bool | โ |
| flex | for | โ |
| bussin | return | โ |
| edgy | if | โ |
| amogus | else | โ |
| goon | while | โ |
| bruh | break | โ |
| grind | continue | โ |
| chad | float | โ |
| gigachad | double | โ |
| yap | char | โ |
| deadass | const | โ |
| sigma rule | case | โ |
| based | default | โ |
| mewing | do | โ |
| gyatt | enum | โ |
| whopper | extern | โ |
| cringe | goto | โ |
| giga | long | โ |
| smol | short | โ |
| nut | signed | โ |
| maxxing | sizeof | โ |
| salty | static | โ |
| gang | struct | โ |
| ohio | switch | โ |
| chungus | union | โ |
| nonut | unsigned | โ |
| schizo | volatile | โ |
| W | true | โ |
| L | false | โ |
| thicc | long long | โ |
| rant | string type | โ |
| lit | typedef | โ |
| unc | __asm__ |
โ |
| Brainrot | C Equivalent | Implemented? |
|---|---|---|
| #cooked | #include | โ |
| #edgydef | #ifdef | โ |
| #edgyndef | #ifndef | โ |
| #endedgy | #endif | โ |
| #slaps | #define | โ |
| #aura | #pragma | โ |
#cooked "path/to/file.brainrot" splices another Brainrot file's functions
and structs into the current one, resolved relative to the including file's
directory. #cooked <name> resolves name to either a <name>.brainrot
file (spliced the same way) or a <name>.so native module (dlopen'd and
registered) by searching $BRAINROT_PATH, then either the install module
directory or a stdrot/ directory next to the running executable
(whichever applies โ an install and a source build can't shadow each
other). See
the language reference
for details (path resolution, the module search path, include-once behavior,
circular-include detection).
Check the user documentation.
The language supports basic arithmetic operators:
+Addition-Subtraction*Multiplication/Division=Assignment<Less than>Greater than&&Logical AND||Logical OR
Current limitations include:
- Limited support for complex expressions
- Basic error reporting
- Struct/union function arguments, return values, and copy-initializers
accept a plain struct/union variable, a by-value member-access
sub-expression (
take(b.corner),bussin b.corner;,gang Point c = b.corner;), or a struct-returning call result (take(make_point()),bussin make_point();,gang Point c = make_point();) of the exact declared type, deep-copied (not aliased). A function may also return a pointer to a struct (gang Point *f()), returning a pointer value (a parameter or other storage that outlives the call) rather than a copy โ returning&localdangles once the call returns, the same undefined behavior as a scalar pointer return in C - Arrays cannot be passed or returned by value (only via a pointer parameter, which aliases the caller's array like in C)
ohio/based(switch/default):basedfires as soon as the interpreter's scan reaches it, so its position among thesigma rulecases matters โ placing it before a case that would otherwise match currently pre-empts that match (#179)
Where Brainrot is headed โ a native C ABI, generated library bindings (raylib first), threads, hashmaps and sockets โ is documented in the roadmap.
Brainrot has a Visual Studio Code extension to enhance your development experience with syntax highlighting and support for the Brainrot programming language. You can find it here:
Feel free to contribute to this project by:
- Forking the repository
- Creating a new branch for your feature
- Submitting a pull request
This project is licensed under the GPL License - see the LICENSE file for details.
- This project is created for educational purposes
- Inspired by meme culture and internet slang
- Built using Flex and Bison tools
Please report any additional issues in the GitHub Issues section.