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

648

u/[deleted] Dec 02 '15

I never liked PHP and glad I don't work on it anymore. But I'm also glad I never turned as toxic as all the PHP haters in this thread.

It's just a language. Congrats to the PHP devs for getting another major release out.

134

u/Yamitenshi Dec 02 '15

Yup, it has its quirks, and I definitely disagree with some design choices, but hey, at least they don't overload their bitshift operators to do I/O, and requesting the numerical month of a date doesn't return zero for January through eleven for December.

Every language has good and bad parts.

32

u/munificent Dec 02 '15

at least they don't overload their bitshift operators to do I/O

I've never seen someone complain about this in C++ who understood why the IO interface was designed this way. Just because a design isn't obvious, that doesn't necessarily make it wrong.

5

u/silveryRain Dec 02 '15

I'm not complaining, but I don't really know why it was designed that way either. Could you please elaborate (or link to an explanation)?

Frankly, I find IO to be a fairly minor part of any program. The way it's done has hardly any potential to make or break a language.

8

u/the_omega99 Dec 02 '15

The why is here. The TL;DR is that they look like the Unix IO redirection symbols (< for input, > for output), but had to be doubled to avoid ambiguity with the comparison operators.

As for why have an operator, it's presumably for readability. See my other comment for an example.

1

u/silveryRain Dec 02 '15

Thanks for the link. Interpolation would have avoided the need for an operator imo, as far as readability goes:

stream.send("abc %1 def %2".args(1,2));
→ More replies (5)

1

u/TestRedditorPleaseIg Dec 03 '15

The why is here. The TL;DR is that they look like the Unix IO redirection symbols (< for input, > for output)

I've seen people complain << and >> in c++, but I've never seen anyone complain about < and > in unix shells.

1

u/the_omega99 Dec 03 '15

Well, I would actually complain that bash has horrible syntax (the actual comparison operators are ugly as fuck). Although many people use shells for nothing more than basic running or programs with arguments and IO redirection, so the differences in operators doesn't matter to them.

1

u/[deleted] Dec 04 '15

I tried to reply to you, but I missed, this was intended for you: https://www.reddit.com/r/programming/comments/3v4l98/php_7_released/cxlrye7

→ More replies (1)

2

u/munificent Dec 03 '15

It lets you overload the << on your own types to support writing them directly into the output stream.

C's solution of using format strings is neither extensible nor type safe. You could do something like:

printf("%s %s", myCustomClass.toString(), anotherCustomObject.toString());

But that's more verbose, again not type safe, and you have to deal with allocating and deallocating those temporary strings.

1

u/kankyo Dec 02 '15

Ah, the old canard "if you just UNDERSTOOD you'd be ok with it". Suffice it to say that's bullshit.

20

u/crozone Dec 02 '15

Ah, the old "Ah, the old canard "if you just UNDERSTOOD you'd be ok with it". Suffice it to say that's bullshit." Suffice to say that's bullshit.

If something doesn't make sense at first glance, it doesn't mean that it's not an intuitive or usable design. Usually systems that are more efficient to use in the long term are harder to understand in the short term. As a core language feature, this is definitely one of these cases.

3

u/Mawich Dec 02 '15

Quite. Let's face it, no programming language makes sense at first glance.

10

u/SpaceCadetJones Dec 02 '15
Day 0: WTF
Day 2: Pretty neat.

6

u/CTMGame Dec 02 '15

Python probably does.

2

u/ajr901 Dec 02 '15

Yeah but Python is a godsend.

2

u/Everspace Dec 02 '15

Because a list comprehension makes 100% sense

→ More replies (1)

2

u/kankyo Dec 03 '15

Sure. Sometimes though it's hard to understand and use because it's just shit :P

→ More replies (3)