Live data from Hacker News

PHP – The Right Way

phptherightway.com

311–320 of 349 posts

Re: PHP – The Right Way

#311
post #19

Earlier quoted context omitted.

Why would you care how many global functions there are in PHP? Just namespace your own functions and the whole "issue" will instantly disappear.

Do you think the problem is that I want the function name mysql_real_escape_string for myself? No, I just don't want thousands of confusingly named, completely worthless and/or actively harmful functions to always be in scope.

> No, I just don't want thousands of confusingly named, completely worthless and/or actively harmful functions to always be in scope.

Again, why would you care whether some functions that you don't use are available should you want to use them someday? It's not as if there's a huge list of thousands of functions stapled to the beginning of all your code files that you have to scroll for 5 minutes before reaching your code.

Re: PHP – The Right Way

#312
post #307
post #296

Earlier quoted context omitted.

PHP releases receive three years of updates :)

You said: > Hell, there's still a lot of 5.x deployments out there that work just fine. forgive my ignorance but I was under the impression 5.x isn't actively maintained anymore?

Oh our company is fully on 7.x and looking to move existing projects to 8.x. (New ones being deployed to 8.x already)

The enterprise client is the one on 5.x (for an interop program for B2B order processing), in a secured intranet system behind firewalls (multiple, on occasion one of their teams breaks one while updating it and we lose access for a day) and a VPN.

They might get up to 7.x this year when they retire the server "our" VM within there is on and reprovision to some new metal.

But by all means, go try and bypass their procurement and change process. I'm sure they'll appreciate your insight into rapidly changing a component of one of their main revenue streams... Just let me grab some popcorn first :)

To be a little less cutting, its admirable to want to be clean and proper, to do it all the right way 100% of the time... But that ain't how the world works and you either bend to accommodate and try to do some good, or scream into the digital void... Your choice.

Re: PHP – The Right Way

#313
post #248

Earlier quoted context omitted.

With copy-on-write: $a = ['a']; $b = $a; $a and $b both point to the exact same bit of memory. Thus passing an array between functions is zero-cost. When you do: $b[] = 'b'; // append 'b' a new array is allocated, the old data copied to it, and 'b' appended to it (basically, but IIRC, it is a bit more optimized than that).

So basically what FP languages do?

Depends on the language. Many FP languages use persistent data structures, sharing some memory with derived/updated values.

Re: PHP – The Right Way

#314

Earlier quoted context omitted.

I will just leave these here: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://software-gunslinger.tumblr.com/post/47131406821/php-...

Ah I see, you partake in cargo cult development. Thank you for elaborating and have a good day.

check, next PHP fan boy please.

Re: PHP – The Right Way

#315

PHP is a language with various features that might make it attractive to certain people: • CGI-like execution model when used for the web, making resource leaks very difficult and encouraging scalable design • not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) — this is a big difference from JavaScript and Python • unusually for a dynamic “scripting” language…

> a standard library that doesn't require import statements I consider this a non-feature in JS. The global namespace is enormous and growing rapidly. As I recall, PHP’s global namespace is similarly enormous (and notorious for its inconsistencies and redundancies). I understand that there are ergonomic advantages to not having to import built-ins, but I think framing it as a feature deserves a healthy asterisk :) >…

well, PHP does have proper namespace support so you can easily avoid collisions. although I don't really think it's that much of a problem either way

Re: PHP – The Right Way

#316
post #286

Earlier quoted context omitted.

Perhaps ironically, this attitude towards backwards compatibility is a big part of what held PHP back for so many years and part of the reason why PHP 6 was abandoned during development and PHP 7 used none/almost none of that work. Instead of introducing a warning and informing the community that a feature was going to change or be removed in an upcoming major update, for years PHP just added new functions. You ended…

> And as developers, we accept that we need to make sure we check that documentation before upgrading Not everyone does. I think I've read a couple times how people commented that Python2->3 was the worst decision made by Guido. (I'm personally grateful that Py3 makes unicode default and more sane than Py2) With every compatibility breaking release, you run the risk of splitting the language into two. Perl suffered t…

This is true. You see this happen all the time with frameworks where the community splinters because of a major change. It doesn't happen as often with languages (perhaps because the average developer feels more removed from the development of those?), but as you pointed out, it does occur.

I think one of the differences here is how active the PHP community is. The Core devs are constantly taking ideas from the community and working those into or out of their plans for the future. They have open periods of discussion for any RFC and will engage with questions and concerns on Twitter and GitHub and Reddit and various other places. Those RFCs are voted on by 30+ different team members and requires a super majority to pass. Everything is transparent. Everything is discussed.

It's not perfect by any means (and the PHP-FIG standards group operated similarly and still splintered due in large part to egos), but it's not as one-sided as other languages and if you engage yourself in the community, you'll generally know what is coming and at least be able to voice your opinion in a forum that will be listened to.

Re: PHP – The Right Way

#317
> Right now PHP does not support Unicode at a low level. There are ways to ensure that UTF-8 strings are processed OK, but it’s not easy, and it requires digging in to almost all levels of the web app, from HTML to SQL to PHP. We’ll aim for a brief, practical summary.

https://phptherightway.com/#php_and_utf8

This is a web language? PHP still has these kind of issues because of its culture: Get it done now and ignore any future costs.

Re: PHP – The Right Way

#318
post #251
post #77

Earlier quoted context omitted.

Quoted post unavailable.

> pointless hearsay This such a typical response of people who live in a bubble, and get angry when nobody else in the real world agrees with their insane ideas. Just because people think PHP is garbage doesn't mean they don't know what they're talking about. In fact, in my experience, the hatred many experience people in the industry have of PHP almost always comes directly from having been forced to use it. In my c…

There's trash projects in every language, and I'm not defending any of them. The terrible projects you have seen are written by terrible programmers, of which you have a lot in any popular language. But modern PHP, with Laravel, Symfony, Composer, and not least of all the features of PHP 8 are unequivocally excellent and as good as or in many ways better than what is standard in the rest of the industry, and most certainly not "amateur hour".

Re: PHP – The Right Way

#319
post #238

Earlier quoted context omitted.

> The language itself, the downsides are very limited and the main one that remains valid is inconsistency of function parameters. Usually one would have an IDE's auto completion to take care about function parameters, and in any case PHP8 has named parameters now to reduce whatever confusion (especially when optional parameters come into play) remains.

Sure, auto-completion makes the code easier to write. But you can't make it easier to read.

Jetbrains shows you the name of the parameter while reading so that part is reasonably easy

Re: PHP – The Right Way

#320
post #88

Earlier quoted context omitted.

Why do you presume this is "hearsay PHP hatred"? I (not parent) have PHP hatred. It is fuelled by decades of PHP development and -exposure. My hatred is based on failing projects, missed deadlines, burnouts, money stolen, severe downtime, and companies going bankrupt. PHP had a role (not the primary, mind you!) in all of them.

You literally said you had only experience with WordPress. Yeah those failing project make a lot of sense now.. Do you know WordPress was build by web-designers, not actual developers? Using it for anything else then a forward facing website is a bad idea. Even using it for a website is a bad idea btw, because it was made for blogs, but whatever, nobody listened then, nobody will listen now. But I have peace with it,…

For clarity: I never said I only have experience with WP. I'm not grandparent commentor. Though I am old :)

I started serious with PHP early in the PHP 3 era. Back in 1998. Coming from Perl and C (in cgi-bin). Like everyone back then, I wrote my own CMS, hacked on PHP and Perl portals, hosted PHP forum software and finally did most of my work in Drupal.

I've seen stuff. And many of it requires eye-bleech if you ever want to look at code again.

Post reply on HN