r/programming • • Dec 02 '15

PHP 7 Released

https://github.com/php/php-src/releases/tag/php-7.0.0
887 Upvotes

729 comments sorted by

View all comments

Show parent comments

-1

u/lucasvandongen Dec 02 '15

Well you can have correct Unicode support or easy to work with strings but you can't have both:

Objective-C* vs. Swift

Python 2.7 vs. 3.x

*verbose, but not hard

1

u/tdammers Dec 02 '15

You can have both, it's easy as soon as you accept that "byte array" and "string" are different beasts, and you need to convert between them. Doing Unicode right is easy in every language that does this (C#, Java, Haskell), tricky but manageable in those that sort-of do (Python, mainly), and a train wreck in everything that doesn't (PHP, Perl, C, ...).

That said, Python didn't really add much in terms of Unicode support from 2 to 3, the difference is mostly that 3 is a bit stricter when it comes to converting, the names have been fixed, and string literals now default to unicode strings, not bytestrings.

1

u/flying-sheep Dec 03 '15

I agree with everything except your categorization of python.

Python 3 is certainly among the languages that strictly separate byte arrays and strings.

All APIs were fixed. Nothing that should handle text accepts or returns byte strings anymore

1

u/tdammers Dec 03 '15

Python 3 is pretty close. I think there are a few somewhat surprising edge cases where conversions are somewhat implicit (e.g. feeding a bytestring to format), and those can bite you, but that's about it AFAIK.

→ More replies (4)