this post was submitted on 30 Oct 2023
1009 points (96.2% liked)
Programmer Humor
32410 readers
781 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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?
[This comment has been deleted by an automated system]
On the flip side, there is VBA which practically enforces bad practices.
Yes
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!
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.
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.