35 ms·
PHP is worth learning and using
- cblconfederate 5y agoHey if you don't like PHP please don't use it. I 'd hate to bring the culture of tiny packages, fake compilers, transpilers and weekly trends to PHP. Personally I use php because it works well and fast and still supports my 10 year old websites, not because it's cool.
- unobatbayar 5y agoI like PHP and still use it today. But never in my life heard PHP is cool. Am I missing something?
- reidrac 5y agoWell, early 2000s it was definitely cool. Using ASP and want to calculate an MD5? Oh, you need to pay an add-on for that. Want to send an email? Ditto. Then there was PHP, with all included (and cheaper hosting, because Linux). I started working on a web shop and after a month ASP was legacy and PHP the new cool thing, together with MySQL instead of using... Access as "database" in ASP.
- grvdrm 5y agoI was new to the world of software development in 2000 (in high school) but immediately loved PHP / MySQL. Made it easier for me to stand up websites for my two bands and integrate more dynamic and database-oriented features into those sites. And hand-wrote JS for things that at the time seemed cool (silly in retrospect hover effects). It was the SQL part of the book that helped me build the SQL skillset that is an integral part of my day job. Used a book similar to this one: https://www.thriftbooks.com/w/professional-php4-programming_john-coggeshall_jon-parise/1185659/ https://www.thriftbooks.com/w/professional-php4-programming_...
- codegeek 5y ago"Access as database in ASP" haha. My first ever project as an intern in 2004 was exactly this.
- tehbeard 5y agoThey're making a rhetoric against JS style of development... Though I question what they mean by fake compilers...
- mclightning 5y agotranspilers*
- hagbard_c 5y agoA compiler translates code from a source language into a target language, normally targeting either physical hardware or some virtual machine. That is not what happens when "compiling" - or more accurately, "transpiling" [1] - JS-related software where what often feels like the JS-related dialect of the day (coffee-, mocha-, type-, tea-, frappucino-, latte-, pilzener-script) is converted into the resident JS dialect, discombobulated through some language feature thingamajig, transmogrified by some other package-combining gizmo (not the same gizmo as you used last week, that is now ancient technology, the new one is sooo much slower^Wbetter and has a snazzy content-less website to prove it), mixed and matched with a bunch of related packages many of which are marked with dire warning about bugs and staleness by the helpful package manager thing (which you had to update before even trying to proceed since the current version was no longer supported even though you're running version 12 and the box stated you needed at least version 9), uglified (as if it wasn't ugly enough already) and zipped up. Doesn't all that make you long for the days of ./configure --prefix=/somewhere/sane && sudo install -d -o yourusername /somewhere/sane && make install? Just add empscripten to the tool chain and you can do web things with it, sort of... [1] https://en.wikipedia.org/wiki/Source-to-source_compiler https://en.wikipedia.org/wiki/Source-to-source_compiler
- 2-718-281-828 5y agoIf people call something "cool" - that's actually a red flag for me.
- kettleballroll 5y agoThat sounds fairly childish. Aside from the very obvious fact that you'll miss out on a lot of cool stuff, if you don't agree with the value judgements of your peers, the problem most likely resides with your choice of peers.
- 2-718-281-828 5y agoRed flag just means that you take a close and critical look - not that you automatically dismiss. And those "peers" are the people on the internet - f.x. blog authors.
- corobo 5y agoHow's that policy working out for you? If I did that I'd have missed a hell of a lot of cool stuff in life haha
- 2-718-281-828 5y agogood, I'd say. I'm not waiting half an hour in a queue in front of a hipster ice cream parlor. when I go into nature I have a good chance of actually finding some peace b/c I do not go where Instagrammers take their selfies. I'm not torturing my soul on TikTok. I use choose technologies conservatively instead of by hype cycle. List goes on.
- corobo 5y agoSounds like you've got one of those "I just sorta hate everything" anti-personalities haha Have a goodun
- davibu 5y agoI would love not to use it, but I'm compelled to. It is not only my choice, but the choice of others who are not interested in new languages (assuming that Python is new language...) and prefer to use PHP because they don't know anything else. So yes, let me express my antipathy toward the PHP language and its ecosystem. I work not "well". It has hundred of issues that are not, and will never be addressed. Like the inconsistent choice of function names, the antic (if not prehistoric) way of extension managing, the clumsiness of xdebugger, the bugs in the PDO library, etc. I spend 80% of the time trying to figure out "a hack", and spend too much time on php.net & stackoverflow hunting for the right answer.
- Ayesh 5y agoOh well we are about to break most of said 10 year old web sites. Particularly, PHP 8.1 has some changes that low key force people to update, such as the use of return types when extending a built-in classes (https://php.watch/versions/8.1/internal-method-return-types https://php.watch/versions/8.1/internal-method-return-types).
- maverwa 5y agoYeah, the area between "backwards compatibility at all costs" and "progress" is full of potholes. I think PHP was to mach on the "backwards compat." site of that gradient, I think that some bc breaks are onavoidable when improving the language itself and its standard library. Sure, it would be nice to have something like rusts "editions" (and I am sure other languages share that concept to some degree) where we could have the runtime support all code that was valid before, but that comes with its own complexity. As someone who still owns their rent coding PHP, I really enjoy the development of the language from php 7 onwards. It certainly feels better in any way compared to the 5.x or even 4.x days. As long as we do not get another python 2 vs 3 disaster, I am happy.
- jbergens 5y agoPhp change from 4.x to 5.x broke my web sites and I still don't trust php after that. I guess they might do it again from 7.x to 8.x, we'll see. If having the same code working for a long time is the most important for you then you should probably use java or .net. Maybe c++ also but that is not as popular for building web apps.
- sdflhasjd 5y agoPHP are deprecating language "features" from 7.x to 7.y. It's very hard for me to treat a language seriously when I could write code that simply won't be valid PHP in 2 years time, or worse, behaving differently. Given the severity of some past PHP vulnerabilities, being on an old version can certainly be a problem. > I guess they might do it again from 7.x to 8.x, we'll see. PHP 8 has some _massive_ breaking changes
- cblconfederate 5y agoI found the transition from 4 to 7 oddly easy, but that might just be the conventions i was using. I don't know about 8, don't plan to use it until i have to
- Viliam1234 5y agoI made my homepage in PHP, nothing important, but I spent some time doing it and I liked the result. Then I didn't have enough time to maintain it, and I stopped paying attention to it for a while. Later I checked my homepage again, the webhosting company updated the PHP version, nothing works anymore. It is not simple to fix, so I gave up. I am not going to spend the same amount of effort on making my homepage in PHP again. Trust is easier lost than gained. I would still be willing to code something in PHP for someone else, because hey, if it stops working in a year or two, it's their problem, not mine. But I would warn them that something like this is possible, and in my opinion likely to happen.
- tommek4077 5y agoThere are package managers, yes, but probably you won't need one. Because of the mighty standard library. Thats a big advantage, compared to the tiny-package-mess at npm.
- brandon272 5y agoI have used PHP for years. Like it. Have accomplished some nice things with it. Think it's evolved nicely in recent years. Feel it's a great tool for particular problems. Will continue to use it. Will always be open to alternatives. Will never understand why some people find that so offensive and will tell you that you mustn't use it or imply that you are ignorant or stupid for using it.
- cityzen 5y agoand the best part is they're probably javascript developers that don't understand the hell they're living in.
- crate_barre 5y agoNow, why’d you have to get JavaScript involved? Can’t something else be a punching bag?
- askonomm 5y agoSo your response to the haters is to be a hater yourself? Why can't we just get along?
- todd3834 5y agoPretty rare to find someone who writes a lot of PHP without also writing a lot of JavaScript. If there are JavaScript engineers who’ve never touched PHP then they probably don’t have much feelings about it at all
- klyrs 5y agoI haven't used PHP for years. I did some Python-based web stuff for a while. Python is a daily driver, but I still reach for PHP when I want to make something that responds to HTTP requests.
- rp1 5y agoI haven’t used PHP in over a decade. I can never forgot how much PHP got wrong in terms of how application development on the internet would happen. The ergonomics of using it were just… bad compared to other frameworks that came on the market. I remember when rails came out and it was so mind blowing compared to PHP. The language was certainly useful for a time, and I’m sure the language has progressed since, but switching to PHP still feels like it would be a huge step backwards.
- yegle 5y agoFor me the main turndown of using PHP is when I need to host the PHP website, php-fpm and Apache+mod_php seem to be the only two options. (FastCGI doesn't even have a proper specification).
- azophy_2 5y agoswoole is a pretty interesting alternative as it allows asynchronous programming in PHP. roadrunner is a PHP server developed using golang, utilizing goroutines for high performance. both used by Laravel Octane, providing very easy integration with the framework. Other than that, php-fpm & FastCGI allows integration with many interestin webserver including Nginx, Caddy, Lighttpd, etc.
- yegle 5y agoRoadrunner looks cool, thanks for the recommendation!
- lessname 5y agoI would be a little bit careful while using swoole. They added some code that loaded code from a third party server [1] (a core developer who seems to be located in china). Even though it seems like they removed it doesn't bring a good feeling. It seems like there were also some disagreements with a contributor who maintained the website of swoole and he forked it [2]: https://github.com/openswoole/swoole-src https://github.com/openswoole/swoole-src [1] https://github.com/swoole/swoole-src/issues/4434 https://github.com/swoole/swoole-src/issues/4434 [2] https://news-web.php.net/php.pecl.dev/17446 https://news-web.php.net/php.pecl.dev/17446
- fogihujy 5y agoLitespeed, or Apache+mod_lsapi are excellent alternatives. If self-hosting, Nginx and FPM is well-tested and very fast.
- andix 5y agoThe only argument is: you can deploy your PHP app on any 1$ shared hosting plan. Just copy the files and you’re done. And yes, PHP is not as bad as it used to be anymore. Apart from that, I don’t see a lot of benefits.
- redm 5y agoI really don't understand all the PHP dismissal on HN. As a language it has continued to evolve in meaningful ways, especially with the latest releases. Companies like Facebook are built on PHP (yes, they extended with Hack, but most of the benefits are available in PHP 8 now without the downsides). Coming from a C background, I found PHP easy to step into as many of of the underlying libraries and common functions are wrapped and available in PHP (with similar names).
- chespinoza 5y agoSame background and that's the same I used to think years ago before learning Python, after Python and after reading awful spaghetti code in PHP 15 years ago I ended up hating it, I haven't touched nor read PHP code since then, maybe now it's better? but really with all the PLs we have available today, at least to me there's no incentive to touch nor read it again.
- dimitrios1 5y agoOne thing I've noticed is people who code in PHP for work or projects don't bother to come on here and try and defend the language. It's underrepresented, but maybe the groupthink ship against PHP has sailed here a long time ago, they don't bother. Or perhaps, more likely, they are too busy creating.
- tedivm 5y agoWhile I primarily program in python these days I have two major open source PHP projects (millions of downloads each). I was also part of the standards group that tried to modernize some aspects of PHP (to various degrees of success). In general I would never bring them up on this site. It's just not worth my time or effort. I've even gone so far as to ask people who have posted my blog posts here to take them down. Hacker News has one of the worst groupthink cases in tech, where if you speak against various core beliefs you get absolutely hammered with trolls both on the site and off of it. Having a reasonable discussion about the pros and cons of PHP is just not something this site is capable of supporting.
- 5y ago
- amacalac 5y ago<?php echo "oh you!"; ?>
- dolni 5y agoThis seems like a desperate attempt to justify not moving on from a language whose death knell rang a long time ago. You might as well try to convince me I should start my next business with cutting edge software written in Fortran or COBOL.
- exclusiv 5y agoNobody cares about convincing YOU; you made up your mind a long time ago and could care less about all the nice things in PHP 8, the performance improvements and the massive ecosystem and huge parts of the web still driven by PHP.
- ianhawes 5y agoIs there a preferable language?
- deleted 5y ago[deleted]
- sumanthvepa 5y agoI consult with startups a lot and routinely program in a variety of programming languages -- C++, Java, Swift, Kotlin, JS/NodeJS, Python, Ruby, PHP and a bunch of bash,awk,sed and perl. Most of these languages have been evolving to support most modern programming styles and have package ecosystems that are well managed and relatively easy to use. The point is not to prove that one language is better. For the most part, for web development, there isn't much difference in productivity for a programmer competent in the language between (JS/NodeJS, PHP, Python and Ruby) Java is a little more heavyweight for pure web development but if you have a bunch of backend services that need to be reliable you will find the type system to be of help.) What is more important for productivity is a deep familiarity with the frameworks, and tools -- the IDEs CI systems etc. that you need to build and deploy your solution. The other important thing is the ease with which you can hire programmers for that language in your market. Here in India finding PHP programmers is easier than say finding Kotlin programmers but harder than finding Java programmers. But that is not the case in other markets like the US. There is also the issue of perception of candidates. If like you, a large majority of candidates think the language is legacy, you'll end up having to pay more to hire them (because they will be harder to find -- most of the extra cost will be search costs not salary costs.) To the extent that the PHP community can convince folks that it is not a legacy language (and it really isn't) that is good for not just the language but the overall tech community. And this article furthers that goal well.
- anm89 5y agoThis seems like a false dichotomy. Is php totally worthless in 2021. Absolutely not. Is php the best language to spend your limited time learning in 2021? Almost definitely absolutely not as well.
- cityzen 5y agoDid you read the article?
- brailsafe 5y agoBut, what is, if not php? Do you shoot for what has had longevity, or what's rising?
- guitarbill 5y agoIf you could predict the future, it'd be easy. And you can pretty much learn any language. The question is who's hiring/where will you work, and what will you work on? In my area, there aren't many PHP shops. So it could be Wordpress or Facebook/Meta. PHP might be long-lived, but if you have to relocate to find a PHP job, does that help? Same with e.g. COBOL, Sharepoint, etc. And to be fair, what's rising has that problem outside tech centres. Something popular like Python is generally a "better" investment, covers more bases.
- eyelidlessness 5y agoI can’t tell if you’re arguing for PHP or against COBOL. I kid, but a lot of the other languages/ecosystems people will consider investing in are at least as old and evolving right alongside PHP. Many of them with very similar evolutions.
- brailsafe 5y agoYa that's basically what I was getting at. Not about COBOL, but about others that are similarly long lasting in the market, dynamically typed, and general purpose.
- anm89 5y ago
- mikl 5y agoPHP is an ok language for web frameworks. But for most other things, it is a poor fit. There’s a reason why people are generally not doing scientific computing, machine learning, hardware integration, systems programming, etc. in PHP (yes, there are likely some obscure projects doing all of those, but in general, it’s not done because of limitations in the PHP runtime). If you already know PHP, you can probably have a long and healthy career in that space. But if you’re new to programming, you’ll probably be better off learning Python or Rust, or maybe one of the platform-oriented languages like C#, Kotlin or Swift. JavaScript is also a very popular choice, because it’s currently the only thing you can easily use in the browser, but that might change with the rise of WASM.
- postalrat 5y agoAnd there's a reason why people are generally not doing web stuff in python or rust.
- __float 5y agopeople aren't doing web stuff in python?? django, flask, etc. are still very popular. maybe not as much as a few years ago, but people tend to stick to tech they know well, and python's web libraries are pretty battle tested at this point.
- mikl 5y agoLots and lots of people do web stuff in Python. There are a whole bunch of Python web frameworks like Django, Pylons, Flask, etc. And there are big sites written in Python, too. Reddit, YouTube, some Google apps, Spotify, Netflix. Rust is still a bit young, but also has several web frameworks like Rocket. No big case studies that I know of, but Rust still has many more fields of applications than PHP does.
- postalrat 5y agoSure, a small minority of sites are partially written in python.
- thirdplace_ 5y agoI have used PHP for years. I like it too. Its tight integration with http is nice. The PHP language can be used as a templating language itself: <?php $user = 'root'; ?> <p> Hello <?= $user ?> </p>
- philliphaydon 5y agoI think* with ASP.NET Razor Pages. You can do the same thing as: @page @{ var user = "root"; } <p> Hello @user </p>
- oaiey 5y agoRazor is awesome... It has this productivity of PHP while being consistent and have the benefit of being conceived later. Only thing which hurts there: not everywhere deployed like PHP is :) And technically you need a 2 files boilerplate. But that will vanish within the next year when I understand the .NET team right.
- jeltz 5y agoPlease, do not do that. Use an actual templating language which automatically escapes output.
- dagw 5y agoDoes PHP still look like that in 'real life'? I was reintroduced to PHP last year via a Laravel based project and it looked nothing like that. It was all Objects and Models and Controllers spread out across a half dozen folders and scaffolding code generated via CLI commands. All actual HTML was generated with Blade templates.
- woleium 5y agoIt is, but not as "worth it" as python
- Subsentient 5y agoI really like Python. It's what I reach for when I need something working quickly. I have a whole folder of one-off python scripts I wrote over years that I occasionally still use. For very large projects, however, I advise against it. The dynamic type system bites you a lot in my experience. I prefer static typing.
- natded 5y agoNone of the reasons listed exclusively argue for PHP; unconvincing. To start the article with the type system of PHP as a reason to learn it in $CY is insanity.
- systematical 5y agoGreat article for PHP devs too. I've spent a lot of time in PHP over the years and found there is a bunch of stuff I didn't know about.
- tgeorge 5y agoAgreed! I didn't know about this project for payment gateways from the article: https://github.com/thephpleague/omnipay https://github.com/thephpleague/omnipay
- eyelidlessness 5y agoI’m going to try to offer a positive take from a non-PHP-fan perspective: yes it’s obvious both from vaguely checking in on the language’s progress and from the article’s presentation that PHP has made considerable strides. It’s impressive how much, over that time, it’s become less insular and much more readily adopted similar improvements to similar languages. The object over time, for example, more and more closely resembles TypeScript, and that’s a good thing. I haven’t worked in PHP for I don’t know how many years, and I probably still have an unfair negative reaction to it. It has a strange cultural idiosyncrasy I find more limiting than anything about the language itself. But I’m happy to see it evolve and I’m happy to see it evolve alongside other technologies I work with more readily.
- cupcake-unicorn 5y agoI don't really understand the reasons for using PHP outside of that people are already familiar with it and like working with it or want to find jobs in that area. If someone is new to software development and in an area of the world where it's not mostly PHP shops, so bigger cities, I don't really understand the benefit. PHP is often used to do certain things or it may be faster for you to whip something up in Laravel but if you had someone who was a complete blank slate and could chose any language and any framework in a town that doesn't have PHP jobs...why? What's the reason then? I really think these articles come off really strange like they're trying to convince me as a "fact" but are really just nostalgia, like someone who goes off about how "cars were built so much better back in the day, there's still uses for older cars!" Maybe there is a grain of truth there and some real reasons behind it (repairability) but for 95% of use cases it's just that there's no contest, for a new driver, in an average situation there's no benefit towards going to an older car, and the guy going on about "older cars are the best", while they may have some weird reason that does actually apply to them (and as far as this analogy goes, I think Fortran is a better example than PHP in this case than PHP as for some maths applications it apparently still has an edge but that could have changed) honestly it's just nostalgia/trying to indoctrinate people...
- skinnyarms 5y agoIf you like PHP, great. Do you plan on creating a start-up that you intend to scale to a babillion customers? That you intend to hire teams of developers for? Probably not a good idea. Are you a new programmer trying to figure out which language to learn first? Absolutely not. Python, Java, JavaScript, C# are much more flexible if nothing else. Anybody who tries to convince new programmers to learn PHP is doing them a great disservice.
- heurisko 5y ago> Anybody who tries to convince new programmers to learn PHP is doing them a great disservice. It depends what location you're in. In Europe there are pockets where PHP is very popular, where learning it can open up the job market.
- 5y ago
- aejnsn 5y agoI use a hammer for nails and a screwdriver for screws.
- Zababa 5y agoI have a few questions: - Is the "your app gets initialized and torn down for every request" true for frameworks like Laravel and Symfony? - Does this model uses OS threads? Does it uses green threads? And then a few remarks about the language: - I feel like the Go model is a way better model for server software than async. Since PHP is mostly used for server software, I feel like they shouldn't go with async. Python is currently going through the transition and it's painful and long. - It feels a bit weird to see how full of objects PHP is. Modern languages (Go, Swift, Rust, TypeScript) tend to use less objects, and more plain imperative code or slightly functional code in my experience.
- dreyfan 5y ago> Is the "your app gets initialized and torn down for every request" true for frameworks like Laravel and Symfony? Yes, though heavy optimization in opcode caching and JIT keeps it fast and the primary process manager today (php-fpm) generally keeps a pool of PHP processes persistent. Each request is initialized from scratch but there's no disk nor interpreter hit after the first. There are, of course, frameworks that simply handle HTTP requests directly (amphp, swoole) that operate as persistent application servers, so state is maintained. > Does this model uses OS threads? Does it uses green threads? No. PHP webserver backends are generally a long-lived forking model. > I feel like the Go model is a way better model for server software than async Swoole [1] offers a coroutine and channel model. It's incredibly fast and the techempower benchmarks [2] attest to the raw speed. > It feels a bit weird to see how full of objects PHP is Agreed. It's often way over the top with Java-esque OOP complexity. It does depend on the libraries in question but the popular ones are very heavy (Symfony). You can of course write very simple imperative code just fine too. [1] https://www.swoole.co.uk/ https://www.swoole.co.uk/ [2] https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/
- heurisko 5y agoI don't agree with Symfony being inherently "very heavy". As set of framework components, you can any part you find useful, and wire to together yourself, if necessary. e.g. https://symfony.com/doc/current/configuration/micro_kernel_trait.html https://symfony.com/doc/current/configuration/micro_kernel_t... Many other PHP projects, such as Laravel and Drupal pick-and-choose Symfony framework components in this way.
- cardosof 5y agoFolks bashing PHP like it's crap but praising any crappy thing if it's built with an esoteric lisp-based language. I mean, if you're starting out, chances are you're better off with js/py or even go but in the end you're paid for the types of problems you solve, not by the language you use... It just turns out that some problems are easier in this or that language, or even people who are good at solving this or that problem just happen to use an specific language (like the bioinformatics people using R when they could have used py).
- noiwillnot 5y agoR is another language that it is bashed constantly, but it is generally much productive in its field (EDA and stats on structured data) than the alternatives like Python.
- Mikeb85 5y agoThis. While I'm not sure I'd build a website or something with R, for pretty much anything data related R is a first choice. Even for big data on clusters or something. It's absolutely amazing at what it does. Super easy Fortran and C++ interop. Bonus that it's well enough known in academia and fields like statistics or economics.
- dagw 5y agoI'm not sure I'd build a website or something with R Have you played with Shiny (shiny.rstudio.com). If you're building a website for interactive data exploration and analysis, it is very hard to beat.
- Mikeb85 5y agoI have. Guess I haven't tried to build something bigger with it. Seemed to me to be mostly something to share visualisations, not for building say, a whole CRUD site Rails or Django-style.
- foxes 5y agoPromoting php is truly a head in the sand attitude. Yes there is valuable old software, but come on. Move on if you don’t have to touch it. Stop being oblivious and rejecting advances in programming language design. That probably goes to a lot of other languages too.
- cblconfederate 5y agowhat's new in programming language theory since the 70s?
- juxtapose 5y agoHmmm... Most points in this article are shouting "yeah we have those too!!" but it didn't give any convincing arguments why I (or anybody who doesn't already know PHP) would like to learn and use PHP over other decent modern languages and ecosystems, which happen to have those points as well.
- kkarpkkarp 5y agofor me the biggest advantage is the size of the market. I know Python and PHP quite decent but I've never found any quick job (or long time job) for my Python skills. For PHP I have to convey some of jobs to others, I am getting so much of them (I even run some job advertisement site only for the purpose to redirect people pinging me with offers, really). But maybe this is just me.
- MattGaiser 5y agoGood jobs though? Lots of PHP jobs in Canada, but the salary is nearly universally always laughably low.
- kkarpkkarp 5y agoIDK what is a good salary in US/Canada, I live in European Union. My salary as WordPress developer is more than 4,5k USD/month and I see job offers with 8k USD as well (still for WP developers, this is my specialization and I know this field the most; I expect for better recognized PHP fields like modern frameworks like Laravel it could be more) And yes, 4,5k USD/month is massively good salary for Europe. On the other hand, I see many job offers with salaries being just a joke (idk if they find any good developers for such money)
- sdevonoes 5y ago4,5 K USD/month is 54K USD/year gross which is 47K EUR/year gross. That's not massively good salary across ALL Europe. In eastern and southern europe: that's probably good for a junior engineer, and perhaps average for a senior In northern europe: that's probably average for a junior, below average for a senior
- pkphilip 5y agoExcellent article. Learned much for this even though I have used PHP for about 20 years. PHP has vastly improved since version 7 - both in terms of language features as well as in terms of performance. However, error handling continues to be an issue. It isn't uncommon for PHP to fail silently. That would be one complaint I have against PHP.
- sandreas 5y agoThere is also a proposal about generics: https://wiki.php.net/rfc/generics https://wiki.php.net/rfc/generics
- dmitrijbelikov 5y agoI've been using this language since 2002. Still good for most kind of tasks in web.
- nxpnsv 5y agoLearning is always good...
- phendrenad2 5y agoPHP is perfectly fine, and all of the "better languages" are only better in an academic sense. But you can't really use PHP. It's too uncool. If you use PHP in 2021, you had better have a really good understanding with your manager, because your manager may read that PHP is "bad" or "a fractal of bad design" and start to question your competence.
- johnnycerberus 5y agoI think PHP gets all the clapping when in fact the statistic that the majority of the Internet uses it to power its services is misleading. Let's face it, Wordpress is a great project, it could have been written in Perl and it would still have had the perks of being Wordpress. When people use it, they don't know what happens behind, I think WP is the perfect example of what a good extensible product is and how it can build an insane ecosystem around it. The plugin architecture is there since 2004, it was and still is very ergonomic. Though Wordpress was not unique in that time, phpBB, vBulletin should be mentioned.
- aeturnum 5y agoThe closest this post gets to supporting its thesis is this section: > You might have heard people say that PHP was "doing serverless before serverless was a thing", and this is kind of true. I believe that PHP is...not bad I guess? I'm sure it can make good things. But after reading this I have no idea why I would pick up PHP over any of the other capable tools out there.
- Darmody 5y agoWhy would you pick any other language instead of PHP for web dev?
- Kovah 5y agoBecause too many people learn only Javascript in their pRofeSSioNal WeB dEv BoOtCamPs so the only thing they know is JS. Why learn a solid backend-focused language if you can throw JS at it?
- paulintrognon 5y agoHave you heard of Nest.js? It's the laravel of JS, and I can assure you it is rock solid.
- jusssi 5y agoIs there now a reliable non-hacky way to do threads or async, to run queries to multiple dbs or backend systems simultaneously in PHP?
- xiaodai 5y agoI heard that Php is unsecure by default. Wonder what's the state of that?
- heurisko 5y agoThere used to be bad defaults, such as "magic quotes" and "register globals". Register globals was turned off in later versions of PHP 4. Magic quotes was turned off in PHP 7, released in 2015. PHP today is no more "unsecure by default" than any other language.
- unobatbayar 5y agoDepends on how you use it. It's always been dependent on the programmer.
- hit8run 5y agoWell lets start with things I do like about PHP. I like that they had the web use case in mind right from the start and this shows in stdlib APIs PHP offers. For example database interaction, image uploads, cookies etc. Many languages need that via a framework but PHP is ready to go from the start. What I do not like is the syntax. Call me picky but referencing attributes with -> instead of a dot (.) is ugly to my eyes and I prefer JS, Ruby or Python when it comes to the pure look of the code. Generally I'm not a fan of dynamically typed languages because I just feel way more productive when I have proper code completion and type safety. In general whatever works for you and makes you happy is good enough. :)
- jfrunyon 5y agoPHP is a lot better. But it still has a lot of the same old issues when you look beneath the service. Good luck remembering what all the str* functions they invented do and what order their arguments are in. Same for the array functions (don't get me started on implode's three signatures - but that's mostly fixed in 8!). And may His Noodly Appendages help you if you come across a function being used which has no documentation and a single decade-old comment from someone asking how it works... And so, to plaster over it's many flaws, people start layering framework upon framework upon framework, each of which slows down the language significantly from all those shiny PHP performance benchmarks you see. And then they wonder why their shiny "what's an array? we need to transit 20 different chained method calls for that" is so slow... And half of them are documented even more poorly than PHP itself. At least their code is in the same language you're already writing, though.
- corobo 5y agoAre str and array parameter order the only problem people have with PHP these days? Seems to be the only argument I come across now anyway Nice work PHP
- that_guy_iain 5y agoThe argument order flaw is never going away. BC. It's a super minor thing. The non-documented functions are often rare and very minor and obivous functions. This layering framework on top of frameworks sounds made up. Mostly people either use Symfony or Laravel. There aren't layers of frameworks. Your example is nonsensical. Frameworks are slower than simple code, this is true for every language. And Symfony and Laravel are both well documented. This comment overall seems to be written by someone who has come in with very little knowledge on PHP worked on a project for 3-4 months. When you work those style projects you're often working on poorly constructed projects. I'm pretty sure I can jump in on a project written in any language that has been poorly constructed and I will end up going wtf.
- jfrunyon 5y agoI am well aware that it is never going away. I wouldn't call it minor, it's an extremely common source of bugs. The non-documented functions are indeed often rare. That's all that can be said about them. They're about as obvious, on average, as the rest of PHP's functions are obvious. Sure, until you want to have a UI framework, and an API framework, and ... LOL @ Laravel being well documented. There's a tutorial and there's autogen API docs. And that's it. This comment overall seems to be written by someone who has worked with PHP for a few years and thinks he knows everything there is to know about it. I've been using PHP since PHP3 and professionally since PHP4, but thanks.
- ammmir 5y agoMost arguments against PHP miss the point. You know why you should use PHP? Because it's fun and you can get something running much quicker than figuring out the Elixir, Ruby, Rust, whatever ecosystem and paradigm. Maybe PHP is not so good at WebSockets or async worker threads, but most projects don't need that. There's no shame in doing long polling, users can't tell the difference anyway! PHP shines when you're trying to get a server-rendered web app off the ground. It's the VB6 of the web. Nothing else matches its development velocity, from keyboard to working code.
- jbergens 5y agoI would guess nodejs has the same development velocity. And you can just copy js files into a server that has node to build a web application.
- spoiler 5y agoI used to believe this, but... But that's just not true. All the things you mentioned are a yum/apt/nix/pacman/ install away on Linux, and probably as simple to install on macOS. I'm sure Windows has installers for these, too. So, it's no harder to develop in them than it is in PHP. You could argue it's cheaper because you don't have to pay for a shared hosting provider to host your files. However that's a bit moot since even back in the day there were LAMP stack Vagrantfiles that would automate this local setup. Also, when speaking about dev velocity or time-to-start: you forgot JavaScript, which probably has much greater development velocity than anything else. Furthermore, PHP is rarely just PHP in production. PHP also comes with various runtime modes (CGI, FPM, etc), .htaccess rules (or nginx equivalents), a bunch of runtime language and feature toggles that are partially controlled by the system (ie your hosting provider), and some can be controlled by the application. The ephemeral process nature of the language makes some tasks very difficult to do in a performant way (but there's caching, so that's at least mitigated). I've seen so many developers (worked for a hosting company) come complain to us about slow servers when in fact they'd just be doing silly stuff. And it was hard to blame them, because the language encourages that model, and the "performant" was was usually orders of magnitude more difficult to implement (ie indexing, image resizing, or most types of batch processing). I'll not go into the horrors of how easy it is to mishandle file uploads in PHP (there's plenty of those around) and how many times people got easily hacked this way.
- dagw 5y agoAs someone actually did (re)learn PHP (last time I used PHP was PHP4) last year for a gig, I would probably say no. Don't get me wrong, it is a much better language now and Laravel is a great framework. With the two you can no doubt build fantastic applications. But I didn't feel it was 'better' in any way than anything else. With Python, Go, Rust, Elixir, TypeScript etc. I can all point to a thing they do and say "if you are solving this sort of problem, then this language is the right choice because of X, and worth learning". With PHP I just couldn't find that.
- 0xad 5y agoHere's one: If you want your operations to be as easy as they can be (LAMP), go with PHP.
- Grumbledour 5y agoI always suspect modern php makes the language nicer but actually reduces it's core feature, the ease of use. Don't get me wrong, I would not like to use older php these days. But just throwing 2 files onto an ftp was always php's biggest strength. It somewhat retains that for "installing" php, which still is often just "copy to server" which makes it really nice for users. But I feel it mostly lost that ease of use for people learning to program. Now, it is still a solid language considering performance and such. It has proven itself to be. But without the easy way from zero to programmer, I am also not sure it is a better choice than anything else. Especially since it always had so many terrible footguns and at least in my opinion is also atrocious to look at.
- kettleballroll 5y agooff-topic, but: Go and Rust seem to aim for the same space (system programming), so when is one preferable to the other, in your opinion?
- jeltz 5y agoI had exactly the same experience. Yes, it has improved, but, no, I did not see any reason for using PHP over any other language (Ruby, Python, JS who all have their own selling points).
- zivkovicp 5y agoI like PHP, it pays the bills. I also like other languages, some because they are a pleasure to use, or give me an opportunity to learn something new... but mostly because they pay the bills. I don't think there is anything wrong with that, these are just the tools of the software engineer, nothing more. We use the tools that are appropriate for the job, no reason to make it into something deeper than that.
- danmur 5y agoIt's fine for the web. I used it for years. Not a great general purpose language though, if for no other reason than the ecosystem is focussed on the web.
- toolslive 5y ago| php is fast. https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/php-python3.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... it's faster than python, but my grandma is too and she died in 1993. However, function calls are extremely slow. If you would bench something like a naieve fibonacci implementation (or ackermann's function) you would be surprised.
- toolslive 5y ago(naieve fibonacci) like this: <?php function fib($n) { if($n === 0) { return 1;} if($n === 1) { return 1;} $r = fib($n-1) + fib($n-2); return $r; } $n= (int) $argv[1]; $r = fib($n); printf("%d %d\n",$n,$r); just did some measurements on my laptop: | Language | n | time(s) | |----------------------+----+---------| | php (7.4.25) | 42 | 422.0 | | python3 | 42 | 90.0 | | haskell (ghc -O3) | 42 | 13.8 | | f# | 42 | 5.6 | | ts | 42 | 2.8 | | ocaml (ocamlopt -O3) | 42 | 0.98 | | C (gcc -O3) | 42 | 0.66 | (edit: added php version in table. )
- hhansen 5y agoIs JIT enabled and configured for PHP?
- beberlei 5y agonaieve and micro benchmarks is not meaningful in 95% of cases. Did you run on the CLI with -dopcache.enable_cli=1 for example?
- idoubtit 5y agoOpcache avoids the compilation step. It's not relevant in this case (compilation ~0.01s out of ~400s). Microbenchmarks are meaningful as long as one doesn't read too much from them. This benchmark shows that PHP seems to have a problem with recurrent calls.
- 5y ago
- corobo 5y agoYou guys think a hell of a lot about your hammers It's a tool, use it or don't. Why do we have this weird slap fight every 2 months? It's so weird
- jeltz 5y agoBecause we use our hammers 40 hours per week. If you use something that much it is perfectly normal to have opinions.
- outime 5y agoI haven't commented on this thread until now (I left PHP so many years ago, I have nothing to add) but are you suggesting to never discuss with other peers about the available tools for the job? Could you be more specific on your proposal?
- corobo 5y agoNo, I'm not suggesting that. I am suggesting that the same conversation happens over and over again "PHP is good now!" "No it isn't!" "That was PHP 4!" "array and string functions" "abstract it with a framework" "PHP is slow" "It isn't" "it is look benchmarks nobody will ever need" See y'all in 2 months haha
- anothernewdude 5y agoJavascript is hot trash, and frameworks die so frequently I have never bothered to learn a single one. I'd still recommend javascript over PHP.
- datavirtue 5y agoIf you haven't worked in PHP, you don't know what you are talking about. You only think you know what you have heard.
- jeltz 5y agoI have worked in PHP recently and it is still a pretty bad language. Not as bad as it used to be but still pretty bad.
- eloisius 5y agoThis conversation gets so vitriolic every year or so when it comes up. I'm temped to go argue in the threads, bust instead I'll just share my (recent) experience with PHP in case anyone is actually on the fence rather than here to flame. I started out doing PHP back in the everything-is-WordPress heyday. It was easy to SSH/FTP directly into sites and edit things live, and that was also a very normal thing to do. I got good at PHP and felt kind of defensive when people said how bad it sucked. Right tool for the job and all that. But, after some time doing it, I knew I wanted to break out of my PHP shell and learn another language. For some reason I felt like I could only pick one more language to learn, so I was hesitant to do so. I ended up going with Ruby. Only then did I understood what all the crap talk about PHP was about. It's probably both a language problem and an ecosystem problem. The ridiculous, complicated iteration over deeply-nested array-dictionary-combo data structures with various counters stuck in local variables here and there that I had previously considered normal vanished before Ruby's sleek Enumerable module. Of course you can code better PHP and avoid writing those kludges, but as a junior coder, that's the thing that stuck out to me when I switched from a PHP shop to a Ruby shop. Kludges and the worst inherited Frankenstein projects of my career. I swore I'd never work on PHP code again. I spent several years doing Ruby, and along the way picked up several other languages and now can't fathom why I originally had such hesitation to pick one to learn. After gaining enough experience to be a senior engineer, a friend recruited me for a job doing PHP. This was at a big company with tens of thousands of enterprise customers, high-scale stuff. The money was good, and I had heard a lot about how PHP had cleaned up its act since the 4.x days. It's object oriented now and has a proper standard lib! I spent 3 years there, and I have to say the engineering talent there was good. Many ideas from other languages like Ruby's Enumerable had been replicated in our toolkit. However, the vast majority of the code was still weird data structures that are unique to PHP development because of its lack's both real arrays and real dictionaries. PHP has indeed acquired standard lib, but many pieces of it still have a crap implementation. It's like they went out of their way to make lousy APIs for things like dates, times, and durations. In every other language I've used, you can easily compare time durations (is 1 hour longer than 1 minute?). PHP DateIntervals are not comparable. The API for creating a new DateTime object at a specific date is still to pass in a specially formatted string. Or, if you don't like that, you can create a DateTime for "now" and then mutate it to set the date. They may be adding language features to catch it up with other languages, but it seems like they're obstinately doing it in the most PHP-like way possible Long-lived resources like database connections, Redis connections, etc. plagued us. We had a whole middleware in our stack dedicated to holding open proxy connections to things like MySQL. The thing that PHP enthusiasts say make it so attractive (edit, save, refresh) also bites you in the ass because PHP processes spin up and die with each request. There is no long-lived process holding onto those resources. As of 7.3, It was still the same old PHP I knew back in 4.0. It's still crap and this time I swear I'll never work on PHP code again ;)
- bayesian_horse 5y agoThis actually convinced me that PHP isn't as bad as it used to be. Though it's still not all that inviting, knowing Python, Typescript, F# etc... From Pyjokes: Coding in PHP is like peeing in a swimming pool. Everybody has done it, but it's best not to talk about it.
- bob331 5y agoNot if you value your mental health. PHP is legacy over complicated dugshit mainly used by people who have never learned how to code properly
- twistedpair 5y agoI learned web programming on PHP, and a ton of anti-patterns well. Making a single script with a very rich stdlib is quite handy, as well as "just running it" on your desktop instantly. However scaling out large projects in a performant way, doing big refactors, or mature server programming, I'd pick nearly any other tool today. Disclaimer: I still maintain my PHP site from '08, so I'm current on trends.
- cjdell 5y agoI'll be honest. I really don't like PHP. However when I was running a coding workshop, very frequently people would ask: "How do I make a web page talk to a database?" I'd say: Well, you know that HTML file? Rename it to become a PHP file and you're almost there! As pretty much all cheap hosting already offers support for PHP (and MySQL for that matter) this would almost always work. I would love to be able to do this with NodeJS, but imagine teaching that to an absolute beginner. The conversation would have to begin with hosting platforms / SSH / server management / reverse proxies etc....
- dexen 5y agoPHP: the original progressive enhancement.
- patates 5y agoIt's still far behind PHP[0], but with Next.js/blitz.js I think we're going in the right direction. [0]: as in, I would have nightmares trying to introduce beginners to full JS stack vs I would have nightmares thinking what they will end up coding when they easily become dangerous with PHP (which is I guess why there are so many bad PHP codebases: it's super easy to start)
- npteljes 5y agoYou hit the nail on the head, this is exactly why I fell in love with PHP. I learnt it back in the PHP4 days, and it just seemed like the perfectly straightforward way to do web. In a similar fashion, I abstracted away the database connection, query and returning of results into one lazy-inited function, so talking to the database really was just like <?=q("select name from users where id = $userid") ?> I worked a lot with other languages, none feeling as natural to me as this one, aside from Ruby.
- gbba 5y agoBe careful as this syntax can potentially introduce SQL injections. PHP's parameterization features in PDO can be abstracted so you can turn this into: $vars = array(":userid" => $userid); q("select name from users where id = :userid", $vars); It's still pretty concise and is much safer.
- dragosmocrii 5y agoPHP needs a proper type system with generic support, and would be a killer programming language
- ampersandy 5y agohttps://hhvm.com/ https://hhvm.com/
- dragosmocrii 5y agoI'm aware of Hack, but I don't have full control over the stack, so having all these features included in core PHP would be the only way in my case.
- idkwhoiam 5y agoTo me personally PHP is the cheapest way of building a dynamic website. Just a few euros/dollars a month will get you a shared web hosting plan with full support for the LAMP stack & free email.
- kakkulaina 5y agoThat was true in 2004. Today you get a virtual server for five bucks a month. Feel free to run ANY stack you prefer.
- idkwhoiam 5y agoVirtual server is great except now you are reponsible for server management, SSL certificates, backups, DB, firewall configuration, mail server, etc. I don't want any of that which brings me to PaaS providers like Heroku and Vercel where the cost is many times higher.
- dncornholio 5y agoPHP is still very popular in EU. In my experience, the consensus of PHP is completely different than what some of the people still post here.
- klysm 5y agoAfter learning and developing with PHP, even with the new stuff, I would never choose to use it for anything.
- whalesalad 5y agoPHP is great as long as you accept it 100% for what it is - a shitty language.
- path411 5y agoHave you used a version of php from the past decade? Or are you conflating a bad framework or codebase with a bad language?
- whalesalad 5y agoYes, it's like an old Model T Ford from the early 1900s that has had a turbocharger, air conditioning, a new stereo, a subwoofer, roof rack for a bike, roof rack for a tent, grounding straps, trailer hookup, clean water system, etc.. bolted onto it. At some point you ask yourself - why did I do all of this to a Model T? Sure, it has some modern facilities but the language itself was never designed and so none of it feels cohesive. The syntax is off-putting. It's just a ton of nightmare for what reason? Why? There are so many other languages to choose from and PHP has no competitive advantage other than $3/mo GoDaddy hosting.
- nick_ 5y agoYou have to give up arguing. The PHP dev will look at a Model T DIY'd into "The Homer", and beside it a 2016 Toyota Corolla. The PHP dev will argue, sincerely, that The Homer is just as practical of a daily driver as the Corolla. You have to just walk away from this kind of person.
- emeraldd 5y agoI've never regretted the time I took to learn PHP. No matter how bad the language may seem, it paid my bills for a long while. It's one those tools that to keep in your back pocket until you need. Keep in mind what it's good for and what it doesn't do so well. That said, php's online documentation is one of my "gold standards" for what good language documentation should provide. (At least it was the last time I had to reference it.)
- FascistDonut 5y agoI really like how the documentation also includes a huge amount of user contributed notes that demonstrate various alternate examples as pointing out certain caveats/nuances.
- TrispusAttucks 5y agoI am surprised when [1] Python or [2] Ruby is recommended over PHP at the very least from a performance standpoint. PHP has a lot of built in standard library utilities and it's execution model is so simple for both web applications and scripting system automation jobs. [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/php-python3.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... [2] https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/php-ruby.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- wilsonfiifi 5y ago> Early PHP was not intended to be a new programming language, and grew organically, with Lerdorf noting in retrospect: "I don't know how to stop it, there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way." [0] This might be an unpopular opinion but I think PHP gained mindshare in the early days because Coldfusion (CFML) was neither free nor open source. [0] https://en.wikipedia.org/wiki/PHP https://en.wikipedia.org/wiki/PHP
- taddevries 5y agoMy team has been using the Slim Framework for years and it has servered us well. It is a microframework and follows most of the PSR standards so it is possible to replace libraries with relative ease. https://www.slimframework.com/ https://www.slimframework.com/
- kakkulaina 5y agoToo little, too late. PHP has nothing to offer. They HAVE cleaned up some of the idiotic behaviour, but much of it still remains. The stdlib is very poor, and having last i looked everything was still global. Some array functions like map/filter had arguments in the wrong order. Unicode support is not there. Its a web language for gods sake! How about focus on that as a high priority? PHP lacks a vision. What does PHP want to be/become? It looks like sometimes PHp steals Javalike features, implements them adhoc and badly, and then again sometimes more scripy features from JS. The typ system is VERY mediocre. You really cant trust it, at least not with the stdlib. The execution model of PHP is still living in the early 2000s. The web is real time, and PHP cant handle it without hacks, and even then you cant use any builtins like PDO (blocks thread) or any IO related feature. Honestly, even if PHP today is ”better” than it was 10 years ago, what does it have to offer? There are multiple better languages for the problem PHP solves, and the other languages have ALSO improved in the last decade. I cant see myself starting a new project with PHP, there is just too little it offers, and too much thats still broken, and wont ever be fixed because of BC that PHp tries so hard to keep.
- kakkulaina 5y agoA simple sniff test thats tried and true still holds. ANY programming language that requires you to use a framework to actually be productive fails the test. PHP is doing very poorly in this realm. How many PHP websites out there are actually using a few libraries and the stdlib only? Not many. Its frameworks, frameworks frameworks. In the PHP case its actually even worse, as there are a multitude of CMS sysytems that some people use. So its not even programming, but point and click and copypaste. Thats not a tool i eant to use in 2021.
- aszen 5y agoPhp can be immensely productive to develop web apps in, it has all the things u need out of the box no libraries needed. Infact that is how most of the old php was written. Nowadays people use frameworks bcz they find themselves more productive
- antback 5y agoSomeone has experience with hyperf?[0] [0] https://hyperf.wiki/ https://hyperf.wiki/
- NGRhodes 5y agoPHP maybe worth learning and using for building websites, but PHP is one of the worst languages to learn for someone who is interested in learning programming as a hobby, interest or career.
- popfastful 5y agophp is very easy to use,it saved a lot of my time,I have used PHP to created a simple Social networking site: alovez.com ,this is my homepage on my website: https://www.alovez.com/bing https://www.alovez.com/bing
- XCSme 5y agoNine years ago I decided to use plain old PHP and MySQL to build a self-hosted analytics platform[0], and to this date I still think this was the best decision I could make. Even though nowadays cloud, Docker, Golang, Node.js, Kubernetes are all the rage, most of the websites and hosting providers are still running on PHP/MySQL, which means running the platform can be done on the same server and customers can try it without having to learn to deploy to the "cloud". Not only this, but PHP/MySQL is such a reproductible stack, if the code is properly written you can run the same app on tens of different server configurations (Windows, Ubuntu, CentOS, various versions of MySQL and PHP) without having to change anything. [0]: https://www.uxwizz.com/ https://www.uxwizz.com/