There's a lot of talk about Type-Safety in programming these days. Yet a lot of programs, especially distributed systems, rely on infrastructure that breaks your type-safety. So what gives? π€
π‘ Why Type-Safety matters
Type-Safety is mainly about preventing Type Errors, which are errors that usually happen when an operation is performed on a data type it wasn't designed for.
πΌ Example: Picture this
In your program you're dividing two integers, but instead of an integer, a string of letters is passed to the function. This is a classic example where unintended behaviour can arise and it all might blow up in your user's face. π€―
Now you might be saying to yourself: I use a modern programming language like Go or TypeScript, which has type-safety "built-in". That ensures my program is type-safe. Right...?
π Cue the huge elephant in the room
Ensuring your code is type-safe is often only half the battle.
If you're building a distributed system, like an event-driven application using Pub/Sub, it's not enough to ensure that each service is written in a type-safe way.π¬
π©βπ¦― This is because, normally, Pub/Sub mechanisms are blind to the data structures of the messages they handle, making the inter-service communication un-[type]safe.
This is common source of hard-to-catch errors that can be a nightmare to debug.
π¦ΈββοΈ Type-Safe Infrastructure to the rescue
π€ What if your Pub/Sub communication could be type-safe? That would prevent a whole class of bugs, and help you catch problems in development rather in production. Saving you time and avoiding plenty of user pains.
π‘ A big part of what we're building at Encore is a fully type-safe Infrastructure SDK that lets you declare infrastructure primitives as type-safe objects in your program.
π€ This means Encore's compiler can ensure you have end-to-end type-safety, even when using things like Pub/Sub. (Other benefits include that it can also automatically provision the infrastructure in your cloud and deploy your app.)
Try it yourself
π Check out this tutorial on building an event-driven system using Encore's Go SDK.
π Prefer to use TypeScript? Join the Developer Hangout on Slack to ask for beta access.
Top comments (0)