this post was submitted on 30 Oct 2023
977 points (96.1% liked)

Programmer Humor

32588 readers
1668 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] jagoan 155 points 1 year ago (16 children)

Isn't Wordpress powering like 40% of the internet? PHP isn't going anywhere anytime soon.

For me the weirder part of that meme is Python in 2022?

[–] [email protected] 59 points 1 year ago* (last edited 1 year ago)

12 years after we learned Flask. 19 years after Django, which also was apparently hot 2 years before it was released.

[–] Tubbles 16 points 1 year ago

Its like the C of web, it'll be a hundred years to kill it

[–] [email protected] 15 points 1 year ago

Maybe all the AI stuff?

[–] EnderMB 14 points 1 year ago* (last edited 1 year ago) (5 children)

IMO, Ruby is a better Python than Python. It's simpler, has a cleaner syntax, and if you want to do funky stuff metaprogramming can allow you to do cool, and sometimes unspeakable things. Python has great library support, and slowness and Rails did make Ruby unpopular for a bit, but I would love to see a Ruby resurgence that wasn't to do with Rails, because it is truly a lovely language to use.

Hell, I would say that in 2023, it's easier/faster to get something set up and working in Rails than it is with frameworks like Symfony, Express, ASP.NET, etc.

load more comments (5 replies)
load more comments (12 replies)
[–] [email protected] 109 points 1 year ago (16 children)

People who say PHP is shit haven't really used it and are just repeating the memes. It's a perfectly fine language and there are a number of excellent tools and frameworks for it. It's reputation is a result of it's easy entry and widespread use. A whole lot of people who knew just enough to be dangerous made a whole lot of stuff, and it ended up causing a whole lot of problems. But for some reason devs shit on the language instead of shitting on the devs who put them in a mess.

[–] [email protected] 44 points 1 year ago (1 children)

The only language people don't shit on are the ones nobody uses.

load more comments (1 replies)
[–] [email protected] 37 points 1 year ago (1 children)

Nah, it's historically been a special kind of shit. It started life as a Perl templating engine, then grew out to its own language where it repeated all of Perl's mistakes while adding more of its own. Its community was single-handedly responsible for keeping SQL injection attacks in the OWASP Top 10 list for years. Notice that it's now bundled with "injection attacks" as a generic label for a wider range of similar issues--SQL injection alone would no longer warrant being there. Its conflation of arrays and hash maps meant it took years to wrestle with algorithmic complexity attacks. Perl kept the two separate, and was able to get a patch out for algorithmic complexity almost immediately (though it turned out to have a few bugs of its own, and a true fix came in a few years later; still faster than PHP solved it).

The web from 1998 through 2010 or so was absolutely riddled with bad PHP programs. "But that's not the language's fault", you say? Doesn't matter. Community is an important and underappreciated feature of a language, and PHP had a special kind of shit community. It almost seemed designed to suck away the dross from all other communities.

Consider the plugin system for phpBB:

  • Its architecture doesn't have any kind of hook system for plugins; they're added by patching the code in place
  • This naturally leads to different plugins interfering with each other
  • Having done that, you might choose one of the patch formats already out there, but phpBB decide to create their own
  • There are, at first, no tools available to automatically patch in plugins, so administrators (often not developers themselves) need to hand edit the source files and modify the database (the plugin format specifies both together)
  • Tools start to emerge over the years to handle it automatically, but they're buggy and unusable for a long time

Is it PHP's fault that one major application was implemented so poorly? YES! Its community is a feature, and its community is what brought us to this.

You want to claim that the language has done better since PHP7? Alright, that's fine. I still don't care. There are so many better options available, and I don't have time to keep up with all of them. I'm happy relegating PHP to being a long-tail language where it trails off slowly over the years like COBOL.

load more comments (1 replies)
[–] [email protected] 23 points 1 year ago (12 children)

I used PHP for the past year. And honestly I still think it is not a good language. Just of the top of my head.

  1. By far the biggest culprit. Arrays. This monstrosity is basically everything. Yes, it is fast but it only teaches bad habits. It is a weird combination of Arrays/Lists/(Dictionary/Hashmap) and you can't know which one it currently is because there are 0 compile time safety checks. Also when used as a parameter it is passing a full copy instead. But the copy of course is only shallow. I have seen so many problems with that. And even worse when someone thinks the way to fix it, is to just json encode/decode the whole thing in order to get a deep copy before passing it.

  2. Generics. I still don't get why this is such a huge issue. Like I would rather have a half-baked optional compile time implementation then none at all. The worst part is that IDE tools support generics so you end up inplementing them on the comment level. I shouldn't be forced to use generics through comments.

  3. $ for variables. I know that this is just based on how the language grew. But god do I hate having to type it. It is not an easy to reach letter and just breaks my typing flow the whole time. You get used to it but still.

4 . The default functions. Yes. You will mostly use framework provided functions or your own stuff. But you still end up in contact with them and the naming schemes are still all over the place, so it is fast to just google it then hope you accidentally stumble upon it through the IDE. And some things are still straight up missing. Like the best way to deep copy an array is json_encode into json_decode. When I saw this the first time I was sure that must be wrong. But no. That is legit the way to do it.

