G#

Show HN: G# –> a new dotnet language like Go/Swift/Kotlin with C# interop

Last verified:

Visit G#

What is G#?

G# (GSharp) is a modern programming language for the .NET runtime that brings Go, Kotlin, and Swift-style ergonomics to developers. It features packages and imports, func declarations for simple function syntax, data classes for concise data modeling, nullable handling with if-let syntax, and structured concurrency with scope. Source code compiles directly to managed assemblies that run on the modern .NET runtime, allowing developers to import any CLR type and call its methods seamlessly.

Key features include sealed classes and discriminated enums, arrow lambdas, pattern-based switch statements, width-bearing primitives like int32, uint64, and float64 that make value sizes explicit, async/await over Task[T], async sequence[T] for async streams, and an opt-in extension for channels and goroutines. The language toolkit includes a command-line compiler (gsc), an MSBuild SDK, a VS Code extension, a language server, and Portable PDB debugging support.

G# is designed for .NET developers who want modern language ergonomics from Go, Kotlin, Swift, and TypeScript while maintaining full interoperability with C# and F# through the .NET Common Language Infrastructure. It serves both as a general-purpose language and is particularly useful for developers who want recognizable syntax from popular modern languages while staying within the .NET ecosystem.

G# pricing

Pricing model: Freemium

G# is completely free and open source. The language, compiler (gsc), MSBuild SDK, VS Code extension, and language server are all available without cost. The VS Code extension is published on the Visual Studio Marketplace as a free extension. The project is hosted on GitHub under an open source license, allowing free use, modification, and distribution.

G# pros

  • Modern Go, Kotlin, and Swift-style ergonomics on .NET
  • Simple func declaration syntax instead of complex method syntax
  • Data classes for concise data model definitions
  • Nullable handling with if-let syntax prevents null errors
  • Structured concurrency with scope for safe async code
  • Compiles directly to managed .NET assemblies
  • Full CLR type interoperability with C# and F#
  • Width-bearing primitives (int32, uint64, float64) make sizes explicit
  • Async/await over Task[T] for modern asynchronous programming
  • Async sequence[T] for async streams support
  • Discriminated enums and sealed classes for type safety
  • Arrow lambdas for concise functional syntax
  • Pattern-based switch statements for clean branching
  • Command-line compiler (gsc) for flexible builds
  • MSBuild SDK integration for .NET project workflows
  • VS Code extension with rich language support
  • Language server for IDE integration
  • Portable PDB debugging for cross-platform debugging
  • Opt-in channels and goroutines extension available
  • Single implementation-grounded language specification

G# cons

  • New language with smaller community than C#
  • Limited third-party library ecosystem compared to C#
  • No expr as T safe cast operator in expressions
  • No expr is T type-test operator in expression position
  • Channels and goroutines are opt-in extensions, not built-in
  • Language server still developing (mentioned as 'coming soon' in some extensions)
  • Requires .NET runtime installation (though acquired automatically)
  • Less documentation and tutorials than established .NET languages
  • May not be suitable for enterprise projects requiring mature tooling
  • GitHub repository shows active issues but language is still evolving

Frequently asked questions about G#

What is G# programming language?

G# (GSharp) is a modern programming language for the .NET runtime that brings Go, Kotlin, and Swift-style ergonomics to developers. It features packages, func declarations, data classes, nullable handling with if-let, and structured concurrency with scope. Source compiles directly to managed assemblies that run on the modern .NET runtime.

How does G# compare to C#?

G# offers simpler, more modern ergonomics inspired by Go, Kotlin, Swift, and TypeScript while maintaining full interoperability with C# and F# through the .NET Common Language Infrastructure. G# uses func instead of complex method syntax, data classes for concise data modeling, and if-let for nullable handling. Developers can import any CLR type from C# and call its methods.

What tooling does G# provide?

G# provides a command-line compiler (gsc), an MSBuild SDK for .NET project integration, a VS Code extension with rich language support for .gs files and .gsproj projects, a language server for IDE integration, and Portable PDB debugging support for cross-platform development.

Can G# use C# libraries?

Yes, G# can import any CLR type and call its methods because it runs on the .NET runtime and uses the Common Language Infrastructure. This allows full interoperability between G#, C#, and F#, enabling developers to leverage existing .NET libraries while using G# syntax.

What is the if-let feature in G#?

if-let is G#'s nullable handling syntax that prevents null errors by safely checking and binding nullable values. This is a feature borrowed from Kotlin and Swift that makes working with nullable types more concise and safe compared to traditional null checks in C#.

Does G# support asynchronous programming?

Yes, G# supports async/await over Task[T] for standard asynchronous programming and async sequence[T] for async streams. It also provides structured concurrency with scope for safe async code management. Channels and goroutines are available as an opt-in extension for more advanced concurrency patterns.

What are width-bearing primitives in G#?

Width-bearing primitives like int32, uint64, and float64 make the size of every value explicit in G#. This means developers don't need to guess whether int is 32-bit or 64-bit - the type name itself indicates the exact width, improving code clarity and preventing platform-dependent size issues.

How do I install G#?

To use G#, you need the .NET Runtime (which is acquired automatically via the .NET Install Tool extension in VS Code) and the C# extension for debugging support. Install the G# VS Code extension from the Visual Studio Marketplace for rich language support with .gs files and .gsproj projects.

What file extensions does G# use?

G# uses .gs for source code files and .gsproj for project files. The VS Code extension provides rich language support specifically for these file types, including syntax highlighting, program structure support, and other IDE features.

Is there documentation for learning G#?

Yes, G# provides a single implementation-grounded language specification that serves as the definitive reference. The documentation includes a language tour at the main website, tutorials for getting started, and an 'Effective G#' idioms guide for learning best practices and common patterns.

Categories

Use cases

Browse all AI tools on NeedAnAI