| Crates.io | sharp |
| lib.rs | sharp |
| version | 0.1.0 |
| created_at | 2025-12-29 04:32:40.019643+00 |
| updated_at | 2025-12-29 04:32:40.019643+00 |
| description | A modern, statically-typed programming language with Python-like syntax, compiled to native code via LLVM. Game engine ready! |
| homepage | https://github.com/Mehxeo/Sharp---Shattered-Game-Engine |
| repository | https://github.com/Mehxeo/Sharp---Shattered-Game-Engine |
| max_upload_size | |
| id | 2009947 |
| size | 167,834 |
A modern, statically-typed language compiled to native code via LLVM. This README is the single source for installation, CLI usage, syntax, types, data structures, and examples — everything a programmer needs to use Sharp.
See the companion engine guide: README_ENGINE.md
cargo install sharpbrew install llvm@18
export LLVM_SYS_180_PREFIX=/opt/homebrew/opt/llvm
cargo build --release
# Compile to LLVM IR
./target/release/sharp program.shrp --emit-llvm
# Run LLVM IR (macOS Homebrew LLVM)
/opt/homebrew/opt/llvm@18/bin/lli program.ll
# Check without codegen
./target/release/sharp program.shrp --check
# Emit object file
./target/release/sharp program.shrp --emit-obj -o program.o
# Emit native binary
./target/release/sharp program.shrp --emit-binary -o program
int, float, bool, string, void, autodef main() -> int {
x: int = 10
y = 20 // inferred
return x + y
}
def add(a: int, b: int) -> int { return a + b }
if/elif/else, while, for i in 0 .. N, matchprint(x) and println(x) support int, bool, and string literalsstruct Vector2 { x: float, y: float }
struct GameObject {
position: Vector2
health: int
active: bool
}
impl Vector2 {
def new(x: float, y: float) -> Vector2 {
return Vector2 { x: x, y: y }
}
def magnitude(self) -> float {
return (self.x * self.x + self.y * self.y).sqrt()
}
}
impl GameObject {
def take_damage(mut self, amount: int) { self.health -= amount }
}
let pos = Vector2 { x: 10.0, y: 20.0 }
let player = GameObject {
position: Vector2 { x: 0.0, y: 0.0 },
health: 100,
active: true
}
enum GameState { Loading, MainMenu, Playing, Paused, GameOver }
enum EntityType { Player, Enemy, NPC, Projectile }
# [T] or [T; N]
positions: [Vector2; 3]
values: [int]
def f(a: int) -> int { return a }
def main() -> int {
total: int = 0
for i in 0 .. 10 { total += i }
if total > 20 { return total } else { return 0 }
}
struct Health { current: int, max: int }
impl Health {
def new(max: int) -> Health { return Health { current: max, max: max } }
def take_damage(mut self, amount: int) { self.current -= amount }
def is_alive(self) -> bool { return self.current > 0 }
}
See the examples directory for runnable programs:
examples/hello.shrpexamples/simple.shrpexamples/advanced.shrpexamples/structs.shrpexamples/enums.shrpexamples/gameobjects.shrpexamples/gameobject_simple.shrpSharp availability targets:
cargo install sharpbrew install sharpdocker pull yourusername/sharpMIT License
Contributions welcome. Please open issues or PRs.