Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:80573 php.internals:80577 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36791 invoked from network); 15 Jan 2015 17:00:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 17:00:38 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:50229] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/60-34371-532F7B45 for ; Thu, 15 Jan 2015 12:00:38 -0500 Received: by mail-ie0-f181.google.com with SMTP id rl12so15943492iec.12 for ; Thu, 15 Jan 2015 09:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=O5lymqIkMFD5z3mFk654XOlLQG5IL7njSzqFg8GgdMA=; b=um59QC68meR6utOub7fQR1vGcvf7qfkbGPCT/17kve+OXQXjqI+G/wLGAq8cKqm3z6 2Rq+v99N+N+39eaBg8qVM3Vbgd4OOPQUMyMfqqtKSg90MytWv+ccGPjfvBPJ2NsegviI NcFSZjiVm5zKQZ1pDIEzmpiP5Nb3JvO+Ru7whXS1+BW1qQLmPDFzh+pE64kTS9LgyO5B ozmdIjgUHFaQLGNwbi4oVY5Zpkr8c4K6b18SLTnmJudgp6tjIxS+NpJ374LVyXyHnOYj GyVg7A+3d9YVqYSuoAr1s1E7MY6V50Q3avw0DsAxVEdSXzUFDS0Yq55hU2kW+uC7SU+z YV/g== MIME-Version: 1.0 X-Received: by 10.42.89.203 with SMTP id h11mr10270787icm.57.1421340922638; Thu, 15 Jan 2015 08:55:22 -0800 (PST) Received: by 10.50.248.45 with HTTP; Thu, 15 Jan 2015 08:55:22 -0800 (PST) In-Reply-To: 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> Date: Thu, 15 Jan 2015 10:55:22 -0600 Message-ID: To: Andrea Faulds Cc: Zeev Suraski , Richard Quadling , Leigh , PHP Internals List Content-Type: multipart/alternative; boundary=90e6ba3fcd29cc76d7050cb3b82d Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: pencap@gmail.com (Mike Willbanks) --90e6ba3fcd29cc76d7050cb3b82d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Andrea, On Thu, Jan 15, 2015 at 8:09 AM, Andrea Faulds wrote: > Hi Zeev, > > > On 15 Jan 2015, at 11:56, Zeev Suraski wrote: > > > > Andrea, > > > > I'm not sure what you're basing that assumption on. The incidental > > interactions you (or anybody) may have with 'the community', by no way > > represent the opinion of the community at large. The vast majority of > the > > PHP community never ever interacts with internals@, never attend > > conferences, don't write blog posts about PHP and are generally > completely > > 'under the radar'. I would actually go to argue that the people who do > > attend conferences, participate on internals@ or write blog posts - are > not > > representative of the PHP userbase at large. The vast majority of > > developers I bump into - you will never ever hear from. They constitut= e > the > > vast majority of the ~5M strong PHP developer base. > > > > So even though my belief / educated guess is that the vast majority of > the > > PHP userbase would prefer to see strict typing kept off this language, > I'm > > not going to argue that - but we must not argue the opposite either, > based > > on the non-representative anecdotal data from a few dozen people. > > 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 we= ak > typing. Thus we have a problem: either approach to scalar hints will upse= t > a large portion of the community. > I actually quite disagree with that statement. Both as a library/framework developer and a user land developer I find strict typing to be more of an issue. For instance: function foo(int $foo) foo('23'); This would be a pain and cause constant glue from userland: Option A: Force Cast aka (int) '23' Option B: Check for digits via ctype_digits then force cast etc. To provide more of a point here, variables coming from HTTP are always a string, this makes strict casting a troubling item, considering that the main way of fetching input is coming from the web specifically. I'm certain this would also affect other areas as well such as reading csv files and more. To me this point alone makes a vastly strong statement against strict typing and as such, it would make life far more difficult for library developers and user land developers alike. > > > > >> Myself, I might have been somewhat happy with just weak hints, but > >> it would upset an awful lot of developers who would like some measure = of > >> strict typing. Developers who would most likely not use the new scalar > >> type > >> hints, because they weren=E2=80=99t strict. And if nobody uses them, w= hy add > them? > > > > 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=E2=80=99ve heard quite a few developers say they wouldn=E2=80=99t u= se them and > continue to use manual (!is_int($foo))-style assertions. > > > If there's one thing that's worse than introducing an alien concept lik= e > > 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=E2=80=99t a runtime option, it is entirely compile-time. Much li= ke > 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. > I agree with the others in that declarative syntax to change it is a bad idea. It actually reminds me of ECMAScript 5's "use strict" ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mo= de) condition. Changing the definition based on user land scripts can lead to bugs and inconsistencies in a library developers purpose of a package and cause bad conditions. It also means that then a library developer would need to handle conditions on both sides (when in weak vs. strict). So I don't really understand where the gains of this would come from and it actually causes me concern in that what if a developer forgets to define strict and you're entire system is built on strict. Regards, Mike --90e6ba3fcd29cc76d7050cb3b82d--