Re: [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript

From: Date: Sat, 29 Jun 2024 15:56:21 +0000
Subject: Re: [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On Sat, Jun 29, 2024, at 17:27, Michael Morris wrote:
> 
> 
> On Sat, Jun 29, 2024 at 7:15 AM Rob Landers <[email protected]> wrote:
>> __
>> 
>> 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 any program that leverages that aspect of it will
> be IMPOSSIBLE to port to PHP line for line without a massive rewrite and restructure that amounts to
> a hell of a lot more than "a bit of finangling".  

This is getting a bit off-topic, but "it depends" on how it gets used. Sometimes you can
use static classes and composition, sometimes you can use traits, and sometimes you can just put the
behavior right on the object because it is only used "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. 

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

But how many projects have you ported? :p

> 
> Now granted, there's a lot of JavaScript out there written by programmers 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.

— Rob


Thread (128 messages)

« previous php.internals (#124046) next »