Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124046 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 29F251ADF70 for ; Sat, 29 Jun 2024 15:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719676689; bh=CYLA3Brio1XVR779R+55jxM9NOV2aGtkqsQifAHOPVg=; h=In-Reply-To:References:Date:From:To:Subject:From; b=GKTPWE06wqt0fN3Goa2NLQPaNOO3mTisn14S+OPLv3F+YeZ+GsQbTYEMtj4203Qj/ N+XUcQ/Ueb0L69I+ARe4BV9NAEIFnTTCXevJMsBft8JrzALZmQY+YjonOVmrS8mSU1 2YOPIxO1nbkvhLlYJsunpcL07Ve+pwZ4VPQhSXfdLDwsQxTS3ZLeDAZUlII4sytWpO r/G6fi+Hx4HMswC8L+rNrzQ7ckl1d4UMRCLRHP4BcoM5NrCAdbaOCo6b4O38mA9+r5 eEMLszbN0FIH8E2I6ftHBxvADHx6VkEHdLnpchXdyOHuHOUrJbFlNWf6HCVfKBom73 XEckxvCfD1qOw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E5770180F56 for ; Sat, 29 Jun 2024 15:58:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 29 Jun 2024 15:58:03 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id C53B011401A4 for ; Sat, 29 Jun 2024 11:56:43 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Sat, 29 Jun 2024 11:56:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1719676603; x=1719763003; bh=CYLA3Brio1 XVR779R+55jxM9NOV2aGtkqsQifAHOPVg=; b=MFSKnymLw72US3lip2BqAFcfTe XDN2RfjyT201DwKY+g4aYOEo8Q6Wrme5E/eH71m6l/vcgi480v3I8PPj5RfP6Q6P FSpPmFk/tHlMcfqzdZ+E+7BfUEVaLXsGAf6xEEconEmZEYn6iADj9TPHlPoOyzb7 7QHUiP/K0IJmjF5G76qw/Jq+ENOEbKWDvOcd1UK94pO3dHOefbDpjHKYZ86gh2UL auAd/4EpATHhInk791T+sNUYuVMFFxEY4PER+EdZuAVugVtWHr5eFmjGR3nCEPG5 ATLSP+1sm4wNFms5N+xJbwQvwYPOxAWya1WySy/5qm6Z5uHKyWfKeR0o+bCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719676603; x=1719763003; bh=CYLA3Brio1XVR779R+55jxM9NOV2 aGtkqsQifAHOPVg=; b=SKmzK4BmZJdEwSJVGfQW27rjBuF5h02eHhNMWaiGC8dW KjRmo0+PhzA9SG9tXE/+T9kHbGlLyW16gE7ZVRO9bogPH4PCaGgPSuDeTmSCzLLz /JmA++T6yo3n45Bm/rI9N6j5mK9aXcf3v7D92+F4JbvnjSTOs6OfgksPtcnusarl fW1ecFyWrwWpxW7iVr+1BjBdflHtgpqGt5dntlyZg4D9zTg6zKZU1DGYTX3jCa+b kiiftrNIFYv7vIi9fcAuCJwf3GnB20gxEfLKQMVzGotDuvNwQZogSXo4udNaNmgW NJJWOwZFUv1vCzrr88xh5HqBOqSTzbgLTWUpBBJKGw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdelgdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrgdtre erreerjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhl vggurdgtohguvghsqeenucggtffrrghtthgvrhhnpeeffeduhfduudeikeekudfghfdugf eljefgkeeghfdvieekledvvdejheetgeetgeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4B37D15A0092; Sat, 29 Jun 2024 11:56:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-538-g1508afaa2-fm-20240616.001-g1508afaa Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <0acedb8e-34be-4348-907b-4075cf7641fd@app.fastmail.com> <9c20b078-f82a-47fe-af23-2f3cdd233079@app.fastmail.com> <50529C6A-42BB-4D49-B720-FE1847577484@rwec.co.uk> <97EA49E2-43A9-42D2-B493-A6B66CC54914@edison.tech> Date: Sat, 29 Jun 2024 17:56:21 +0200 To: internals@lists.php.net Subject: Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript Content-Type: multipart/alternative; boundary=9acd2dd92b8e4aeaaa7dc9d096cf5b79 From: rob@bottled.codes ("Rob Landers") --9acd2dd92b8e4aeaaa7dc9d096cf5b79 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Jun 29, 2024, at 17:27, Michael Morris wrote: >=20 >=20 > On Sat, Jun 29, 2024 at 7:15=E2=80=AFAM Rob Landers wrote: >> __ >>=20 >> With a bit of finangling, you can actually port JavaScript line-for-l= ine to PHP, but not the other way around. >=20 > JavaScript uses prototypical inheritance, and any program that leverag= es that aspect of it will be IMPOSSIBLE to port to PHP line for line wit= hout a massive rewrite and restructure that amounts to a hell of a lot m= ore than "a bit of finangling". =20 This is getting a bit off-topic, but "it depends" on how it gets used. S= ometimes you can use static classes and composition, sometimes you can u= se traits, and sometimes you can just put the behavior right on the obje= ct because it is only used "locally". There are some basic patterns of w= hen to use each and how. It's actually pretty straightforward. It gets weird when people modify the protypes of arrays, strings, and ot= her base-types, but people (mostly) stopped doing that ~10-15 years ago.=20 >=20 > As someone proficient in both languages I find that claim hilarious. But how many projects have you ported? :p >=20 > Now granted, there's a lot of JavaScript out there written by programm= ers coming from a classical inheritance background (i.e. PHP, C#, Java) = who therefore never leverage prototypical inheritance at all, and those = programs are trivial to port between the languages, but that isn't all t= here is to JavaScript. Yes, this is indeed the easiest. =E2=80=94 Rob --9acd2dd92b8e4aeaaa7dc9d096cf5b79 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Sat, Jun 29, 2024, at 17:27, Michael Morris wrote:
=


On Sat, Jun 29, 2024 at 7:15=E2=80= =AFAM Rob Landers <rob@bottled.codes> wrote:


<= div>With a bit of finangling, you can actually port JavaScript line-for-= line to PHP, but not the other way around.

JavaScript uses prototypical inheritance, and a= ny program that leverages that aspect of it will be IMPOSSIBLE to port t= o PHP line for line without a massive rewrite and restructure that amoun= ts to a hell of a lot more than "a bit of finangling".  

This is getting a bit o= ff-topic, but "it depends" on how it gets used. Sometimes you can use st= atic classes and composition, sometimes you can use traits, and sometime= s you can just put the behavior right on the object because it is only u= sed "locally". There are some basic patterns of when to use each and how= . It's actually pretty straightforward.

It = gets weird when people modify the protypes of arrays, strings, and other= base-types, but people (mostly) stopped doing that ~10-15 years ago.&nb= sp;


As= someone proficient in both languages I find that claim hilarious.

But how many projects h= ave you ported? :p


Now granted, there's a lot of JavaScript out there written by p= rogrammers coming from a classical inheritance background (i.e. PHP, C#,= Java) who therefore never leverage prototypical inheritance at all, and= those programs are trivial to port between the languages, but that isn'= t all there is to JavaScript.
Yes, this is indeed the easiest.

=E2=80=94 Rob
--9acd2dd92b8e4aeaaa7dc9d096cf5b79--