sharp-0.1.0 is not a library.
Sharp Programming Language
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
Install or Build
- If published:
cargo install sharp - From source (macOS example):
CLI Usage
# Compile to LLVM IR
# Run LLVM IR (macOS Homebrew LLVM)
# Check without codegen
# Emit object file
# Emit native binary
Language Fundamentals
- Types:
int,float,bool,string,void,auto - Variables with optional types:
def main() -> int { x: int = 10 y = 20 // inferred return x + y } - Functions:
def add(a: int, b: int) -> int { return a + b } - Control Flow:
if/elif/else,while,for i in 0 .. N,match - Operators: arithmetic, comparison, logical, and compound assignments
- Printing:
print(x)andprintln(x)supportint,bool, and string literals
Data Structures and Methods
Structs
struct Vector2 { x: float, y: float }
struct GameObject {
position: Vector2
health: int
active: bool
}
Impl Blocks and Methods
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 }
}
Struct Initialization
let pos = Vector2 { x: 10.0, y: 20.0 }
let player = GameObject {
position: Vector2 { x: 0.0, y: 0.0 },
health: 100,
active: true
}
Enums
enum GameState { Loading, MainMenu, Playing, Paused, GameOver }
enum EntityType { Player, Enemy, NPC, Projectile }
Arrays (type annotations)
# [T] or [T; N]
positions: [Vector2; 3]
values: [int]
Syntax Reference (Quick)
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 }
}
Examples
See the examples directory for runnable programs:
examples/hello.shrpexamples/simple.shrpexamples/advanced.shrpexamples/structs.shrpexamples/enums.shrpexamples/gameobjects.shrpexamples/gameobject_simple.shrp
Roadmap
- Arrays with methods (len/push)
- String utilities and formatting
- Traits and generics
- Pattern matching on enums
- Standard library (math, collections, io)
Distribution
Sharp availability targets:
- Cargo:
cargo install sharp - Homebrew:
brew install sharp - Docker:
docker pull yourusername/sharp - GitHub Releases: download binaries
License
MIT License
Contributing
Contributions welcome. Please open issues or PRs.