1 post tagged with "csharp"

View All Tags

Designing the C# Pond: Union Types

Benjamin Sieffert

Benjamin Sieffert

Distributed Systems Engineer at Actyx

One of the many projects we’re currently pushing forward at Actyx is a port of the Actyx Pond V2 from TypeScript to C#.

C# and TypeScript build on very different foundations. Both are modern multi-paradigm languages; both have somewhat dynamic function dispatch mechanisms; but the typical C# program is still very much concerned with the runtime type of objects, as modelled by the CLR. TypeScript meanwhile is all about type shapes (or duck typing): The type system itself is quite strong, but its reality does not carry over into the (JavaScript) runtime.

One way this difference in typing plays out is union types. Union types are a cornerstone of TypeScript programming, and prominently feature in our TypeScript Pond interfaces. But C# does not have an exact equivalent. In this blog post we are looking at ways to preserve all the TypeScript Pond’s features, without giving up idiomatic C#.