4 ms·
> PHP's problems are actually quite solvable without core language changes How do you fix weak typing?
by Ralith 14y ago
> PHP's problems are actually quite solvable without core language changes
How do you fix weak typing?
- 10098 14y agoOstensibly, by writing lots and lots and lots of unit tests. In practice, however, no one has time to write or update unit tests. Which is bad, but understandable, because circumstances can be pressing. In that case, the only fix for weak typing is praying that nothing blows up :-)
- Ralith 14y agoWhile I appreciate that your post is mostly jest, it's worth noting that a "fix" that places an immense amount of additional load on the programmer is not worthy of the title (in part due to the consequences you describe). And even then, even the best unit tests rarely cover every case.
- Joeri 14y agoJavascript has weaker typing than PHP (in php you can have typed parameters for object parameters), but javascript is the new hotness and php gets no love. Typing is not the issue that makes php so ugly. Also, i write php all day and i almost never run into bugs due to typing. You adopt some habits like always casting before use, and use an ide that warns you when you're doing stuff like using uninitialized variables (phpstorm is awesome), and the whole issue goes away for 95%. I'm not saying it doesn't cause bugs, just that i've found it to not be that big of a deal.