Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85699 invoked from network); 15 Jan 2015 14:51:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 14:51:26 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:45527] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/DB-14306-DE3D7B45 for ; Thu, 15 Jan 2015 09:51:26 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id D4371B00085; Thu, 15 Jan 2015 09:51:22 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id fEifwPeDw1-9; Thu, 15 Jan 2015 09:51:22 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 510E5B0007B; Thu, 15 Jan 2015 09:51:21 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Thu, 15 Jan 2015 14:51:18 +0000 Cc: RQuadling@gmail.com, Leigh , PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <85F6139E-6332-4645-91B8-C852B07EA62A@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> To: Zeev Suraski X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: ajf@ajf.me (Andrea Faulds) Hi Zeev, > On 15 Jan 2015, at 14:32, Zeev Suraski wrote: >=20 >> 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. >=20 > 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=E2=80=99m not really sure this is true. I agree that strict types = aren=E2=80=99t entirely in keeping with the =E2=80=9CPHP way=E2=80=9D. = However, there are plenty of people who are against them not for that = reason, but simply because they don=E2=80=99t work well for them. Plus, = I=E2=80=99m 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=E2=80=99= t stop PHP being weakly-typed. They just check types at function call = boundaries. Think of it as a sanity check. >=20 >>> 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. >>=20 >> Not all of it was positive. Sure, a lot of people would use them = though, >> but >> I=E2=80=99ve heard quite a few developers say they wouldn=E2=80=99t = use them and continue >> to use manual (!is_int($foo))-style assertions. >=20 > 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=E2=80=99s have a look. =46rom 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=E2=80=99s position. This is unlikely to be super-representative of the PHP community. = However, I=E2=80=99m not sure I=E2=80=99d say =E2=80=9Coverwhelmingly = positive=E2=80=9D. 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=E2=80=99t think it=E2=80=99s 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=E2=80=99t think this is true: if we are making a feature less = useful (and therefore making many people avoid it), it=E2=80=99s worth = considering if that is a problem. If we can easily cover the vast = majority of people=E2=80=99s use cases, rather than catering to only one = group of people (who may or may not be the majority), why don=E2=80=99t = we? >=20 >>> 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. >>=20 >> This isn=E2=80=99t a runtime option, it is entirely compile-time. = Much like >> namespaces >> are not a runtime option. There isn=E2=80=99t even the ability to = toggle it at >> runtime, >> unless we somehow add some ability to edit the flags on individual >> opcodes. >=20 > 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=E2=80=99re using some = weird extension which lets you edit the flag on the ZEND_DO_FCALL = opcode. Thanks! -- Andrea Faulds http://ajf.me/