Live data from Hacker News

25 Years of PHP

jetbrains.com

411–420 of 426 posts

Re: 25 Years of PHP

#411
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…

You might be interested in this study I found. There might be more, but this was the first one:

https://www.i-programmer.info/news/98-languages/11184-which-...

"The languages with the strongest positive coefficients - meaning associated with a greater number of defect fixes are C++, C, and Objective-C, also PHP and Python. On the other hand, Clojure, Haskell, Ruby and Scala all have significant negative coefficients implying that these languages are less likely than average to result in defect fixing commits."

Re: 25 Years of PHP

#412
post #129

Earlier quoted context omitted.

> I definitely get where you're coming from. But everyone is different, and thinks differently. You have talked about preference a lot, and I honestly don't really care what people do or don't prefer, that's totally up to them. I will judge people for it, in the same way I would question someone's judgement if they insisted against all evidence that there was nothing wrong with their shoe-hammer. Personaly I quite li…

> The problem with PHP is that there's a huge amount you have to know about the corner cases and edge cases that could cause you to write a bug or security flaw into your application. The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do. I don't make assumptions about what people are trying to build. > I will judge people for it, in the…

> The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do.

Not really. You aren't insulated from the edge cases until your application reaches a certin number of lines, at which point PHP flips the switch and you get the edge cases.

The edge cases are there and affect you from the smallest program right up to the largest, it's just that with larger programs you're more likely to hit them because you have more code. The target is bigger.

Re: 25 Years of PHP

#413
post #374

Earlier quoted context omitted.

Same. I love Go, the language, much more than PHP, but Laravel.. Laravel is really great. I wish Go had something as convenient and complete as Laravel. Unfortunately that's impossible to achieve in a static language without polymorphism (generics) or metaprogramming. I'm waiting for Go to introduce polymorphism and I'll be watching closely to see how 'post-generics' web frameworks make Go great again!

Have you tried the Buffalo framework? It's touted as Go's answer to Rails.

I've tried Buffalo. It's... fine, but it doesn't have the same feel as Laravel does for PHP.

Re: 25 Years of PHP

#414
post #412

Earlier quoted context omitted.

> The problem with PHP is that there's a huge amount you have to know about the corner cases and edge cases that could cause you to write a bug or security flaw into your application. The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do. I don't make assumptions about what people are trying to build. > I will judge people for it, in the…

> The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do. Not really. You aren't insulated from the edge cases until your application reaches a certin number of lines, at which point PHP flips the switch and you get the edge cases. The edge cases are there and affect you from the smallest program right up to the largest, it's just that wi…

So you're saying if I do a simple PHP status page that is only rendering data from a static JSON file into some HTML (which is basically all I'd use PHP for these days) it requires me to know a pile of edge cases?

Does someone making a simple a PHP application on a home NAS that isn't exposed to the outside world need to worry about SQL injection from their kids?

Re: 25 Years of PHP

#415
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…

PHP also has great bindings for openssl versus the incomplete pyOpenSSL library in Python.

Re: 25 Years of PHP

#417
post #124

Earlier quoted context omitted.

What are you using state for in a web app or API?

Yeah sure, no need for state in a CRUD API. But while it is the most common use case for PHP applications (well actually for application written in scripting languages working with http servers), it's not the only use case. When the only place where you can put state is the database then every piece of state is written in the database. Which lead to intelligent individuals (no pun/offense intended) to write clever pi…

Yeah, but having to use Redis is a must for any web app/API that grows. So all PHP is doing here is forcing you to adhere to best practices of shared-nothing architectures early on.

Re: 25 Years of PHP

#418
post #360

Earlier quoted context omitted.

> My only real gripe with PHP is the annotation syntax. Yikes. Stuff that's in comments SHOULD NOT AFFECT RUNNING CODE. Who came up with that? Don't check out Golang then...

Could you elaborate?

They use comments for compilation directives, build instructions, code generation and other such stuff.

https://dave.cheney.net/2018/01/08/gos-hidden-pragmas

https://dave.cheney.net/tag/build-constraints

https://blog.carlmjohnson.net/post/2016-11-27-how-to-use-go-...

Re: 25 Years of PHP

#419
post #412

Earlier quoted context omitted.

> The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do. Not really. You aren't insulated from the edge cases until your application reaches a certin number of lines, at which point PHP flips the switch and you get the edge cases. The edge cases are there and affect you from the smallest program right up to the largest, it's just that wi…

So you're saying if I do a simple PHP status page that is only rendering data from a static JSON file into some HTML (which is basically all I'd use PHP for these days) it requires me to know a pile of edge cases? Does someone making a simple a PHP application on a home NAS that isn't exposed to the outside world need to worry about SQL injection from their kids?

Are you saying that PHP is only suitable for trivial non user-facing apps? We are in agreement!

The reason you need to know all the edge cases though is because when you write a sigle line of PHP you need to know how to avoid the edge cases in that single line.

Just because you are writing a short program doesn't mean the edge cases aren't there. Array keys getting converted to numbers doesn't suddenly start to become a problem when you hit 300k lines.

If you don't know the edge cases then when you do need to write something more complex, or larger, or user facing, PHP is a terrible choice because there are so many edge cases that they are hard to completely internalise.

Wouldn't it be better to write in something that isn't such a terrible footgun?

Re: 25 Years of PHP

#420
post #375

Earlier quoted context omitted.

This gotchas are similar to JS or Python ones. I hit more issues related to php configuration or server configuration then language issues, maybe because I use a good IDE that will prevent such trivial bugs.

There are edge cases in many languages, there are more in PHP. It would be better to not have the edge cases than to have an IDE that tried to pretect you from them.

I agree with you in most part, just it seems you imply PHP is the worse, I assume you mean is worse then Go,Python ,JS etc. As I said earlier if PHP If you disagree I am curious of a really example of something that is super hard to do in PHP compared to Python/Ruby/Go , some real world thing. I am aware of the weak points of PHP but I think you can do your job with it, the language is not dragging you down.
Post reply on HN