Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58068 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77750 invoked from network); 25 Feb 2012 21:11:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2012 21:11:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:43692] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/44-46034-C7E494F4 for ; Sat, 25 Feb 2012 16:11:25 -0500 Received: by werh12 with SMTP id h12so51948wer.29 for ; Sat, 25 Feb 2012 13:11:21 -0800 (PST) Received-SPF: pass (google.com: domain of kris.craig@gmail.com designates 10.180.99.100 as permitted sender) client-ip=10.180.99.100; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kris.craig@gmail.com designates 10.180.99.100 as permitted sender) smtp.mail=kris.craig@gmail.com; dkim=pass header.i=kris.craig@gmail.com Received: from mr.google.com ([10.180.99.100]) by 10.180.99.100 with SMTP id ep4mr15729785wib.7.1330204281684 (num_hops = 1); Sat, 25 Feb 2012 13:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/ap/eOJry9ZhMtnjxb02EHNGPCDXlM0H6J6cTnIGC8U=; b=S2Ci056YAxFCWc/9/a7Si27W09Wibghl7FfHX502uIDPDCAD+IShNbWNM48Xtob7gF tbp4Y6V9/MF/KXNHLt3hVpiPS6w3HQUB/klTr0m2EkE+6JqGR354fZbXQ0RxbiTWEihY N+dtmTNEnWNkHhHQhGFGHPC7AmRvusyERj2fs= MIME-Version: 1.0 Received: by 10.180.99.100 with SMTP id ep4mr12562465wib.7.1330204281602; Sat, 25 Feb 2012 13:11:21 -0800 (PST) Received: by 10.223.75.146 with HTTP; Sat, 25 Feb 2012 13:11:21 -0800 (PST) In-Reply-To: References: <4F455C96.50706@gmail.com> <4F455E91.2060408@alliantinternet.com> <028001ccf1ab$0b200050$216000f0$@alliantinternet.com> <4F457517.7050901@alliantinternet.com> <028d01ccf230$91d79b00$b586d100$@alliantinternet.com> <4F4686C6.2040207@sugarcrm.com> Date: Sat, 25 Feb 2012 13:11:21 -0800 Message-ID: To: Samuel Deal Cc: Richard Lynch , John LeSueur , Stas Malyshev , Anthony Ferrara , Dmitri Snytkine , Sebastian Krebs , PHP internals list Content-Type: multipart/alternative; boundary=f46d04428e5caf01bd04b9d05142 Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: kris.craig@gmail.com (Kris Craig) --f46d04428e5caf01bd04b9d05142 Content-Type: text/plain; charset=ISO-8859-1 There are advantages to strict typing other than speed and safety. The biggest compliant I hear from people asking for this is that weak hinting often leads to bulkier code that is much more difficult to read, particularly for someone who frequently switches between PHP and compiled languages like C++ and C#. Therefore, allowing for strict typing, i.e. leaving it to the discretion of the code author, would not necessitate converting PHP into a compiled language or require anything close to a fundamental rewrite. Furthermore, it would allow for 100% backwards compatibility with existing code. This would essentially make PHP more flexible, not less. We'd simply be adding a new dimension to it that has been overwhelmingly requested from the outside for many years. --Kris On Sat, Feb 25, 2012 at 12:27 PM, Samuel Deal wrote: > Hi, > > Going to Strict tying it's really a major paradign shift. > > To clarify my talk, When I say "strict typing", I'm talking about strict > scalar check, variable definition or return type check. > I'm ok with weak scalar type hinting. > > > We have type hinting, yes, but it's a kind of syntaxtic sugar for : > if(! arg1 instanceof MyClass){ > throw new exception("How are you using my work ?!!"); > } > Any check we make slow our execution time. > Before type hinting exists, we performed manualy this check, and it was > verbose and slower than same check done by PHP native code. > > > PHP is a script language. No compilation pass. > In all cases, because someone made a bad use of a function, it will break > at execution time. > So type hinting and strict typing will not make our code safer or faster. > > We don't have to be ashamed of using a script language. > Thanks to this, we can do metaprogramming. > for instance, __call() allow us to do really awesome things > If we look at other script languages, Python, Ruby, Perl or Javascript > doesn't have srtict typing nor type hinting. > > I love static languages. > I write code in C, C++, Java, As3 and C#. > They have good performance, stric typing, static checks at compilation > time. > But it's a different technology, and their philosophy is allowed only > because there's a compilation phase. > > That's why when facebook, with HHVM, tryied to make a faster PHP, it can > only work with a subset of what is realy PHP. > For this reason, it's really really difficult to make javascript a fast > language (v8 and sipermonkey are very complex). > For the same reason, now Adobe decide to give up with the dynamic part of > ActionScript (wich was limited compared to PHP) to speed up their VM. > > So I think going to scrict typing only make sense if we want a static > language, with compilation phase and performances gains due. > But it would be more than a major compatibility. > A lot of things will be not only be broken, but will be impossible. > > Finally, it would be a so big engine change that it would be better to > restart the engine from scratch. > And if we start from scratch without backward compatibility, is this still > PHP ? > > And is there a language which already works as expected? Java ? > > Just my 0.02$ > > -- > Samuel DEAL > samuel.deal@gmail.com > > --f46d04428e5caf01bd04b9d05142--