Sorry to hear you have to work on shitty code. But neither the choice of language nor the lack of framework are to blame. Blame the developers and/or the organizational culture that caused it to be in such a poor state.
This is partly true. It is possible to make something great with substandard tools. I suspect a master craftsman with a set of dull saws and blunt chisels using his shoe for a hammer will still have the skill to create something pretty good.
But it will be frustrating, and most people aren't master craftsmen so what they will produce will be adversely affected by the quality of the tools. If you give most people better tools they will have more chance to create something good.
PHP is the rusty saw of the programming world (and yes, I have spend a fair amount of time programming it).
You absolutely can create something great in PHP, but the sheer amount of gotchas and edge cases mean that for a lot of people it's hard to produce something good. There are a lot of people out there who aren't master craftsmen at PHP, and this is reflected in the frequency of the low quality PHP application that are out there.
I am also sure that in your first years of coding your code had no issues similar with the ones you described.
"here's one place that PHP doesn't prevent poor quality code that is the same as other languages, and so all languages are the same"
No languages prevent these things (that I am aware of), but not all languages have the same number of edge cases that PHP has.
> and also fixes the bugs for you, let me know this cool language so I can try it.
I've written a lot of languages over the years, but right now I'm enjoying Go, which kinda does help prevent me from writing bugs with it's static typing, but also it's simplicity.
> I am also sure that in your first years of coding your code had no issues similar with the ones you described.
What's your point here? Noobs write bugs and bad code? Sure, we agree! But that doesn't mean that PHP is a good programming language.
> but not all languages have the same number of edge cases that PHP has.
I agree , some have more some have less
The things is that from your comment it shows you have no idea what you are talking about, I suggest you let people with experience in PHP to explain hat are the issues and how to work around them. I have a few experience in PHP, experience with 5.4 and older PHP not the 1990 version. What I could complain about PHP are small things I do not feel that I need some feature from Java or C#, my time is spent reproducing bugs reported by our users, debugging and fixing them or spent on adding new features, creating solutions etc.
I admit when I was younger I would complain about why do we have to use AS3, or PHP or X for this, there are better languages but this days I know that the language is a small part of the entire project, the hard part is creating solutions, a new dev will start by typing code and offering you a fast solution that someone else needs to fix it later, an experienced dev will think at 2,3 or more solutions, consider all the advantages and disadvantages, test then and finally start writing the code - so IMO the fact that soem language has a bit more sugar coding or and IDE starts 2 times as fast is irelevant, what is important is the person that generates the solutions and the person that when a bug is raised can dig deeper and find the cause and fix it.
I don't really understand what you mean here.
> I could probably find some bad code base made in Go and prove that Go is bad.
"It is possible to write bad programs in PHP and also in Go, and therefore the languages are the same"
YOu can write bad code in all languages, but PHP makes it harder to write good code.
> The things is that from your comment it shows you have no idea what you are talking about
Yes, my 21+ years of experience writing code in over 10 different languages, including a decent amount of time writing PHP, pretty much means I don't know what I am talking about.
> I suggest you let people with experience in PHP to explain hat are the issues and how to work around them.
<raises hand>
> What I could complain about PHP are small things I do not feel that I need some feature from Java or C#
I am not talking about features. In fact, Go has a surprising lack of features, it's one of the things that makes it pleasant to write, and easy to write well.
You are trying to compare PHP with Go, probably Go is better then PHP, but if Go is better that does not mean PHP is bad, just that Go is better (probably not for all use cases).
So you have experience with PHP, probably are you thinking at html code mixed with PHP code? yeah that thing is bad but only news use that for large projects. If you do not mean that then I am not sure what PHP issues prevent you to write good code.
You're over simplifying my point to make yours.
I have seen bad PHP code. I have seen bad Go code. I have seen bad code in many languages.
The proportion of bad PHP code however, is higher in PHP, for the reasons I've stated around edge cases and the difficulty in reasoning.
> You are trying to compare PHP with Go, probably Go is better then PHP, but if Go is better that does not mean PHP is bad, just that Go is better (probably not for all use cases).
Go being good doesn't make PHP bad, and PHP being bad doesn't make Go good. I'm not saying one thing is true because the other thing. I'm saying that PHP is a bad language.
> So you have experience with PHP, probably are you thinking at html code mixed with PHP code? yeah that thing is bad but only news use that for large projects.
Nope, you're making untrue assumptions about my experience. The largest project I worked on was over 300,000 lines of PHP and used templating. It controlled everything from a companies finances, to printing plate layout, to believe it or not, sorting robots on a conveyer belt.
> If you do not mean that then I am not sure what PHP issues prevent you to write good code.
I've talked about this. Edge cases and the inability to reason about the code. In PHP there are a ton of weird little behaviours or edge cases that you just have to know about that could cause bugs. It's hard to know all of these, and even if you do the sheer number of intricacies of the language means that it would be easy to miss some.
PHP isn't alone in this. Go has little gotchas, Ruby has a fair few, Javascript has plenty, but PHP has loads.
Moved the examples to a gist due to HN formatting:
https://gist.github.com/wjessop/0923e0667d7dd53ae0503459894e...
If you disagree I am curious of a really example of something that is super hard to do in PHP compared to Python/Ruby/Go , some real world thing. I am aware of the weak points of PHP but I think you can do your job with it, the language is not dragging you down.
PHP (and to a lesser extent JS) are the only languages (that I have experience of) that it seems actively work against the developer writing bug free programs.
Tools reach a point where they can be considered to be dull, and they're not dull before that. PHP in my experience and opinion has crossed that boundary.
> it does not mean PHP is a dull tool and not suitable for some projects.
I think it depends. Should you use PHP for small stuff? one-off's that you run on your home network? I mean, you could, right? No-one's going to access it other than you, so you don't have to worry about user supplied data. But should you use it for Internet facing stuff? Shopping carts, user data? The difficulty is going to be ensuring that you've not coded bugs or security problems into your code, so I would say the answer there is no. I looked, there's been a study (there might be more than one, this was the first result) that has found that PHP is more prone to defects than a lot of other languages (beaten only by c and c++): https://www.i-programmer.info/news/98-languages/11184-which-...
The interesting quote:
"The languages with the strongest positive coefficients - meaning associated with a greater number of defect fixes are C++, C, and Objective-C, also PHP and Python. On the other hand, Clojure, Haskell, Ruby and Scala all have significant negative coefficients implying that these languages are less likely than average to result in defect fixing commits."
This is my experience both writing PHP (lead developer for over a year on a 300k line plus app), and reading it. PHP is hard to write well.
So if you have decided it's not for you with the big projects, why bother with the small ones? They might after all become big projects, but even it they don't, the other languages aren't really that hard. I wrote a Go program yesterday that reads temp and humidity off an i2c bus connected sensor on a Raspberry Pi and writes the data to an influx DB. It is less than 100 lines. It can run from systemd, it uses threads, it's damn fast, and it was even easier to deploy than PHP necause it's just a binary.
It's also far far less likely to have bugs in it.
> If you disagree I am curious of a really example of something that is super hard to do in PHP compared to Python/Ruby/Go , some real world thing. I am aware of the weak points of PHP but I think you can do your job with it, the language is not dragging you down.
You can pretty much do anything in PHP that you can in other languages, it's turing complete after all, but then again, so is the sendmail configuration language.
The issue with PHP is that it makes the task of writing bug free software so so hard.
So yes my first year code was better than what these 2 interns did in PHP and a random text editor.
Had they used C# (or Java for that matter) the app would be much more maintainable in the short time that I can allocate to it.
Is PHP substandard though? While it's no longer my cup of tea, I do remember it being fairly stable and performant.
Some of the enterprise software I work with, that was written in Java is ridiculously bad, but I don't consider Java substandard. Real world example: the "Configuration" app I use takes a minute to start up on modern hardware, and it's main job is to give a tabular GUI to an XML file. Even saving the configuration can take a minute.
The main problem with PHP, the real killer, is not that it's complex, or the needle/haystack parameters to functions changed, or the iffy string escaping/unescaping or all that stuff, it's that it's hard to know all the edge cases in the language that could cause you to write a bug. It's hard to look at a piece of code and say "that's going to work the way I think it does". Javascript has the same problems with it's string/number/NaN/coercion wattitude.
I want to be able to reason about my programs, because almost all of what I do (and I guess most people writing anything other than the most trivial application) revolves around handling data. Names, emails, files, data, preferences. If the language I am writing makes it hard to see the bugs, then it makes it more likely that there will be bugs.
There is a common counter to this, and that's that good PHP programmers know about the edge cases, but there's a hell of a lot of average programmers out there.
I definitely get where you're coming from. But everyone is different, and thinks differently.
I did a lot of Rails after PHP, so I like using Coffeescript, even though that admission would get me mocked on any JS forum, since I've seen many people be called an idiot for not preferring Typescript.
As for frameworks, I like Svelte, because it works the way I think. I've seen a lot of negative comments from React and Vue users on people using less popular frameworks like Svelte.
My general attitude about these things is "if it works for you, that's great". I'm no longer a PHP user, but I don't think the reasons why I liked it 15 years ago have changed, even though my preferences have.
You have talked about preference a lot, and I honestly don't really care what people do or don't prefer, that's totally up to them. I will judge people for it, in the same way I would question someone's judgement if they insisted against all evidence that there was nothing wrong with their shoe-hammer. Personaly I quite liked Objective-C, but a lot of people kinda thougt it was the devil in programming language form.
The problem with PHP is that there's a huge amount you have to know about the corner cases and edge cases that could cause you to write a bug or security flaw into your application. It's like there's an encyclopedia of weird behaviour that you have to remember all of, and it's going to be hard to remember all of the issues in all situations.
The amount of PHP you need to know to avoid the sharp edges depends on the complexity of your application and what you're trying to do.
I don't make assumptions about what people are trying to build.
> I will judge people for it, in the same way I would question someone's judgement if they insisted against all evidence that there was nothing wrong with their shoe-hammer.
I also don't make assumptions about how a person evaluated and/or prioritized the tradeoffs involved with their choices, because their choice in itself doesn't tell a complete story.
Sometimes what might appear to be a bad choice was well reasoned at the time it was made. When Twitter was made, "Rails doesn't scale" was a common insult against it. But Twitter might not have been built they been forced to make it in Java.
Not really. You aren't insulated from the edge cases until your application reaches a certin number of lines, at which point PHP flips the switch and you get the edge cases.
The edge cases are there and affect you from the smallest program right up to the largest, it's just that with larger programs you're more likely to hit them because you have more code. The target is bigger.
Does someone making a simple a PHP application on a home NAS that isn't exposed to the outside world need to worry about SQL injection from their kids?
The reason you need to know all the edge cases though is because when you write a sigle line of PHP you need to know how to avoid the edge cases in that single line.
Just because you are writing a short program doesn't mean the edge cases aren't there. Array keys getting converted to numbers doesn't suddenly start to become a problem when you hit 300k lines.
If you don't know the edge cases then when you do need to write something more complex, or larger, or user facing, PHP is a terrible choice because there are so many edge cases that they are hard to completely internalise.
Wouldn't it be better to write in something that isn't such a terrible footgun?
There are hundreds maybe thousands of languages. And when you measure all things (expressiveness, stdlib, productivity, ability to build a team, etc.) PHP would come up in TOP10 for any webapp.
Of course, it has its gotchas. So does Clojure, Ruby, Python, C#, etc. Honestly, once a person knows PHP very well, switching a language has almost no impact besides their "feeling".
I have switched from PHP to Clojure 8 years ago. I feel better. But I am not significantly more productive. The brevity of code is higher, abstractions easier to do, overall it just feels better. But it's not a silver bullet. At the end, when a huge amount of webapps are mainly working with a database, validation, putting data to templates, and all the auth staff. All this is usually well developed in existing frameworks and libs without any extra overhead. There's not a lot of space for elegant abstractions in average webapp.
I was curious, there's about 9000 according to a cursory google search.
> And when you measure all things (expressiveness, stdlib, productivity, ability to build a team, etc.) PHP would come up in TOP10 for any webapp. > > Of course, it has its gotchas. So does Clojure, Ruby, Python, C#, etc. Honestly, once a person knows PHP very well, switching a language has almost no impact besides their "feeling".
Maybe PHP is in the top 10 for some of the things you mentioned, and you can definitely build a PHP team pretty easily, however:
Productivity:
I am sure that most people can get their PHP programs to a state where they at least seem to do what they want, the problem with PHP is the sheer number of gotchas and edge cases. Here's some I put together for another commenter: https://gist.github.com/wjessop/0923e0667d7dd53ae0503459894e.... It took me minutes to find these, there are many many more.
Sure, you might be able to get your e-commerce site off the ground really fast in PHP, but are you doing the job that you should be doing? Did you remember to check for every single edge case? Are you coding security flaws into your app? How sure are you that you didn't miss an edge case and you're tallying your basket wrong in some circumstances?
Unless you are very very good at PHP then you are going to miss this stuff and it's going to come back and bite you in the ass. There has even been a study into how bug-prone different languages are: https://www.i-programmer.info/news/98-languages/11184-which-...
A key phrase:
"The languages with the strongest positive coefficients - meaning associated with a greater number of defect fixes are C++, C, and Objective-C, also PHP and Python. On the other hand, Clojure, Haskell, Ruby and Scala all have significant negative coefficients implying that these languages are less likely than average to result in defect fixing commits."
All languages have flaws, but PHP has way more than most.
Building a team:
Most PHP developers are likely very average PHP programmers, just like most Ruby developers are likely very average Ruby developers. You would need to be a super-human to be able to program PHP correctly taking into account all the edge cases, and so yes, building a team is easy, but if you want to build a team that build software that isn't a liability, then you need to hire the absolute best PHP programmers, and that's going to be very hard.
So is it easy to build a PHP team? It depends.
These days I would be more inclined to celebrate the death of C than its birthday !
It's hardly PHP's fault.
> more than 10 years ago
How that looks to me: Wow, that application has provided so much business value (over a decade worth) despite being designed by less experienced software engineers. PHP must be a great language.
My point is that all else being equal if it had been developed in Java or C# my job would be much easier.