I started freelancing in my area doing Ruby on Rails, and found it far harder to maintain a project. I also found it harder to acquire clients in my area for new RoR development.
More work was available locally with PHP. Clients were more willing to pay. I've done a ton of things in WordPress that shouldn't have been, "to save money". And I've done greenfield development with CodeIgniter, Laravel (v3 and v5), and a customized set of the Symfony components. I've also maintained and improved brownfield projects that were outsourced.
I'm very tired of hearing that PHP sucks. PHP is a good language. And in my opinion, it has fewer ways to sabotage your own project than any language with monkey patching. PHP7 looks really awesome, and the community has been upgrading quickly toward it. PHP has always had best-in-class documentation in my opinion.
More often it's the programmer who sucks, not the language.
Give us a break, as a language PHP is a terrible language, and yes I do develop and get paid because of PHP, and I do so for the same exact reason you listed. It pays the bills and does so handsomely too.
I have 20 yrs of programming experience in various languages than I care to count, as much as 20! So I do know my languages. From an academic perspective, PHP blows! But from a practical standpoint, it's a tool. It get's the job done, so long as you know it's quirks, you can avoid them. It's much better now with the OOP support and with PHP7 supporting scalar type and return types declaration. It's going to even make it possible to develop more robust software.
I'm indifferent to hearing about PHP sucking. So people say it as a put down. Perhaps they groovy or scala. I really don't care. It pays and that's all I care about. When I engage in my own personal projects, I never use PHP. PHP's documenation is not bad, but best-in-class? Please! With that said, I agree with your last sentence, in the sense that a good programmer can get more done with a bad language like PHP than a bad programmer can get done with whatever the hell one chooses to consider a good language.
You're using Apache Groovy as a counter-example to PHP blowing? Groovy's the PHP equivalent in the JVM world, the sloppy partner to the more exacting Scala, Clojure, and Kotlin.
Since its first release in late 2003, Groovy's been extended and repurposed so many times it's not really one unified language anymore. The MOP stuff was added for Grails in 2006, the half-baked types when generics were added in v 1.5, the pluggable annotations in v 1.6, the command syntax in v 1.7 to appeal make Gradle builds look nicer, the static typing in 2.0, traits in 2.2, the unsuccessful switch to Android deliverables after that, with backwards incompatibilities between minor versions. And then there's the stuff that silently got dropped, like interceptors and empty try statements.
Groovy's OK for quick'n'dirties scripting Java classes and defining builds, but for actually building systems use a language built from the ground up for that purpose, e.g. Java, Scala, or Kotlin.
Yes it is, and I really don't like JS much to begin with.
There's seriously wonky things in there like the associativity on ?: being wrong, and == being even more broken than in js. There's order of arguments on array_map and array_filter being inconsistent. It's not that there's a massive flaw in there that kills it, it's death by a thousand paper cuts.
PHP's massive flaw is that it does one thing very well (web-dev), but does everything else rather poorly. It becomes the default choice for projects that start out as a web front-end, but then gets used in other situations where it's ill-suited. A lot of PHP projects have components that are hacked together and work, but are confusing and less-than-ideal from a design perspective.
Threading/asynchronicity comes to mind. I've worked on a few projects that started out as a web-front end, but then needed to do some background processing. Eventually the background process needs to be multi-threaded and the choices are: rewrite your code to support pthread's wrappers classes, use fork and shared memory segments, asynchronous web requests. All those solutions work, but they are much more complicated than the same task would be in most other languages with native threading support.
In my opinion JavaScript is being used exactly what it was intended for now more than ever. It was originally supposed to be based on Scheme (an elegant functional language) and after many years the trend of functional reactive programming has finally become mainstream.
I find it quite sad that most PHP developers seem to think that writing code that looks more like Java is the "correct" thing when its greatest features have always allowed loose types and first class functions. After all that's what makes it so easy to work with?
Perhaps PHP could have been more like Scala a few years back already.. the perfect combination of Objects and Functions...
I understand JS having its place as being ubiquitously supported in browsers but, just as PHP, it's bad and its problems are not about niceties from IDEs or static typing.
'Not worse than JavaScript' is a low bar to clear. JavaScript has exactly two advantages: it is deployed everywhere, and it is dynamic. The latter means that with sufficient pain one can accomplish whatever one needs to.
It's not quite bad enough to count as a Turing tarpit like INTERCAL or brainf*ck, but it's one of the closest mainstream languages to the tarpit.
PHP is more or less a dynamic typed C++ especially tailored for web development, that's how I see it. PHP originally borrowed a lot from C (syntax and function names) and later borrowed a lot from C++, Java and even JavaScript.
I like PHP and JavaScript a lot. They are not perfect but these organically grown languages tend to be better from my experience.
WOW... i mean PHP is nothing like C++. It is closer to some sort of dynamically typed C with classes. C++ is not just C with classes it is much much deeper language.
That being said, C with classes for web is not bad thing to be.
>I'm very tired of hearing that PHP sucks. PHP is a good language
And I'm quite tired of hearing this silly, totally meritless defense in every single thread that discusses PHP. Can't we just agree that it's not a very good language, but people are still doing cool stuff and lots of money with it? So many pointless fights could be averted like this.
A personal anicdote, but I run a SaaS, and there is an extremely pronounced (negative) difference in the sophistication of technical support queries asked by PHP devs vs those in other languages. This may be because PHP is so ubiquitous and approachable, but these types of silly questions (how do I make a POST call to your API?) are why PHP gets it's reputation.
Yes, the biggest strength of PHP is that anyone can pick it up quickly... which means anyone will. There are "best practices" but they're not necessary to get the job done.
I usually recommend that new developers start with Python. It teaches structure and consistency without as much variation or room to screw up.
Tell people to code it in Java or C, preferably in vim.
Advantage: they'll never create a mess that you'll have to maintain.
/s
Yes, I totally agree with you: the advantage of PHP is that anyone can pick ut up, and they have done.
The question was often never if it should be coded in PHP or Java but if it should be coded at all and, if so: if it should be an excel file on a file share or sent in email or a php script.
Disclaimer: PHP and Java coder. I can get stuff done quickly in Java, but it takes some practice.
I'll agree that what makes a good language is subjective, and that most all languages have their problems. There is a certain threshold where "good enough" is what matters.
Personally, I'd rather everyone just stop the good/bad language debates entirely.
Programming has to be the only environment where the voices of academia don't seem to matter because "my language gets shit done". Deep inside, what do you think those researchers in the PL community, the people that know the ins and outs, that theorize about languages, the people who spent years and years learning about the theory behind it all, who created the OCamls, the Haskells, the Coqs, the Idrises and so forth, what do you reckon their opinion of PHP is?
So really I don't think "good language" is subjective. PHP is not fast, it's not well-designed, it's not particularly terse, it doesn't have particularly great tooling (Facebook has made that better with their HHVM initiative in all fairness), it isn't consistent and easy to reason about and the worst offender of all, it doesn't offer a dramatically different or original model of thinking about programs.
What is has going for it has nothing to do with the language itself: jobs, ecosystem and easy hosting. I totally agree that a good language is whatever works for you, but in the meantime, "whatever is good enough" is a mindset that doesn't help us strive for something better, which does matter if we're going to collectively spend decades in this line of work.
> Programming has to be the only environment where the voices of academia don't seem to matter because "my language gets shit done".
Wrong, otherwise we would have this discussion in Esperanto.
Sometimes Real Life (TM) experience beats clever design. PHP was first, has iterated, always had a niche and is now better than ever. Not good but good enough to save people a lot of work.
I don't quite grasp your logic. That comparison only means that PHP is faster than other slow languages. Being faster than slow doesn't mean you're fast.
Hi Veejay, I do not know for how long or just how intensely you have been in contact with the "academia" so far, but let me tell you this: however much a certain solution is promoted in academic circles has close to nothing to do with how useful it actually is to general (programming) society.
The average academic bases his assumptions of what makes a language "good" or "bad" on 6-12 months of internship at a medium sized company (preferably in a mgmt/assistant position), some tutorials he went through and 5 years of theorizing with a professor who did his last serious programming work back in the 1980s. Granted, this approach sometimes yields exciting innovations that might someday be adopted by real world applications. But this does and will not make Haskell and OCaml appropriate for the other 95% of problems developers have to solve.
PHP, as a language, particularly since somewhere in the 5.x series, is basically "flawed, but still more than adequate."
The real problem is that so many people who use it are utterly incompetent.
When someone says they work in/with PHP you immediately wonder if they're in the "let's duplicate a 900-line function across dozens of files just to give various pages a different icon" camp, the "I call myself a PHP Developer, but all I really do is Drupal Templates" camp, or in the "using Composer and everything is pretty much like you'd expect it to be in any web app built with Ruby or Python or Node" camp.
Until you know, you fear acknowledging them or associating with them. But you can't really ask them up front. So it's easier to just avoid them.
And I say this as someone who occasionally works in PHP.
I graduated in 2003. I haven't been able to stop coding php. Why? Because of the amount of work. I know other languages, but the pay for php these days is totally astronomical. (I live in sf, pacific-heights / WELLL over 6 figs / wife doesn't work). Currently I feel like I have a massive technical advantage (I wont share). Right now I work on iphone/android backends - at massive scale, top 10 (PHP is fast). When people say PHP sucks, I actually encourage them. We can't even employ a new graduate these days because they are pre-programmed to like node.js (cool! let's rewrite everything!) and to hate php. So yeah! PHP SUCKS!!!
I've mostly tried to fight the anti-PHP movement because I WANT new developers to come on board and create great things. I want new packages to pop-up as soon as some new tool/api/widget becomes available.
I've felt for quite some time that most of the anti-PHP sentiment is an effort of other developers to justify the language they've selected to focus on. "Yeah, I'm doing Javascript and Node.js and yeah it's got it's sharp edges, but at least it's not PHP!"
The problem is, if the negativity continues, the next step is that business WONT want PHP in their ecosystem... And not because it can't get the job done for them, but just because "ew PHP. I heard that was bad."
>I've felt for quite some time that most of the anti-PHP sentiment is an effort of other developers to justify the language they've selected to focus on.
Would you be surprised if I told you that pro-PHP sentiment looks exactly like that as well?
I could see that, to a degree. But I agree with this article that most (if not all) of the "bad" of PHP has been completely papered over through best practices, documentation, fantastic tooling, or removal from the language. So the pro-PHP movement is more of a "guys, we're doing the same thing as you, why can't we all just get along?"
When was the last time we saw a "PHP is Great!" article make it to the front page of HN? Most of the time, PHP developers are on their heels because it seems others are constantly on the offense. I've not figured out what value this constant aggression provides to these developers making the arguments. My only conclusion is that they're just trying to make themselves seem more important. To that note, the pro-PHP camp becomes more of a "non-anti-PHP." :)
>the "bad" of PHP has been completely papered over through best practices, documentation, fantastic tooling, or removal from the language.
I mean sure I could just reimplement a sane standard library from a different language in PHP and then live with the suboptimal syntax or maybe I don't waste my time and just use that language with the better standard library from the get go.
I disagree. Wanting to get new grads into PHP is bizarre. They would be ostracized. They don't have the technical experience to know WHY it is a good language (CI/unit testing/years of libraries/API support in everything/bla bla). They should be working on things that are new and untested. That is what a twenty something should be working on. Check please?
I think this criticism is missing the biggest problem most new grads have: how to work well with others.
Version control, documentation, checking their work before committing and sending to QA, documentation, and learning how little they actual know about development on a real timescale >> which language they use. I'd rather start out in a well run IT shop that uses PHP than a quirky single dev small shop (or god-forbid an academic ivory tower of babel) with the most cutting edge startup blessed tool set.
I started in PHP but moved away from it because everyone always wanted to pay less than a CS grad should/would get using other languages "because PHP programmers are supposed to be cheap." Which meant not only did I get paid less, but that my coworkers frequently had very questionable ideas and no CS fundamentals. "No, you can not secure/maintain a session by base64 encoding a user name and id and putting them in a url" is a conversation that really shouldn't have needed to to take place.
What's beautiful and what pays our bills are unrelated.
If I have to do a beauty contest of the programming languages I used a lot, from uglier to most beautiful, I'd sort them like this: PHP, Perl and C (no ++), Java, JavaScript, Ruby.
I didn't use Python a lot and I'm undecided if it should be placed before or after JS. That silly method(self) looks as useless as PHP's silly $this->attribyte. They're just bad designs and other languages knew better. I'm starting to use Elixir and it goes between JS and Ruby so far.
Java has its own way to make me feel like wanting to wash my hands at the end of the day (the language and the tooling) but not as much as PHP, even if I agree that PHP7 is somewhat more sane than it used to be. Why didn't they do it at version 2?
And if I have to sort them about what pays more... We could sort them by looking at the salary stats but eventually it's a matter of where we live and which opportunities we have. Any language will earn us money. No hard feelings.
Python's method(self) is very useful. It gives the ability to call methods in the same way you use functions, which is what they really are. It allows you do things like map(str.strip, list_of_strings).
But why can't the interpreter/compiler implicitly add that argument to each instance method definition? There is no need for the programmer to type it. I understand that self plays also a role in the declaration of class methods but other languages found ways to do without method(self) and still have class methods. Java's static (coming from K&R) or Ruby's def self.method
Anyway, that is the way of Python. A lot of people is happy with that and will never be changed. It's beauty contest matter :-)
> But why can't the interpreter/compiler implicitly...
"Explicit is better than implicit" -- PEP 20
Python was the first language I ever learned and I just took it for granted that you had to manually specify "self" like that. When I see code with implicit self, it reads strangely to me. Like, "Where does 'this' come from? Oh yeah."
Or to quote Matz "No language can be perfect for everyone. I tried to make Ruby perfect for me, but maybe it's not perfect for you. The perfect language for Guido van Rossum is probably Python."
My first serious language was C, which is way more lower level than Python. Still Python has something that reminds me of C. Those wierd __xyz__ methods, looking like what we used sometimes in #define; the useless : instead of some { (I know where the : comes from but it should be deprecated or made optional) and that self, which is the pointer to the C struct we were using to implement OOP in C. It's a strange mix of low and high level constructs, not fully OO and definitely not functional. Being at midway on many axis maybe it's the reason why it appeals so many people: it's a little bit familiar to everybody and this is important for the success of a language. Think of Elixir which was designed to look similar to Ruby, even if they have nothing in common.
> More often it's the programmer who sucks, not the language.
In the context, it's also a common occurrence that I can tell when developers came from the php (non framework) world. When I see them move to Rails (or in javascript), I often see an obvious lack of understanding / adaptation of MVC, Single Responsibility, asynchronicity, testing, and variable scoping - I've seen Senior PHP Developers come out with less of these concepts than codeschool graduates.
That's not to say that PHP has this, or that every Rails/JS developer writes tests and understands these things (it still confounds me how companies choose rails and don't implement any tests, despite testing being a core idea)..
I suspect that a decent amount of people saw PHP 10 years ago, decided that PHP4 sucked (it did), and do not pay close attention to further PHP development ever since. Newer PHP is a much nicer language than it used to be. Newer frameworks can be reasonable and elegant.
OTOH RoR has its own bunch of problems, and exploits a number of anti-patterns "in the name of simplicity", and Ruby as an ecosystem has its own set of pain points (e.g. deployment).
>The language also is written by a programmer, who sucked in PHP's case IMO.
Yes, I am a terrible coder, but I am probably still better than you :)
- Rasmus Lerdorf
Modern PHP is written and maintained by a team of programmers. It hasn't been the language Rasmus wrote (badly, as a hack he never intended anyone else to use) for years.
He's right, though. Most people who rant about how terrible PHP is and how incompetent a programmer Rasmus is couldn't come up with anything better themselves.
| More often it's the programmer who sucks, not the language.
Whilst it is possible to write structured, elegant php, its very hard, and thats the languages fault. The barrier to entry to write bad PHP is very low, thats what makes people think it 'sucks', because 90% of PHP codebases do. :(
It's not hard to write structured elegant php, that is horseshit. Please look at code for symfony or laravel. Hell, my annoyance with writing good code in PHP is that it ends up looking like Java, which begs the question, why not just do it in java.
Symfony is the worst thing that could've happened to PHP. Dependency injection with varying degrees of XML/YAML madness everywhere. It's terribly slow and pretty much unusable w/o several caching layers in front. I can honestly say that I hate this framework with a passion, and the language too. PHP's core and a big part of the community is copying features and methodologies from Java, but they will never get close to its performance, nor its functionalities. I left the ecosystem when PHP 5.1 was around... I left for good.
This! Symfony is so wrong, i actually can't believe it. First version was kind of rails, replacing all that ruby awesomeness with PHP madness. Newer Versions suddenly want to be like Java only 1000times slower.
I won't say it's the worse thing, it did bring some good and really help drive plenty of new projects towards being OOP. I'm no fan of it either! My point is that the code is structured! Now is the framework architecture good? Whoops, that's another discussion, and I can't likewise stand the layering upon layering of components and configuration nightmare.
I don't think what you say really invalidates his point though. Namespaces and traits might help a lot, but that still doesn't make them used wide spread or introduced them to the overwhelming amount of terrible legacy code bases that have no namespaces and untested functions that are hundreds of lines long. You can write bad code in any language, but PHP used to be a much worse language and many developers got socialized with that. When you are leaning PHP it's easy to pick up bad habits because the code base tut are using is likely full of them. You are likely to look at code examples using old versions of PHP that don't teach you good practices. That of course doesn't mean you can't error awesome code in PHP it just means it's easy to write bad code.
In which ways do Traits of all things help write good, disciplined code bases?
I think traits, and their Java equivalent, are OK to touch up legacy APIs (as they did with the Java collections API) but I have found no good place to stick them in a new project.
Not to say PHP hasn't been introducing functionality for writing good, stable code bases (type hinting in function signatures, namespaces, better garbage collection, an actual AST — as an aside: how ON EARTH did they do without an AST pre-PHP7?) but traits don't strike me as the feature to think of when designing a new code base.
They're not extendable, they're not overridable, they're monolithic, and classes expose their implementation details to them, which makes traits super fragile.
Right, and who's paying me to work with one of those alternatives? No one.
My reference for what you quoted was a Rails project written by a Python dev who thought he needed to make Ruby more like Python. The resulting code was so horrendous that I literally cannot tell which of 2-3 parts that compose one feature (all heavily monkey-patched together) is responsible for what. It's like 2-3 complete implementations, but depending on load order any piece of the 2-3 implementations could be handling it. The client didn't have the time required for me to fix it.
... to quote myself:
> More often it's the programmer who sucks, not the language.
> Right, and who's paying me to work with one of those alternatives? No one.
Give me a break, it's not like there are only PHP jobs out there. If you can't find anything else then it's because you're not capable of coding something that is outside PHP domain, IE basic CRUD apps ..
A lot of software developers are are also business people. They focus and make decisions based on the needs of the organization, given the local job market, current staffing, past investments, the future roadmap of whatever product they are working on, etc. If PHP is the best route, then that's not something a business person is going to spend a lot of time worrying about.
In many ways, if a "coder" comes in and starts wanting to change a bunch of things purely because they are opinionated about languages, then that person is not going to go very far.
Umm... outside of R&D or the valley, the breakdown is something like:
PHP: 30%;
.NET for finance/enterprise: 25%;
Java for finance/enterprise: 20%;
Java for android: 10%; iOS: 10% (~5% overlap);
Everything else: 10%.
And as far as payscales go, PHP is nearly always > the "Everything else" unless it's super specialized. But clearly everyone paying median or above for PHP is getting conned and they should convert their entire business to [flavor of the month] language.
[edit]And I'm leaving js off there on purpose as there are very few web devs who are expected to only work in PHP and never touch the js. And in those other orgs, you usually have a specific "front end" developer that probably doesn't deal with any other kind of code and makes less than the "full stack" devs.
Nah, the client might not know how to explain what they want, but that's okay. Plenty of people go to the hospital and can't explain what is wrong with them. It's your job as a professional to extract what the client wants, just as it's a doctor's job to perform correct diagnosis and not blame you for poorly explaining your symptoms.
I will say this: I whipped out the backend of a site in 1 night that had most of eBay's functionality... in PHP.
But I quickly moved away from it and I'll explain why.
I think that many programmers are starting to realize that the less "cognitive load" your language demands of you as a programmer, the better (the fewer bugs, etc.) Simple example, the recently-maligned "==" comparison operator has a very complex table of possible outputs (note that Javascript is also implicated here): http://stackoverflow.com/questions/7615214/in-javascript-why...
I mean, as a PHP programmer debugging code that used ==, you'd have to basically have that table memorized in order to successfully debug it. Contrast this with, say, Ruby, where only nil and false evaluate to false and everything else evaluates to true.
While there are of course "PHP best practices" that suggest === (which has a MUCH more sensible truth table), I find that much of the language is still simply not well thought-out and therefore is unsuitable for any large codebase. Sure, you can "get by" (see: Facebook), but you'd "get by" a hell of a lot better in a different (possibly a functional) language.
If you can't grasp all the cognitive load mentally, then you are invariably going to introduce unexpected states into your code (read: "bugs").
Lastly, a language should be 100% deterministic. Last time I checked, PHP didn't even consistently pass its own test suite. It literally has so-called "flagging" and "known-fail" tests which are just marked as such (and not fixed). I cannot explain how bad this is to build something else on top of.
So, yeah. If you're a great programmer, you can code almost anything in PHP (since you can handle the cognitive loads it introduces), just like you could code almost anything in, say, Brainfuck, or assembly. But as a great programmer, you'd be far better served by another high-level language (speaking as someone who knows and has worked with dozens of computer languages) which demands less cognitive load and therefore naturally reduces the number of bugs you will introduce.
No. It's actually not hard. It was for an art reseller in Greenwich, CT, they held an art auction that was simultaneously online and in-the-flesh. I had account registrations, search (with image results), anonymous bidding, outbid notifications (via email), winning-bid notifications. I implemented the whole "what's the highest bid you would accept" functionality (also not hard). I did not write the frontend (a friend did that) and I didn't handle payments nor shipping (winners were expected to go to the physical store). Hence "ALMOST" all of eBay's functionality. :P
Either that, or I'm just a really good programmer under pressure (I pulled an all-nighter for that one), which I would not disagree with, I've basically been coding since I was 12 in 1984, so I would HOPE that I'm somewhat of a force to be reckoned with at this point. ;)
I used to feel the same way a lot of times, a shame it seems for being a PHP dev. Now, I don't care. I've been using it since 1999, and I use it to get stuff done.
My customers and users of my applications don't care what it's written in.
But, you should definitely learn more languages as a programmer.
> And to anyone considering programming as a career, or trying to get into it... stay away from PHP.
This is the part I disagree with the most. The language is getting better and better with every release. It's incredibly fast, much safer to use (the Error exception type, scalar static type hints, all the garbage from the early 2000's has been removed), and easy to work with. The ecosystem (with the introduction of Composer) has _completely_ changed and reinvigorated the language. It's easily one of the best package managers out there. I definitely recommend giving PHP a look or a second change if you've written it off.
Unfortunately, the issues aren't with "new" PHP, it's with the mountains of "old" PHP code that invariably finds its way into your project.
Also, having had to maintain a Wordpress site the past few months, may God have mercy on all daily Wordpress devs. I truly admire your stalwartness now in putting up with that.
The problem is that clients really want WP a lot. Bigger and bigger companies currently and for most of their departmental sites. This is WP shoe-horned in a full site CMS function. The thing is, users seem to love it. I would wager that if you just rip out the guts of PHP and leave only the frontend (the /wp-admin part that is), but leave it 100% as it is and write a solid backend in Django/Rails, you have a winner. The problem is that when people attempt this, their own 'taste' comes in and it always ends up being a vastly different frontend which then users don't want as it's not 'the same as WP'.
Before anyone says it; sure some users use WP for the themes and plugins; we use some of them but we are very careful using plugins. They have to be rocksolid for many years, actively supported and we have to have reviewed the code. Next to that they have to add something significant; installing a plugin for some social buttons is very much not worth the pain of updates / security breaches on a 100k+ (+ SLA) project. And so in the end we end up using 4-5 the same plugins for projects and the rest is either not needed or easy to implement anyway. So the hero implementing those guts in Django/Rails could also implement those plugins. I believe you would have something safe for the enterprise. Until then, they'll just use WP and trust admins/coders to fix the issues.
> I would wager that if you just rip out the guts of PHP and leave only the frontend (the /wp-admin part that is), but leave it 100% as it is and write a solid backend in Django/Rails, you have a winner.
I would love for WP to exist as only an admin interface to a clean, backend data store. Unfortunately, the problem is the database schema that WP ships with and the way WP handles data. It's almost impossible to get data out of WP press without using its lackluster DB "abstraction" layer and running the fetched data through its many obscure filtering mechanisms. To top it off, WP smashes everything into a handful of tables and makes doing normal, straightforward relational looks up (as any sane schema would allow for) a complete nightmare. Alas, when you go the WP route, your data is very much dependent on WP (and by default PHP).
Any organization that uses WP for an extended period of time and builds up a non-insignificant amount of data will run into this wall, guaranteed. If you truly value your data and your project is anything beyond a personal blog that you'll give up on in 6 months time, do yourself and your organization a favor and find an alternative solution. If you must use WP, use it as what it was originally intended for: a blog. It's not a framework to develop a complex application off of.
As the person who wrote a patch to import data from WP to Pelican I agree. It's a complete nightmare. In order to properly maintain the formatting from ~6 years of blog posts I had to literally translate the PHP code that parsed the database representation into Python... which is some really gnarly code.
Have you looked at/heard about the WP REST API[1]? Basically, it allows WP to function as that backend admin tool that you talked about, and you can build the front end as what ever you want[2].
I agree with everything you said here but I can explain this to clients usually however not always. There is, for instance, a supermarket chain running all their web through WP. They spent and spend millions on it; they cannot be convinced and although I might not choose a certain tech for my own company assets, I am not spreading religion (although as I get older I feel more and more the need to do so) and we are not in the position to just say no to large contracts.
> The problem is that clients really want WP a lot.
This. I can waste my breath talking about another CMS which is better suited for the task, has cleaner data representation (good for 5 years' time) etc, and try to get stakeholders to buy into it. Or I can mention WordPress and have brand recognition do the work for me.
> The thing is, users seem to love it.
In my experience, the users find the admin confusing. It's the managers and above who love it. They know what they're getting and it feels safe.
It used to be "You're never fired for buying IBM". Now it's "You're never fired for buying WordPress".
> In my experience, the users find the admin confusing.
My 'entry' into the enterprise world was web CMSs; my previous company used to make/sell a respected web CMS. If you talk about 'confusing admins' then the web CMS world is where you should look. Boot up a Liferay (oh and check out that code by the way) or Alfresco or Sitecore or Oracle CMS and stare in disbelief.
This is what these users are used to and compared with those, WP is really very simple. That's why no (?) enterprise will replace an international corporate roll-out with WP, but regional, if allowed (and it usually is as marketing simply doesn't work the same way worldwide), they will. Because of the ease and less friction; create a new content writer? Fill in paper work and ask the main IT dep vs do it yourself in 5 seconds and that kind of thing.
"old" PHP code should not be finding it's way into your project. Use a facade, adapter, proxy or bridge pattern to decouple your new shiny awesome code from the legacy cruft.
I understand that the negative pressure can have a long term effect. Personally that has never gotten to me and it's sad for the author that they have been slowly worn down over time to a breaking point.
I totally agree with "But, you should definitely learn more languages as a programmer." In my current position I led a ground up build in Python/Django after 10 years of personally using PHP. I learned so much that I wanted to bring back to the PHP stack, only to find that the PHP community is already working on those things. It's really fun to see the parallels.
I am a strong believer in coding fundamentals and try to preach language agnosticism to my team. Yes there is often a right tool for the job, but in many cases the major platforms will be able to achieve the problem at hand – at least for typical problems.
If you're a PHP dev, you really ought to add a complementary language, not one that, like Python, is really quite similar when it comes down to it in terms of performance, execution model, language features, etc. There's a lot of good options out there and there's more coming every year now. Go is a nice choice because it really nicely complements PHP, being good at some things that PHP is bad at, and PHP being good at some things Go is bad at. Rust might be a good choice with just a bit more web dev work on it. Erlang/Elixir, Clojure, something with a great concurrency story, an easier time getting to high performance, and some (good) static typing for when you're in the code where that's a good idea, that sort of thing. PHP->Python is not a bad thing necessarily, but it's not really "diversifying" very much.
Resume driven devlopment. As you say PHP and Django are similar in what you can use them for. I would choose either of the over Rust for a standard web app. Unless you have a specific need for concurrency, the PHP and Django are far more mature in the web app space.
It is far worse I would say. Legacy PHP code is some of the worst code I have seen in my life. Everyone with HTML/JS knowledge could also do PHP and they did. There are many production systems (banks, insurance etc included) running old style php with html mixed with php mixed with JS. And it runs fine, but if you need to fix something that broke or had to be changed...
I have seen some real crap in Python recently. Then I was asked to move a PHP app to a new server. A quick look at the code looked terrible - string concatenations for all the SQL. (Does PHP provide some way of making this safe, or should I warn management about potential SQL injection? I don't know a lot about PHP).
I also disagree strongly with that piece of advice. Even though, as others have pointed out, if you become a PHP developer you're going to have to deal with nasty legacy code; there's nasty code written in Ruby, Java, Python, etc. too. It's just nasty in a different way.
PHP is actually the language I do recommend people learn if they're interested in web development (obviously along with JavaScript), because PHP developers are in high demand. PHP developers can always find work, precisely because there is so much PHP out there.
The thing that hurts PHP the most is lack of structure and patterns used in the most popular projects. These popular projects are usually where the bulk of work lies, where developers point to when they're considering PHP. When juniors start they're typically working on WordPress or Drupal. The problem is that WordPress and Drupal are terrible guides of how to write a web app and that knowledge is completely useless when you go to write something in an actual framework. I was expecting a lot with Drupal 8 but I decided against using it entirely after reviewing the codebase and testing it out, 7 is in no way compatible with 8 and you have to start over.
When you step outside these mini ecosystems and look at PHP as a vanilla tool to work or to use a proper micro/full framework you start to question why use PHP at all? One possibly acceptable framework, in my opinion, is Laravel. The problem is PHP outside of these mini ecosystems isn't nearly as popular. It looks like people migrate to an entire new language like Python, Ruby, Node, etc. If we're talking about sheer people hiring Ruby, Node and Python typically trump PHP every time and are using frameworks - not Drupal or WordPress. Granted there are custom PHP apps out there and some very good ones but they're not the norm.
I switched full-time to Python using Flask and Django. It's like a breath of fresh air. My 2 cents is if you're on the fence, figure out how to work on one project using this new language full-time. Then you can make a better decision.
The thing that hurts PHP is also the very thing that makes it popular and creates the demand. it's easier to build things with it. It's damn near the BASIC of backend programming.
> 7 is in no way compatible with 8 and you have to start over
There's an upgrade path, sort of, but more importantly major versions of Drupal live for years. I think we'll keep seeing new D7 projects for at least 2 more years.
I used to like Laravel, but lately it feels so enterprisy. There is a lot of boilerplate in Laravel today and it was changing too fast for me to keep up with it.
The thing that kept me away from it for actual enterprise use was the fact the project is run by a single person. Where would it be without Taylor? Django and others have actual foundations that will keep it going for the long-term, more mindshare and more committers as part of the core project team.
The flip side of that question, though, is "where would Laravel be if it were built by committee rather than benevolent dictator?" I'd wager Taylor's "I'm doing shit my way" has been at least part of what has made Laravel so successful.
In my most recent (side) project, I'm doing a Yii2 website and I'm feeling like it's not enterprisey enough. I have to go out of my way to figure out the best way to split things apart (which, I guess is good because it doesn't actually make that difficult for me at all - it's just something I have to choose to do)
I used Yii2 at a previous job. The way that it splits things out feels horrendous. The documentation is sub-par, and I feel like I spent more time trying to figure out why something didn't work the way I expected (from reading the code) than I did fixing things.
I'm sure at least some part of that was the previous developer who built the application. But there is absolutely no reason for documentation to not answer the basic questions that seem to come up many times per day in their IRC channel.
I commonly recommend Yii and laud it's extensive documentation and "Definitive Guide" that covers basically everything.
In my current experience as a developer, Yii's documentation is the best I've ever utilized. Much better than any Javadoc I've googled or even php.net's
What are forms and form validation like in Yii? [Have looked at the docs, but after real-world usage]
I've used form libraries from the PHPClasses one back in 2003 through Symfony forms now (which has cognitive overload, and is so flexible as to be restrictive). Most business systems I write are data focused so forms play a massive role in them - and in my developer happiness.
Validation works directly with the model and you can pick a number of ways to check the input and have it return an appropriate error message.
The view/controller layers are very flexible and can be hooked up to anything from an HTML template using Yii to angular/bootstrap (which is what we're using) or another framework to handle the forms.
Use it at my current job. Also used li3 before that. The current version works pretty well without having any of the weirdness that can plague a framework once it gets more mature and people start wanting to graft in whatever is trendy from other projects.
What I like about it is the flexibility of the ORM, where you can use the model in a sane way but can completely toss it aside and just use SQL for those edge cases that would be a PITA in something like Django.
I like Laravel Elixir (the npm package) and Eloquent (the ORM). Laravel itself is overly complex and the learning curve keeps getting higher. I'm much happier with Slim 3
I think with the composer package manager mixing and matching components fais what makes modern PHP so effective. I'm using the mini-framework Silex and a bunch of components I find useful (twig, phpexcel ).
> I used to like Laravel, but lately it feels so enterprisy.
You think that feels enterprisy? Try Symfony, and listen to the community, with its "way to do things" that change every 6 months depending what's in vogue - and each time are invariably more abstract and complicated.
I have no idea since I don't use Laravel or PHP anymore, but I tried it a couple of months ago and it seemed completey different from a year ago or more.
> ... And to anyone considering programming as a career, or trying to get into it… stay away from PHP. There’s lots of fun, interesting languages out there that also get the job done quick, but with a better reputation and this will have an actual effect on your future career options.
> Looking for a PHP developer for your next project? I'm looking for work! Check out my resume or drop me a line!
I hate PHP too, but I write it almost every day at work. There's something to be said for how stable it is. I spent a large amount of my career doing .net development and deployed very rarely. It was a big day when I deployed. I would say to my wife, probably going to late tonight, we're deploying. Because something always went wrong when deploying.
Here, I deploy every other morning. Usually, while my coffee is getting to the right temp. The ability to just "throw it on the server", and to take it back if you need to make it great. There's a bunch of devs here, and that deploy all day long every day is one of the main reasons we move "so much faster" than our competition.
So as much as I hate how weird it is, and how frustrating it is not to have strong typing... i respect the heck out of it.
The thing is different languages lend themselves to different processes. Let's say you have the exact same bug in a web app, maybe you need to modify the where clause in the data layer of the app (or something small like that). In the C# version, you'll have to compile it and then push it. Maybe recycle the pool depending on factors in the architecture. In PHP, you just modify the file and throw it out there. Because of the slight differences, the nature of the way work is done leads to companies designing processes around it.
Same. It took us awhile at our company to wrap Octopus around our existing workflow (we don't do some things the way Octopus expects, but over time I found workarounds), but once a project gets set up, it's so super easy and just works, so much so that it's made deployment fast and predictable.
Once we switched over to Octopus we no longer had to bring several people on the team in and expect them to work 6+ hours on the weekend to do a deploy anymore, catch mistakes made during the deploy, etc. Now it's just done with a netops team clicking 'start' for each project, my boss on standby, and the whole thing done in about an hour, usually.
I understand what you are saying about easy-deployment. I work in PHP and .NET, and the difference I think comes down to deploying a few updated files to a PHP environment versus having to deploy your whole compiled application in .NET. Tools like Octopus and Visual Studio features mitigate the problem in .NET, but I totally know what you mean when I have to work without those tools and spend an hour trying to find some missing dependency or web.config entry in our project that often happens in .NET.
I still prefer .NET and C# for the cleanliness, correctness, and the fact that it's easy to write code that works the first time, but it is nice when I just need to update one PHP file and drop it on the server without any downtime to recompile on our WAMP server.
"Developers who more-so live in the Java-dominant corporate bubble"
That's me but ... I've known quite a few good PHP developers like this author. I've also seen horrible, horrible things - things that other languages and frameworks simply won't let you do. A language that gives you a lot of slack also gives you more opportunity to hang yourself. There's nothing that says you have to hang yourself.
As mentioned, the barrier to entry is low with PHP. The combination of a "loose" language and a newbie programmer is dangerous. And didn't all of us, as newbs, think we were done when it seemed to work properly? So the correct statement is not that PHP sucks, it's that many write sucky PHP. I'd rather see everyone aspire to not sucking (and certainly not hanging themselves) regardless of the language they use.
NOTE: I wrote a lot of PHP code in the late '90s and reworked part of a project in 2005/2006 so I obviously don't know anything about the current state of PHP. I'm not against it - I simply choose not to use it (at least at the moment).
this. when i evolved from the procedural mess that were tutorials and books, even, i watched most other programmers and/or collegues staying behind.
embedded php worked for them. little bit js here, css there... up to this day people just don't evolve from php.
and then there's the other extreme. the overly scientific who brings all sorts of crap into the language or the frameworks. it's justsuch a shit show.
I worked at a PHP-based company and after a year of intense interviewing, we finally decided to switch core languages and tech stacks because we weren't attracting strong enough candidates.
What we found is that most good programmers didn't want to work in php and most php developers were designers that learned how to code php. But they didn't understand CS fundamentals or even a decent idea how to code. They could cobble together a web site that worked and even looked great, but they didn't know how to write maintainable, modular code.
It got to the point where I would ask the candidate to merge two sorted arrays and 70% couldn't do it properly.
In terms of language, I thought php itself was a surprisingly productive language. I just quit though because I didn't want to be known as a php developer because of the stigma and there poor quality of other php developers that I encountered.
I found that if you advertise for php programmers you get mostly people working on fairly simple web applications. The more talented programmers would apply when we emphasized that we use php for the front of the backend systems, but we also use Go and node.js for more realtime parts of what is a suite of micro services. once we got them in the door they were happy and productive php programmers
> It sucks that every HTTP request is a whole new instance of my PHP application.
In fact, this is one of PHPs greatest strongs, not a weakness! NodeJS, Ruby and especially long-running Java web apps easily turn into huge memory leaks.
PHP, on the other hand... not so much.
> PHP is generally not approved in the enterprise
I believe OP is looking from the wrong angle. There certainly are successful, enterprise-used PHP applications (e.g. SugarCRM, Drupal, Typo3), so it certainly is not a problem of approval.
IMHO the real problem is the total dominance of (extremely!) outdated COBOL/FORTRAN/(other mainframe stuff), SAP and Java (hello Lotus Notes!) applications in business.
"The 2016 StackOverflow Survey puts PHP developers as the least paid" - which is very unfair. I think PHP developers should actually get paid more as compensation for having to put up with PHP on a day-to-day basis, but that's just me unfortunately...
I've been doing primary PHP for almost ten years and people honestly just throw money at me to solve their problems. I really don't know how I make as much as I do; I hit the point where I made more than my parents combined a few years back and that made for a strange reflection point in my life.
Basically for all the decent PHP developers I've known in my life money has never been an issue.
Not being a developer, but having had lot's of great moments with them, I can say, that in my tangenital environment there are lots and lots of school taught mediocre to bad PHP devs, that always find jobs, but on a very low pay grade (and rightly so).
So maybe there are lots of mediocre php devs pulling the average down?
I think the low salaries are more a reflection of the fact that there are a lot of inexperienced developers writing PHP and that there is a lot of unimportant software written in PHP than it is that a given developer would make less by using PHP. A highly talented developer working on business critical software will make a lot more than an untalented developer working on low value software regardless of whether each piece of software is in PHP or Java; it's just that the first scenario is more common in Java than in PHP and the second scenario is more common in PHP than in Java.
This is one of my fears, as I work primarily modernizing PHP applications.
I think it's possible my salary has hit a plateau. Most SMBs do a false equivalence between PHP developers and junior developers. One place I worked at the owner used to brag about hiring people starting out for $12/hr.
The thing is, with my experience in PHP it's easier for me to write secure code in PHP than anything else at this point. I can do it really fast, too. I've internalized a lot of micro-optimizations in PHP. Project scaffolding on a greenfield project ends up looking a LOT like Express if you use the Slim framework. And I stay away from PHP if I need concurrency (and so far, per business requirements, I haven't). I can scale it really well, and I rarely have to worry about memory limits like you do with the JVM.
I'm hoping for a breath of fresh air with PHP7, because I'm not entirely sold on the current runtime alternatives - JavaScript, Python or Ruby. I've been trying Scala and I write less code than Java, but definitely more than PHP. It's also hard to jump into the Play framework if you don't grok the 'weird' operators. I also find that it's easier to hang yourself with incompatible components/libraries. So far it's fun to write though, but I don't think I've seen anyone hiring for Scala in my town.
The vacuum of negativity is vast and relative. Who cares if Java developers think they're better than PHP developers? From the perspective of a C developer neither can properly allocate and manage memory effectively if their life depended on it (heap-based programming, lolzors).
In my experience the modern PHP developer is characterized by a crippling self-consciousness. When I meet someone who is a fellow developer and tell them that I do C and Python and stuff... they usually begin with a bit of self-deprecating humor: I do PHP and stuff, not real programming like you, blah blah blah. I feel obligated to correct them.
The best thing you can do for yourself as a programmer is to not pigeon-hole yourself to a single language regardless of how tempting it might be from an economic/marketing perspective. Learn maths and get good at identifying problems and simplifying them. Become an expert in at least one general-purpose language and one specialized one for sure... but remember to think like an engineer: these are just the brick and mortar of the job! You still need a good mind for design, creating blueprints, and the experience to make informed trade-offs.
It's not about a language or a technology, it's about what you do or can do with it...
All trendy technologies might be replaced anytime (hey React, Go, I'm looking at you!), one day they are very cool, the next day nobody maintains them and everyone talks about another new cool thing; how many of these have we seen?
New cool stuff are important to know, explore, test, use because they bring a lot of interesting stuff, but often they only address some use cases, as they have been made by a team with specific needs (looking at all hundreds NoSQL databases?); php and some others (like ruby) are stable, well known, cover a vast area of use cases with very well made and long thought frameworks and tools (symfony, doctrine, phpstorm, ...).
You are always free to follow trends, like with clothes, or just choose the best thing for what you need to do. You'll definitely find jobs with any of these, if you are able to explain why they are good for what you are doing.
I hate it, because it makes me feel defensive. PHP in their minds
is much worse than it practically is. Im tired of defending
PHP, Im tired of being set back and having to proof my compete
by virtue of being a PHP programmer.
For me it is the other way round. I like it when journalists ask me what super advanced tech stack I use. When I get tweets about what libraries I use in my projects. And students mail me questions about the technology behind my Startup. And I can reply "It is just your average LAMP stack".
What Evert is referring to (the "reputation" of PHP and people's reactions) is even worse in infosec. I very frequently get accused of being a charlatan simply because I write PHP.
This is silly when you think about it. If so many systems run PHP, wouldn't you want your infosec people to know PHP and work with it more often? Why are we, culturally, encouraging such a blind spot by ostracizing folks who know it well? That part never made sense to me.
This conversation plays out more frequently than I like:
Rando: Hahaha PHP security is an oxymoron.
Me: Okay, then hack paragonie.com. It runs PHP. Logically, you should
be able to hack it _just for running PHP_ if PHP is so insecure.
Rando: But that website's mostly static content!
Me: Yes, but it runs PHP. So it must be insecure, right?!
So far, despite giving people permission so the prospect of CFAA convictions don't discourage them, none of these "PHP is inherently insecure" folks have succeeded. I wonder why. :)
TL;DR - A lot of the hate against PHP is founded on ignorance and peer pressure. Be open to constructive criticism, of course, but a lot of the hate you'll hear is bullshit.
My company does penetration testing and most of the projects involve web apps. Our clients use PHP, J2EE and .NET, and after 7 years of operation, we clearly see a trend where the number and severity of security issues are highest in PHP apps, lowest for .NET, with J2EE in the middle. Of course, there's the odd secure PHP app and the .NET project with gaping holes, but the trend is obvious.
So it's not peer pressure, we actually have data to back this up, and if you think about it, the whole thing boils down to motivation. Sure, you can write secure and insecure code as well in any language/environment. But defaults are powerful, and it makes me feel sad every time I have to write in reports that "you should've paid attention to opt-in to the secure solution every time you do X" vs. when we do demos to developers and we have to work really hard to disable every protection built into ASP.NET. (And no, I don't like Microsoft at all.)
Please tell me more about these PHP projects, if you have the data available to you.
* Did they support EOL'd versions of PHP?
* Are they legacy WordPress/Drupal/Joomla projects that haven't been updated in years?
* Are they in the "we (didn't use a framework|rolled our own framework) and used the mysql_* functions" league?
* Did they attempt to do something weird/crazy (i.e. store all session state in an encrypted cookie instead of server-side like normal, but forget to authenticate the ciphertext)?
Those are the kinds of things that I rarely find in modern PHP projects.
One thing I think Evert neglected to mention in his post: There's definitely an ecosystem problem. Incidentally, I've been working on cleaning it up on multiple fronts:
* Improving the quality of information developers will find via Google search or StackOverflow
* Improving the security of the tools and frameworks developers use
* Working to improve the language itself (part of the reason why PHP 7's CSPRNG functions don't fail open is because a few of us were very vocal on how/why that would harm security)
I know little about most of them, since we did penetration testing (simulating what could an attacker over the 'net do) most of the time, as few of our clients have the budgets for a proper source code review. No CMSs were used, we had one Wordpress, but that was actually almost perfect, since they kept it up to date. These projects were custom-made business applications, not "dynamic" web sites.
Frameworks were sometimes used, although their effect on security is somewhat baffling at first sight -- and this is regardless of the platform, although we found most issues with PHP and J2EE. Sure, when you use the framework for security-critical things such as constructing SQL queries (SQLi) or HTML output (XSS), things work quite well. However, since most developers don't think about these issues, the single time they have to "escape" from the framework, since it doesn't (or they just think it doesn't) support a certain scenario, they don't know about all the things PHP and in smaller ways, J2EE requires to do for security.
Of course, this way, the framework protects 9x% of the application, but the asymmetry of security is that the attacker only needs a single vulnerability while the defender must patch it all.
I'm not surprised to hear that custom-made business applications fared so poorly. Back when I worked for a telecommunications company, I saw some of the worst code imaginable endorsed by corporate and deployed to production with wild abandon. I reported no less than 10 vulnerabilities in my first day with a new codebase and they were all ignored. My boss took me aside and said, "There's some politics going on right now, just keep that in your back pocket in case you need to bring it up later. Now's not the time."
I agree with the sentiment that, compared to other languages, all else being equal, PHP-the-language sucks; and also agree that all else is not equal, since PHP has a massive installed base, infrastructure support, etc., and that the balance can often tip either way. My first programming job was in PHP, which was used only because of its ubiquity on shared hosting (we even maintained support for PHP 4, when PHP 5.3 was current).
Personally, I don't see much point in arguing the merits of PHP compared to, say, Python, Ruby or Javascript, since those languages are so similar: procedural scripting by default; opt-in use of OO as the happy path for most libraries; functional programming possible, but an uphill struggle WRT APIs, tailcalls, language cruft, etc.
There's also a lot of interbreeding in those language's ecosystems, so there's rarely a killer library/framework/app in one which doesn't have a few carbon copies in the others. I would recommend developers in those languages look at what the others are doing, but I don't see much point in switching between them as an end to itself; go for it when convenient, but nothing much will change (e.g. I was heavily into Python, but fell into PHP dev roles commercially).
The more interesting comparisons are to be made with languages/ecosystems which have a different philosophy, e.g. Java/C#, Haskell/ML, Lisp/Scheme/Lua, C/Go/Rust, C++/D, Smalltalk, Forth, etc. Those kinds of comparison have meat; they're not just bikeshedding about which syntax to write imperative procedural/OO scripts in. I commend the author's choice of learning Go (although I'm not familiar with it myself).
I think the procedural/OO scripting languages will be around for a while to come, but I think their niche is in public-facing applications (usually Web sites, but Python certainly has a heritage of desktop GUIs and CLIs). Certainly the use of REST services is making it easier to use languages for those jobs they're good at; for example, using Go for data crunching, while Web site rendering is done in PHP.
I come from a Java background and right now I'm working with some PHP. As a tool for websites, it is as such, OK. It feels a bit messy and "ADHD" at the core, but for non-critical stuff its acceptable. With "non-critical" I mean: systems that won't kill anyone if they fail. See, one of my early projects was designing and building control systems for a huge pharmaceuticals factory. Errors, in either logic or data, could literally end up killing someone. Testing became 2nd nature. Since that experience, I've evaluated programming languages by how robust their error-handling mechanisms are and how much rigour is enforced at compile-time. In that arena, I think Java is the most mature. In critical systems, checked exceptions -are- your friend. One glaring problem with PHP is its freak error-handling. PHP can get the job done, but don't trust your life to it.
I left PHP for C# and JS. I've been burnt so many times from the tacky standard library it's not even funny. Coding php in a large application is both boring and hard. XDebug barely works and is hard to set up.
Still, PHP is so goddamn cheap it's not even funny. But I recognize everything the author is describing.
I don't fully understand what you mean but if you're saying it will under-perform with this hardware I assure you that it will scale better then Node.js :)
The author's biggest mistake wasn't betting on PHP, it was betting on a single language. He should have learned more languages a long time ago, just to expand his set of tools, and maybe way of thinking.
Besides, learning a new language is fun and not that hard... They are all pretty much the same...
... until you try to switch paradigms (e.g. to Lisp, Erlang or Haskell).
I agree that learning new languages is very useful. But as analogies go, going from PHP to another imperative language is more like switching dialects than learning a foreign language.
Sadly, most of the complaints to PHP as a language also apply to JavaScript (even worse IMO), but seems like people are more forgiving to the JavaScript/ Node.js community nowadays.
Programming with PHP is sort of like eating/buying McDonald's food.
Yes it gets the job done and you can argue it is readily available, a calorie is a calorie etc....
...but the reality is even "new" McDonald's is not terribly good for you and people will judge you if continuously eat there (I'm not saying that is a good thing but it does happen. Just try asking coworkers to go there with you).
And that is the point. The OP doesn't like to be judged but the general consensus is PHP is "probably" not good for you long term (regardless of the caveats of the language one cannot argue that other language programmers are generally paid much higher).
Imagine it this way. Imagine a fitness professional saying: "you know calories are the main thing that make you fat so I eat a small McDonald's meal and fast the rest of the day".... what would you think of this fitness expert... would it honestly not affect your judgement?
I'm not saying PHP is bad... I'm just saying I understand the behavior the OP doesn't like.
Functions can represent any subset of computation within a program, or in some cases a function can represent all of the computations of an entire program. If you're hung up on small nuances of a language, you're probably just not doing it right. That's not a bad thing. A lot of people find themselves in this position, but the bottom line is you're probably just not writing your programs with the correct lower level abstractions.
That's it. It's not magic, but it's not always easy either. You shouldn't feel bad about it. Just keep trying and one day you'll realize that very little of what makes a great programmer has anything to do with the language you're using.
NOTE: This isn't in response to the author. They appear to have a strong reputation within the PHP community. This is really just a general response to all of the PHP hate in this thread.
> We’re not taken as seriously, and we’re being paid less. The 2016 StackOverflow Survey puts PHP developers as the least paid. Hilariously that position is shared with “LAMP” and “Wordpress”, both of which are also PHP.
The author didn't explicitly state it as a causal relationship, but doesn't this have more to do with supply and demand than respect?
It's true that if you're a guru in a more esoteric language you're going to earn more respect than a guru in PHP (although if you're really a guru in PHP you're probably also pretty good in more respected languages).
But it's also true that your skills would be in much higher demand for any available jobs in that esoteric language than PHP skills are for its available jobs.
[EDIT: I suppose an argument that cuts the other way is that PHP projects -- regardless of what the employers know or care about the language -- tend to be lower status and lower paying than those built on more esoteric or more "serious" languages.]
> A big part of this issue is that the barrier to entry in PHP is so damn low, almost everyone can start hacking wordpress templates. For many people, PHP is the first programming language they try without formal education.
This really hits the nail on the head. A lot of the criticism of PHP comes from people who have never worked with a good PHP codebase and have only seen some of the many examples of awful PHP code out there. A well written PHP codebase is really nice to work with.
> The problem I have with PHP has nothing to do with the language, it’s its reputation. I can’t count the times I’ve started a conversation with a programmer who upon finding out I primarily do PHP got awkward with me.
I've experienced this many times as well. I think the previous point is really the root cause of this. People have a lot of misinformed ideas about PHP due to the sheer amount of really low quality PHP code and "developers" (i.e. people with no experience just trying to get shit done).
I don't think you can argue it's just an opinion. I haven't seen anyone argue that php isn't badly designed or implemented. Other than stating that it works and you can work around it.
> The problem I have with PHP has nothing to do with the language, it’s its reputation. I can’t count the times I’ve started a conversation with a programmer who upon finding out I primarily do PHP got awkward with me.
I'm a developer. I use tools to get things done. PHP is one of many tools in my arsenal. For certain projects, it's awesome. For others, it's very much not awesome.
That's the beginning and the end of it. I don't get defensive. If I bring up PHP and someone says something like, "Oh, I’m sorry about that" -- that's an indication of that person's immaturity, not any weakness on my part. It's a super condescending thing to say to someone...
If I didn't just give up on them at that point, maybe I'd explain why I chose PHP. If I'm wrong and I'm actually making a bad choice of tools for the given project -- happy to have that conversation and learn a thing or two!
So much uneducated hate going on in the comments section here. As someone who's developed high load projects in a few languages (C++, PHP, Node.js, ColdFusion, Rails) I can say with absolute certainty that any of the modern, popular languages are just as good as the other. What some may see as a slight, others will see as a strength. It's up to the programmer to write structured, thought-out code. Heck, one can argue that too much forced structure can be bad for performance (assuming skilled programmers are at work).
As an aside, my favorite syntax is C#.
But at the end of the day, the author has the right idea and it seems many of you don't. If you're a skilled programmer the language is a preference, not a precursor to what your app will turn out to be. If for any other reason than platform related your code turned out bad it's a good indication you're not one of those skilled programmers.
"The problem I have with PHP has nothing to do with the language, it’s its reputation. I can’t count the times I’ve started a conversation with a programmer who upon finding out I primarily do PHP got awkward with me."
The HN post title is sure helping with the reputation.
Asp.net on linux, Go, Elixir, Python, Ruby,Java ...
PHP kinda saved itself when it got Java like classes(which are fairly rigid thus allowed retrofitting "type safety" in PHP) which allowed engineers to write large and maintainable codebases (Symfony,Doctrine...).
So again, no need to complain, go see your manager and try to convince him to try an alternative solution. Of course if you're using a CMS like Worpdress or Magento it might be a bit more complicated to migrate. But for projects started from scratch frankly, an engineer that can write a Symfony/Doctrine app can easily switch to Asp.net, it's exactly the same level of complexity.
PHP get in your way only when your starting.
You never make these "bad language mistakes" once you're experimented. And then you can write really clean code.
ASP, however, makes me vomit everytime I read a single line.
COBOL is more readable !
C# (the most commonly used ASP.Net language) is one of the best designed mainstream languages out there. I'm not a fan of any of the ASP.Net web frameworks, but the language itself is great.
I remember teaching myself PHP back in 2001 after the dotcom crash. I still use it occasionally to whip up quick sites on a shared server setup. I have also used to quickly build out some web based systems at my day job.
You can hate it as much as you like, but bad code comes from bad coding practices. PHP has all the features other languages have. It even fairs pretty well in the benchmarks game against its peers http://benchmarksgame.alioth.debian.org/
Its so funny that people are so polarized either for or against PHP. Give me a language that doesn't have pitfalls and stuff that doesn't make sense and I'll show you an Amish NASCAR driver.
The one thing I never understood about developers is how your programming languages are a total pissing match. If it gets the job done, who gives a fuck if it has a few quirks here and there? Can you create something cool? Can it be properly secured? Ok, great, let's focus on building something instead of whether we're using wood or concrete.
Having used a few mainly languages in my time, I far prefer working with Python or Perl over Java or Visual Basic. I encourage people to use the better ones, so that hopefully the crap ones do die out (as VB seems to have!)
For anyone wishing to look at a small modern PHP7+async codebase, check out https://github.com/Room-11/Jeeves (I am not involved with it). It shows the new guts of the language, and AFAIK some PHP core contributors wrote part of that code as well.
On the article itself, it is a mindset issue with people. Not sure how it is different from people saying "haskell is useless" or "JS is a toy language".
Once you need a framework and the complexity that goes with it, PHP starts to suck. It lacks the behavior and tools to nicely manage complexity beyond a pile of files.
But when what you need is a pile of files, PHP is awesome.
With PHP you can grow your own infrastructure from being a couple of calls to your RDBMS/MySQL up to installing modern libs and implementing a framework.
On the other hand: With RoR, Python, NodeJS, et al (which by itself can do anything, since they need frameworks and libraries for anything web-related) you have to start with these HUGE dependencies and package managers that only add more technical debt to your project plus your projects can't start from dead-simple bd-calls it has to be all or nothing and under the same structure because "it's the right thing to do bro, you will thank me later"... guess what: i still don't use everything.
The day a languages appears that is web-ready and dead-simple with no technical debt that's the day we can say: PHP Suck.
That's why I like Brainfuck as my goto language so I don't have to deal with the newbs jumping into my language <sarcasm>. I once had a python programmer say I shouldn't use php because it doesn't have classes "so theres still some old thoughts on the language floating around" and I know java api devs who don't know the difference between POST or GET request so bad programmers come in all languages.
The problem of PHP is its community of cheap workers not caring.
But I love them. As long as they stayed doing PHP they didn't contaminated other communities.
Now that they came to python with their bad practices exacly for the bad reputation reasons described in the article, I see PHP kind of coding ... SQL injections, shell injections ....
Please PHP coders I love you doing PHP, don't leave PHP.
This post hits it on the head. I had been a 12+ year PHP developer and a little less than 2 years ago I had left PHP for Node.js because I was sick of constantly defending my competence to people who used PHP for 15 minutes back in PHP4 days or had to fiddle with a crappy WordPress theme/plugin and completely dismissed the whole ecosystem.
I think it's hilarious when the same people who bash PHP will expound on their love of YavaScript in the next sentence. It's like there is not distinction between trendy and good. Actually, I think the author's post could be titled "PHP isn't trendy" without loosing any meaning.
This is a great move on his part - every programmer should know as many languages as they feasibly can. Being a monolingual programmer is like being a carpenter who only uses hammers. Or maybe a better analogy would be an investor who only owns stock in one fund, or a physicist who only studies one type of particle.
The true programmer doesn't get attached to one language or another. If you get 'fed up' with a language and switch, then you are taking the language way too seriously. Use languages for what their particular strengths are, and that's it.
>This is frustrating, but the best time to plant a tree is 20 years ago, the second best time is today.
What a great way to look at this. Author has some really interesting insights into why the PHP stigma exists and the problems that it creates for a (good) PHP developer.
IMO any good dev can be professional in any language, its just harder in some than others. It is a bit sad to see someone who has built up their knowledge and skill leave it because of its social stigma.
Why PHP is so successful? Well...
"Shantytowns are usually built from common, inexpensive materials and simple tools. Shantytowns can be built using relatively unskilled labor. Even though the labor force is "unskilled" in the customary sense, the construction and maintenance of this sort of housing can be quite labor intensive. There is little specialization. Each housing unit is constructed and maintained primarily by its inhabitants, and each inhabitant must be a jack of all the necessary trades. There is little concern for infrastructure, since infrastructure requires coordination and capital, and specialized resources, equipment, and skills. There is little overall planning or regulation of growth. Shantytowns emerge where there is a need for housing, a surplus of unskilled labor, and a dearth of capital investment. Shantytowns fulfill an immediate, local need for housing by bringing available resources to bear on the problem. Loftier architectural goals are a luxury that has to wait."
PHP has always had this hyper productivity about it. You just made a change in your editor, saved the file, and refreshed your browser for rapid feedback. It's always been like that.
It's also stateless - less rope to hang yourself with.
Many web programming environments started with the same simple CGI model, but eventually moved away chasing performance (for the computer), and leaving behind rapid feedback during development time.
hyperdev.com is nice, but it's still way more complicated than a single file PHP app.
PHP became successful when hosting companies began offering cheap PHP hosting. PHP runs on low cost servers with very little memory,so hosting companies could put many customers on a single server.
It was then just a matter of uploading a few files via FTP to have a working website. .Net deployment, Java deployment were always more complicated and expensive. It was also easy for administrators to deploy Wordpress or Drupal, with next to no PHP knowledge whatsoever. That feature (ease of deployment) was often underestimated by other solutions, until the PAAS era.
Could PHP have been made better language wise while keeping the same features absolutely, but PHP was not taken seriously by people who could have fixed it early on.
Well.. people that don't know how to code but want to hack in a 1 line dynamic thingy.. where else would they turn? It build a pretty good community for newcomers.
To be fair, FB struggled to scale with PHP, although it certainly fares better out of the box (even then). A lot of their work has gone into making PHP more performant and better by way of Hack.
PHP7 took a lot of great ideas from Hack but is still saddled with its legacy.
They did? I remember numerous Twitter outages due to scale and the infamous Fail Whale. Twitter's issues risked the company losing users or even it's sustainability as a business.
Facebook wouldn't likely exist if it wasn't for PHP. Zuck wrote something quickly in what he knew. They were able to deploy quickly, scale quickly, etc. Internally, they likely had the hope to migrate off of it at some point, but the business goals trumped the tech stack. From an outsiders point of view, no one cares about the tech problems they face with their tech stack.
A few years later there would have been Rails or Django. With the strides FB made in PHP it would have been cool to see what they could have done with those frameworks/languages.
While RoR, Python, NodeJS et al don't solve the most annoying issue for every developer: Deployment. Then they don't solve anything.
And don't start talking about docker... that's a patch/hack to a serious problem, if i need an entire "jail manager" just to run your app then deployment is not as easy as you kins think it is.
Typically deployment is a "solve-once" problem, even if you don't use docker. You set up chef, puppet, ansible or fabric to handle deployment, installs, database migrations and so on, and tweak as needed.
Of course that may not be the case if you have some kind of commodity service you have to install in lots of different environments, such as Wordpress.
There is a big difference with the word "should" and "need".
While i should run PHP in a jail, it doesn't mean i need to. While with python, nodejs, ruby et al, i need to otherwise it becames a dependency mess for every app on the same server.
I wouldn't ever recommend a beginner learn PHP. I would definitely recommend a beginner learn Laravel. It has tremendously awesome free or inexpensive learning materials, great documentation, great community support, and comes out of the box with everything you would need for 95% of websites.
If that's what you're after, you can go with Rails and not be stuck with PHP at all. (Of course, if you go with Rails, you're stuck with Rails, so maybe it's a wash.)
From the bottom of the article: "I regret using such a clickbaity title, but . . . . " You could have called it, "PHP's stigma sucks and I'm leaving." It would have been more attractive and honest, instead of piling on more of the stigma that you dislike.
PHP "sucks" as a language, but it's productive, great for getting things done. It has some decent frameworks, like Laravel. You can bang out a ton of functionality quickly.
I've made a ton of money doing PHP contracting locally. For my day job, it's been Python, Java, and Go.
to op: glad you're taking time to check out golang. I too have worked mainly as PHP dev since 1999 or so, and recognize most of what you are saying. I loved the new era of php with the composer ecosystem, but after investing too many hours into Laravel, i finally had enough when I realized I could not even use the backtraces to debug some issue I was having after upgrading. So I decided to never touch it again.
Coming from php to golang is insane, you will be very impressed by all the mature and insanely fast tooling.
For example I now have test suite running in about 0.3 seconds, where my last PHP (laravel) app took about 20 minutes testing similar stuff.
I don't think that PHP sucks, I think that lot of PHP projects sucks, because exists lot of newbie developers without any minimum knowledge about programming, making mess in lot of project just because is so easy to use PHP.
Composer is not a new wave but piece of shit which brings old shit-code style with rules "don't touch it while it works" and "legacy code is a good reason for bad architecture".
Is there some consultant out there who is getting paid good rates to program with Go, Rust, Elm, Erlang? I would love to hear some stories. Most people I know only get paid for php, rails or node.
PHP is a see-saw at a kids' playground; on one end there's a small, sensibly dressed kid and on the other, an overweight kid having a great time, with his/her side stuck firmly to the ground.
The child suspended in the air is wailing about how the whole playground is being totally ruined by the other kid.
The other children watch, bemused, from the other playground equipment, happy that they've grown out of the seesaw; all the parents watch from outside the playground, not caring who plays with what.
There’s a lot of outdated information on the Web that leads new PHP users astray, propagating bad practices and insecure code. PHP: The Right Way is an easy-to-read, quick reference for PHP popular coding standards, links to authoritative tutorials around the Web and what the contributors consider to be best practices at the present time.
There is no canonical way to use PHP. This website aims to introduce new PHP developers to some topics which they may not discover until it is too late, and aims to give seasoned pros some fresh ideas on those topics they’ve been doing for years without ever reconsidering. This website will also not tell you which tools to use, but instead offer suggestions for multiple options, when possible explaining the differences in approach and use-case.
PHP will still be the most accessible backend language for a long time and only JavaScript stands a chance at outcompeting it for a long time. (And yes I know JavaScript is normally seen as a frontend language)
PHP, Javascript, C, C++, Java. Arguably "great" languages given their success, and each attracts a mob with pitchforks and torches wanting to burn it down.
I would like to see Hack take off a bit more though. The XHP extension alone solves so many headaches with templating. Treating XML elements like first class citizens and having the language be able to reason about its current context, and not having to echo HTML strings everywhere and just hope you escaped everything properly, is something I wish PHP had picked up years ago.
PHP is an oddball child for sure but I get more done in it than anything else. Who gives a crap if other developers don't respect you? My bills are paid and I know I do good work, everything else is just bonus.
I'm kind of glad I'm very disconnected from the communities and the various groups that handle this stuff, I just write my code and go home. It sounds like thousands of bickering children.
That's a pretty useless truth, who doesn't know that?
Many languages (like Go or Clojure) require you to learn quite a few concepts and exercise your mind in general. This automatically filters out incompetent programmers, and puts the rest in the right mindset.
I don't really agree on Go, however it is true that some programming languages scare away beginners.
I wouldn't say that it filters out incompetence completely though. I remember when I was writing Prolog for a school project and wasn't familiar with any of its concepts. I ended up writing terrible Prolog that looked a whole lot like the imperative stuff I was used to (wait, comma doesn't mean next instruction?!).
I'm by no means an expert on PHP but whenever I begin having similar thoughts like the author, or begin having internal language religion wars in my head about PHP, i remember that PHP actually stands for "PHast Prototyper" (language/platform)..and tools/platforms like that have their place in the world to help us...and then this thought allows me to regain my peace and progress forward on my day (focusing on bigger things). This does not mean PHP is inherently good or bad, merely a tool; to be used under the right conditions (in this case rapid dev.).
Perhaps remembering that PHP could mean "PHast Prototyper" could help you/your team come to terms with all this?
The point isn't that it's easy or hard. It doesn't require the user to understand things like scope or the rudiments of typing to get started, which means it's insanely permissive.
Yeah, I could understand that perception if chainsaws were given away for free to everyone who owned a house in the woods, and if they were touted as an easy-to-use entry-level sawing device.
More work was available locally with PHP. Clients were more willing to pay. I've done a ton of things in WordPress that shouldn't have been, "to save money". And I've done greenfield development with CodeIgniter, Laravel (v3 and v5), and a customized set of the Symfony components. I've also maintained and improved brownfield projects that were outsourced.
I'm very tired of hearing that PHP sucks. PHP is a good language. And in my opinion, it has fewer ways to sabotage your own project than any language with monkey patching. PHP7 looks really awesome, and the community has been upgrading quickly toward it. PHP has always had best-in-class documentation in my opinion.
More often it's the programmer who sucks, not the language.