News for hackers. Stuff that matters.
Re:What's new in PHP 8? by erik_seaberg on Thursday August 13, 2020 @10:45PM (#24152637)
It's a shame PHP borrowed so much from Perl but not separate "eq" and "==" operators that coerce to string and number before comparing. I want always one or always the other, not both unpredictably.
Re:What's new in PHP 8? by jcfields on Friday August 14, 2020 @04:34AM (#24155370)
PHP half-copied Perl a lot. Another example is implementing arrays and hashes, but not as separate types. So you have odd behavior like the array sort functions sorting values but not renumbering keys because there's no distinction between an array and a map. Or copying Perl's string interpolation and concatenation operator but not its regular expression literals, so writing regexes in PHP requires an extra layer of escape sequences.
Re:What's new in PHP 8? by cutler on Friday August 14, 2020 @11:53PM (#24165770)
I'm not aware of any extra layer of escape sequences required in PHP compared with Perl. Could you elaborate?
Re:What's new in PHP 8? by jcfields on Sunday August 16, 2020 @06:55PM (#24182093)
PHP requires escaping quotes and literal backslashes (i.e., backslashes not used for metacharacters or escaping other characters). For many cases, it doesn't affect anything, but it can turn into a bit of a nightmare if you're matching anything involving backslashes since you need four backslashes to match one literal backslash. Perl's regular expression literals are also nicer for things like splitting a long expression over multiple lines.
Re:What's new in PHP 8? by cutler on Tuesday August 18, 2020 @07:49PM (#24205686)
I thought preg_quote() took care of that just like quotemeta in Perl?
Re:What's new in PHP 8? by qalmakka on Friday August 14, 2020 @06:24AM (#24156097)
Yeah, that's a real shame. I wrote lots of Perl and while it requires a bit of experience, I almost never incurred in issues such as those we see in PHP and JS. The fact Perl is also quite strict in you specify if the variable is hash, array or scalar also helps a lot, and IMHO the concept that it's the operator, not the operand that determines the type of the arguments is very powerful.