Hi Zeev, > On 15 Jan 2015, at 14:32, Zeev Suraski <z...@zend.com> wrote: > >> Whether or not they are in the majority, a very large portion of PHP >> developers would prefer strict typing. In particular, the most vocal ones >> would seem to. There are also a lot of PHP developers who would prefer >> weak typing. Thus we have a problem: either approach to scalar hints will >> upset a large portion of the community. > > That's correct. As I said though, the source of the opposition is > fundamentally different. > The camp which opposes weak typing opposes it based on the idea that it > doesn't behave in the way that would suit their needs. > The camp which opposes strict typing - which incidentally includes most of > the people who originally created the language - opposes it based on the > assertion that it goes against the spirit of the language. That is equally > true for the v0.2 proposal you've just submitted.
I’m not really sure this is true. I agree that strict types aren’t entirely in keeping with the “PHP way”. However, there are plenty of people who are against them not for that reason, but simply because they don’t work well for them. Plus, I’m not sure strict typing causes as much of a problem if it is off by default. Nobody is forced to use it, the language would stay beginner-friendly and weakly-typed. Indeed, strict type hints don’t stop PHP being weakly-typed. They just check types at function call boundaries. Think of it as a sanity check. > >>> How do you deduce that 'nobody uses them' from the fact that some >>> group of people said they won't? I'm sorry, but it makes no sense, >>> especially given the positive feedback you saw on internals, making it >>> clear that there would be in fact people using it. >> >> Not all of it was positive. Sure, a lot of people would use them though, >> but >> I’ve heard quite a few developers say they wouldn’t use them and continue >> to use manual (!is_int($foo))-style assertions. > > Of course not all of it was positive, but it was overwhelmingly positive. > Very few opposed. Someone saying they won't use it doesn't count as > opposition. Let’s have a look. From a quick skim over the thread for v0.1: * In favour of weak types (or the RFC anyway): Adam, Stas, yourself, Jordi, Pierre, * Against, in favour of strict types: Maxime, Nikita, Markus, Marco, Leigh, Levi, Sven(?) * In favour of strict types, not against weak types as compromise: Matthew * Somewhat in favour: Sebastian * In favour of allowing both approaches: Marcio, Thomas, Marco I apologise if I am misrepresenting anyone’s position. This is unlikely to be super-representative of the PHP community. However, I’m not sure I’d say “overwhelmingly positive”. It can be easy to get confirmation bias when reading RFC threads. It is very clear to me that a lot of people would like strict types, and some people would like weak types. As to their relative numbers, I cannot say. I don’t think it’s really fair to cover only the use case of one half of the PHP community. The other half counts too. This is a rather divisive issue. > You see, PHP exists for 15-20 years now. There aren't any > must-have features that aren't in it. No single feature we add will be used > by everyone, and people telling us they won't use this feature shouldn't > 'deter' us in any way. I don’t think this is true: if we are making a feature less useful (and therefore making many people avoid it), it’s worth considering if that is a problem. If we can easily cover the vast majority of people’s use cases, rather than catering to only one group of people (who may or may not be the majority), why don’t we? > >>> If there's one thing that's worse than introducing an alien concept >>> like strict typing into PHP, it's introducing it as a feature that >>> will include all the negatives of this alien concept, PLUS have the >>> ability to radically change how it behaves based on a runtime option. >> >> This isn’t a runtime option, it is entirely compile-time. Much like >> namespaces >> are not a runtime option. There isn’t even the ability to toggle it at >> runtime, >> unless we somehow add some ability to edit the flags on individual >> opcodes. > > Compile time and runtime in PHP are intertwined when you factor in > cross-file interaction. Except that is not the case for this proposal, which explicitly and deliberately prevents the directive affecting inclusion. The behaviour is impossible to toggle at runtime, unless you’re using some weird extension which lets you edit the flag on the ZEND_DO_FCALL opcode. Thanks! -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php