Hacker News new | ask | show | jobs
by Capricorn2481 3 hours ago
Can you explain what about PHP has less context? Are you working in a PHP codebase with no types?
1 comments

Even with types the code does not have enough context.

You can type a variable as array. Now what's in? You don't know unless you read a lot of code.

You can type a variable as a class. Now what's in it? You still don't know, because properties and methods may be dynamically added in various code paths. What methods can you call on this class? You don't know, because it uses magic methods for resolution.

You see a variable in a function. Is it defined? What's it's value or type? You don't know, because there are no local types in PHP. And you don't know if the variable is defined because it could have been defined 3 layers of nesting deep in the function. You have to read more code to find out.

You call a function. Is it defined? You don't know, because it could have been included in an include() somewhere else in the class or function.

You just have to read 10x as much code to get the same amount of context that a language like C# gives you for free via the compiler.