Live data from Hacker News

25 Years of PHP

jetbrains.com

351–360 of 426 posts

Re: 25 Years of PHP

#351

Earlier quoted context omitted.

So TLF's exist and get used constantly but people don't write them often in code you look at (they do in the code I look at), you don't have to use classes and lots of pages don't but frameworks tend to stick with them, there are global variables, the syntax looks a lot more like C but class semantics exist, therefore it's exactly like Java. Whatever, if that's how you see it I guess I can't stop you.

Syntax != semantics And, even with syntax, the singular part of the syntax that looks like C is the arrow for method calls. Everything else looks like Java, including the fact that you use `struct` to group data in C, not `class`. Also, you said C++ originally, not C. And PHP classes are NOTHING like C++ classes. They are everything like Java classes. You're just wrong about being inspired by C++. At least in its cur…

I never said PHP was inspired by C++. There are some similarities to any language of course but to me it's closer to looking like C with classes which is where the C++ comparison came from. Not really interested in that subject anymore.

> What projects do you look at that use TLFs?

Drupal defines a lot of TLF's and I've seen user-defined ones in it sometimes. Smaller/hobby projects use them a lot.

Re: 25 Years of PHP

#352

Earlier quoted context omitted.

Well, it was episode I, which of course was the 4th film.

It's not which verion of Star Wars you worked on in what year, it's that you're choosing to defend mysql_real_escape_string, and the culture that produced and maintained and evangelized it. What you've so brilliantly and unwittingly illustrated here is that PEOPLE MAKE MISTAKES. And that contradicts your argument that attempts to shift the blame for PHP's footguns like mysql_real_escape_string onto "crappy coders" in…

This is quite the thread and I'm having trouble following it, so maybe there's a reason why you're referencing such an old version, but you know PHP's currently on 7.4 right? Tons of progress over the last few years. If someone picks up a book that's 10 year's old or reads a blog post from 2010 and expects it to be 'current' then they have bigger issues. There are plenty of resources that cover modern PHP.

Re: 25 Years of PHP

#353

Earlier quoted context omitted.

Yeah, alright, I understand your example now but I would argue that it's more of a problem with actually using filenames as array keys than it is a problem with PHP. Even so, wouldn't you be able to ensure that it's a string by doing `$array[(string)$filename] = ...`? (Again, I don't think using filenames for array keys—in any language—is a good idea but we're theorycrafting here.)

> Yeah, alright, I understand your example now but I would argue that it's more of a problem with actually using filenames as array keys than it is a problem with PHP. No. Just no. There is no reason, a priori, that you can reason that filenames shouldn't be keys in a hashmap. I think you're just projecting from "can't be done reliably in PHP" to "software should not do it" which are NOT the same things. Seriously. W…

I'll be damn, you're right! https://repl.it/repls/NegativeLightpinkScreencast That is indeed super weird.

> You can point out the most insane behavior and someone always comes by and says "Nothing to see here. Just don't do that." Or "I just know not to do that, therefore PHP is fine."

I'm pretty sure what you're describing there is every programming language—or any object of fancy really. People tend to defend the things they like.

