Welcome, fellow primates, to Apelang!
Before there was Humanlang (that fancy language with networking and logic at humanlang), and even before Apelang itself, there was something even more prehistoric, DinoLang.
Apelang is a direct evolution of DinoLang, a fossil-fuelled toy language from a time when variables were declared with "FOSSIL" and strings were ROARed into the digital void. DinoLang predates Apelang by several geological epochs. Apelang is basically a newborn mammal by comparison.
Apelang modernizes Dino's prehistoric grunts into tribes, trees, and swinging loops, with structured syntax, string support, modules, error handling, and even data structures. But don’t worry, it's still 99.8% banana-powered.
Apelang is a prehistoric programming language.
Forget your high-level abstractions and complex frameworks. Apelang operates on pure, unfiltered primate instinct. It’s simple, it’s raw, and surprisingly very effective for tasks that involve a lot of swinging, asking, and printing trees.
- Primitive Data Types:
number,string,boolean,nil - Arithmetic:
ooh(add),aah(subtract),eek(multiply),ook(divide) - Control Flow:
if,else,swing(loop),banana(while-loop),give(return) - Logical Operators:
ripe(and),yellow(or) - Functions:
tribeblocks withgive - Input/Output:
tree(print),ask()(input) - Arrays:
bunchof values:[1, "banana", true] - Maps:
canopykey-value stores:{"food": "banana"} - String Manipulation: Built-in functions for powerful string operations:
tally(), slice(), graft(), scan(), and shed(). - File I/O:
inscribe()to write to scrolls (files) andforage()to read from them. - Modules:
summon "helpers.ape"to include external code - Error Handling:
tumble { ... } catch (err) { ... } - Interactive REPL: A live, interactive shell for experimenting.
- Bytecode Disassembler: Peek under the hood at the compiled ape bytecode.
- Package Manager:
apebananafor installing community modules.
You’ll need a C compiler (gcc or clang) and make.
git clone https://github.com/duongddinh/apelang.git
cd apelang
makeMake apeslang available from anywhere with:
sudo mv apeslang /usr/local/binOR, even easier:
chmod +x install.sh
./install.shThe install.sh script:
- Builds the
apeslangbinary - Installs it to
/usr/local/bin - Verifies installation
After that, you can use apeslang anywhere in your terminal!
To make sharing and using code even easier, Apelang comes with a simple package manager called apebanana. It lets you fetch community-made modules directly from the banana-modules repository.
You can install any available module from the tribe's collection. For example, to install a module for math utilities:
apebanana install maxThis will download max.ape into your current directory. You can then use it in your code with the summon keyword
ape: Declare a new variable.tree: Print to console.ask(): Get user input.if/else: Conditional execution.swing: Loop.inscribe: Write new wisdom onto a scroll (file).forage: Read the contents of a scroll (file).banana: A while loop that continues as long as a condition is true.tribe: Define a function.give: Return from a function.tumble/catch: Try-catch-style error handling.summon: Import another.apemodule file.tally: Get the length of a string.slice: Extract a part of a string.graft: Concatenate two strings.scan: Find a substring.shed: Trim whitespace.
| Symbol | Meaning |
|---|---|
ooh |
Addition / Concat |
aah |
Subtraction |
eek |
Multiplication |
ripe |
Logical AND |
yellow |
Logical OR |
ook |
Division |
== |
Equality |
!= |
Inequality |
< / <= / > / >= |
Comparisons |
Apelang comes with powerful tools for interactive development and debugging.
For quick experiments or learning the language, start Apelang in interactive mode. It keeps your variables in memory until you exit.
apeslang repl
You'll be greeted with a >> prompt.
Apeslang Interactive REPL. Type 'exit' to quit.
>> ape x = 5
>> tree x ooh 2
7
>> ape y = "hello"
>> tree y ooh " ape"
hello ape
>> exit
Ever wonder what your Ape-speak looks like to the machine? You can decompile your .apb files into a human-readable (and ape-commentated) format. This is great for debugging or understanding how the VM works.
First, compile a file:
apeslang compile your_script.ape
Then, disassemble it:
apeslang disassemble your_script.apb
Example: A file containing tree 10 ooh 5 would produce:
== your_script.apb: The Ape Scrolls ==
0000 OP_PUSH NUMBER 10
0009 OP_PUSH NUMBER 5
0018 OP_ADD ; gather more bananas
0019 OP_PRINT ; ape screeches about bananas
0020 OP_NIL ; nil, the absence of bananas
0021 OP_RETURN ; ape returns to the tribe's canopy
Install directly from the Visual Studio Code Marketplace:
🔗 duongddinh.ape on Visual Studio Marketplace
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X/Cmd+Shift+X) - Search for:
duongddinh.ape - Click Install
Or via terminal:
code --install-extension duongddinh.apeape myBunch = [10, "banana", true]
tree myBunch[1] # Prints: banana
myBunch[0] = 99
tree myBunch
ape myCanopy = {"name": "Koko", "age": 5}
tree myCanopy["name"]
myCanopy["age"] = 6
tumble {
tree "Trying something risky..."
ape fail = 10 ooh "banana" # Type error!
} catch (err) {
tree "Caught an error!"
tree err
}
summon "helpers.ape"
tree helperVar
sayHelloFromHelper("Koko")
Apelang has powerful, built-in functions for manipulating strings.
tally(string) - Counts the characters.
tree tally("banana") #> 6
slice(string, start, end) - Extracts a piece of the string.
tree slice("banana", 1, 4) #> "ana"
graft(string1, string2) - Joins two strings.
tree graft("ooh-ooh-", "aah-aah") #> "ooh-ooh-aah-aah"
scan(haystack, needle) - Finds the starting index of a substring.
tree scan("jungle vine", "vine") #> 7
tree scan("jungle vine", "tree") #> -1
shed(string) - Removes whitespace from the start and end.
tree shed(" lots of space ") #> "lots of space"
Apes can now record their wisdom for future generations or read ancient knowledge from found scrolls.
Create a new scroll and inscribe some wisdom
ape path = "ancient_scroll.txt"
ape wisdom = "A banana in hand is worth two in the tree."
inscribe(path, wisdom)
Later, another ape can forage for this wisdom
ape found_wisdom = forage(path)
tree "The ancient scroll says: " ooh found_wisdom
apeslang compile hellobanana.apeOutput:
Compilation successful. 🦍🍌
apeslang run hellobanana.apbtree "OOH-OOH-AAH-AAH! Hello, Jungle!"
ape bananas = 5
swing bananas {
tree "I have a banana!"
bananas = bananas aah 1
}
ape bananas = 3
banana (bananas > 0) {
tree "Still have " ooh bananas ooh " bananas left to eat."
bananas = bananas aah 1
}
tree "All bananas gone!"
ape weather = "sunny"
ape time = 14 # 2 PM
if (weather == "sunny" ripe time > 12) {
tree "Good time to forage for berries!"
} else {
tree "Stay in cave."
}
tribe wiseWords() {
tree "Ape who chases two bananas catches none."
give nil
}
wiseWords()
tree "How many bananas do you have?"
ape myBananas = ask()
tree "You say you have " ooh myBananas ooh " bananas. OOH-OOH-AAH-AAH!"
Apelang runs on:
macOS (Intel or Apple Silicon) Linux (x86_64, ARM with GCC) Windows (via WSL, MinGW, or Cygwin)
To support all platforms:
- Share
.apesource or precompiled.apbfiles - Share the
apeslangbinary built for that OS/CPU - Use
install.shormakefor easy builds
While Humanlang, with its modern Wi-Fi era, creates advanced networking capabilities and runs on fancy interpreters. Apelang is a much more less grounded language. Apelang is a compiled language, meaning your ape code is translated directly into raw, efficient bytecode that the VM executes. There's no middle-ape interpreter like THE TALKING SNAKE; it's a direct connection to the machine's primal core. This also means, unlike its futuristic descendant, Apelang doesn't concern itself with the like of networking or the internet. Our apes communicate through shouts, gestures. If you want to connect to other apes, you'll have to do it the old-fashioned way: by swinging over to their tree.
- DinoLang is raw binary driven by integers and yelling.
- Apelang builds on DinoLang with loops, scopes, strings, modules, and basic error handling.
- Humanlang is the sleek, Wi-Fi-enabled descendent, more evolved, but less hairy.
Each speaks to a different era in evolutionary coding. Choose based on your brain size, tool preference, and number of bananas nearby.
Disclaimer: This project is an educational tool and a work-in-progress. It contains known security vulnerabilities and is NOT suitable for running untrusted code or for any form of production use.
The primary security weakness in Apeslang stems from the Virtual Machine (VM) completely trusting the bytecode it is instructed to execute. The VM performs no verification or bounds-checking on the bytecode, which allows a specially crafted .apb file to compromise the interpreter's integrity, leading to crashes, information disclosure, or potentially arbitrary code execution.
- Sometimes the compiler throws a banana peel at you. Try again.
- The VM might go on a spontaneous swinging spree. It's not a bug, it's enrichment.
- Error messages are in “Ape-speak” and may require interpretation.
Found a bug? Got a new banana idea? Fork and PR. We love more apes in the tribe!
