TypeScript With Go and Rust Errors? No Try/Catch? Heresy
<p>So, let’s start with a little backstory about me. I am a software developer with around ten years of experience, initially working with PHP and then gradually transitioning to JavaScript.</p>
<p>I started using TypeScript somewhere around five years ago, and since then, I have never gone back to JavaScript. The moment I started using it, I thought it was the best programming language ever created. Everyone loves it; everyone uses it… it’s just the best one, right? Right? RIGHT?</p>
<p>Yeah, and then I started playing around with other languages, more modern ones. First was Go, and then I slowly added Rust to my list (thanks, Prime).</p>
<p>It’s hard to miss things when you don’t know different things exist.</p>
<p>What am I talking about? What is the common thing that Go and Rust share? Errors. The thing that stood out the most for me. And, more specifically, how these languages handle them.</p>
<p>JavaScript relies on throwing exceptions to handle errors, whereas Go and Rust treat them as values. You might think this is not such a big deal… but, boy, it may sound trivial; however, it’s a game-changer.</p>
<p>Let’s walk through them. We will not dive deep into each language; we want to know the general approach.</p>
<p>Let’s start with JavaScript/TypeScript and a little game.</p>
<p>Give yourself five seconds to review the code below and answer why we need to wrap it in try/catch</p>
<p><a href="https://betterprogramming.pub/typescript-with-go-rust-errors-no-try-catch-heresy-da0e43ce5f78">Visit Now</a></p>