DEV Community


Discussion on: PHP sucks, can it suck less?

adam_cyclones profile image
Adam Crockett

What the? I'm curious, what make you feel so strongly? There are a ton of fantastic lower and higher level languages to try, does it interest you to try something else. You might find the experience helps your writing better code in general.

sandbird profile image
Sandbird • Edited

But of course i'm going to use other languages as well. And it does help in writing better code knowing other languages but I've used many languages both in web and game development (C++, obj C, java) and even various js frameworks like vue, nodejs etc but for some reason i always end up using php either as a backend or for logic and data manipulation and db interaction. Why? Because it is way faster, cleaner and easier to do all that compared to the rest. Try handling db queries with Vue, java or Obj C...and i am not talking about simple Selects here, but creating db queries based on user entries where you have tons of if/else/cases before deciding the ending query. I was working on a big project with a search form that had 50+ fields, combining 20+ tables, and 2 databases to bring back results. How are you going to handle all those cases if not with PHP? How many days would it take you to write that code using any other language?
Let me give you another example. My phone company gives me about 300min of mobile calls free of charge per month. It has no way of notifying me when i go over the limit (and why would they), so i had to think of an easy way of doing that myself. I wrote a parser that logs in my web account, checks my balance, uploads the stats in a db for a graph i made, then decides whether to notify me if i am approaching my limit etc via sms, email or push notification depending if my phone is under the same network or not. This thing uses crons, bash scripts, mysql, and also provides a GUI for various tweaks like check intervals the graph etc, all controlled via php. How long is the code? about 100 lines of code, done in a few hours. How would do all the above if not with PHP? How long would it take you, and how many different languages would you use?
You want another example ? There was a project that had a huge db of addresses that were stored in textareas (entries from an old system) and needed to have them separately each part in a different column, like zip code, address, area, country etc. There are some libraries out there that can do that, but you'd have to load an .so or .dll on the server first and that was not doable at the time. I wrote a parser that would break down a db entry into parts then try to figure out which is which using A.I algorithms to predict what is a street address, what is a zip code etc, and if it couldnt find or it wasnt sure about something, it would google it and then from the page results it will figure out if it's a city, a village, a country, a zip code, a phone number....whatever...and then act accordingly....yes..using PHP and it had 100% success at separating any entry you threw at it. I am sorry but how would you solve this problem using any other language?

Thread Thread
adam_cyclones profile image
Adam Crockett • Edited

I am not a PHP hater, I am not a hater period. I don't know if I agree, because subjectivity, I feel that Rust is the best language out there... For specific reasons. PHP is probably the best server language for PHP based servers. As for your numerous examples. I don't understand really why a language like rust with a decent package manager could not achieve what you have described. You have listed so much it's hard to answer. But I could say this, where there's a package manager there's probably a solution in ANY language. I'm glad you like PHP but keep an open mind, PHP is not forever 😅

Forem Open with the Forem app