4 ms·
> What does surprise me is that adding types to your PHP code adds _runtime_ errors There are static analysers for PHP too, but yeah they’re also enforced at r
by deergomoo 3y ago
> What does surprise me is that adding types to your PHP code adds _runtime_ errors
There are static analysers for PHP too, but yeah they’re also enforced at runtime.
I think I prefer that, if there’s going to be a non-zero risk of bad types landing in production code, I’d prefer that be an error than for it to just carry on and potentially fail later in strange ways.
That said, one of the reasons cited for PHP not having generics is the performance cost of runtime enforcement. So there are a few people out there now making the case for a generic syntax that is ignored at runtime, but that can be built into static tooling. Which I can get behind—PHPs type system is really not bad at this point, but generics would be really nice.
- DandyDev 3y agoI would also prefer type checks to be done at runtime as well. The reason Python doesn’t do that is likely indeed the cost to performance