Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92299 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34570 invoked from network); 14 Apr 2016 12:47:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 12:47:52 -0000 Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.47 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.218.47 mail-oi0-f47.google.com Received: from [209.85.218.47] ([209.85.218.47:33110] helo=mail-oi0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/51-25796-8719F075 for ; Thu, 14 Apr 2016 08:47:52 -0400 Received: by mail-oi0-f47.google.com with SMTP id w85so92094802oiw.0 for ; Thu, 14 Apr 2016 05:47:51 -0700 (PDT) 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; bh=gTVTuyF+igXKD+k03ZlwZcjEw2XHl4KsUUo+A+WZ9/I=; b=GxsCTvznk/hi721TACfoMpDS/WDPgM338n8aYhGm9SVAXE8eShZvyYSkX9VxY9Oojk Iw79in+BrCffuC+TtOc46X+gwpAasRYDQTgxAECAQGcTjCXkfGB3KozkzVCCQ9T92NwO hEnE49BppljNm3kx2W+sS6TFKqx/c7EyCB95VCJLd3wunHRYjYO1k4jkDrPakX7509zF 905o87oBiIb6LJ3rqx6YSRCEoLmVF1ubox+vUaOsiFY/MsKywokfQMGcT56POvb9rgtK /MlIvrpHB8ODH05461xTgRu0Cx3HI6Nl9Aoa6vUtKUKWP2pj2a7m+iE+4JX00isHg3dC g2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=gTVTuyF+igXKD+k03ZlwZcjEw2XHl4KsUUo+A+WZ9/I=; b=QfGkEKGELd4scXkQzVqz16umulD/uDbQqp7sDhwPbg338QPBg0ggyO3PLnr7leHnLH nul9+nTYmS6WBMeS3lesidLRBazyPpNuyQ6dew9iYvhTDy7j57iEz73qtLKF8fPeuVC5 ZS2NbiJJ0ieI2/4JauvOISvz7KRSu4BH56c0xzlqrcYcq2TtoJQtZzjeNBkvKQGP6fPo N+ReWkxlZD5HdDL4Zzi2QEUoGOKJxIk5xP74HogWjoDhlL/vTKI9knnGugDs7AYGs80n 57EWU4z8IyRLVChasUlaiP4Eo1K1kHhr0lvCwKz1jLlerHiR9f60Du+hI43tWHHIRMij hM8w== X-Gm-Message-State: AOPr4FXQHDhNz2qJNtWHTGuRB4h8CbbghYdq7T6jYin+Gg+wPU5dBCq+JyoMQKANOcG0j1lq9jcKbOk7D2RYZw== MIME-Version: 1.0 X-Received: by 10.202.234.135 with SMTP id i129mr7107388oih.10.1460638069647; Thu, 14 Apr 2016 05:47:49 -0700 (PDT) Received: by 10.157.7.194 with HTTP; Thu, 14 Apr 2016 05:47:49 -0700 (PDT) In-Reply-To: <20160414094440.GF19347@phcomp.co.uk> References: <570E99AC.3090804@fleshgrinder.com> <570EA5EB.8090501@fleshgrinder.com> <570EAB0D.6080706@gmail.com> <570EB67E.8010908@garfieldtech.com> <5B147E88-CC0A-4CBC-A49D-C7FE3BF557C0@zend.com> <6F.C3.12455.94C5F075@pb1.pair.com> <20160414094440.GF19347@phcomp.co.uk> Date: Thu, 14 Apr 2016 20:47:49 +0800 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113d395e4974970530714d67 Subject: Re: [PHP-DEV] Re: Improving PHP's type system From: cornelius.howl@gmail.com (Lin Yo-An) --001a113d395e4974970530714d67 Content-Type: text/plain; charset=UTF-8 On Thu, Apr 14, 2016 at 5:44 PM, Alain Williams wrote: > On Thu, Apr 14, 2016 at 10:00:41AM +0100, Tony Marston wrote: > > > I agree with Zeev 100%. There are too many people out there who are > > trying to make the language more complicated than it need be just to > > prove how clever they are. The aim of any language should be to > > enable programmers to do complicated things in a simple way, and not > > to do simple things in a complicated way. > > I disagree. My way of looking at it is that adding some features(eg the > current > type specification/checking) adds to the simplicity because I can say what > types > I want and don't need to write code to check the types of argument > received by a > function (etc). Why would I want to check: because I value robustness, ie not having my code > fall over because, somehow, a wrong type slips by unnoticed. I think the original purpose of adding type system in Hack, is to provide just-in-time compilation, this provides more information to let compiler to optimize the code with specific type. Haskell, OCaml, C or C++, these statically typed languages compile code into executable binary, the compiler raises the warnings or errors before executing it, thus they have more time to check type information, they usually don't check type in the run-time. However PHP is not, PHP runs script on the fly, and check the type in the runtime (instead of compile time), therefore the type checking implemented in PHP is a kind of execution performance trade off (until we implemented the JIT compiler). and a complex type system add more extra work to the whole system than statically typed language. Adding type hinting makes people writing PHP code with more confident, I like the scalar type hinting implemented in the current PHP. But weak type conversion and union type are not, it introduces more complex rules of how variables should be converted into another values, and there will be more implementation defined behavior. People will have to always have a cheatsheet or something to check whether if they write the correct code. And I believe, if we can remove the support of weak type conversion, PHP could be a "consistent", "simple" language and it can help people write confident code. Cheers, Yo-An Lin --001a113d395e4974970530714d67--