{"id":48655068,"url":"https://github.com/antonsynd/sharpy","last_synced_at":"2026-04-10T09:05:56.262Z","repository":{"id":348629918,"uuid":"918506336","full_name":"antonsynd/sharpy","owner":"antonsynd","description":"A statically-typed Pythonic language for .NET","archived":false,"fork":false,"pushed_at":"2026-04-09T22:05:05.000Z","size":29854,"stargazers_count":1,"open_issues_count":23,"forks_count":0,"subscribers_count":1,"default_branch":"mainline","last_synced_at":"2026-04-10T00:17:12.325Z","etag":null,"topics":["ahead-of-time-compilation","cil","compiled-language","dotnet","msil","python","python3","pythonic","statically-typed"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonsynd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":".github/agents.md","dco":null,"cla":null}},"created_at":"2025-01-18T05:21:04.000Z","updated_at":"2026-04-09T00:09:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/antonsynd/sharpy","commit_stats":null,"previous_names":["antonsynd/sharpy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/antonsynd/sharpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonsynd%2Fsharpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonsynd%2Fsharpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonsynd%2Fsharpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonsynd%2Fsharpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonsynd","download_url":"https://codeload.github.com/antonsynd/sharpy/tar.gz/refs/heads/mainline","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonsynd%2Fsharpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31635972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ahead-of-time-compilation","cil","compiled-language","dotnet","msil","python","python3","pythonic","statically-typed"],"created_at":"2026-04-10T09:05:50.950Z","updated_at":"2026-04-10T09:05:56.249Z","avatar_url":"https://github.com/antonsynd.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sharpy\n\n[![.NET 10 Build](https://github.com/antonsynd/sharpy/actions/workflows/dotnet10.yml/badge.svg)](https://github.com/antonsynd/sharpy/actions/workflows/dotnet10.yml)\n![.NET](https://img.shields.io/badge/.NET-10.0-blue)\n\n**A statically-typed Pythonic language for .NET**\n\nSharpy 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.\n\n```python\n# hello.spy\ndef greet(name: str) -\u003e str:\n    return f\"Hello, {name}!\"\n\ndef main():\n    message = greet(\"World\")\n    print(message)\n```\n\n```bash\n$ sharpyc run hello.spy\nHello, World!\n```\n\n## What Sharpy Adds\n\n### Static Typing with Full Inference\n\nTypes are checked at compile time. Inside functions, the compiler infers types so you rarely need to write them — but module-level declarations require annotations.\n\n```python\ndef main():\n    x = 42          # Inferred as int\n    pi = 3.14159    # Inferred as float (double)\n    name = \"hello\"  # Inferred as str\n\n# Module-level requires annotations\ncounter: int = 0\n```\n\n### Null Safety\n\nNon-nullable by default. Nullable types are explicit, and the compiler tracks nullability through control flow.\n\n```python\ndef process(calc: Calculator?, a: int, b: int) -\u003e int:\n    result: int? = calc?.add(a, b)  # Null-conditional\n    return result ?? 0              # Null coalescing\n\ndef check(x: int?) -\u003e None:\n    if x is not None:\n        print(x + 10)  # Narrowed to int — no unwrap needed\n```\n\n### Optional and Result Types\n\nTagged unions for safe error handling — no exceptions required.\n\n```python\ndef find_user(name: str) -\u003e str?:\n    if name == \"Alice\":\n        return Some(\"alice@example.com\")\n    return None()\n\ndef safe_divide(a: int, b: int) -\u003e int !str:\n    if b == 0:\n        return Err(\"division by zero\")\n    return Ok(a // b)\n\ndef main():\n    print(find_user(\"Alice\").unwrap_or(\"not found\"))  # alice@example.com\n    print(safe_divide(10, 3).unwrap_or(0))            # 3\n```\n\n### Interfaces\n\nNo duck typing — implement interfaces explicitly.\n\n```python\ninterface IDrawable:\n    def draw(self) -\u003e str: ...\n    def area(self) -\u003e int: ...\n\nclass Circle(IDrawable):\n    radius: int\n\n    def __init__(self, r: int):\n        self.radius = r\n\n    def draw(self) -\u003e str:\n        return \"Drawing Circle\"\n\n    def area(self) -\u003e int:\n        return 3 * self.radius * self.radius\n```\n\n### Structs (Value Types)\n\nTrue value semantics — copies on assignment, allocated on the stack.\n\n```python\nstruct Point:\n    x: int\n    y: int\n\n    def __init__(self, x: int, y: int):\n        self.x = x\n        self.y = y\n\ndef main():\n    p1 = Point(10, 20)\n    p2 = p1       # Copy — value semantics\n    p2.x = 99\n    print(p1.x)   # 10 — original unchanged\n```\n\n### Generics\n\nType-safe generics on classes and functions with bracket syntax.\n\n```python\nclass Cell[T]:\n    value: T\n\n    def __init__(self, initial: T):\n        self.value = initial\n\n    def get(self) -\u003e T:\n        return self.value\n\ndef identity[T](x: T) -\u003e T:\n    return x\n\ndef main():\n    c = Cell[int](42)\n    print(c.get())          # 42\n    print(identity[str](\"hi\"))  # hi\n```\n\n### Properties\n\nFirst-class property declarations — no `@property` boilerplate.\n\n```python\nclass Person:\n    property name: str\n    property age: int\n\n    def __init__(self, name: str, age: int):\n        self.name = name\n        self.age = age\n```\n\n### Named Tuples\n\nLightweight named types via type aliases.\n\n```python\ntype Point = tuple[x: float, y: float]\n\ndef main():\n    p: Point = (x=1.0, y=2.0)\n    print(p.x)  # 1.0\n```\n\n### Pattern Matching with Guards\n\n```python\ndef describe(value: int):\n    match value:\n        case 1:\n            print(\"one\")\n        case x if x \u003e 100:\n            print(f\"big: {x}\")\n        case _:\n            print(\"other\")\n```\n\n### .NET Interop\n\nImport .NET types directly. `snake_case` calls auto-map to `PascalCase` .NET methods.\n\n```python\nfrom system import Console\n\ndef main():\n    Console.write_line(\"Hello from .NET!\")\n    Console.write_line(f\"2 + 2 = {2 + 2}\")\n```\n\n### Async\n\n```python\nasync def fetch_value() -\u003e str:\n    return \"hello async\"\n\nasync def main():\n    result: str = await fetch_value()\n    print(result)  # hello async\n```\n\n## Familiar Python\n\nClasses, inheritance, decorators, comprehensions, f-strings, generators, lambdas, dunder methods, `try`/`except`, `match`, `enum` — they all work as you'd expect. Sharpy is designed so that valid Sharpy code *reads* like Python.\n\n```python\n@abstract\nclass Shape:\n    name: str\n\n    def __init__(self, name: str):\n        self.name = name\n\n    @abstract\n    def area(self) -\u003e float: ...\n\nclass Circle(Shape):\n    radius: float\n\n    def __init__(self, radius: float):\n        super().__init__(\"Circle\")\n        self.radius = radius\n\n    @override\n    def area(self) -\u003e float:\n        return 3.14 * self.radius * self.radius\n\ndef fibonacci(n: int) -\u003e int:\n    a, b = (0, 1)\n    i = 0\n    while i \u003c n:\n        yield a\n        a, b = (b, a + b)\n        i += 1\n\ndef main():\n    c = Circle(4.0)\n    print(f\"{c.name}: {c.area()}\")  # Circle: 50.24\n\n    doubled = [x * 2 for x in range(5)]\n    evens = {x for x in range(10) if x % 2 == 0}\n    squares = {x: x * x for x in range(5)}\n```\n\n## Getting Started\n\n### Prerequisites\n\n- .NET 10.0 SDK ([Download](https://dotnet.microsoft.com/download))\n\n### Build \u0026 Test\n\n```bash\ngit clone https://github.com/antonsynd/sharpy.git\ncd sharpy\ndotnet build sharpy.sln\ndotnet test\n```\n\n### Using the Compiler\n\n```bash\n# Compile and execute\ndotnet run --project src/Sharpy.Cli -- run hello.spy\n\n# View generated C#\ndotnet run --project src/Sharpy.Cli -- emit csharp hello.spy\n\n# View parsed AST\ndotnet run --project src/Sharpy.Cli -- emit ast hello.spy\n\n# Multi-file project\ndotnet run --project src/Sharpy.Cli -- project path/to/project.spyproj\n```\n\n## Design Philosophy\n\nSharpy follows three axioms in strict priority order:\n\n| Priority | Axiom | Meaning |\n|----------|-------|---------|\n| 1 | **.NET** | Always compiles to valid C# for the CLR |\n| 2 | **Types** | Statically typed, non-nullable by default |\n| 3 | **Python** | Syntax and idioms yield to the above when conflicts arise |\n\n## Documentation\n\n- [Documentation Site](https://antonsynd.github.io/sharpy/) - Full documentation (language reference, stdlib API, tooling)\n- [Try Sharpy Online](https://antonsynd.github.io/sharpy/playground/) - Browser-based playground\n- [Language Specification](docs/language_specification/) - Complete language reference (source)\n- [Contributing Guide](CONTRIBUTING.md) - How to contribute\n\n## Project Structure\n\n```\nsharpy/\n├── src/\n│   ├── Sharpy.Compiler/             # Compiler (lexer, parser, semantic, codegen)\n│   ├── Sharpy.Core/                 # Standard library (runtime)\n│   ├── Sharpy.Cli/                  # CLI tool\n│   ├── Sharpy.Lsp/                  # Language Server Protocol server\n│   ├── Sharpy.Compiler.Tests/       # 4,914 test fixtures + unit tests\n│   ├── Sharpy.Compiler.Benchmarks/  # Performance benchmarks\n│   ├── Sharpy.Core.Tests/           # Runtime library tests\n│   └── Sharpy.Lsp.Tests/            # LSP server tests\n├── editors/vscode/                  # VS Code extension\n├── docs/language_specification/     # Authoritative language specification\n└── build_tools/                     # Build automation and dogfooding tools\n```\n\n## Editor Support\n\nSharpy includes a Language Server Protocol (LSP) server for IDE integration.\n\n### VSCode\n\nInstall the **Sharpy** extension from the marketplace or build from `editors/vscode/`.\n\n### Other Editors\n\nAny editor supporting LSP can connect to the Sharpy language server:\n\n```bash\nsharpyc lsp\n```\n\nSee [docs/tooling/editor-integration.md](docs/tooling/editor-integration.md) for configuration guides for Neovim, Emacs, Sublime Text, Helix, and Zed.\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n**Links:** [GitHub](https://github.com/antonsynd/sharpy) · [Documentation](https://antonsynd.github.io/sharpy/) · [Playground](https://antonsynd.github.io/sharpy/playground/) · [Issues](https://github.com/antonsynd/sharpy/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonsynd%2Fsharpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonsynd%2Fsharpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonsynd%2Fsharpy/lists"}