Live data from Hacker News

25 Years of PHP

jetbrains.com

141–150 of 426 posts

Re: 25 Years of PHP

#141
post #122

Earlier quoted context omitted.

If PHP is a bad language, your complaints are just just irrelevant, I could probably find some bad code base made in Go and prove that Go is bad. > but not all languages have the same number of edge cases that PHP has. I agree , some have more some have less The things is that from your comment it shows you have no idea what you are talking about, I suggest you let people with experience in PHP to explain hat are the…

> If PHP is a bad language, your complaints are just just irrelevant I don't really understand what you mean here. > I could probably find some bad code base made in Go and prove that Go is bad. "It is possible to write bad programs in PHP and also in Go, and therefore the languages are the same" YOu can write bad code in all languages, but PHP makes it harder to write good code. > The things is that from your commen…

I mean your proof is I seen PHP code then conclusion is PHP is bad.

You are trying to compare PHP with Go, probably Go is better then PHP, but if Go is better that does not mean PHP is bad, just that Go is better (probably not for all use cases).

So you have experience with PHP, probably are you thinking at html code mixed with PHP code? yeah that thing is bad but only news use that for large projects. If you do not mean that then I am not sure what PHP issues prevent you to write good code.

Re: 25 Years of PHP

#142

Earlier quoted context omitted.

That reasoning is true to a third. Length as hash was indeed a thing in PHP/FI 2. Second third to the reason is that PHP often takes names from underlying C libraries. strlen is strlen since that's the C name etc. Third third reasoning is that early PHPade it easy to contribute. You had a need and a patch - a few minute Slater it is in. Nowadays there is more of a debate and vote before things are added (in my person…

A good place to start would seem to be creating naive aliases to these functions to at least fix the consistency problem. There's a possibility of breaking some code out there if someone made their own, say, "str_cmp", but we're used to breaking changes between major revs, and these could be fixed with a grep -l | xargs sed. After that's done, we can talk about deprecation warnings, and then finally outright removal.

Doing that means you have to first agree on a name, strcmp has vertical consistency with C. str_compare might be nice, string_compare even nicer.

Once that debate is over you have to migrate all old code and all developers and teach them to use the new form. Throwing away all preexisting documentation and telling them why typing more is better.

Only then the old form can be removed.

Is it really worth it? - And yes, there is an argument "in the next 25 years there will be noore code written than in last 25" but still, is it worth it?

To give a feeling on the time period: PHP had this register_globals feature where URL (GET) and POST parameters became global variables. Getting rid of that, from introducing a replacement, over changing default and final removal of the option, too 10 years. When taking that time frame it's 10 years of confusion.

Re: 25 Years of PHP

#143
post #74
post #6

PHP is damn fast now, no joke. And with all of the modern features it's actually not so bad to work in. I'm becoming increasingly puzzled every time I see PHP hate now, especially when I read tired comments like "just use rails". Laravel is arguably as good or even better than rails at this point, and PHP 7+ is definitely light years faster and lighter. One thing that still sucks is package management / composer.

> One thing that still sucks is package management / composer What about Composer? Sure is in par with Slack when it comes to memory usage, bit it's functional and feature rich. v2 has partial offline support, faster downloads, etc. ( https://php.watch/articles/composer-2 ). Composer IMHO is one of the best dependency managers for any language out there. Disclaimer: the link above is a for a site I maintain.

Having to setup 10gb swap to get it to work is pretty awful.

Re: 25 Years of PHP

#144
post #32

