1008
PHP is dead? (telegra.ph)
submitted 8 months ago by sag@lemm.ee to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] TrickDacy@lemmy.world 14 points 8 months ago

There are a lot of people who think that if a language or framework doesn't completely disallow bad practices (and of course the authors have to agree with their very specific subjective ideas of what bad practices are) then it sucks. I've always found that weird. Like why are you mad at a tool for being "too flexible"? Why not be okay with learning what not to do?

[-] frezik@midwest.social 6 points 8 months ago* (last edited 8 months ago)

If you're going to do that, then you also have to have a community that stresses best practices.

In 1999, Perl was leading the world with a tutorial for DBI (its primary database driver interface then and now) that uses placeholders in its very first code example. The community made that the standard, and it was the first hit on "Perl SQL tutorial" on Google for a long time. Perl applications with SQL injection attacks are out there, but have been relatively uncommon.

Notice that the API doesn't force you to use placeholders. It's simply strongly encouraged by the community.

Also in 1999, PHP was leading the world in not having a database driver interface through a common API, but rather a thin wrapper over whatever C libraries were used for individual databases. If that database supported placeholders at all (MySQL didn't, and guess which database was most popular with PHP?), then it often had a different syntax* for every one. (Note that Perl's DBI uses a translation interface that can implement "?" as a placeholder for you if the underlying DB doesn't do anything else or uses weird syntax). You could always use a filtering function, and PHP devs would routinely try to write their own rather than use the one that came with the database API that's already vetted. Either way, there was no widespread community pressure to use safe practices, and PHP led the world in SQL injection vulnerabilities for well over a decade.

*As a side note, I was recently accused by another dev of having a Python app riddled with SQL injection vulnerabilities. In fact, it was well protected, but it was using the psycopg interface to PostgreSQL, and it has a weird placeholder syntax that the other developer wasn't familiar with. Thanks, psycopg!

[-] xmunk@sh.itjust.works 2 points 8 months ago

An interesting thing you may have missed is that the PHP community actually aggressively removed posts from stack overflow suggesting the old broken autoquoter approach. I'd say that PHP actually has an incredibly security minded community at this point.

[-] frezik@midwest.social 5 points 8 months ago

I don't doubt the language has improved. I just don't see a point when there's a million other options. In the 90s/early 2000s, you had Perl, Python, Java, and PHP. Ruby was playing around the fringes. There had been some attempts at server side JavaScript, but they weren't well developed or integrated with the frontend the way it is today.

We're now spoiled for choice, and I see no reason to give PHP any of my time over Elixir, Rust, Go, or TypeScript.

[-] skullgiver@popplesburger.hilciferous.nl 6 points 8 months ago* (last edited 7 months ago)

[This comment has been deleted by an automated system]

[-] droans@lemmy.world 3 points 8 months ago

On the flip side, there is VBA which practically enforces bad practices.

this post was submitted on 30 Oct 2023
1008 points (96.2% liked)

Programmer Humor

31217 readers
37 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS