28 ms·
PHP in 2020
- brakmic 7y agoPHP, LOL.
- deleted 7y ago[deleted]
- whalesalad 7y agoPHP is tolerable if you NEED to use it. If you don't absolutely need to use it, why bother? (I spent a few solid years of my career writing PHP professionally, so this isn't just a vapid hot take) Serious question. The only reason I can think of for choosing PHP is if your target deployment environment is going to be shared/commodity hosting. WP is king here and will continue to be king for this reason. Ghost is not working becuase it isn't LAMP stack.
- npo9 7y agoMy understanding is almost all PHP dev is done because it’s improving a legacy system or it’s integrating into a legacy system, or the first engineer could just move faster in PHP because of personal reasons.
- ioulian 7y agoI'm mostly Frontend developer recently so I haven't been much up to date with Backend technologies. If I need a CMS for my frontend, what technology(-ies) can I use?
- toper-centage 7y agoHugo and Gatsby come to mind. They are based of tech like react, go, and graphQL.
- tooop 7y agoThose aren't CMS...
- dewey 7y agoI'd go with Ruby on Rails if it's mostly CRUD operations. You'll be very quick to get something up and running to power your frontend. You could also use some hosted services like https://firebase.google.com https://firebase.google.com / https://www.contentful.com https://www.contentful.com but that depends on your use case and if you want to be dependent on someone in return for being a bit faster.
- FormFollowsFunc 7y agoYou could use Wagtail (built on Django) in headless mode. Drupal also supports headless mode.
- tooop 7y agoWhy exactly bother with anything else than PHP?
- TylerE 7y agoWhy bother eating anything except cold gruel?
- mitchty 7y agoI can only offer my reason: I don't know it.
- whalesalad 7y agoPHP isn't an application server. It's tightly coupled to the request/response cycle. There are things you can do to sorta get a longer running environment but for the most part you are loading and tearing down everything for every single request. Contrast this to Python, Ruby, Node, Go, really any other platform where you tend to model applications with an application server that is long running. In a scenario like this, your application is running all the time and doesn't boot up on every request.
- gscott 7y agoFor that matter MS Asp Classic works fine too which is my favorite.
- blantonl 7y agoTo all the haters out there. I self taught myself PHP almost 15 years ago, and I've completely developed over the years, from the ground up and from scratch by my self, a complete network of businesses: RadioReference.com and Broadcastify, that does Public and Private APIs in SOAP, JSON and XML. Complete user authentication and session for millions of users. Integration with third-party best of breed apps like MediaWiki and Xenforo. Database, Ticketing, Location, Admin, User, Payments management. Provisioning, Scripting, Web Services consumption etc The code is ugly, barely any OOP except for some reusable internal classes. Tons of copy paste from Stackoverflow. I'm still using mysql_query() in a lot of places. Did we hit some security issues, sure! But it works, it generates millions of dollars in revenue, and it's all managed and developed by one person. So, to all the PHP haters out there. See above.
- TylerE 7y agoYou are making the argument for the haters. You can build a house out of kindling coated in gasoline too. Doesn't mean it's a good idea.
- mthoms 7y agoAs someone who likes modern PHP and hopes to see old stereotypes go away, this comment made me sad.
- blantonl 7y agoWhy sad? The objective is to build a business, generate value and execute on a vision using a programming language, not win a popularity contest by proclaiming your use of anonymous classes, unicode codepoint escape syntax, and the spaceship operator. I'm doing some really cool things in PHP, and some really ancient things as well. Who cares? The business is killing it, delivering some of the latest and great technologies to end users. That's all that matters.
- mthoms 7y agoIt's just that your cavalier attitude towards best practices and apparent pride in having a shoddy codebase perpetuates the stereotype that PHP developers are second rate. And no, I'm not advocating for using the latest and greatest just for bragging rights. There is a middle ground. > "Who cares? The business is killing it" What happens when you want to sell the business, or the sole developer of this monstrous codebase becomes ill? Based on the picture you've painted of it, a good developer won't want to touch it with a ten foot pole. Anyhow, I am very glad for your success. It does sound like an interesting story. Just don't be surprised to see a negative reaction from a community of professional developers when you brag about how poorly written (and vulnerable to attack) your "million" dollar application is. I can only hope that you aren't operating anything that other businesses rely on, or worse — handles personal data.
- phlyingpenguin 7y ago> 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. You can write clean, and maintainable, fast and reliable applications in Perl. Just because you can, doesn't mean you should. I'd rather not attract the PHP dev crowd that gives it the reputation to any project I'm working on.
- winternett 7y agoOK, so what's better and why is it better? There's a lot of criticism of PHP in here, but no real facts behind it... We always love the language that we know, and hate others we don't, it's something we should try to keep under control.
- phlyingpenguin 7y ago> 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. RTFA? My sentiment is not about the language so much as the culture around it. You can certainly write great code in it, but I also have worked plenty of PHP dev shops and have no desire to ever go back to that life. It's clear you're hurt that the language you know has a bad reputation. My condolences on that. I don't need to list off languages that I like to know that I don't want to use PHP or work with PHP developers.
- dubcanada 7y agoI mean there is probably no point in saying anything to you since you seem to have made up your mind and don't care about anything else. But how exactly is a "PHP developer" equal to being a negative/bad programmer?
- phlyingpenguin 7y agoTo answer your question, I'll once again just paste the same quote. Sure, there are good programmers out there. But PHP is a pretty good heuristic for this class of programmer. > 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. There's no point in having a conversation if we all need to cheer on the article. Yeah, I've made up my mind. I think this article is misguided. No amount of technical changes to PHP changes legacy codebases or exactly the opening paragraph of the article that everybody seems to be ignoring.
- captn3m0 7y agoWhy is nobody reading the damn article? >I hope I was able to show you that PHP has evolved tremendously over the past years, and you're perfectly able to write clean and maintainable code with it.
- deleted 7y ago[deleted]
- rapfaria 7y agoHN mostly goes straight to the comments. And this is what people have to say about PHP...
- notJim 7y agoPeople have been writing this take (and it has been true) for something like 5–10 years. I doubt anyone who didn't believe it was just waiting for PHP to get type annotations to be convinced.
- chess93 7y agoI have no php experience so I have absolutely zero conception of what the language used to be like, just what it looks like now. I can't help but see it as some kind of frankenlanguage put together with pieces of java/python/javascript and a ton of dollar signs. In other words, it seems too similar to languages that I already know to be worth learning. Lisp was fun to learn because it is an alien language. C was worth learning because of its usability and centrality to modern computing. The only benefit I can see from learning php is being able to understand more of software history. Cool but I'd rather learn another lisp. Does anyone disagree with my analysis? I wish the language well but I don't see what it offers me. Obviously it offers a lot to the people who see JS as franken-php and so forth. Union types are cool though.
- open-source-ux 7y agoAlthough I don't use PHP, I'm impressed by its staying power and the improvements in speed (which are substantial compared to other dynamic languages). It has almost universal support amongst web hosts. It can be deployed by simply uploading your code to a directory on your web host. It's a widely criticised language, but still accounts for the vast majority of server side code (80% according to some sources). And in 2020, it's still the only language that gives your users a relatively easy method to self-install web apps or products. (Sorry, but Cloudron, Sandstrom, Docker etc will never match your customers definition of 'easy'.) Having a ridiculously easy web app installation process for servers would unlock countless opportunities for developers to reach more users or customers. PHP is closer than most. No other language has tackled it (or cares). This is an excerpt from a blog post by programmer Jeff Attwood: "If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option. If that doesn't scare you, then check your pulse, because you might be dead." To broaden choice, Attwood argues we should: "build compelling alternatives and make sure these alternatives are equally pervasive, as easy to set up and use as possible." That was written in 2012 (https://blog.codinghorror.com/the-php-singularity/ https://blog.codinghorror.com/the-php-singularity/). It's 2020 and none of the alternatives are 'as easy to set up and use as possible' for server-side installs as PHP. Why?
- mywittyname 7y ago> Why? PHP was designed from the start to be a web-first language that solved the issues people had using Perl as a server-side scripting language. I think experiencing the pain points people were having trying to repurposed other languages for the web lead to a lot of good* design decisions. * Good, in the sense of ease of use. It also didn't really give you many options in the beginning: everyone just used the LAMP stack and made it work. You could use Windows or Postgres, but you just didn't without a compelling reason. Nobody today wants to design a single-purpose language that locks users into a platform. Users don't want to learn a single-purpose language and be locked into a platform.
- freehunter 7y agoWe love forgetting lessons we learned the hard way. With Rails we forgot that dev environments and deployments should be easy like they were with PHP. With Node.js we forgot that programmer time is important and boilerplate can be automated like it was with Rails. We’ll see what the next popular language holds for us, and what we forget along the way.
- la_fayette 7y agoI teach web development at a university. We have used, java, javascript, python and php for a basics course in webdev. Php has built in web features and one doesnt need more than a php interpreter (considering the built in web server as well) to get started. For all other languages i know of, there is quite a process to get started (e.g. start with python flask one needs a package manager, environment variables, command line experience, ...). Php is a web native language and great for learning and getting started. Considering professional development (https://en.m.wikipedia.org/wiki/Programming_languages_used_in_most_popular_websites https://en.m.wikipedia.org/wiki/Programming_languages_used_i...) it seems that it doesn't matter what language one chooses, various different stacks are used by the most popular websites..
- penagwin 7y ago> needs a package manager, environment variables, command line experience Is this not the same with PHP? If you want to use packages then you'll need to use a Package manager, you still need command line experience etc. Node.js comes with a package manager NPM, and has no need for anything like virtualenv's to keep packages separate per project. Python doesn't need virtual env's at all, it's just good practice. And to be fair, as a naive non-PHP user, I have 0 clue how you would go about setting up long running scripts that don't necessarily correlate to a web request.
- CiPHPerCoder 7y ago> If you want to use packages then you'll need to use a Package manager, you still need command line experience etc. PHP has a package manager IF you want to use the vast offering of open source PHP libraries and frameworks. https://getcomposer.org/download https://getcomposer.org/download To use it, create a composer.json and run: php composer.phar install On my systems, I like to alias it so that I just have to type: composer install Alternatively, if you use a Jetbrains IDE (i.e. PHPStorm), you can usually install dependencies with one click. > And to be fair, as a naive non-PHP user, I have 0 clue how you would go about setting up long running scripts that don't necessarily correlate to a web request. php /path/to/script.php It can run as long as you'd like. If you want to do it on demand (i.e. writing a webserver in PHP), that's difficult. But generally: Why would you want to do that? It becomes an X-Y Problem.
- timw4mail 7y agoPHP is, and always has been a practical language. 7.4 has been especially exciting with the introduction of FFI. Few other languages even have runtime FFI, and in most cases you have to do the binding stuff in C. I even ported a terminal-mode text editor (which uses FFI somewhat) from C to PHP: https://git.timshomepage.net/timw4mail/php-kilo https://git.timshomepage.net/timw4mail/php-kilo I would guess most of the PHP haters got stuck working on Wordpress, or someone's old business app, or they just hate PHP because it's popular to do so.
- Snelius 7y agoPHP is, and always has been a "Personal Home Page"
- Piskvorrr 7y agoHasn't been since about version 3, which went obsolete in the previous millennium;) Not even technically correct: I mean, Windows for IoT doesn't even need to have any windows, therefore it's not actually Windows, eh? (No. That was a joke.) In other words, PHP is still "PHP hypertext preprocessor", even though it is used far more generally.
- int_19h 7y agoWhat mainstream languages are you thinking of that don't have runtime FFI? (that have runtimes making it necessary in the first place)
- wahern 7y agoThis new FFI support intrigued me. But looking at the source, it's just a wrapper around libffi. I don't know of any language that doesn't provide a wrapper around libffi, though not all provide it as a default-installed module. PHP's bindings also provide a simple YACC-based parser for automatically extracting simple size and layout information from C header files, though this is easy enough to write in-language (heck, there's a full C99-compliant LPeg parser). Notably, PHP's parser, like LuaJIT's, doesn't handle the preprocessor, so its useless without resorting to a separate program (e.g. cpp(1)) if you want automagic bindings.[1] So, kudos for PHP for doing this. Not exactly a game changer, though. The performance cargo cult dislikes libffi as it can be relatively slow compared to an inline binding (static or dynamic) due to the need to copy input parameters (by reference, not by value) to an intermediate data structure on every invocation, and due to the fact that some JIT'd languages can JIT through the external function invocation (LuaJIT can do this, IIRC). It's ridiculous, but it is what it is; libffi effectively "taints" FFI support as non-native, which is a death sentence these days. I think PHP is a horrible, cobbled together language. If the core maintainers had a strong grounding in language theory, design, and practice, they do an impeccable job filtering it out of the final product. It's been this way from the very beginning, and by everything I see today, remains so. That said, it's the first thing I turn to when I need to put up a simple web page with server-side logic! I have absolutely no desire or tolerance to fsck around with CGI, modules, packages, or anything else, and the PHP ecosystem Just Works out-of-the-box on every system (Linux, BSD, Windows) I've ever tried it on. [1] Such parsers are kind of useless. Better to provide built-in sizes for core system data types like time_t and then, optionally, provide a simple, quasi-C grammar for expressing redundant definitions that you parse inline. Which is presumably how such parsers are used in practice, notwithstanding the pretense. Plus, I run all my web applications in jails (chroot, pledge, seccomp, etc). If system and library headers are visible at runtime, something is broken. If someone really wanted to go the extra hundred miles for proper automagic bindings, one could use ELF symbol information, for example debug symbols (e.g. DWARF) or simpler symbol info (e.g. BTF on Linux, derivative of Solaris' ABI metadata, which was directly supported by OpenBSD before the Linux project got started).
- skor 7y agoCan anyone suggest anything that is superior to PHP in its development cycle: save file.php = instant result? As far as I've seen, everything else needs to restart a server, obviously much slower. What about its die-hard intention of fulfilling a request no matter what? What about autoloading? And what about the amount of things you can do in vanilla PHP, no libs, no extensions. Hey i've worked with it for some time and sure, its got its nasty things, like gotos :)
- TylerE 7y agoBasically any other framework/language will have some sort of dev-mode autoreloader that will restart everything faster than you can switch tabs.
- skor 7y agoyeah, I know, but PHP does not even need that. That's the point.
- TylerE 7y agoIt's not an actual advantage, and PHP's "throw the world away" execution model is so so dumb.
- skor 7y agoI see your point, it makes sense to me in application development. However, regarding a web request, for me it's totally fine to throw it away :). Same as the statelessness of REST.
- TylerE 7y agoWell, I don't what to tell you except that that is a very shallow view. Every non-trivial web app I've ever worked with has tons of persistent state. DB connection pools. Translations. Configuration. Recreating that on every request is just wasteful.
- jimatlampio 7y agoI should probably get around to making a ShowHN, but my co-founder and I, having worked with loooots of clients that are still very actively working with PHP code bases (sometimes even still in datacenters!), aggregated and productized our "dream" stack as a PHP PaaS. Please check it out, kick the tires, and let us know what we forgot! https://www.lamp.io/ https://www.lamp.io/
- gitgud 7y agoNice implementation! I really like the pricing page's variability, But it does seem kind of expensive. Probably about 30$/month to run a wordpress install.... Are you using AWS or GCS? Maybe Kubernetes would be a cheaper option... Definitely submit this as a "Show HN"!
- jimatlampio 7y agoThank you! Its built on kube (gke) on gcp. For pricing we just started with the standard retailer keystone margin without oversell/oversubscription. We're hoping ease of use trumps saving a few dollars a month, it has for our first few customers, but we're still testing it out. Our goal is not to be the bottom-barrel-cpanel hosting world, but rather the freelancer/professional market for whom the extra 10 -20/month is a rounding error if it makes life easier. Also as a clustered service where we handle the os/image layers for you its more akin to a failover pair of vps's with some devops services (like forge) so its actually right in line with those as a bundled price, we just need to communicate it better. Also we're working on improving the webhooks/ci-cd functionality to eat into the $/month people pay for stuff like envoyer or travis-ci too.
- ryanmccullagh 7y agoInteresting project. And it's great to learn about your company. My project, Amezmo [0] is providing a similar service, but focused exclusively on php hosting along with continious deployments and managed databases. We bundle deployment and hosting. I've been working on this since 2018. [0] https://www.amezmo.com https://www.amezmo.com
- selfsimilar 7y agoI have a love/hate relationship with PHP but it has undeniably gotten better than its reputation would imply. That said, I think that regardless of the language's continued improvements its reputation will continue to suffer simply because it IS so easy to write and deploy code. Any sufficiently popular and widely supported web language will be the most common entry point for new coders and entrepreneurs who learn just enough code to get that MVP out the door. They will blog about their successes and add to the the number of 'not serious' coders putting poor quality code out in the world. If Python or Go were this easy to deploy, we'd be see their reputations suffer as well.
- oaiey 7y agoVery true. It is the same with Basic.
- ausjke 7y agofor system coding you have c, c++, rust, even java and go. for scripting you have bash and python these days, no need for php. for web frontend, js remains to be the king, the sole ruler. for web backend where PHP used to shine, you have python(django,flask,etc)) and js(nodejs,etc)), plus go and java, very crowded area. In short, PHP is only good at web backend, nothing more, but that place is getting really crowded these days, PHP no longer is the first choice. While recent PHP added nice features and performance boost, I feel it might be too late. Its high time has passed. I can learn Python do CLI/web-backend/AI/ML, I can learn JS for frontend/backend, I can learn C/C++/Rust for system programming, I use Java for enterprise,etc. I really do not need PHP anymore and there is only so much time left to master all the languages.
- dpau 7y agoI'm fairly language agnostic. What keeps me working in PHP is the Laravel framework, with all of the application plumbing and core functionality built-in and tested for me, so all I have to do is write the code specific to my application. Every once in a while I search for other frameworks but still haven't found anything that competes.
- kugelblitz 7y agoI also like Laravel, though nowadays Symfony wins it for me. But it's probably also a matter of taste. Doctrine's DataMapper vs. Eloquent's ActiveRecord pattern and the use of configuration in Symfony vs. convention in Laravel (e.g. facades) are my 2 main pain points with Laravel. But having 2 big frameworks is awesome, both are upping their game constantly and the whole ecosystem is benefitting. (E.g. I use Laravel's Homestead for Symfony development, but I might also use Blackfire.io to improve Laravel performance).
- cdolan 7y agoIt’s possible to use a data mapper in Laravel though, and it works very well!
- notJim 7y agoIt's kind of interesting (or incredibly mundane) how the feature sets of popular web languages have converged. The examples could almost be typescript (and the only reason I don't say Javascript is because of the types.) My understanding is that new versions of Ruby and Python also will have (or already have, I don't follow either language very closely) optional type annotations. It seems like the real difference is on the operational/deployment side, which tends to be elided (or only addressed on the surface level) when we talk about languages on HN.
- ironmagma 7y agoThis is why the development of new languages and constant iteration of “reinventing the wheel” (as some say) is worth it, I feel. Ideas from new languages make their way into old standard languages. If over time, every language starts to look the same, that seems to indicate we are honing in on a sort of global maximum. The power and expressivity of programming languages is immense but not infinite (practically speaking), and it is quite arguable that eventually we will find ourselves with no major improvements to make. At that point, it will make sense to settle. Until then, it makes sense to keep building new ones and using them as inspiration for the existing ones.
- axegon_ 7y agoPHP was intended to be a templating engine and nothing more. It's the community that pushed it in that direction even though that wasn't the creator's intention. And though that has lead to some bad decisions, let me be the one to say it: though it is by no means a good language, it's far not the worst. Surely, dive into most other dynamic languages and you will quickly want to stay as far away from php as possible. And in the modern day and age if I were to start any project from scratch, regardless of what it was, I can't think of a single reason to use PHP over most other available options. As a matter of fact java and javascript are the only two languages I'd avoid more than PHP. Java for all the annoying boilerplate code you have to deal with as well as the incredibly strict way of how you need to structure your application and javascript because it's horrible in every way - syntax, type system, ecosystem, npm is probably the worst thing to ever come out of mankind. I think this might be the result of a small number of js developers who were above average and wanted to prove the "haters" that javascript can do more than juggling dom elements. I can probably write an entire book of why both java and javascript are horrible languages but that's not the point here. PHP has evolved and while I can't really find a single vallid reason for using it in 2020, other than legacy systems or maintaining something that isn't worth the effort doing from scratch, it isn't the worst language out there. Certainly not as horrible as people portray it to be.
- rhacker 7y agoI guess those are personal preferences. I would rather use typescript and Java moreso than PHP, Python, Ruby, C++, C#, etc... Not exactly sure what exactly is specifically wrong with npm, have you tried yarn?
- axegon_ 7y agoBoth tpescript and yarn live under the npm ecosystem which, to put it mildly, is a meal that was un healthy and tasted horrible and in attempt to make it better, thousands of cooks tried fixing by eating it, puking it out, cooking it again and repeating that process thousands of times. As I said, I can write a book about the bad things which from all the languages I've used, are only applicable to js & co.
- krick 7y agoWow. I'm honestly surprised by the amount of people (on the HN!) in 2020, thinking PHP is some pre-historical language clearly inferior to... I'm not even sure what. JS? That would be funny. (It feels like I'm defending PHP now, which is feels weird, because I can go on for hours talking about the stuff I hate about PHP. But there is a difference between hating it for problems it actually has, and just not treating PHP as seriously useful modern tool which it definitely is.) That aside, I cannot really treat seriously author's recommendation of Amp, ReactPHP and such as a solution for async. Don't bring up HHVM either. There's no real solid support for async/await in PHP, not even in the form Python has for quite a while now. And for me, it might be the biggest problem it has right now, which seriously hurts in some applications.
- CiPHPerCoder 7y ago> There's no real solid support for async/await in PHP, not even in the form Python has for quite a while now. I'll second this. Async/await support in PHP is at best an ugly hack. I don't know if we'll ever get first-class async/await support since there is no event loop in the PHP runtime, and because of how PHP works (build and teardown on each HTTP request). > And for me, it might be the biggest problem it has right now, which seriously hurts in some applications. What problem are you trying to solve where a lack of async/await would help?
- krick 7y agoI've encountered dozens, maybe hundreds of problems where it was actually something that would matter. Here's one example. Consider you need to process lots of requests, that require making multiple requests that take a long time to finish (like 10-30 seconds) and you need to do it nearly in real-time. Given there's no sane multi-threading in PHP as well, you end up building your own parallelism support, which requires running lots of workers. Now, every of these workers does some pre-processing, makes a requests and waits for multiple damn seconds, to get the result back, make some computations and get to the next job. Consequently, to handle the same number of requests/sec you need much more workers, which has a lot of overhead, which results in needing more servers. Sometimes you can use CURL to just make multiple similar requests in parallel and call it a day, but in practice I rarely could make use of it (consider that service you need to call might require some fucked up protocol, like SOAP, so you best option would be to rewrite SOAP client using CURL with parallel requests, which is not fun at all). At that point you really start thinking some (any?!) other language would be a better fit for the application, but you have tons of very domain-specific business logic written in PHP that you'd need to rewrite for that app, as well as a team of PHP-developers that are not necessarily ready to learn whatever you have in mind, sooo...
- darknoon 7y agoIt's a shame that Hack didn't replace PHP in general use. I didn't see a mention in the article, but it was created to be exactly this safer/faster/more elegant version of PHP. For example, it has a broad type system including generics. My first decent sized codebase was web site for my high school in vanilla PHP. It was a total mess (mostly due to my lack of experience and the need to support Netscape 4.7). I understand that some PHP apps are good, though I got burned by WordPress vulnerabilities enough to swear it off. I wrote a little code in Hack while at fb, and the incremental typing was slowly evolving a messy codebase to some kind of order. (https://hacklang.org https://hacklang.org)
- timw4mail 7y agoWordpress is not PHP. Wordpress would be just as bad in Hack.
- Implicated 7y agoSeconding this. As someone who built (5 years ago now) and maintains a client application that runs along side a Wordpress/WooCommerce shop of pretty high volume - it's absolutely mind blowing to me the kinds of decisions that Automattic/Wordpress/WooCommerce make... from a code and operation viewpoint.
- xixixao 7y agoI agree, it's a shame we don't push Hack more broadly (in general I think the reason is our teams are focused on internal adoption and improvements, and don't feel they would benefit from supporting open source community), it's such a pragmatic language, so familiar that folks pick it up super quickly, it's getting an awesome standard library now, it's a got a great type system, great IDE integration, scales to our bizillion lines of code...
- wink 7y agoI think part of it was because it was being pushed at all. I didn't see a lot of collaboration from Hack towards PHP. It was a - sadly typical - "Hey, here's our thing, it's better". A few select individuals came forward (or were part of PHP core already) but it felt like a Silo, so I'm not surprised there wasn't a lot of participation from outside. PHP 7 and the speed improvements were a direct answer to HHVM, though.
- rahuldottech 7y agoSee also: PHP in 2019: https://news.ycombinator.com/item?id=19917655 https://news.ycombinator.com/item?id=19917655
- CiPHPerCoder 7y agoA lot of people hate PHP because they don't think it's possible to write secure PHP code. Sometimes companies enshrine this ignorance as official policy, and their knowledge of PHP security is as shallow as "php.ini hardening". When anyone encounters such ignorance, point them here: https://paragonie.com/blog/2017/12/2018-guide-building-secure-php-software https://paragonie.com/blog/2017/12/2018-guide-building-secur... Or for more general code quality complaints: https://phptherightway.com https://phptherightway.com I'm looking forward to PHP 8, and beyond. Mentalities that were only relevant in PHP 5.1 (or earlier) are outmoded and should be laid to rest.
- rvz 7y agoAbsolutely, most of all your points can also be applicable to the same reasons why many programmers complain in their hundreds of thousands about how much they hate C++ due to its footguns and sheer complexity which they assume that they have to literally learn everything in the language and from their bad experiences from C++ 2003. So Rust becomes the most loved alternative to C++ but is also equally just as complex, slightly harder to read, twice as frustrating due to some having bad 'anecdotal' experiences fighting with the borrow checker and a large lack of post-1.0 libraries. Those wanting to "Rewrite it in Rust" from a C++ code base will be quickly disappointed... Perhaps the answer to both the PHP, C++ and Rust issues from programmers is always a reply saying "You'll get used to it"...
- deleted 7y ago[deleted]
- tyingq 7y agoAgreed. Most of the historical PHP security problems are mitigated with practices that are common for any language. Like "use a template DSL", "use SQL bind variables" and "don't let the web server user have write permissions to the docroot".
- buboard 7y agois there another language that was written domain-specifically for building websites?
- darkstar999 7y agojavascript?
- brlewis 7y agoBack when I was doing a lot with server-side rendering of HTML I made one: https://brl.codesimply.net/ https://brl.codesimply.net/ These days I generally make SPAs. I occasionally think of reviving BRL but don't have any plans.
- adventured 7y agoColdFusion / CFML was essentially that. It started as a pretty simple tag language that made it very easy to implement basic web application logic. Its ambitions in the beginning did not go very far beyond building websites and connecting to a database. ColdFusion was probably the only language of that era that was easier to learn than PHP. https://en.wikipedia.org/wiki/ColdFusion_Markup_Language https://en.wikipedia.org/wiki/ColdFusion_Markup_Language
- pjmlp 7y agoVBScript, for doing ASP web sites, scripting COM libraries in the process.
- bovermyer 7y agoIf I were to teach a course in basic web development, there are three languages I would introduce students to. These would be Go, JavaScript, and PHP (alphabetical order, not pedagogical order). All three are forgiving languages. Each of the three focuses on a different part of the stack. None of the three will save you from writing gawdawful shitty code, but none of the three will prevent you from writing the most elegant code known to man either.
- rawoke083600 7y agoBrilliantly put ! >writing the most elegant code known to man either. Lol oh the PHP-haters will agree and show you a "Look at my perfect code in xyz"... but the thing about perfect elegant code is no two ppl can agree on it.
- hopia 7y agoWouldn't it make pedagocially more sense to introduce languages that are more different (paradigm) from each other than those languages you listed?
- bovermyer 7y agoIn a single course? I don't think so. Choosing languages that are this similar will make it easier to make the transition between them. The intent is to teach foundational skills in different areas of web development, and not to teach everything about programming.
- hopia 7y agoIf it's a single course, then I'd say teaching more than one language is already too much. Javascript is necessary to learn as a webdev no matter how you look at it, while the other two are not. Javascript can do all the aspects required from a programming language in the web domain so focusing on that would make the most sense.
- rgj 7y agoPHP nowadays has almost all the syntactical candy of Ruby, and Laravel has all the neat stuff of Rails. But PHP is so much faster and easier to deploy. All it has against it is its bad past and ditto reputation.
- verisimilidude 7y ago> PHP nowadays has almost all the syntactical candy of Ruby Seems like a stretch. Ruby's whole mantra is about offering a very flexible and forgiving syntax. Matz wants to make programmers happy. The whole language is candy. You get powerful tools to make your own candy. It's extremely sweet. For some people, it's too sweet, which is understandable. PHP is not that. You may have a point if you're limiting the conversation to people who use OOTB Laravel or Rails to build basic CRUD apps. I'd argue Ruby is a much richer language for those who explore it beyond Rails.
- mekster 7y ago> PHP nowadays has almost all the syntactical candy of Ruby Umm, no? Ruby's syntax is far better. No war against where opening brackets go, no semi colons (which is quite important for typing less after auto completion) and apparently you don't surround with multiple functions to chain which would make the code totally unreadable on PHP with random prefix/suffix/underscore separated function names.
- app4soft 7y agoI would just quote Fredrick Brennan's statement on PHP in 2020:[0] > “There was nothing wrong with the PHP 5 language specification. The problem with PHP is PHP Group.” [0] https://www.youtube.com/watch?v=9crnlHLVdno https://www.youtube.com/watch?v=9crnlHLVdno
- jameslk 7y agoI could not even begin to consider using PHP again until php.ini is completely eliminated. Not even optionally eliminated, I need to know I won't have to deal with a hidden php.ini with all it's configured extensions somewhere on a system before use, surprising me with missing, insecure or completely changed PHP behavior. The fact that I didn't know what features a server supported until I investigated or configured this file was a sinkhole of my productivity in any new project.
- tylerjwilk00 7y agoWhy not run phpinfo()? Lists all loaded configuration as well as extensions and their configuration. Basically everything about the runtime environment your in. Beginner level stuff.
- jameslk 7y agoYes, that was the first thing I had to do when starting a project. Create a file called pi.php that ran that very function and scan pages of configuration looking for a specific key. I would have to do this not once but many times, whenever I thought I was losing my sanity because some random extension wasn't available or the configuration enabled something unpredictable that I only found out about at runtime (e.g. magic quotes was a perfect example).
- gremlinsinc 7y agoyou couldn't just run "php -i | grep xdebug" ? Or even explicitly set/unset the phpini settings from the app in question or even your nginx settings? Lots of ways to ensure everything works as needed. You can also include excensions as requirements in composer so it errors if they aren't installed so you don't forget to install them.
- jameslk 7y agoI spent 10 years in the PHP world and yes I can do all that stuff. I had to do it just to use PHP. Grepping around configs isn't even the problem I'm trying to point out. It's the surprises, and having to do anything at all to prevent these issues.
- nwmcsween 7y agoThe PHP ecosystem is similar to the language (I work on it daily), tools are a mishmash of features that may or may not be relevant to the tool. PHP ORMs in general (compared to say Ruby or Python) are absolutely painful to work with, which leads to most large projects that need a DB making a hard dependency on MySQL.
- Implicated 7y agoDo you have any examples of "tools are a mishmash of features that may or may not be relevant to the tool"? Or why the ORM's make MySQL a hard dependency? Honest questions, genuinely curious. I, too, work with it daily and am curious as to what you're doing/seeing/running into that I'm not.
- pbowyer 7y ago> PHP ORMs in general (compared to say Ruby or Python) are absolutely painful to work with Which PHP ORMs are you thinking of? I've worked with Doctrine ORM, I would not say it's more painful than SQLAlchemy.
- purerandomness 7y agoThere's an excellent Postgres data mapper called Pomm: http://www.pomm-project.org/ http://www.pomm-project.org/ with similar concepts to Java's jOOQ. I can't think of any ORM that makes MySQL a hard depedency. Doctrine, EasyDB, Atlas ORM, ... all support Postgres or any other DB.
- pabs3 7y agoDoes PHP have the ability to be run as a WSGI script yet?
- treve 7y agoWhat would the benefit be? (I don't know WSCGI that well)
- zonidjan 7y agoArray destructuring: already existed, list() pseudo-function Array spreading: already existed, array_merge Variadic functions: are probably better implemented as a function accepting an array, especially now that there's a proper array syntax instead of a pseudo-function. Also already existed, func_get_args. Argument unpacking: already existed, call_user_func_array Arrow functions: are not any shorter, and are less clear, than anonymous functions. Literally the only item on your list that was any good for the language is the null coalescing operator. The rest are just re-implementing something that PHP already had, in yet another incompatible (and often unclear) way. Hell, good luck coming across '??' and trying to find any documentation on what it does. Searching Google for 'php ??' returns results for 'php', searching php.net for '??' returns seemingly random functions, going to php.net/?? gives you the homepage.
- colordrops 7y agoThe problem with PHP is that every discussion is about PHP's reputation. It's a language that is overly self-conscious.
- krapp 7y agoThe language isn't self conscious. Programming languages have become subject to fashion trends, unfortunately, and "discussing PHP's reputation" is the tech equivalent of virtue signalling that one is too hip to shop at Wal-Mart like a common pleb.
- Keverw 7y agoNice overview. I like how it seems like PHP has a lot bigger built-in standard library compared to Node, as some people install NPM packages for little simple things. Then PHP has a built-in time and date helpers, like timezones. However, the $ dollar sign for variables kinda annoys me, as switching back and forth between PHP and other languages like JS. Like recently ran into an issue where I forget $ in front of a var and JSON encoding it, and then went to var_dump it but realized I forgot the $ so it was outputting the variable name instead of the variable contents. I guess muscle memory. I know I was reading a blog post though where someone built a React frontend around Wordpress as a headless CMS, thought that was interesting but haven't looked into how to do it yet 100% but was proposing it to someone I know that has a large site built around WP but seems like a mess of plugins and theme tweaks so I felt moved to something else would let controlling the design and changing things without forking plugins when there are tweaks wanted that isn't part of the official plugin, etc as I feel like that would allow more complete control of the presentation layer without tweaking multiple things and stuff. However some businesses don't really care about the tech under the hood, they just want it done quick with results, don't really understand all the technical stuff and care about costs, so not like a tech startup where you care about a lot of the little details or maintaining things for the future. Then some people don't even really know what they want either, but I guess business people managing tech people, but even big tech companies I doubt all of their CEOs are even technical either though but maybe they hire technical project managers to help bridge the gap between the two parts of the business but their product is mostly tech though anyways so I assume a different culture than tech in a non tech business. Looks like some projects to do server-side react with PHP too, but haven't played with any personally - but that's useful if someone cares a lot about SEO even though Google can crawl SPA's but other search engines might not be as capable, then sharing on social media not sure if they use server-side rendering when grabbing the metadata for open graph for example. That'd be neat to pitch to non tech businesses who might just be running on a cPanel server and don't want to really invest in servers and managing them much yet, so mix both PHP and React would be prefect maybe for some types of companies, PHP and MySQL for the data part with a nice clean modern and fast react front end with near instant page loads. Kinda interesting about support for web sockets and more async stuff in the future, I guess in theory than you could write real-time game servers in PHP for example? I know some game servers are in C, C#, C++ or Node though, but long-running PHP code would be useful for other types of applications that aren't just mainly restful web pages or APIs. Then another thing is you might find examples or libs in PHP but have to dig for equivalents in other languages, probably since PHP is so popular and easier to get into maybe. Then somethings you'd find a good lib in Python like I was looking at something and didn't see an official JS client but they offered a C, Go and Python one... Would be neat if somehow you could easily just combine the languages, I seen there is a Node PY bridge though and sounds like some experiments of compiling PHP to WASM but haven't played with it(wondering if it compiles only the code you wrote(I guess perfect for code you happen to strongly type) or the entire PHP binary along with it, but I know FB was working on compiling PHP to C with the HACK project, so a similar idea might work for WASM but not sure if it's a sane idea - maybe just porting the code you need would be a better answer maybe... but that'd be an interesting way to develop, but I guess with microservices you could mix and match too but some little tiny things seems a waste with all the networking calls.
- epicgiga 7y agoPHP is a fantastic language, and my personal favourite. It was the first language written with web serving in mind. It is packed with features due to all the adding to it over the years, meaning you can write code how you want, no how they want. What it also acts as is a good barometer of dev mentality. When a dev declares PHP is a [expletive] language, he's telling me how he's going to be to work with, how he's going to engineer his work, and how concerned with adding value to the business he's going to be versus playing with "hot new tech". Even if it's for a .NET role. The plurality of the internet is PHP back, html/css/js front. Those who thumb their nose at that are profoundly arrogant, and probably currently experimenting with their 8th new framework for the year. Junior devs do as they're told and don't form opinions. Mid devs know enough to be dangerous, run their mouth on everything, and bad mouth anything that isn't precisely their opinion or something they personally like. Senior devs see the big picture, have realised the folly of their earlier ways, have a healthy respect for practical reality, and are more concerned with codebase integrity than in if it contains "hot new tech" (fuckarounds). This is why it's critical to have truly senior devs at the top of the hierarchy, as otherwise there's no one to suppress the mid level devs, who will in turn mislead the juniors.
- dijit 7y agoI don't doubt that PHP is becoming (has become?) a decent language. Especially with frameworks such as laravel which are mature and clean. But PHP has a legacy, lots of bad PHP code exists already, bad practices are usually the first result on google and very "lazy" developers who never learned anything else exist and this muddies the waters very much when talking to people who prefer to build new things in PHP. There's also the nitpicky fact that the old way of running PHP was that every page request runs the code from scratch, meaning you have to build state each time which is profoundly expensive and inefficient, although I believe people rarely do this anymore it's still definitely the default for most PHP projects I've seen. (both FOSS and proprietary). I don't like your overgeneralisation about junior/mid/senior developers, the lines are super blurred in the real world. (I say this as a non-developer who works with developers)
- epicgiga 7y ago
- pjmlp 7y agoI used to be on the hate side and kept searching for alternatives for my site, until I decided to actually spend some time learning PHP best practices. Quite happy that I took that route, and that I was able to keep getting the language and eco-system improvements along the way. Modern PHP is quite good for the context of building web sites, its original purpose anyway. Languages don't need to be good at every domain.
- nkozyra 7y agoThis is a quibble but reminiscent of the kinds of inconsistency PHP programmers are known for: $value = $object->property ?? 'fallback if null'; $value = $array['foo'] ?? "fallback if key doesn't exists";
- lemcoe9 7y agoI do not understand, both of the expressions on the left-hand side are NULL, which looks like ?? is doing the same thing in both examples. A non-existent array key and a non-existent property on an object are logistically identical.
- nkozyra 7y agoI was referring to the single-versus-double quotes.
- slifin 7y agoI think PHP suffers from the java migration, we now write code like this https://github.com/aran112000/Advent-of-Code-2019-PHP/blob/master/Day01/Day01.php https://github.com/aran112000/Advent-of-Code-2019-PHP/blob/m... when functions in a namespace would have sufficed It seems like collectively developers are patting themselves on the back for putting the same old crap code in classes, as if putting data into a change by reference data structure is a good idea Personally I'm trying to migrate out to Clojure where mutation is hard and controlled by default & we don't pretend modelling reality with a tree of nouns is a good idea
- pas 7y agoClasses are/were thought as awesome because you can do dependency injection via providing an object, but you can't easily do that with just providing a different implementation namespace. That said, maybe PHP is not the language where you need to do DI. Just have a few different config files around, do the includes and wiring there and that's it. And hope for the best. (After all there's no compile, no checking of interface correctness with any kind of DI either.)
- luord 7y agoI'm happy for the PHP developers. I still find it an eyesore to read, but everyone is free to use their preferred languages. Stuff like this article shows that good software can be created in any language if there's the will. Even in brainfuck (I assume).
- lunias 7y agoPHP is so polarizing... so much so, that it's enough for me to pass entirely. Even if the language has improved I think the culture is still broken.