13 ms·
Choosing PHP in 2022 and beyond
- dabernathy89 4y agoMaybe you're not a PHP developer, but you probably have some kind of skill to teach others! We're looking for talk ideas on a variety of topics such as accessibility, devops, frontend, testing, programming patterns, tooling, and more. I wrote up this quick post to tell you why PHP is still relevant and why you should consider sharing what you know with PHP developers.
- ttctciyf 4y agoAs a talk idea, "Everything you know about PHP is wrong" has no direct hits as a phrase search on google, and, judging by the comments that PHP generates on hn, might have some mileage. You'd need someone with unimpeachable domain knowledge and ready access to asbestos underwear to deliver it though!
- hgazx 4y agoPhp will never be able to shake off its legacy. It’s a lost cause imo. Which is a shame since it’s faster than most (all?) languages in common use for backend development of websites.
- bilekas 4y agoHave you checked it out recently? It's unbelievably improved from the days where you could write spaghetti code.. they really put a lot of effort into beat practices.
- deleted 4y ago[deleted]
- ttctciyf 4y agoCongrats on your eye-catching title :)
- echelon 4y agoPHP is great for people that know it and are productive in it. For legacy codebases and software. Newcomers should learn to use something else. Go, Ruby, Python, Node, Nim. The tools are better, more modern, with broader library support, and you can use the languages in more ways throughout your career.
- dabernathy89 4y agoI agree with you on portability. If that's a concern, and you're a web developer, I'd say TypeScript is a more obvious choice than Go, Ruby, etc. Re: "tools are better, more modern, with broader library support" - I would need a lot of evidence to convince me this is the case, particularly for Ruby and Python.
- Ensorceled 4y ago> I would need a lot of evidence to convince me this is the case, particularly for Ruby and Python. Both Django (python) and Rails (ruby) are great, popular and well supported environments with very "broad library support". This is a bizarre statement.
- dabernathy89 4y agoWhy is that evidence that they are _better_ than PHP's ecosystem? That's the claim I'm skeptical of.
- Ensorceled 4y agoI just found it weird that you singled out the two languages that are the basis for two of the most popular web development frameworks.
- phpisthebest 4y agoSo your defense of broader library support is that each of them have one framework to choose, where php has dozens of web frameworks, all of which have broad library support (often sharing libraries between them)
- sigmonsays 4y agodespite it's terrible APIs it was fast and easy to setup and manage. Speaking from over a decade ago here.. My experience was good with PHP for simple web applications. However any form of concurrency can't easily be achieve with PHP, so that limits the types of applications you can build easily. Today, you'd be much better off picking up a language that provides concurrency primitives and has tools to build simple pages w/ a request/response flow. Just my $0.02
- dabernathy89 4y ago> any form of concurrency can't easily be [achieved] with PHP This was true 10 years ago. Not so today - the tools are there, and the frameworks are making it simple to deploy them. https://twitter.com/aschmelyun/status/1548270721964462081 https://twitter.com/aschmelyun/status/1548270721964462081 https://laravel.com/docs/9.x/octane https://laravel.com/docs/9.x/octane https://openswoole.com/article/symfony-swoole https://openswoole.com/article/symfony-swoole But more importantly: the vast majority of apps don't need this. PHP by itself is fast enough for most use cases when set up properly.
- ozim 4y agoFrom my understanding of how php works it should be "concurrent" by default - each request is handled by web server and then php interpreter is running code in concurrent manner. There is some shared context that is session for example but how I understand it each request is concurrent anyway. Is there support for running single script continously?
- kyriakos 4y agoYour first point assumes that you always run a web application. PHP can be used for general purpose scripting as well. Also even on a Web context how would you support websockets with traditional php? You can how achieve that with swoole.
- dabernathy89 4y agoThat's one way to look at it, but there is much better support now for writing code that behaves concurrently within a single web request.
- s-xyz 4y agoWhat is the market share of developers using PHP? Having difficulty finding it?
- idontpost 4y agoPull the other one.
- dbbk 4y agoWhat do you think is better?
- TylerE 4y agoAlmost anything?
- dbbk 4y agoYou can't have a discussion being this vague
- adventured 4y agoThe many people posting Reddit-like spam comments (ie zero value, attack focused) in this thread are not attempting to have a dialogue. They're just here to attack.
- idontpost 4y agoI assume you didn't see the original title, which was zero value, aggrandizing nonsense. > PHP Is the Right Choice in 2022 and Beyond
- TylerE 4y agoOk, any of: Python, Rust, Go, Swift, C#, Java, Zig, Nim, D...
- dabernathy89 4y agoI don't understand this comment
- the_biot 4y ago
- labrador 4y agoIf I were in charge of giving out awards I would give PHP the "Most improved language of the 21st century." PHP3 at the turn of the century was trash but it was easy to build websites with it and it was easy to find people to do so for you. PHP8 is a world away from PHP3.
- leeoniya 4y agoi would say JS (both the language and the VMs) has come even farther
- labrador 4y agoI agree if you include the TypeScript scaffolding
- sshine 4y agoAnd why not? TypeScript really is a feature of JavaScript in many ways.
- upupandup 4y agoPython is a better candidate imho mostly because of the explosion in its use case in the past decade, especially due to data science/AI fields. I have a hard time going to another language that requires appending semicolon at the end of each line, dealing with curly brackets, and requiring a bunch of middlelayer tooling. I'm willing to bet that I can train someone without any coding experience in Python. It's built for readability and very accessible. Javascript? No way I would introduce them until they get some handle. PHP? Not unless I am trying to create a sweatshop.
- dabernathy89 4y agoOof - I find Python very ugly to read. Give me semicolons and curly braces any day.
- 4y ago
- sshine 4y agoI've worked with PHP throughout 2020, and it is still the worst crap I know. Static typing: We're not there yet. Lack of generics means arrays can contain anything. Not even close to TypeScript, and let's not compare to functional languages. Types in PHP is still duct-tape. High performance: Nope. PHP is fast compared to what PHP used to be, but PHP is not fast compared to compiled, optimizing languages. I'm sorry, but this claim of PHP being a performant language is either delusional or unambitious. I basically have not been in contact with PHP in the last two years where performance wasn't a serious problem. This isn't entirely because PHP performs bad, but largely because PHP programmers, on average, have a weak understanding of CS principles. I don't mean to bash any individuals; I saw a talk by a PHP programmer, whom I have great respect for, as late as yesterday. Incidentally, the talk was about how to make DSLs in Rust. Maybe if all you did was PHP, PHP is pretty great. The killer feature of PHP is that you can always find cheap labor.
- rboes 4y agoCouldn't agree more
- sergiomattei 4y ago> High performance: Nope. PHP is fast compared to what PHP used to be, but PHP is not fast compared to compiled, optimizing languages. Well, duh. It’s fast for its class of language. > but largely because PHP programmers, on average, have a weak understanding of CS principles Way to generalize and dismiss a whole class of programmers in the field. Do better.
- sshine 4y ago> [PHP] is fast for its class of language You mean loosely typed scripting languages? I won't disagree with that. > Way to generalize and dismiss a whole class of programmers in the field. I don't intend to be mean. PHP programmers have fewer years of formal CS training, on average. This isn't controversial.
- sergiomattei 4y ago
- phpisatrash 4y ago
- TylerE 4y agoThis is the sort of comment that keeps people from taking PHP seriously.
- dabernathy89 4y agoRead the username. It's trolling.
- cozzyd 4y agoI'm sad to hear they finally fixed this ridiculous behavior: https://wiki.php.net/rfc/ternary_associativity https://wiki.php.net/rfc/ternary_associativity
- dabernathy89 4y agoOn the other hand, nested ternaries are pretty awful even when they work as expected.
- TylerE 4y agoTernaries are just a mistake, period.
- dabernathy89 4y agoI use them all the time, as long as they can be written legibly. $result = $someCondition ? $foo->abc() : $foo->def(); To me that's much nicer than an if statement.
- kaba0 4y agoI believe parent commenter was thinking of if expressions, which are quite similarly short - and I’m also on the opinion that they are much more readable and less prone to mistakes (like how does nested ternaries operate in your given language)
- Dudeman112 4y agoThe problem with ternaries is people getting so excited about it they build some one line monstrosities that really should be broken down into more lines And for what's not a monstrosity to begin with... It's not a monstrosity to begin with, you ain't gaining much
- wizofaus 4y agoI'd kinda like to see a language that allowed ternaries but only when the components were sufficiently simple, e.g. no compound ternaries or even no more than a single arithmetic/boolean operator. Though enforcing it with linter rules is probably the better option.
- slt2021 4y agoPHP is a great language to get stuff done, absolutely love it
- vorpalhex 4y agoEvery php project ends up hitting the "php lifetime of the request", writing a terrible cronjob system that never works and you get super into the weeds of debugging some garbage job system. Or, better yet, you load a billion deps on every request and your request time is atrocious.
- sshine 4y agoThat is funny. I've had the exact same observation.
- kevingadd 4y agoIt's impossible for me to take anyone seriously if they suggest picking PHP for any new project or deployment. Yes, there are existing high-quality services and libraries written in PHP and some of them have amazing communities, but that's true for any programming language, and many of those other programming languages aren't PHP. I recognize that people have extensive investments in PHP, and I won't tell them that they have to throw that away, but don't try to drag newbies into the muck, please. PHP is a fundamentally broken design for a scripting language and the decades of heroic work from its maintainers cannot change that the basic underlying design was bad from the start. You can only fix so much without just devising a new language from scratch and somehow getting people to migrate, and at that point, they could just migrate to a language that doesn't have all the baggage and a bunch of old (now inaccurate?) documentation and old broken code floating around. At one of my first paid engineering gigs we ran a social game for 10m+ users where all of our online services were backed by PHP - live chat and state updates for the game's native PC client went over http and were stored in memcached/sql, we did transaction processing for user-to-user cosmetics sales, we had forums and custom user home pages, etc. Underneath all of that we had to build some complex systems so we had weird things implemented in PHP like distributed locks for cross-server concurrency (yes, really). We were able to get a lot done in PHP, which I guess is to its credit! On the other hand, PHP was a constant nightmare. Every single line of PHP we deployed was a liability and a lot of it was stuff we didn't have much visibility into. Once some random popular package we used for our forums - the coppermine photo gallery i think? or maybe phpbb itself? - was used by an attacker to jump in and exploit vulnerabilities in OTHER popular php packages we were using like osCommerce and clear all our payment processing configuration, making everything free without registering in the logs. I spent probably upwards of a dozen hours that friday night and early morning reading over every line of those packages with some colleagues to try and figure out WTF was happening, and it was SO difficult to do that audit because every single line of PHP was potentially hiding an assassin that wanted to stab you in the neck. To be able to ship and maintain our software at all we had to write an incredibly extensive set of automated unit and functional and integration tests, we required regression tests for every single fix and multiple tests for every new change because without that kind of rigor it was impossible to run a real service using PHP. Naturally we had to build most of the automated testing infra ourselves because the state of the art PHP testing frameworks were bad. Later on we had another fun bug where the PHP unserialize() function was deserializing 4.0 into 12.0 (yes, really... though it may have been a different constant). I spent hours w/a colleague reading over PHP's C implementation trying to puzzle out how this could happen and in the end the conclusion we came to was that a .dll our payment provider required us to run in the PHP server was changing the floating point rounding flags for the thread, and not only did PHP not control its own rounding flags but it was extremely vulnerable to having them changed. Frustrating. (This is of course something that could happen with any language, but the low quality of PHP's underlying implementation made it more impactful) Also... WordPress. When's the last time someone ran a wordpress install without it getting hacked? I don't think I know anyone who's successfully kept one up without getting owned. I lost at least one website because the shared hosting instance kept getting hacked via other people's wordpress installs until the server's owner gave up and took it down. Over time PHP certainly has improved but I've used dozens of horrible languages and I think I would pick almost any of them over PHP if only because every time someone I know has used it they've ended up paying for it later. I would sooner write tens or hundreds of thousands of lines of VB6 or Perl or AS3+Flex than have to write and deploy a thousand lines of PHP because I just know the PHP would end up being a liability somehow. If I could wave a magic wand and disappear one piece of software from history, it would be Bitcoin, but if I had two choices the second one would be PHP. Of course, this would probably be a setback for the progress of technology somehow since PHP empowered a lot of newbies and amateurs to ship working software, but we need only look at the long trail of mayhem and sorrow to see the cost they paid for shipping it using PHP.
- nullfish 4y agoI've been using PHP for our latest venture after 8+ years of node.js and it's become the de facto language to use at our company. Anyone writing comments about "scaling" or "performance" has never had to deal with a half-baked application written by some junior node.js developer who thought their microservice had to be Internet Scale(tm) PHP is a great choice in 2022. Hell, it'll be a great choice in 2032 I'm sure. The tooling and debugging that PHP provides is incredibly powerful. Developers are easy to find, it's easy to pick up (which sure makes it easy to get wrong), but those who get it right will do it incredibly well. Arguments against PHP are lead by developers who think they're smarter than they really are.
- ankaAr 4y ago
- pluc 4y agoI always get a kick out of seeing the HN Who's Hiring thread and searching for "PHP". Results in actual job requirements are rare, but most URLs people link all end with .php. It's such a funny double-standard.