Also I am stuck with PHP7 so some of my other complains seemed to be fixed in later versions. Also please don't recommend DS for my first issue. I tried to push for it but it got vetoed because "it is too complicated for new devs".

[–] moriquende 10 points 1 year ago (1 children)

Not sure why you focus on arrays for deep copying. Deep copying objects is a problem in many languages and brings some challenges with itself that make it almost always necessary to delegate it to a library.

load more comments (1 replies)
[–] gornius 9 points 1 year ago (1 children)

The language itself is not that bad. Especially the newest releases are really great, thought out DX improvements. What stinks are its legacy parts and how it needs to be run.

My biggest pain is that for it to actually behave like it should it requires some sort of an actual web server like apache or nginx.

Also, servers written in are actually request handlers - every time a request comes, the whole app is reinitialized, because it just can't hold its state in memory. In many apps every request means reinitializing connection with database. If you want to keep some state, you have to use some caching mechanism like redis or memcached.

Also had one time when Symfony app was crashing, because someone forgot to close class braces, and everything was "working" until some part of code didn't like it and was just dying without any error.

And one time when someone put two endlines after php closing tag at the end of the file, confusing the entire php interpreter into skipping some lines of code - also without warning, and only in specific php version.

load more comments (1 replies)
load more comments (10 replies)
[–] TrickDacy 15 points 1 year ago (6 children)

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?

load more comments (6 replies)
[–] [email protected] 13 points 1 year ago (3 children)

It has also improved a lot in the last years. PHP5 and especially versions older than that weren't very good and deserved a lot of the criticism. PHP7 and onward are much better languages and don't deserve the hate.

load more comments (3 replies)
[–] [email protected] 11 points 1 year ago

I used to think that php was a bad language until recently (used php5 when i was just learning to program, cooked some delicious spaghetti). But after 5 years I had to use PHP at work. The language has improved a lot, but I think a lot of the bad parts are still there.

Like, why does stdclass exist? Why not just use associative arrays? Why are there warning, error, fatal errors, exceptions? Some functions throw exceptions, other raise errors, others return false, other fail silently and you have to call another function to check if there was an error (last_json_error). Why do find functions return false instead of -1? Like every other language? Why can't I use strings with numeric values as maps keys? (I can't have ["001" => value], it gets casted to ["1" => value].

There are no generics, you have to use mixed everywhere. The stdlib is an inconsistent mess, some_snake_case, someCamelCase, verb_noun, noun_verb, functions are not namespaced, everything is global. A lot of duplicates: die vs exit, print vs echo, etc. You are forced to use PSR & autoload to be able to use namespaces in a tolerable way, not including_once everywhere. No UTF-8 support, only ascii. You have to manually use mb_ functions. Variable scoping is weird. Variable variables? Why?

And all that is just comparing it to the average language. If compared to a modern language like Rust, Zig, Swift, php is light years behind.

It's not hot garbage, but I wouldn't call it "good". There's laravel, but not much more. PHP still makes you shoot yourself in the foot by default, unless you spend a lot of time learning its edge cases. Just like javascript.

load more comments (10 replies)
[–] [email protected] 76 points 1 year ago

There are two kind of programming languages:

  1. The ones everyone complaints about
  2. The ones nobody uses.
[–] lankybiker 67 points 1 year ago (17 children)

PHP is amazing

If you're thinking of PHP version less than 8 you need to have another look

Totally stateless. Uncached server side rendered response times in double digit milliseconds.

Types

Extremely battle, highly tested frameworks.

Excellent tooling for tdd, bdd, static analysis, automated browser testing, coding standards and auto fixing. Even fully automated refactoring for things like package upgrades (Rector)

Regular, solid, releases bringing updates and fixes

Arguably one of the best package management systems, Composer. And only one, none of this constantly changing tooling that some other ecosystems seem to do

Properly open source platforms to power all kinds of web projects from e-commerce, CRM, social, scraping, analytics, monitoring, API, CMS, blogging

Basically if your target is server side web stuff then it's really good

Or, you can continue to demonstrate how out of touch you are by continuing with the old "PHP bad" jokes if you want!

[–] [email protected] 20 points 1 year ago (7 children)

Uncached server side rendered response times in double digit milliseconds.

Thirst thought, that sounds slow. But for the use case of delivering html over the Internet it is fast enough.

[–] moriquende 16 points 1 year ago

Get this man some water.

load more comments (6 replies)
load more comments (16 replies)
[–] pixxelkick 66 points 1 year ago (7 children)

It's hard to justify using anything other than JS or if you wanna be fancy, Web Assbly, for the FE.

Any other front end language involves generating Javascript from your language, which inevitably ends up with you making a weird Frankenstein project that mixes the two.

I'd rather just use stuff like Webpack or Vite to compile my JS front-end out of JS (or TS) from the start. It always ends up being a cleaner result.

My backend though can be whatever the fuck I want it to be.

But if you ever think dynamically compiling/transpiling a JS front end on the fly on demand is a good idea, instead of simply just delivering static pre-compiled/transpiled pages, you're part of the problem for why the web is so slow and bloated.

