Hacker News new | ask | show | jobs
by HumanDrivenDev 3044 days ago
> This light bulb is exactly why many people prefer statically-typed programming languages, especially above a certain codebase size/complexity and team size.

I agree, with the caveat that sometimes you need an escape valve.

Basically I want static typing 99% of the time and I don't want guff from the compiler (or fanboys) in that 1%.

2 comments

C# and Typescript are great at this, and a great combo together.
That’s what (unchecked) exceptions are for.

They’re supported by all general purpose programming languages because we — as developers — are smarter than the compiler.

1. GP is talking about type safety in general, not just exceptions.

2. Not “all general purpose programming languages” support exceptions. To name a few that don’t: C, Rust, Go.

Go has the empty interface, if you really need it.
The empty interface is not an unchecked exception, but panic() is. https://golang.org/pkg/builtin/#panic
I don’t actually know Go, but can panic() be caught? If not, it’s not an exception.
With recover(), yes.