However, PHP wasn't even my reason for not wanting to use filenames as array keys. You're reading WAY too much into my response. And maybe you're right, maybe it's fine to use filenames as keys, but my initial thought was that maybe some programming languages weren't too happy about using e.g. emojis as keys so I'd prefer to be a bit more in control of what ended up in my keys, but I guess a string is a string (except when it's not ... apparently).

> Would you really believe this if you were working in another language?

I'm not even primarily working with PHP. I just don't have any huge issues with it and its quirks. You're not gonna hear me deny that it has its inconsistencies but I don't feel like I'm spending more time fighting the language than I save by developing in it, so for me it comes out as a net positive still.

> And I think it speaks to my point that you tried and failed to solve the issue.

I disagree. First of all, I gave you the very first idea that popped into my head without even knowing at what point the bad type-casting occurred. It was even phrased as a question specifically because I wasn't sure if it would fix it. Second, I would argue that this is an edge-case. I've done PHP on and off for a long time ("off" for at least the last 6 months though) and I've never run into this before. Or maybe I have, but then it hasn't been a problem because I usually don't mix associative and numerically indexed arrays, so `$arr['123']` would still find `$arr[123]` and I'd likely never notice what was actually happening underneath.

Re: 25 Years of PHP

#354
post #296

Earlier quoted context omitted.

> This revisionist stance that there was never anything really wrong with PHP This strikes me as a strawman. PHP spent years being a generally loathed language for reasons that at this point aren't really worth reiterating. But, in an analog to Javascript, it has made progress, grown up and become a better language. One of the best? Like Javascript, no. But serviceable at worst. I stopped earnest work in PHP ~ 5.7. I…

>This strikes me as a strawman. PHP spent years being a generally loathed language for reasons that at this point aren't really worth reiterating. This story is called "25 years of PHP" and the parent starts their comment with "I wrote a lot of PHP from 1999-2008". In this context I think it's fair to remind people of the many... controversial choices the PHP developers have made (or, maybe more accurately, stumbled…

Really, though, who denies the language has a very bad reputation? A lot of these decisions were questionable, but explainable, like mysql_real_escape_string coming from the MySQL C code itself.[1] that doesn't excuse it, but it explains it.

[1] https://dev.mysql.com/doc/refman/8.0/en/mysql-real-escape-st...

Re: 25 Years of PHP

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

I also wrote a lot of code in PHP back in the day - although less than you, it sounds like.

I started using PHP just before PHP 5 came around. And let me tell you - working with legacy code that used magic quotes or auto-globals is the reason I'm a die-hard strong type programmer today.

On the other hand, PHP didn't get in the way. It gave you a simple way to map a URL to a piece of code, and then let you respond to the request however you wanted - without "middleware" and "routers" - or "servlets". I sometimes miss that.

Re: 25 Years of PHP

#356
post #82

Earlier quoted context omitted.

> The only ceremony you need to write executable code is the This is a really underappreciated aspect to development in general and web development in particular. There are (or at least were) an awful lot of "shared hosting" providers which are cheap, convenient, and run PHP and CGI only .

ColdFusion, Java Server Pages, and other languages copied this syntax. I don’t see it anymore except with php. Does anyone know of any other languages still in use that have this?

Perl5 has HTML::Mason which runs on Apache mod_perl. The reason that never caught-on is the liability of running mod_perl compared with mod_php which is much better at isolating global variables.

Re: 25 Years of PHP

#357

Earlier quoted context omitted.

ColdFusion, Java Server Pages, and other languages copied this syntax. I don’t see it anymore except with php. Does anyone know of any other languages still in use that have this?

You can do it in a lot of templating engines like Jinja2 and ERB.

That's not comparable with PHP as ERB files are not executable by default within the document root.

Re: 25 Years of PHP

#358

I have a theory that PHP is kind of like erlang -- as a framework and dev environment, not the language itself. Each request is pretty much independent of the others, and each one can independently crash. There was also CGI, but CGI always felt a little heavier, and the crashes were harsher (usually just a 501 error and nothing more). PHP embraced the crashes more and provided more information allowing faster debuggi…

> Each request is pretty much independent of the others, and each one can independently crash. Not the case anymore with phpfpm.

php-fpm uses a worker pool. How is this true unless you corrupt the shared memory segment?

Re: 25 Years of PHP

#359
post #194
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…

Nothing "wrong" with PHP itself, but it's clearly not designed for modern web programming patterns which makes it feel outdated. No separation of model-view-controller, not friendly for API or AJAX, no class structure until later add-on, and so on.

That's because PHP, like Ruby, Python and Javascript, is not an MVC framework. If you want that you have Laravel and Symfony. PHP, Laravel and Symfony are perfectly fine for returning JSON instead of HTML. I don't get your point. As for classes PHP has had them for 16 years.

Re: 25 Years of PHP

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

> 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?
Post reply on HN