Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83484 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42218 invoked from network); 22 Feb 2015 20:38:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2015 20:38:56 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.48 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:34889] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/B3-18531-E5E3AE45 for ; Sun, 22 Feb 2015 15:38:56 -0500 Received: by padfa1 with SMTP id fa1so22298319pad.2 for ; Sun, 22 Feb 2015 12:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=V9H9ewsHbQeQ2Ym3q83Sy8exKhZy/nRnihIPDyTIVN4=; b=Gc+OHkDa5UZOvh1KZ8k/vYhCYlGBnW7gLsfm1wj8S+Vax++XO51lLCz+qj9OkFIO6c PjF06lbDxnbQTadzanI+xiu7mV1Nq1qYQtg3cPE/kV3gaRJ+I4OJlOuZZaFylKKwXtVp XYtSzz8TcbG08fWI4FfF7biQMGjtp3taTH+KgJA5NrAKrYYKo2UR3SEmXWaF08vC3LFW R35PBhmRi98VN3y0loTpKc3vX3Q6OMt5Ws/u2JxaXw7Pb7IFJcL05xQPKybu0BjKgGqY yLNY8eKPfroK9RTEUCwrtnKQBFtQyxUwAqEdTfMqyioEcp8zsQcw2w6toNF9TBlYRsRY VHzA== X-Received: by 10.68.172.98 with SMTP id bb2mr13787768pbc.156.1424637531755; Sun, 22 Feb 2015 12:38:51 -0800 (PST) Received: from [192.168.2.102] (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id oq4sm19460943pdb.73.2015.02.22.12.38.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Feb 2015 12:38:51 -0800 (PST) Message-ID: <54EA3E59.3000706@gmail.com> Date: Sun, 22 Feb 2015 12:38:49 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jefferson Gonzalez , Etienne Kneuss , Anthony Ferrara , Zeev Suraski CC: PHP internals References: <7ef509ef10bb345c792f9d259c7a3fbb@mail.gmail.com> <8250289916f5128b5bc1a114428d374e@mail.gmail.com> <54E9E6B5.3030905@gmail.com> In-Reply-To: <54E9E6B5.3030905@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Coercive Scalar Type Hints RFC From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > A JIT or AOT machine code generator IMHO will never have a decent use of > system resources without some sort of strong/strict typed rules, > somebody explain if thats not the case. Yes, that's not the case, at least nobody ever showed that to be the case. In general, as JS example (among many others) shows, it is completely possible to have JIT without strict typing. In particular, coercive typing provides as much information as strict typing about variable type after passing the function boundary - the only difference is what happens _at_ the boundary and how the engine behaves when the types do not match, but I do not see where big performance difference would come from - the only possibility for different behavior would be if your app requires constant type juggling (checks are needed in strict mode anyway, since variables are not typed) - but in this case in strict mode you'd have to do manual type conversions, which aren't in any way faster than engine type conversions. So the case for JIT being somehow better with strict typing so far remains a myth without any substantiation. > while on strict mode the generated code could be: > > int calc(int val1, int val2) { > return val1 + val2; > } No, it can't be (at least it can't be the _entire_ code of this function), since the user still can pass non-int into this function - nothing introducing strict typing in functions, as it is proposed now, prevents it. What strict typing does is to ensure the error in this case, but to generate the error you still need the checks! BTW, your weak mode code is wrong too - there's no need to generate Variants if you typed the variables as int. You know once coercion is done they are ints. At least in the model that was now proposed. > If my example is right it means strict would be better to achieve good Unfortunately, your example is not right. > to another level of integration with PHP and performance. IMHO is harder > and more resource hungry to implement a JIT/AOT using weak mode. With Please provide a substantiation for this opinion. So far what was provided was not correct. > Thats all that comes to mind now, and while many people doesn't care for > performance, IMHO a programming language mainly targeted for the web > should have some caring on this department. Please do not strawman. A lot of people here care about performance, and you have not yet made case that strict typing has any benefit on performance, so implying that opponents of strict typing somehow don't care about performance while you champion it does not match the real situation. -- Stas Malyshev smalyshev@gmail.com