News for hackers. Stuff that matters.
Re:PHP 8.0.0 Alpha 1 available for testing by fimbulvetr on Friday June 26, 2020 @10:36AM (#23652421)
This is just FUD. You didn't give us any real use cases to agree with or refute, only your opinions. Lots of people and companies do very productive, very real, very "typed" and very effective applications and code in PHP. I am stunned that you are writing "because a lot of times your code will seem to run fine until it doesn't" as it wouldn't be such a widely used programming language if that was the case. Your entire comments reeks of trolling.
Re:PHP 8.0.0 Alpha 1 available for testing by aliswe on Friday June 26, 2020 @12:26PM (#23653778)
I liked developing in php. But, the language itself is horrible. It COULD have been good, though.

Like if(1 == "0.999") which iirc evaluates to true.

Re:PHP 8.0.0 Alpha 1 available for testing by Master_Odin on Friday June 26, 2020 @12:45PM (#23654041)
This is untrue: https://3v4l.org/PLcj1

I mean, if you stick enough 9s, it'll probably become true, but that's true in most languages (ignoring the implicit type coercion, but if you don't want that, then use ===, same as JS).

Re:PHP 8.0.0 Alpha 1 available for testing by ragnese on Friday June 26, 2020 @01:07PM (#23654284)
Which part of that offends you? The string conversion or the floating point math? Because floating point math is evil in almost all languages, because they all follow IEEE and because some numbers can't be represented in binary.
Re:PHP 8.0.0 Alpha 1 available for testing by aliswe on Friday June 26, 2020 @05:15PM (#23657135)
Not the string conversion or the rounding, it's both of them combined that makes me unsecure my revolver. That's a joke... Seriously, I look back at my PHP years with mostly great joy. Even though the language is terrible I hardly ever noticed it when practising it.
Re:PHP 8.0.0 Alpha 1 available for testing by spaced-out on Friday June 26, 2020 @10:48AM (#23652569)
Do hashes in PHP still break if one of their keys starts with a number?
Re:PHP 8.0.0 Alpha 1 available for testing by zowanet on Friday June 26, 2020 @11:29AM (#23653088)
This[1] works fine in every version of PHP since at least v4.3.0 (released in 2002). Do you have a concrete example of this supposed breakage?

[1]: https://3v4l.org/DWDLn

Re:PHP 8.0.0 Alpha 1 available for testing by ragnese on Friday June 26, 2020 @11:38AM (#23653183)
I think the parent was referring to this: http://phpsadness.com/sad/47
Re:PHP 8.0.0 Alpha 1 available for testing by spaced-out on Friday June 26, 2020 @12:19PM (#23653702)
It seems so, my memory must be from using an older version.
Re:PHP 8.0.0 Alpha 1 available for testing by ragnese on Friday June 26, 2020 @11:10AM (#23652844)
Well, I thought it was a given that this is my opinion.

But let me go ahead and address your points:

> You didn't give us any real use cases to agree with or refute, only your opinions.

There are tons of sources online for all of the inadequacies of PHP as a language. The "fractal of bad design" essay is the quintessential one and even though it was written about a decade ago, many of the things are still true.

Things such as `==` literally being incorrect, logically.

In one of my previous "anti-PHP" comments, I made a point that even a couple of seasoned PHP developers were surprised about where if you use the built-in `array` type as a dictionary and you try to use strings as keys, it will convert those strings to ints if they look like numbers. If you don't know your keys ahead of time (such as storing an association of file names in a directory to their size), you can have surprises when you try to use the array_* functions assuming that your keys are all strings. This behavior is totally insane, even for a dynamically typed language.

Or how about the fact that when you use `foreach`, it leaves an allocated reference to the last element in the collection you're iterating over? But, it's PHP- who cares about memory bugs?

I could go on forever. But- let me guess- "You can write bad code in any language", right? Or "all languages have warts"? PHP has more warts than anything else I've ever used. Period. It has so many warts that it has probably caused a ton of economic harm that could've been prevented.

> Lots of people and companies do very productive, very real, very "typed" and very effective applications and code in PHP.

You can write code in Brainfuck if you want. You can even write correct code if you work hard enough.

Like I said, PHP has some really strong libraries and frameworks. The language is garbage. If these companies didn't need a particular PHP library and just wrote it in PHP, anyway, I truly believe they would've had an even better, even cooler, even more profitable project if they'd chosen almost anything else.

> I am stunned that you are writing "because a lot of times your code will seem to run fine until it doesn't" as it wouldn't be such a widely used programming language if that was the case.

See my examples above. Everything looks great, and your tests even pass. Then all of a sudden somebody has a username of "123" and your site breaks. It happens.

I honestly can't explain why it's such a widely used programming language, other than pure inertia and people not wanting to learn anything else. JavaScript at least has the excuse that it's really the only option in the frontend.

> Your entire comments reeks of trolling.

Depends on your definition of trolling. At this point, I do get pleasure from pointing out PHP's flaws. But I never say anything that I believe to be untrue. And underneath any snarkiness, I genuinely want people to write better, more performant, and more correct software, and to have an easier time doing it. Many people haven't moved outside of "enterprise" programming languages, so they don't even realize how bad stuff like PHP is at converting business logic into code. Try doing a real project in Kotlin if you like static types. Try Clojure or Elixir if you like dynamic types.

If I come across as troll-y, it's because I'm kind of exasperated that people still think PHP isn't a bad language, and I can't decide if they're just trolling...

Re:PHP 8.0.0 Alpha 1 available for testing by solraph on Friday June 26, 2020 @09:37PM (#23658835)
> Many people haven't moved outside of "enterprise" programming languages, so they don't even realize how bad stuff like PHP is at converting business logic into code. Try doing a real project in Kotlin if you like static types. Try Clojure or Elixir if you like dynamic types.

Outside of your average copy/paste stack overflow Wordpress dev, most PHP programmers are very aware of it's flaws, and would probably welcome the chance to move on.

However, the frustrating thing about the prevailing attitude is that creates a stereotype that all PHP developers are incompetent, and this stops PHP devs moving on. I've been trying for the better part of a decade to move out of PHP as my main language. I have github projects in various other languages, submitted patches to open source projects, but the above attitude means that outside of existing PHP shops, no one is interested in hiring me.

I've literally had one potential job tell me that they liked my python code assignment, but they had a policy of not hiring PHP programmers. It was not an isolated incident.

Given those attitudes, are you surprised PHP devs bitterly defend the language?

Re:PHP 8.0.0 Alpha 1 available for testing by ragnese on Saturday June 27, 2020 @08:30AM (#23661411)
Hey, I'm sorry. That's awful and wildly unfair.

For what it's worth, this stranger on the internet does not believe that a real PHP developer is somehow incompetent. When I said the language is horrible and you shouldn't use it or promote its use, it's not a personal attack on anyone.

Most of the devs (PHP or otherwise) I've ever met have only used a subset of the 5-6 most common languages: PHP, Java/C#, JavaScript, C, Python, C++. This includes very smart, very talented developers. So that has little to do with it. But if you haven't gotten to try Swift, Rust, Go, Elixir, Clojure, OCaml, etc, you just can't realize how bad PHP and Java are.

But a PHP dev defending the language is definitely counter productive to the goal of looking knowledgeable about programming.

The only positive thing I can say about the language is that it handles (non)nullable types better than Java. Java's nullable references might be the worst language design decision of all typed languages.

Re:PHP 8.0.0 Alpha 1 available for testing by capableweb on Saturday June 27, 2020 @04:57AM (#23660460)
> but they had a policy of not hiring PHP programmers

Sounds like you avoided a bad apple there, so silver lining and all that. If a company has a blanket ban policy based on what a programmer currently does for a living, sounds like a place where you wouldn't be able to grow and they just look at your previous experience without considering you as a person who can learn and grow. So lucky you :)

Re:PHP 8.0.0 Alpha 1 available for testing by fimbulvetr on Friday June 26, 2020 @02:05PM (#23655028)
And here I was thinking you might have something of merit, but it turns out it's still the old 2007 arguments about === and array functions. I can see our definitions about what we spend our time on differ, as I could barely bring myself to reply to these tired FUD arguments that you and all of your predecessors have argued are fatal flaws of the language. Apparently, it's some sort of quest for you to get people off PHP. GLWT, but I will not be seeking your input on PHP flaws in the future as it's always the same on HN, reddit, etc. Some of us have moved on.
Re:PHP 8.0.0 Alpha 1 available for testing by ragnese on Friday June 26, 2020 @03:13PM (#23655795)
Some of the things people complain about are genuinely silly and not important like the names of functions or the order of their parameters. Even complaints about == vs === are often a result of misunderstandings around object identity and equality.

But there are (many) other things that PHP does that are surprising and actually incorrect. The fact that it took until about last year for json_decode to do the correct thing around null is evidence of the kind of minefield that PHP is. It's actually wrong. Like, not subjectively, or "that's your opinion, man" wrong- actually logically incorrect behavior.

If you believe that it's okay for a real, professional, programming language to not have actual List, Stack, Dictionary, Set constructs; and to not have threads or async; and a broken foreach, then you're on your own.

EDIT: Also, it's the same arguments from 2007 because PHP hasn't actually improved that much since then. Furthermore, way strong languages have come on the scene since 2007, so some of those things are even less acceptable today than they were in 2007.