Question about strict_types
#35
-
Heya, I just discovered this project and I'm very impressed so far. I have a question about If it's the former (performance), I'd really like to learn more. And if it's due to preference, then that's all fine by me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Good point. If anything, the To be completely honest, I'm not too happy that PHP does type checking at runtime, but I understand why they had to take that route. When it comes to performance, there are few "micro-optimizations" that actually matter, but it mostly comes down to the following:
To come back to your question :) It's not a conscious decision, and I think we could adapt the directive quite easily, as most things should already be properly typed. |
Beta Was this translation helpful? Give feedback.
Good point. If anything, the
strict_types
directive could potentially even shave off a few microseconds, as from my understanding, the Zend engine would not need to perform potential implicit casts (though I haven't checked the source to back up that claim).To be completely honest, I'm not too happy that PHP does type checking at runtime, but I understand why they had to take that route.
When it comes to performance, there are few "micro-optimizations" that actually matter, but it mostly comes down to the following:
Always try to reduce computational complexity. For example, if collision detection is your bottleneck, use an octree, etc.