Is PHP Still a Worthwhile Language To Learn? (stitcher.io) 137
mbadolato (Slashdot reader #105,588) shares this post from Belgium-based programmer Brent Roose:
It's no secret among web developers and programmers in general: PHP doesn't have the best reputation. Despite still being one of the most used languages to build web applications; over the years PHP has managed to get itself a reputation of messy codebases, inexperienced developers, insecure code, an inconsistent core library, and what not. While many of the arguments against PHP still stand today, there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP.
In this post, I want to look at this bright side of PHP development. I want to show you that, despite its many shortcomings, PHP is a worthwhile language to learn. I want you to know that the PHP 5 era is coming to an end. That, if you want to, you can write modern and clean PHP code, and leave behind much of the mess it was 10 years ago.
The article notes PHP's opt-in type system and performance-enhancing rewrites (including the ability to store compiled chunks of PHP code in memory). And it argues that PHP "is still evolving today," with a package repository averaging over 25 million downloads a day. There's also PHP web application frameworks (as well as asynchronous frameworks), so "PHP isn't just WordPress anymore."
And in keeping with the core team's yearly release cycle, PHP 8 is expected at the end of 2020, which will include a JIT compiler, "allowing PHP to enter new areas besides web development..."
In this post, I want to look at this bright side of PHP development. I want to show you that, despite its many shortcomings, PHP is a worthwhile language to learn. I want you to know that the PHP 5 era is coming to an end. That, if you want to, you can write modern and clean PHP code, and leave behind much of the mess it was 10 years ago.
The article notes PHP's opt-in type system and performance-enhancing rewrites (including the ability to store compiled chunks of PHP code in memory). And it argues that PHP "is still evolving today," with a package repository averaging over 25 million downloads a day. There's also PHP web application frameworks (as well as asynchronous frameworks), so "PHP isn't just WordPress anymore."
And in keeping with the core team's yearly release cycle, PHP 8 is expected at the end of 2020, which will include a JIT compiler, "allowing PHP to enter new areas besides web development..."
Short Answer, no (Score:2, Insightful)
Re: (Score:1)
I agree, unfortunately a lot of various solutions have been made using PHP.
It's of course simple to say it was wrong to use it, but it's the same with many script languages that results in obscure files where three languages effectively co-exist, in this case PHP, HTML and JavaScript - with a lot of bugs and security holes as a result - even worse you could also have some SQL in it too for "good measure".
Re:Short Answer, no (Score:5, Insightful)
Can you point me in the direction of a scripting language for web development that avoids HTML and JavaScript?
Re: (Score:2)
Can you point me in the direction of a scripting language for web development that avoids HTML and JavaScript?
Well, in theory, there's WebAssembly.
Re: (Score:2)
Re: (Score:2)
Soon or later it is supposed to get access to the DOM, which means you can replace HTML, CSS and Javascript with any language that supports WebAssembly.
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
I know. Quit asking.
Re: (Score:2)
Re: (Score:3)
Re:Short Answer, no (Score:4, Insightful)
I would advise everyone to learn it, just not as their first language
PHP should be learned on an "as needed" basis.
If you don't need it, don't learn it. When you do need it, learn just enough to fix the current problem.
Many languages teach you new principles and perspectives. Even horrible languages like JavaScript have good parts [reddit.com]. But PHP isn't like that. It was a quick hack without any underlying design philosophy, and then more and more hacks were inconsistently glommed onto it. You don't learn and grow by studying something like PHP.
Re: (Score:2)
It's worthwhile if, say, your job requires you to hack on WordPress.
Re: (Score:2)
Re: (Score:2)
I disagree. It sucks, it's a terrible language, but:
(1) it's one of the most popular languages in existence and probably the most popular for back-end web work, and as a result if you want a fucking job you better learn this shit, and
(2) it has enough gotchas (because it's awful) that it's a language that you have to learn. It doesn't take very long to learn it, but you can't just go in and say "I know Javascript, this is JS with dollar signs and explicit classes". As an example, you have to find out, extremely early, why you rarely use the '==' operator, and likewise switch() and some other statements for similar reasons.
I would advise everyone to learn it, just not as their first language, as, like BASIC in the 1980s, it'll set you back if that happens.
Basic was the first language I learnt. And it didn't set me back. It made me learn assembly, and since then, when learning a new highler leve language I always understand what is happening underneath.
Re: Short Answer, no (Score:2)
No
Simple. (Score:3)
Do you have an irrational dislike for programmers, and assume that if you were a programmer you'd be better than all of them, but you're wise enough not to want to learn about any of that stuff?
But now you need to write a dynamic web application?
If yes, learn PHP.
If no, learn any other web language.
Good code != good language (Score:5, Insightful)
there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP
You can right clean and maintainable code in any language. That doesn't make the language suitable for the job or desirable.
Quite frankly, PHP needs to die. But considering how much of it is deployed out there, it is definitely a worthwhile language to learn, just for job security. I learned COBOL decades ago for that very reason and I still make decent money with it to this day, although the language is hateful and totally deprecated.
Re: (Score:2)
PHP strongly resists writing clean and maintainable code. Maybe it is possible for small projects, but not for anything significant.
These days there are much better languages for this task and if you see a job advertising for PHP it's probably a good indication that you will be stuck in hell dealing with the worst legacy code base imaginable and should run a mile if you can.
Re:Good code != good language (Score:5, Informative)
If you use a decent framework, you can write clean maintainable and even secure code in PHP. Most of the jobs want experience with the frameworks rather than the language these days. Learning a bit of PHP to throw together a dynamic web page is easy. Mastering Laravel so you can develop a scalable data-driven front end for a major client is another thing altogether.
Re: (Score:3)
All programming is based on writing clean, maintainable code.
If you can't write clean, maintainable code, YOU SHOULDN'T BE A PROGRAMMER.
If you have to pick a development environment to compensate for your basic inadequacies, that's not everybody else's problem!
Re: (Score:2, Insightful)
All programming is based on writing clean, maintainable code.
All programming is based on getting whatever you are paid to do done.
If you can't write clean, maintainable code, YOU SHOULDN'T BE A PROGRAMMER.
Everyone thinks their shit doesn't stink... more at 11.
Re: (Score:2)
Re: (Score:2)
there's also a bright side: you can write clean and maintainable, fast and reliable applications in PHP
You can right clean and maintainable code in any language. That doesn't make the language suitable for the job or desirable.
Quite frankly, PHP needs to die. But considering how much of it is deployed out there, it is definitely a worthwhile language to learn, just for job security. I learned COBOL decades ago for that very reason and I still make decent money with it to this day, although the language is hateful and totally deprecated.
This so much. But there's more because the kind of people who write in PHP are often (not always) the kind of people who hate software. People who choose PHP simply because that can get them a well paid job and so really don't take a pride in their work. Having watched PHP code at a few companies and seen that it seems to get worse and worse at a higher rate than other languages, this is the explanation I have come to. People who don't care choose PHP which means that people who choose PHP mostly don't
Re: (Score:3, Informative)
I don't think there is much PHP out there anymore...
Have you ever heard of a little platform called WordPress? It has been claimed over a quarter of the top 10-million websites use it.
I'm not arguing that WordPress is any good, nor that PHP is any better, but I think it's safe to say there is still a LOT of PHP out there.
PHP still making money (Score:3, Interesting)
Re: (Score:2, Interesting)
It doesn't matter but it does (Score:2)
Framework design/choice makes a far bigger difference than the app language. All mature languages have ugly sides, and you just learn your way around them.
That being said, it's a fad-driven industry and if you pick the wrong trend/fad, you can get screwed career-wise; so I can understand why one would be hesitant to avoid anything with a "Legacy" stamp on it. Python is currently the "in" language, for good or bad.
I do wish PHP would add optional named parameters, though. C# got me addicted to those.
Re: (Score:1)
Re: (Score:1)
PHP does have optional named parameters though. Not sure if it has since the beginning, but definitely since version 5 at least.
Re: (Score:2)
And all a framework does is enforce good coding standards/structure/architecture anyway, and it makes it relatively easy to do so since it is doing all of that for you.
Without a framework or template engine, etc. it is still easy to write good PHP code, and organize a project well. Just takes a lot of discipline. And using 7.x and doing the proper thing with database queries (prepared/parameterized statements) , etc. And not mixing back end code and front end code and mixing markup and code output and su
Re: It doesn't matter but it does (Score:2)
The reason it's a fad driven industry is because most people don't evaluate new technologies, they just switch to them when everyone else does.
Yes (Score:4, Interesting)
Yes, it certainly is. PHP has made me a ton of money. Paid off my homes, cars, and almost everything else for the last dozen years or so. Vacations, toys, etc etc etc.
But hey, I'm unfairly biased because I tend to approve of things that make me a ton of money.
If I was just starting out, I'd probably learn Python, but PHP is still extremely useful.
Re: (Score:2)
Good job it's not an either or world. :) Best idea is to learn something reasonably well, then add it to a toolbox, and use the right tool for the right job in the right place. :)
Re: (Score:2)
I wrote a PHP app that sold for over $7M to a major corporation.
Re: (Score:2)
I wrote a PHP app that sold for over $7M to a major corporation.
Standby for incoming haters... jealous incoming haters. They'll spend their time telling you how bad PHP is while we're busy printing money with it.
For example, I'm literally sitting in a nice house in a nice neighborhood that was paid for by little ol' me writing PHP here at home in my office, and I own a 2nd house in another country that was also paid for by writing in this terrible, terrible language. Curse you, PHP!!
So yeah, someone please tell me again how awful PHP is, because I can't see it from here
Re: (Score:2)
Re: (Score:2)
A carpenter will argue with another carpenter till they are both blue in the face about what kind of hammer is best. Then when they are done, they'll both go back to building houses with their hammers. Point being? Use the tool that works for you.
I'd say "use the tool that's right for the job, not for you."
You don't want to use a Roofing Hammer for framing, and you don't want to use a Dead Blow Hammer for blacksmithing.
Re: (Score:2)
I'd say "use the tool that's right for the job, not for you."
You don't want to use a Roofing Hammer for framing, and you don't want to use a Dead Blow Hammer for blacksmithing.
Absolutely fair point. I was more referring to the different sizes, weights, handle type, face type, material, quality, etc of framing hammers that area available.
Re: (Score:2)
Absolutely fair point. I was more referring to the different sizes, weights, handle type, face type, material, quality, etc of framing hammers that area available.
Everyone knows that the Husky 22 oz. Milled Steel Framing Hammer is the only one that true patriots use.
The founding fathers all used it, which is why they're called "the framers of the constitution". A lot of people don't know that.
Re: (Score:2)
Of course! (Score:4, Informative)
Re: (Score:2)
Very much agreed. I learned PHP back in the 90's since it was a fast and easy way to get a database backed website up and running. I've moved to python since then, but I'd expect after 20+ years of improvement PHP is still really good at it's core abilities.
That and once you learn the fundamentals of programming with PHP, you can take those skills to your next language.
I'd suggest if you aren't learning a new language every 5 yrs then you may be limiting your potential.
No, it is not (Score:4, Interesting)
Just like saying you worked in QA at one point in the past is carreer suicide, so is saying you've ever worked with PHP
PHP is (probably) a great gateway programming language, but it's not valuable for your career compared to something like Python, and you can find good paying jobs with growth companies using it.
Most companies hiring for PHP developers are not growth companies and PHP jobs pay average at best
PHP is like Javascript - it works just fine... (Score:4, Interesting)
In short, yeah. It's a good enough language to learn because it has real value. If if didn't, PHP wouldn't have outlasted other languages like Perl, Ruby, etc.
Yes - It is true that if you've thrown together "Howl's Moving Castle" platter of procedural PHP spagetti, driven by feature creep while missing sound architecture design and a long-term plan for support, etc. PHP will hate you and your family.
Yes - It is true that if you have to pick up a Drupal/Wordpress mess that someone previously cobbled together with no relevant CMS experience - other than cobbling together Stack Exchange answers, PHP will hurt even more.
But if you hire an experienced developer (ideally one that uses a reliable, supported PHP framework and knows PHP 7.2+), then PHP the language will not let you down.
Just like Javascript - a widely reviled, mocked language than PHP until recently - PHP just has to be wielded by the right hands.
The language has matured. PHP developers just need to follow suit.
(I don't know about the JIT compiler feature. That sounds like shoehorning PHP into a use case it wasn't really designed for, where it will be competing with superior solutions...
Re: (Score:3)
PHP always needed a JIT like caching accelerator to make its performance acceptable. I recall needing to use one in 2007.
I loathed PHP in those days. The consultancy I was working for started pitching Drupal as a CMS and so inevitably they started asking me to write plugins
Re: (Score:2)
It's a good enough language to learn because it has real value.
I entirely agree. PHP is a fine language for the job it performs. The quality of written PHP code is directly proportional to the quality of the programmer writing it. I find that PHP is most reviled by the same type of low-quality programmers who think that their poor performance can be blamed on their tools.
Re: (Score:2)
PERL and Ruby are general purpose scripting languages. PERL is an incredible text processing language that can do damned near anything. Ruby is used in Chef. Python, which I despise (it has significant white space which is literally moronic) , has taken over a lot of the use cases for PERL and Ruby.
Re: (Score:2)
I have plenty of scripts on my linux servers that have been written in PHP. They work just fine and writing them is usually much faster and easier than in Perl, Ruby or Python.
If someone's paying you, then yes. (Score:5, Insightful)
If they're not, then no.
I get paid a load of money to program in PHP and that's handy because it would take a lot of money to make me program in PHP.
Worth knowing, under most circumstances (Score:2)
Unless you are completely the master of your own domain... if you want to get paid for your time versus hobby programming or FOSS project volunteering - the languages you'll need to use are going to be at least partially driven by the choices made by others. You're not going to walk into a job and have the latitude to choose what you'll be writing your code in, nor what platforms are being used.
While I don't particularly like the language, if you need to do more than trivial support for any popular web CMS
With a decent framework, yes... (Score:2)
For anyone using Laravel (which uses substantial parts of the Symfony framework) the answer is undoubtedly yes. I have an easy to install, excellently documented framework with lots of features out of the box. It's on par with Rails (largely because founder Taylor Otwell takes the Rails as part inspiration).
Package management: Composer packages through packagist are readily available. All of AWS covered, most major SaaS companies (HubSpot, Pipedrive etc) have SDKs for PHP. Admittedly some packages are of po
It's a shame (Score:2)
I have used PHP since 1997, where appropriate (web middleware) or easy (scripting). Python is slower and you can do anything with it that PHP does, with a standard set of idioms. Now that I can spin up 10 machines, that's not such a bad tradeoff. Reading PHP now is a lot like reading Java and that's the fault of The PHP Development Team. Like JS, they are SLOWLY morphing the language into something to gain traction outside of their niche, as if breaking backward compatibility over time will give PHP the bes
Re: (Score:2)
Such a low user number, Such a low amount of useful information.
No. (Score:1)
Uh well... you could do worse. (Score:2)
What would you use for dynamic websites instead? (Score:3)
Re: (Score:2)
what simpler way than HTML5, CSS3, MariaDB and PHP?
HTML5, CSS3, PostgreSQL or MariaDB or SQLite, and Python.
Python is not venomous. Python gives hugs.
Re: (Score:2)
Re: (Score:2)
You wouldn't really want to build something up "from scratch" but using one of the many Python webapp frameworks makes it easy. Django is popular, though I don't use it myself, and if you're curious here's a tutorial showing how to make a very barebones blog app off Django in python: https://djangocentral.com/buil... [djangocentral.com]
Flask is another popular framework, although does far less than Django, but I like it for what it does. It's lightyears better than working in PHP in my experience. Python generally just makes
Re: (Score:2)
PHP is just as good as the programmer is (Score:2)
Anyone can write crap code with any given language.
WTF? (Score:4, Insightful)
Is the most popular and most used scripting language on the Internet worth learning?
What the fuck, are you a fucking moron?
90+% of the Internet is running on PHP.
Yea, listen to the fucking idiots here who say no. Also, buy Bitcoin.
Horses for courses (Score:2)
There are many tools to master.
Churn and more churn (Score:3)
If you're going to ask a such a leading question with the answer of "no", at least provide an alternative that's superior in every respect (including ease of programming, popularity, and so on). Until then, programmers have to churn through learning every single programming language in hopes that one of them is in demand.
Instead of burning energy on making these questions, they could instead be focused on making tools for better programmers and their practices- make it easy to write and debug code, not worry about fiddling with compiler settings, update the documentation that explains replacement for deprecated functions, etc. Software development is paraded as a profession - lets treat it as such rather than keeping it like ad-hoc alchemy.
And unlike the OP, I'll make a recommendation myself: INTERCAL.
Yes. Absolutely. Here's why: (Score:3)
Disclaimer : I do PHP and WordPress for a living. A good living. And I get to leave work at 17:00.
PHP is a language that shows how domain specific languages look like when they do their job well. PHP makes the server side Web trivially easy compared to anything else out there.
It goes something like this :
- No memory leaks. Only the occasional timeout.
- Stateless? Nope. You can have all the state you want. But only for 3 minutes.
- Check out our awesome integrated deployment process: Copy. Paste. Done.
- 3000 projects on one host. 0% CPU load.
- We run bad code really really well. IWhat do you think made WordPress so successful?
My time to market for any project is roughly 10 days. And that's because marketing takes 3 days to agree on their logo. In a nutshell: PHP - Getting the job done since 1994.
Welcome to the club.
Second that assessment (Score:2)
Well said. My experience is similar.
I'm writing a simple WP plugin for a client right now today, good money fast and easy.
3 minutes is my default ... (Score:2)
... for script runtime on Apache. I think it's actually the Debian default. Not sure about that though.
The web's COBOL (Score:2)
What is not so good is that PHP devs are everywhere and AFAIK, the pay is not so great. But I guess that a good PHP dev with up to date skills can probably make his/her own money.
You are implying bosses are competent. (Score:2)
The overlap between bosses who demand PHP and bosses who are competent is pretty much zero. Nobody cares if you are competent. Nobody could even tell. :)
It never was. (Score:2)
This is like asking somebody who never drinks: Do you still drink a bottle of booze a day, or did you stop?
As somebody who had the "pleasure" of professionally coding PHP for five years: ... and it would work!! Because any unknown identifier is interpreted as a string literal (WTF#1) and any expression with a return value that i
The languge is a joke. Worse than JavaScript. All language parsing rules seem to be tacked on ad-hoc. I remember writing lines of code, then a line with a random word, then more code
Re: (Score:2)
I would never code life support machine using libraries, that just isn't a safe way to write code that absolutely cannot fail.
As an add-on maybe (Score:2)
well (Score:2)
No, but that is no surprise (Score:2)
Not just no, but fuck no (Score:2)
The great thing about PHP (Score:2)
The great thing about PHP is you can write absolute garbage code, and it'll still run.
The bad thing about PHP is you can write absolute garbage code, and it'll still run.
No (Score:2)
I decided to at least learn the basics (Score:2)
I'm not necessarily going to try to become proficient at it, but I think I should at least be familiar with it.
Just now I started out with PHP Tutorial [w3schools.com]. (Your basic "Hell! Oh, World." lesson).
I'm mostly a C person. PHP is something I've only glanced at before. So I did the first exercise and then took the quiz [w3schools.com]
I admit I was blindly guessing at a lot of them, but despite all the horrible things I've heard about PHP I decided to guess the way that I thought made the most sense for some of the ones I truly
Re: Why "still"? (Score:4, Insightful)
Re: (Score:2)
Re: (Score:3)
Re: (Score:3, Interesting)
I use perl, by choice, with NGINX, on Raspberry Pies. It works great and is for me a lot easier to program and understand than PHP, which is still a fractal of bad design.
Re: (Score:2)
Parroting an antique old article that 1) you've never read 2) is out dated 3) was never accurate to begin with.
Also, Perl? Easier to understand and use than PHP? Just how retarded are you anyway? If you were still using Perl after 2002, you're a lost cause. Everyone moved to PHP because it was better in every conceivable way.
It's still better than just about every alternative. That's why everyone still uses it despite the countless challengers over than last 20 years.
Hate PHP, fine, but everything else
Re:Why "still"? (Score:4, Informative)
There was never a time when Perl CGI was the only option. There was a time when it was dominant, but that's not the same thing. You could have been writing CGI in C if you knew it. All you had to do was send "Content-type: text/html\r\r" and start spewing HTML, and maybe parse some environment variables or STDIN for form data. I used Perl too, because I didn't know anything but BASIC and Perl was easy to learn, but it was never mandatory.
I used shell scripts for some of my first CGI, too. And I had one of the earliest dynamic hobby websites on the interwebs, my ancient drinking games website "drink's games". (As featured in Xnet magazine.) I started with static pages, then moved to using shell scripts to generate the content from CSV and flat files, and then changed it to use Perl with the same content before using Perl and MySQL.
Re: (Score:3)
Indeed. I still demonstrate that to students today. Any language that can be used to create executables that can read stdin, write stdout and can read the environment variables can be used to do CGI. With a simple wrapper script, even Java can be used.
Re: (Score:2)
My website https://www.transsee.ca/ [transsee.ca] uses CGI written in Free Pascal, a compiled language. The Free Pascal library has code to take care of the CGI stdin/stdout interface, so I only have a vague idea how it works.
The nice thing about CGI is that the process only exists for the time require to generate the page, so I often don't bother freeing memory. There are probably some performance benefits of switching to FastCGI, but there other bigger performance issues.
Re: (Score:2)
There was never a time when Perl CGI was the only option.
For instance, there was mod_perl. Which Slashdot was written with. I wonder if it still is.
Re: (Score:2)
PHP is proof that something can fill a vacuum and still suck.
Re: (Score:2)
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
ASP.NET was a JSP wannabe that attracted a less competent class of developers and sysadmins. Classic ASP was even worse - it was like PHP but with VBScript as the language embedded in the HTML.
Re: (Score:3)
PHP was something for cold fusion developers to migrate too and claim you could even manage your system with it.
I have forgotten how much bad there was in that language.
If you want to get a job maintaining terrible PHP code it is probably worth learning. However, if your aim is to maintain legacy code then just get into cobol.
Re: (Score:2)
Re: (Score:2)
Re:Even more now (Score:5, Informative)
PHP 6, as I understand it, was a failed attempt to do the same sort of split between 8-bit strings and "Unicode" strings that Python 3 did. After UTF-16 was discovered to do more harm than good, the team refocused on making 8-bit strings encoded in UTF-8 the standard.
Most other language features developed for PHP 6 ended up backported to PHP 5.3 and 5.4, with other language and library cleanups occurring over 5.5 and 5.6. This gave a stronger foundation for the interpreter rewrite that formed the basis of PHP 7. The language still has its quirks [pineight.com], many of which parallel those of JS, but it's no longer quite as fractally wrong [rationalwiki.org] as it was in 2012 when Eevee wrote her infamous rant [eev.ee].
Re: (Score:2)
Hear, hear. I use PHP daily. I wish there was something that was objectively better than it, but there isn't.
PHP is the worst possible web development language. It's just better than any other one we've actually tried.
Re: (Score:2)
* There's the IBM Stack which is Java, Rational Application Developer, Websphere, DB2. It has healthy licensing fees.
* There's the Microsoft Stack which is C#, Visual Studio [microsoft.com], SQL Server. That too has healthy licensing fees. I can't imagine Microsoft would let a free download compete with a 6K-7K a year subscription product.
BUT... IBM will allow you to download all their products for free IF you promise only to use it on a single user development PC. But... put it into production, and they catch you - that
Re: (Score:2)
It doesn't have meaningful white space. It's also significantly faster. It's also trivial to deploy a PHP application. That last bit is why it's outlasted just about every other competitor.
I don't get the love for Python. It is really, really, poorly designed. (Just one example, the poorly designed syntax is why lambda's are forever crippled.) I'm shocked that someone would bash PHP and praise Python. I figured that you'd either bash both or simply be indifferent to them.