Skip to content

antonsynd/sharpy

Sharpy

Sharpy

.NET 10 Build .NET

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!

Features

  • 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 @property boilerplate
  • Pattern matchingmatch with guards, type patterns, destructuring
  • Async/await — first-class async support
  • .NET interop — import .NET types directly, snake_case auto-maps to PascalCase
  • Familiar Python — classes, inheritance, decorators, comprehensions, f-strings, generators, lambdas, dunder methods

Getting Started

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.spy

Design Philosophy

Sharpy 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

License

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.

About

A statically-typed Pythonic language for .NET

Topics

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors