Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50645 invoked from network); 18 Apr 2016 18:24:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2016 18:24:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.42 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:34478] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/EA-11975-64625175 for ; Mon, 18 Apr 2016 14:24:07 -0400 Received: by mail-pa0-f42.google.com with SMTP id r5so24966281pag.1 for ; Mon, 18 Apr 2016 11:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Rige41pU+qryVX3D7MtMFvqZN0vqjBpBBASNPlwVdeI=; b=BdonwaAXYVsJKPCkkesD2EIcOpr34OoKNXbLuHBZ7F4KGr86AieMEMbtDr/M0Y+wih frPOk7D/6Z0QolDakQQKj9caW2fQ5e8maNFql8qA87R6Ritn6hx0PvqIDRkCg/C8VhoS aplDSMWBOaaqqd6W0xxJ3Y/KWxd/GT+NE+y6h8h3Hg3lhtLp9Y3gPXGDDQUpal5bttuB B9E8LFKm9T/jf+XweWIIHNwU0/Pf3DeBFTK/fbWhSmHfdr3MOpQ7qDXBx6xPEgnIO9uL QItUKNbY0/KEQ3kNDdwjvs6uhiFZIJd8lqQorxAfRD72/nafM67ktnbPCM68kZwIAFcR XSQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Rige41pU+qryVX3D7MtMFvqZN0vqjBpBBASNPlwVdeI=; b=IDsEWGDVvdPQxjLeniQJgCAx2gKBXAq76bcR5Wpe9zLNXha28oKmrDaJ5z62NZ3Lym 0qSKae0tB1NsewlCZD9Mq2FIgWzBLiZQ+Ra4pYVoeqLZwzF1/2BVmNXPi81YcvkNdEtc Tb1x+Hvw0XkKBVclF1cTkzCC1PmiYJ022YEDkQ1ZQpUupAgmcbuJovMZ8QXvZcYP2bpk k04yJvojtNndIKxIMhPNHQpQYDl+5UbV6SRTvDL1IPg/Tel6ehXdND6vnjUVHs7/GS49 0nlhFU01bGc4BKtAA9uGzpVRikA/WklFhBdaxDYenG1Pah96VjG7IUK7ANyhUA6ltnVv dfvw== X-Gm-Message-State: AOPr4FX+X0xUjyi6saTacHZT6APrMCBkU+TGKTs889vc0sisCdj9gsUsSvfm780FIBOCGw== X-Received: by 10.66.184.40 with SMTP id er8mr52216314pac.134.1461003844348; Mon, 18 Apr 2016 11:24:04 -0700 (PDT) Received: from Stas-Air.local (76-220-46-95.lightspeed.sntcca.sbcglobal.net. [76.220.46.95]) by smtp.gmail.com with ESMTPSA id m87sm85321300pfj.38.2016.04.18.11.24.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Apr 2016 11:24:02 -0700 (PDT) To: Larry Garfield , internals@lists.php.net References: <57103A46.6040803@garfieldtech.com> <5710BA79.5060108@lsces.co.uk> <57110DC5.8000007@garfieldtech.com> <571338E6.50507@fleshgrinder.com> <57145AF7.7060607@garfieldtech.com> <57149405.2040701@lsces.co.uk> <57151210.7040704@garfieldtech.com> Message-ID: <57152641.7050602@gmail.com> Date: Mon, 18 Apr 2016 11:24:01 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <57151210.7040704@garfieldtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Nullable Return Type Declaration From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > I am not sure what you're implying by "some people have no appreciation > of the usefulness of"... I am well aware of NULL's use cases. I am also > well aware that the general zeitgeist in the language development > community is that they're dangerous; the designer of the first language I would like to note in general that following the latest fashion in academic development is not always a good idea for PHP. It's fine when you experiment with academic languages, but when you have language that a) focused on simplicity and low entrance barrier and b) is in production use by millions and has 20 years of existing practices, libraries and habits, we have to be a bit more wary, I think. I am *not* saying we should not improve, or ignore academic developments, I am saying that we should be careful with not jumping to the idea-of-the-day bandwagon too fast, before it is clear it is good and necessary for PHP. As an example, I don't see how exactly eliminating null would be good for PHP, or doing *anything* with null for that matter. > to have them calls them a "billion dollar mistake", many languages > actively avoid having NULL in favor of something deliberately more > structured. NULLs are a very common cause of avoidable fatal errors in > many languages (including PHP). NULLs are rude to users of your API, as > it balloons the error handling code they need to deal with. I think this description is misleading in a way. Nulls are immediate causes of many errors, technically, in a meaning that "if I find null where I expected to have DB connection, I get an error" - but this is only a technical cause. The *real* cause is the failure to check whether your attempt to connect to the database succeeded, or that you have proper DB configuration, or such, and null is just a symptom of that error - and that error is not automagically fixed by having some other object instead of null. You have to actually design and write code for it, there's no replacement for it. So declaring null "cause of all evils" is ignoring the real causes and blaming immediate technical cause instead, and it would not be helpful. It is true that for some languages with more complex type systems it is possible to largely get rid of nulls by using those complex types and ensure type system controls for all checks at least to be present (note that doesn't guarantee proper function either, since no type system can ensure you handle the case of missing DB connection properly, it just can ensure you have a branch for it). But that requires much more complex and involved type system that PHP has - or, in my opinion, should have. > I am on record and will continue to be on record that null is *usually* > wrong. I consider that position entirely justified, as does the > academic CS community. I am also now on record suggesting that we use > union types to allow type-or-null returns/parameters, which you're > welcome to quote me on. :-) I think this position is way too narrow, simplistic and detached from real language use towards abstract academic purity. There are tons of causes where using null is completely fine and exactly what is needed. I also think union types is a great and unnecessary complication of the language and in order to do them properly we'd need lots of facilities PHP does not have (like type pattern matching and static compilation) and I am not sure it should have - ones looking for Haskell know where to find it. And there are a lot of cases where failing on null is exactly what one needs - if it doesn't work, just fail and let somebody come and check what is going on. If your database died, your DB-bound code is not going to fix it. With or without nulls - it has to just fail and wait for somebody to fix it. There's no need to overcomplicate that. -- Stas Malyshev smalyshev@gmail.com