On 16 August 2025 10:16:40 BST, "Christoph M. Becker" <cmbecke...@gmx.de> wrote:

>Because it would still be rather confusing to JavaScript developers who
>are used to
>
>  str.split(separator)
>
>and now would have to deal with
>
>  split(separator, str)


The fact that PHP doesn't have methods on strings, numbers, and lists, is 
something you learn once and applies to dozens of different functions. It's 
like saying "it would be rather confusing that you have to write split($foo, 
$bar) instead of split(foo, bar)".

And why focus on JavaScript anyway? Have a look at this comparison of how to 
"tokenize" a string in dozens of different languages: 
<https://rosettacode.org/wiki/Tokenize_a_string>

If they have a built-in implementation, it is nearly always called "split", 
regardless of whether it's a method, a free function, an operator, or whatever 
else. Apart from PHP, the only built-ins called "explode" appear in Modula-3, 
and an obscure teaching language called Basic256.


Let's face it, "exploding a string" is a slightly odd metaphor. I wouldn't be 
surprised if it causes extra confusion in people who don't speak English as a 
first language, as well.

I can only assume the original split() function came first, taking a regex 
because of the influence of Perl; and explode() was chosen when hunting around 
for a distinct name later.


I do accept the argument that aliases can lead to confusion when reading code 
that mixes them, though. I've seen people completely convinced that sizeof() 
means something different from count()


Rowan Tommins
[IMSoP]

Reply via email to