A statically-typed Pythonic language for .NET
Sharpy starts with Python's syntax and adds static typing, null safety, tagged unions, and seamless .NET interop — then compiles to idiomatic C# via Roslyn with zero runtime overhead.
# hello.spy
def greet(name: str) -> str:
return f"Hello, {name}!"
def main():
message = greet("World")
print(message)$ sharpyc run hello.spy
Hello, World!- Static typing with full inference — types checked at compile time, rarely written inside functions
- Null safety — non-nullable by default, nullable types explicit (
T?), compiler-tracked narrowing - Optional and Result types — tagged unions for safe error handling without exceptions
- Interfaces — explicit implementation, no duck typing
- Structs — true value semantics, stack-allocated
- Generics — type-safe with bracket syntax, variance support (
out/in) - Properties — first-class declarations, no
@propertyboilerplate - Pattern matching —
matchwith guards, type patterns, destructuring - Async/await — first-class async support
- .NET interop — import .NET types directly,
snake_caseauto-maps toPascalCase - Familiar Python — classes, inheritance, decorators, comprehensions, f-strings, generators, lambdas, dunder methods
Requires .NET 10.0 SDK.
git clone https://github.com/antonsynd/sharpy.git
cd sharpy
dotnet build sharpy.sln
dotnet test
# Compile and run
dotnet run --project src/Sharpy.Cli -- run hello.spy
# View generated C#
dotnet run --project src/Sharpy.Cli -- emit csharp hello.spySharpy follows three axioms in strict priority order:
| Priority | Axiom | Meaning |
|---|---|---|
| 1 | .NET | Always compiles to valid C# for the CLR |
| 2 | Types | Statically typed, non-nullable by default |
| 3 | Python | Syntax and idioms yield to the above when conflicts arise |
- Documentation Site — language reference, stdlib API, tooling
- Try Sharpy Online — browser-based playground
- Language Specification — complete language reference (source)
- VS Code Extension — syntax highlighting, LSP integration
- Editor Integration — Neovim, Emacs, Sublime Text, Helix, Zed
- Contributing
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project shall be dual licensed as above, without any additional terms or conditions.