[HN Gopher] Taking PHP Seriously (2016) ___________________________________________________________________ Taking PHP Seriously (2016) Author : ziodave Score : 65 points Date : 2020-12-02 21:06 UTC (1 hours ago) (HTM) web link (slack.engineering) (TXT) w3m dump (slack.engineering) | blibble wrote: | how's PHP's websocket support? | | presumably if it's a thread per websocket then they're using | something else to serve that? | TazeTSchnitzel wrote: | There isn't direct support for WebSocket in PHP like there is | for HTTP requests. But there are WebSocket servers written in | PHP that work in a similar way to node.js. | latenightcoding wrote: | Somewhat unrelated comment, but the fact that PHP got so good and | most people are still not willing to give it a second chance goes | to show how hard it is for a language to regain market share | after people left for greener pastures. | pvg wrote: | Forum share, maybe, but it's been and remains an extremely | popular language. | andreygrehov wrote: | Given PHP 8 has been released, does Hack provide enough value to | consider it as an alternative? My take on it is no, but I'm | curious about other people's opinions. | mgkimsal wrote: | only played around with it briefly a few years ago. my view is | "probably not unless you've already used it, or have knowledge | of some specific PHP issue you know you're going to need that | Hack provides". I think 4-5 years ago, there was a point where | Hack might have been able to grow out of niche status, but I | think that time's passed, with the growing community around | 'modern' PHP and the ecosystem provided via composer and | frameworks. | munk-a wrote: | It is good to keep in mind that this article is more than four | years old. I would advise against Hack at this point since | _most_ of the good bits have been integrated into the main PHP | release - typing is a lot more predictable and enforceable for | instance. | andreygrehov wrote: | Oh boi, my apologize, I missed the "Written 4 years ago" | part. Good call. Thank you. | [deleted] | say_it_as_it_is wrote: | I thought Slack was running on Perl CGI.. | [deleted] | [deleted] | paxys wrote: | The best language for a startup is one the founders know the | best. Every other discussion will at best make a 1% difference. | twelvechairs wrote: | Or the language of any libraries that are useful to build on | munk-a wrote: | Close I think - the best language to use is the one you will | have the easiest time hiring good talent for. If you found a | startup and all really love and are fluent in COBOL that's | great but... good luck when it comes time to hire another | employee. | nullsense wrote: | That's making a bold assumption you get as far as hiring. | paxys wrote: | If you have a good product new engineers will learn whatever | language it is in. This very article is a perfect example. | I'm sure Slack isn't hiring kids out of college with | extensive PHP experience. | fiddlerwoaroof wrote: | This is strange to me because I've taken and succeeded at two | positions now where I didn't know the language going in. | polote wrote: | at best 1% and most of the time -50% | ransom1538 wrote: | Fist bump. | pqb wrote: | Discussed previously: | | * https://news.ycombinator.com/item?id=12703751 | | * https://news.ycombinator.com/item?id=15262981 | | PS. Would you mind adding a [2016] in the title? It will show | readers it is needed to take a historic context to understand the | article correctly. | aussieguy1234 wrote: | This was written 4 years ago. Since then, PHP7 and PHP8 have | incorporated many of the benefits of HHVM. | okareaman wrote: | Thanks for pointing this out. I read this article as "PHP is | bad, use Hack instead" | ransom1538 wrote: | Long live PHP. | | 15 years of PHP dev work. Games, mobile apps, health care, etc. I | have been unemployed for 2 days in 15 years. PHP runs %80 of the | internet. Talk to anyone at facebook that wears a suit on friday | -- they code PHP (and very well i might add). I think I will be | 90 years old hacking on PHP.If you really don't like how the | arguments are passed just use an IDE. Or get stuck with real | problems like python (urllib3/urllib2) wtf. | okareaman wrote: | I've used a lot of PHP in my life and now feel Go is better | suited for my needs. My gut tells me Go libs are written by | professionals, while there is a ton of PHP code written by | amateurs to contend with. I'll know more once I get further into | Go. | hu3 wrote: | Do they still create new backend code mainly in PHP or have they | also adopted other languages for new code? | apeace wrote: | So the entire argument is that PHP is single threaded and each | request starts with no state? Am I missing anything else? | | I'm trying so hard not to rant here, so I just wanted to confirm | that those are the only positives he outlines about the language. | recursivedoubts wrote: | FTA: _" I claim that PHP's simpler "think; edit; reload the | page" cycle makes developers more productive._ | | I agree wholeheartedly with this. I prefer statically-typed | languages w/ a bit of local inference (I end up in java | usually, but C# got it right) and I consistently see people in | my world underestimate the edit/reload workflow. Even a small | compilation step is enough to break flow and make development a | chore, once you've worked that way. | | As a side note: java not allowing signature changes and | requiring a whole server restart is absolutely awful. It didn't | have to be this way: the DCEVM[1] was presented at the 2009 JVM | Language Summit[2], by Thomas Wuerthinger. He patiently | demonstrated and explained how his work allowed for hot swap of | arbitrary class changes, while the Sun guys sitting in the | audience told him that what he was demonstrating was | impossible. We ended up using the DCEVM for a long time, but as | of right now I'm back to restarting my server when I make | breaking changes. It's a funny world. | | -\\_(tsu)_/- | | [1] - This is a modern fork of the project: | https://dcevm.github.io/ | | [2] - http://wiki.jvmlangsummit.com/Hotswap | apeace wrote: | It's hard for me to relate, because I just don't see "edit; | reload" as being that important. | | I think the difference is I write tests. I usually code | everything while writing/running tests. Then it always works | the first time I run it, so there's no need for "edit; | reload". | recursivedoubts wrote: | Oh, you were asking about benefits that you can easily | relate to. | | Well, in that case then you'd be in a much better position | to answer than I am. | munk-a wrote: | I really like working in PHP but I'd actually agree that | edit;reload is a virtue of the language (in the environment | everyone normally assumes it's running in) that is losing | value. | | This virtue was incredibly valuable to me when I was | throwing a website together with ducttape and bubble gum | and it was the only way (that I knew of) to be able to | clearly and quickly see the results of my changes. With | tests in the picture I think it loses a lot of that value - | it still has some since nobody likes writing front-end | tests but most of your code changes should be "proven" by | some level of automated test coverage. | coldtea wrote: | > _I'm trying so hard not to rant here_ | | Not that hard, there's a bias showing. | | First, those things you've mentioned are nothing to sneer at, | are actual very good decisions (even if accidental) for a | webserver-centric language. | | They enable even naive developers to achive good scalability | and isolation, and make fast development/debug cycles trivial. | | Second, PHP has been improved by leaps and bounds from the days | of 4, to the point of being a totally different language - all | of the above points are already made in TFA. | | Most arguments against it are moot today, or only apply | superficially to the standard library, not the language (order | of arguments, and so on). | | Plus, it is speedy too, post 6, and especially post 7 (and | there's a whole new JIT in 8). In any case, it has constant | work on speed and memory reduction. | | And of course it has a huge ecosystem of libs, projects, and | frameworks, including not available anywhere else projects like | Wordpress. | | And the standard library (warts included) between JSON, DB | drivers, LDAP support, SMTP, etc., is one of the most complete | ones this side of Python, and perhaps even fitter than Python's | for typical web development work. | | Plus the deployment model is one of the best. Copy your files | to a directory. Done. Add a redirect instruction to your server | if you want to make it more fancy... | | For third party libs, composer is up there with any major | package dependency/install solution. | | And for the core libs, plugins, etc installation is handled | perfectly by the standard package managers in all Linux distros | (and probably Windows too), and is even easier with MAMP, WAMP, | etc for local development. Trivial to dockerize too if that's | your thing. | throw_m239339 wrote: | > PHP has been improved by leaps and bounds from the days of | 4, to the point of being a totally different language. | | No, most of bad parts are still here, all the stdlib | inconsistancies and co are still here. Just because add more | functions to a language doesn't change the bad design | decisions at its core. The weird mix between dynamic typing | and Java style rigidity (without most of its benefits) didn't | go away. | | What makes it a different language since PHP 5? more type | guards? no, it's still a templating language. | munk-a wrote: | Those strange naming choices definitely still have a cost | but a lot of effort has been invested in documentation and | alternatives to lessen their cost. | | The mixed typing is... honestly, it's amazing. You really | need to try it out for yourself in PHP7 or 8 - you can lean | on really strict type checking in your application, go the | old route or generally adhere to strict typing and relax | that for entry points and library calls. | | Lastly, PHP has come down hard and actually introduced | backwards compatibility in a few key places to address some | of the biggest WATs, I've been pretty impressed by the | balance of the language stewardship. | | It does definitely have warts, but there are warts on | everything that people actually use in industry. | zug_zug wrote: | IMO it's such a good thing about PHP that I think other stacks | should follow that model (I assume ROR does). | | I think it's a superior model to the long-running application. | Unless your company has 0 developers in it who make a memory | leak, or make a fatal uncaught exception. | fuzzy2 wrote: | Hm. This is this and that is that. It is perfectly possible | to write a stateless service hosted in a stateful process. | | In fact, the popular PHP-FPM way to host PHP does just that. | | If you want to take it to the extreme, there's always CGI, of | course. | pentium166 wrote: | Ruby on Rails lives inside a long-running application server. | In development, it has dynamic class loading and will reload | on file changes, but in production an app can have a lengthy | startup time. It does have the memory problem, but I have | never seen the server crash outright as a result of an | exception while handling a request. | glaucon wrote: | You might have missed this bit - "Did Facebook, Wikipedia, | WordPress, Etsy, Baidu, Box, and more recently Slack all | succeed in spite of using PHP?" | IshKebab wrote: | They didn't provide any real arguments that the answer is | anything other than "yes". | | Plenty of languages have support for hot reloading, which | means you can just edit, save, refresh exactly the same as in | PHP, with the added benefit of not having to use PHP. | nickthemagicman wrote: | PHP after 5 is great. I guess from PHP 7 on things changed pretty | significantly. | | Combine it with Laravel and nginx, and you've got an enjoyable | stack in my opinion. | Superfrag wrote: | "For instance, 123 == "123foo" evaluates to true (see what it's | doing there?), but 0123 == "0123foo" is false (hmm)." | | Can anyone explain this to me? I know if a string starts with the | number, PHP takes the number part and throws the rest, so | "0123foo" should be 0123 for the comparison, so why is that | false? | tsm wrote: | Edit: I was wrong. 0123 is octal, not decimal | | [Incorrect original post: 0123 evaluates to the integer value | 123] | [deleted] | mam2 wrote: | So ? | bugfix wrote: | 0123 (octal) != 123 (int) | civilized wrote: | But the integer part of the string "0123foo" is also 123 | munk-a wrote: | Not quite - 0123 is the octal value 123 which happens to be | 83 in decimal. Numbers starting with a 0 in PHP are assumed | to be in octal but I this isn't the case for strings[1] - to | add to confusion "123foo" == 123 => true but "0123foo" = 0123 | => false. | | 1. https://3v4l.org/hAoL2 | [deleted] | ed25519FUUU wrote: | > _Slack uses PHP for most of its server-side application logic, | which is an unusual choice these days. Why did we choose to build | a new project in this language? Should you?_ | | We already know the painfully obvious answer to this question | even if it's not listed in the "reasons": because the technology | decision makers were comfortable with PHP and they _wanted_ to | use it. | mgkimsal wrote: | is this terribly different from many other choices made by | other companies? | | "Whew... we're all totally psyched with node, and all have | experience with it, know how to solve problems with it... but | we're going to commit to Django. We don't _want_ to, but we 're | going to." | | Does that exchange ever happen? I've seen the opposite - almost | every tech stack I've seen at small and medium sized companies | was primarily the result of the few decision makers who had | experiences (good or bad) with specific tech which influenced | their decision to use X. | asamarin wrote: | Article written in 2016, mind you | zapt02 wrote: | A bit sad that despite Slack being (or being built) on top of | PHP, there is still no official PHP SDK four years later. | rabuse wrote: | This seems to be an unpopular opinion in the tech world, but I | honestly enjoy working with PHP. It's such a simple, robust | language, and you can use it in many different ways, depending on | what you're building (OOP, scripting, microservices, etc). | mgkimsal wrote: | I'm with you. 10 years ago I was doing moderate 'shell | scripting' type stuff in PHP - if I needed to scan a dir, parse | some files, etc. PHP seems usually far more useful than trying | to shoehorn the problem in to bash. And... writing shell | scripts in Java ain't ever going to be a thing. ___________________________________________________________________ (page generated 2020-12-02 23:00 UTC)