I wrote a lot of PHP from 1999-2008. First as a hobby, then professionally. From 20 LOC guestbooks to payment gateways used to process millions in payments. It wasn't until recently that I was sure I'd written more code in any other language than PHP. These days I'll occasionally poke around with it or patch a bug, but that's about it. Is it a perfect language? No. But which language is? (I can hear the Lisp crowd gr…

> A lot of the criticism really should have been aimed at certain PHP developers, rather than the language or the community at large. Communities should be kept responsible for setting quality standards or failing to do so.

+10000000

PHP has been horrible at maintaining the core library. The core library is a guide for developers, as to what their code should look like. (Brian Goetz goes on a long talk about the fact that all of your code is an API, even if you don;t mean it to be)

That's why every time I chastise Scala developers and Martin Odersky for symbolic operator overloading. The guy talks at length about how it's wrong to abuse the symbolic operator overloading in creating unintuitive operators.... and then introduces :$#@%$%$%:;:/ operator to create a list.

Re: 25 Years of PHP

#145
post #32

I wrote a lot of PHP from 1999-2008. First as a hobby, then professionally. From 20 LOC guestbooks to payment gateways used to process millions in payments. It wasn't until recently that I was sure I'd written more code in any other language than PHP. These days I'll occasionally poke around with it or patch a bug, but that's about it. Is it a perfect language? No. But which language is? (I can hear the Lisp crowd gr…

While I agree that PHP does have pros as well as cons, I find it disconcerting that I've read MANY assertions here on HN, that PHP detractors just haven't used it very much or are mostly complaining about things like bad standard library function names. I've used PHP in earnest. It and JavaScript are tied for worst programming languages I've used. JavaScript gets more of a "pass" from me because I'm just not a dynami…

> PHP, on the other hand, is basically just worse-Java

It’s much more like C than Java. And Java was in its infancy when PHP came out so it makes sense that it’s inspired more by C than Java.

Re: 25 Years of PHP

#146
post #32

I wrote a lot of PHP from 1999-2008. First as a hobby, then professionally. From 20 LOC guestbooks to payment gateways used to process millions in payments. It wasn't until recently that I was sure I'd written more code in any other language than PHP. These days I'll occasionally poke around with it or patch a bug, but that's about it. Is it a perfect language? No. But which language is? (I can hear the Lisp crowd gr…

> It has a very rich standard library Yet I still have to define startsWith() and endsWith() any time I touch PHP code... (More importantly, PHP is the one language I can never write from memory without referencing the manual for each and every function call because of how inconsistent it is. Eg Sometimes $haystack is the first parameter and sometimes it is $needle.)

str_starts_with() and str_ends_with() are coming in PHP 8.0.

Re: 25 Years of PHP

#147

Earlier quoted context omitted.

What are the "modern" features of php? It looks like it's trying to shed it's dynamic nature and add types (with annotations etc). Also frameworks like Symfony / Laravel look more and more like java web frameworks to me. I'm not saying this is necessarily bad but there's nothing modern about types. Also, might make more sense to choose java if you need types.

The biggest advantages of PHP over Java are build and deploy times, so coding a php app is much more rapid. You can test your app right away, even after a single line change and get immediate feedback on the screen, which I think is important in web dev because a lot of it is visual. The other advantage is the run-time. Java has a slow startup time and when you redeploy then you need to stop/start your entire app. Wi…

For what it's worth, Java has hit code reloading, even though it doesn't work perfectly all the time.

Re: 25 Years of PHP

#148

Earlier quoted context omitted.

While I agree that PHP does have pros as well as cons, I find it disconcerting that I've read MANY assertions here on HN, that PHP detractors just haven't used it very much or are mostly complaining about things like bad standard library function names. I've used PHP in earnest. It and JavaScript are tied for worst programming languages I've used. JavaScript gets more of a "pass" from me because I'm just not a dynami…

Just like I tell people that buy cordless drills at Harbor Freight, "sometimes it IS the tool". Does that mean you can't build fast, meaningful, cool things with it? Of course you can. But, the deeper you get, the more problems you'll have to solve with weird esoteric knowledge. I'll agree with all of your points on horribly inconsistent and broken language features. I get that people that have grown up with the lang…

And I think you've hit the nail on the head here. People who defend PHP as "not that bad" are probably people who have used it for so long that they just work around its insanity by muscle memory.

It is NOT okay that `foreach` leaves an allocated reference to the loop-local value.

Re: 25 Years of PHP

#149

Earlier quoted context omitted.

A good place to start would seem to be creating naive aliases to these functions to at least fix the consistency problem. There's a possibility of breaking some code out there if someone made their own, say, "str_cmp", but we're used to breaking changes between major revs, and these could be fixed with a grep -l | xargs sed. After that's done, we can talk about deprecation warnings, and then finally outright removal.

Doing that means you have to first agree on a name, strcmp has vertical consistency with C. str_compare might be nice, string_compare even nicer. Once that debate is over you have to migrate all old code and all developers and teach them to use the new form. Throwing away all preexisting documentation and telling them why typing more is better. Only then the old form can be removed. Is it really worth it? - And yes,…

Problem 1 is basic standardization and naming things. Hard, but possible.

Problem 2 is is solved by adding the deprecation warnings. The code works, but it generates warning messages.

Yes, it'll take some time, but I'd argue it's necessary. Unless you've memorized the entire standard library, remembering which functions use underscores and which don't (and which ones use "to" vs "2") is an unnecessary mental burden.

Re: 25 Years of PHP

#150

Earlier quoted context omitted.

While I agree that PHP does have pros as well as cons, I find it disconcerting that I've read MANY assertions here on HN, that PHP detractors just haven't used it very much or are mostly complaining about things like bad standard library function names. I've used PHP in earnest. It and JavaScript are tied for worst programming languages I've used. JavaScript gets more of a "pass" from me because I'm just not a dynami…

> PHP, on the other hand, is basically just worse-Java It’s much more like C than Java. And Java was in its infancy when PHP came out so it makes sense that it’s inspired more by C than Java.

Incorrect. Old PHP was more like C. If you see a modern, best practices, PHP code base today, it reads like Java 7 did in 2011.
Post reply on HN