It's wild how crazy of projects people will build that take 3 entire seconds to just deliver a 500kb static form that doesn't even need angular to do anything. They turn a couple hundred kb into several mb for no useful reason, it's wild.

[–] [email protected] 17 points 1 year ago (1 children)

On that last bit. I agree with you, but people are getting paid to produce, and since they probably just know angular, they use angular everywhere.

[–] pixxelkick 17 points 1 year ago (1 children)

I prefer html personally :x

But yeah, I mostly blame the project managers that encourage this behavior, it's wild how much overengineering goes into basic stuff like making mostly static websites.

load more comments (1 replies)
load more comments (6 replies)
[–] [email protected] 53 points 1 year ago

PHP isn't dead. It's just smelled that way for decades.

[–] [email protected] 43 points 1 year ago* (last edited 1 year ago) (8 children)

This was nearly a decade ago. I worked at a small app company (5-10 developers) for a bit that used Ruby on Rails for our product. The product was in active development, but was available to customers so it was “done”. We were hiring a senior level dev to oversee the team and we interviewed this guy (maybe in his 40s?, a but older than most people in tech) and he said his first order of business if hired would be to refactor the entire code base to php. I don’t think he was joking. I’m not sure why he interviewed.

load more comments (8 replies)
[–] [email protected] 42 points 1 year ago* (last edited 1 year ago) (1 children)

This is an irritating meme.

Were people saying PHP was dead in 1995, the year it was released? I guess maybe?

But who was suggesting abandoning PHP for Django in 2003, two years before the latter was publicly released? I suppose the person who made this must've read that Django development started in 2003 and gone with that; most of these years correspond with when the respective project started.

So, the reason Perl (which remained more popular for web development than PHP or any of these things into the early 2000s) isn't on the list must be because it actually predates PHP.

But then what is up with Python in 2022?

[–] [email protected] 29 points 1 year ago (1 children)

I also appreciate that you're supposed to learn Django 19 years before you learn Python.

load more comments (1 replies)
[–] effward 36 points 1 year ago

I like how 3 of them, across almost 20 years, boil down to "learn Python". When's that dude gonna die??

[–] [email protected] 36 points 1 year ago (13 children)

I'm sure there are a lot of reasons why PHP is better than Python for the backend, but I created an app wirh Symfony 5 and then an app with Django 4.

Symfony is so weird compared to Django. With Django I can just sit down and get things done. Symfony always seems to have some quirks which are mostly due to PHP (and me not knowing how to program in PHP).

That said, PHP hosting is so much easier and cheaper, this probably is important for smaller projects.

[–] [email protected] 12 points 1 year ago (4 children)

You don't need a framework for PHP. That's the beauty of it, you don't need anything. You cannot build a website with Python without a framework.

[–] _stranger_ 16 points 1 year ago

I know this answer is flippant and dickish, but:

python3 -m http.server 80
load more comments (3 replies)
[–] [email protected] 10 points 1 year ago

Django is pretty nice, yeah. We also have good compiled webapps, with go and rust. Gitea for example uses go.

load more comments (11 replies)
[–] [email protected] 29 points 1 year ago* (last edited 1 year ago) (1 children)

2022: learn python

Who said that, exactly?

[–] ElectricMoose 30 points 1 year ago (1 children)

The dude trying to push Django in 2003

[–] Moc 10 points 1 year ago (1 children)

This year is finally the year of Python, I can feel it!

load more comments (1 replies)
[–] [email protected] 24 points 1 year ago* (last edited 1 year ago) (10 children)

https://w3techs.com/technologies/overview/programming_language

On the server-side PHP is used by 76.8% of all websites (a large chunk of that being WordPress). It is not going anywhere, soon. Looking at this statistics, nothing else seems to be even in the same league from a pure usage point of view.

I have yet to see a reason why it should change. Serious question: What is the disadvantage of using the tried and tested PHP8 compared to the alternatives, if you already know PHP?

load more comments (10 replies)
[–] [email protected] 19 points 1 year ago
[–] [email protected] 17 points 1 year ago* (last edited 1 year ago)

Symfony, Laravel & other PHP based frameworks are going strong. PHP isn't going away anytime soon.

[–] [email protected] 16 points 1 year ago

2023 is the year qbasic comes back i can feel it

[–] dinckelman 15 points 1 year ago (1 children)

The PHP I've once used is probably not even remotely close to the PHP people use today. The issue is, once you lose the trust and confidence, it's hard to gain it back. All the people who consistently shit on PHP have also probably not tried it in a very considerable amount of time

load more comments (1 replies)
[–] nucawysi 15 points 1 year ago* (last edited 1 year ago)

django and flask are python btw and people wanted to learn python or perl from like 15 years ago, the popularity of python 2 and its "Issues" led to robust dev on python 3, not to mention it being a default for many linux distros since a long time ago

[–] Presi300 14 points 1 year ago

PHP is dead, learn javascr... no

[–] [email protected] 12 points 1 year ago

What is dead may never die

load more comments
view more: next ›