But, for a brand new greenfield application. Why would someone choose PHP for their backend, when Golang is available?
I was at a developer meeting with a company who were reviewing what to use for a client project. The developers are from PHP/jQuery shop, however they felt it necessary to be with the times so to speak, for the future to get other projects. They opted for Vuejs and Golang with server side processing.
Apparently the client has some server side operations which are particular heavy and mentioned that php/python/ruby are just too slow with their own internal testing.
I'd say probably a large part of the reason PHP devs opt to use different languages in new projects (when given the choice) is because of FUD spread about PHP. Everyone wants stability in their career. If the voices on the interweb are loud enough saying PHP is dead / dying, it kind of becomes a self-fulfilling prophecy.
I would hazard a guess that if PHP was not so hated (like the one kid on the playground that everyone decides to mock because everyone else is, and because it keeps attention off of them) devs who are familiar with and articulate in PHP would not hesitate to start new projects with it.
Anyways, my personal perspective is server-side is becoming a smaller and smaller piece of the web. Any reasonably designed language should be sufficient. Unless maybe if you're Google or Microsoft, or deal heavily with extremely large datasets such as BigData / Analytics / Machine Learning companies. And even then worst case scenario you just throw all the data into AWS RedShift or something like that.
If you're writing an OS, building a Linux driver or writing a memory management library I'd certainly recommend avoiding PHP :)
BTW, I've run side projects where PHP (before 7.*) sufficiently handled databases with 100's of tables containing billions (yes, that's a 'B') of rows each on a single $250 laptop. That includes jobs running relatively heavy analytics jobs on those tables. My guess is if the company was spending money to get appropriate talent to handle their infrastructure they might be able to make PHP work well for them without a lot of trouble. And by that I don't necessarily mean they have untalented people. I'm saying if they're truly "fluent" in PHP, or are willing to put in the effort to learn PHP, it shouldn't be hard to do.
>I'd say probably a large part of the reason PHP devs opt to use different languages in new projects (when given the choice) is because of FUD spread about PHP. Everyone wants stability in their career. If the voices on the interweb are loud enough saying PHP is dead / dying, it kind of becomes a self-fulfilling prophecy.
No programmer can expect to use just a single language over their whole career. They might have career stability if they choose that but very risky stability.
True. I read the OP as describing a scenario where (a) Devs were originally hired as PHP devs, (b) Those devs decided to use a different language in the new project.
- it's easier to find PHP programmers
- you get a lot of mature frameworks with huge communities
- most of the time you don't need fast but fast enough
just some of the reasons, PHP7 is actually quite nice.
Yeah PHP can be pretty slow. For example on the symfony3 project (also with Vuejs) I currently work on which has ~6 doctrine DB classes, 5 controllers and returns just a simple json representation (1kb) of one the entities using symfony serializer I get response times of 70ms in production mode on an i7-4790K with 16 Gigs of ram. Getting the same entity simply from CouchDB yields response times of 3ms.
The problem is that PHP needs to bootstrap the entire environment for every request (minus some more or less efficient caching) which may be OK for monolithic applications but as soon as you want to build an app on HTTP2 that runs many requests, it will just always feel sluggish. And for this symfony already cheats massively by merging all class files into one huge bootstrap.php file etc. PHP just wasn't made for large applications.
I agree there are very few people who know PHP well enough to build large web apps with it. On the same token I doubt, once you get that big to where it really matters, there are many web devs who know how to write web apps that scale well at all.
Everyone else is just taking advantage of a few milliseconds here and there (for example compiled language vs interpreted language) that might "appear" the language is better suited to the task, but ultimately only are as good as the architect(s) of the system made them.
I disagree PHP the language is deficient in any significant way that would prevent anyone from building large, modern web apps with it.
It's not just doctrine that makes it slow, it's the whole bootstrapping process on every request.
Compare this to a Java Application using JPA and JAX-RS with >50 model classes and >10GB data which gives response times of <10ms with debugging enabled (OK it uses more RAM, but meh).
> It's not just doctrine that makes it slow, it's the whole bootstrapping process on every request.
When you use proper opcode caching, you avoid the startup hit.
And having a generous amount of RAM usable as disk cache also helps in framework-heavy projects - the more files can be cached in RAM, the less PHP has to hit the disk on require/include.
All those opcodes etc. are the "hacks" to accelerate php bootstrapping. For example in java there are already threads waiting for the request and when a request comes, the path of the request until the controller is much less. There are cache connection, db connection, everything is ready waiting for the request. In PHP for every request the same story is repeating and repeating. If you have a index.php, serving directly your logic, there is no problem, php is designed for those use cases. But if you are using a modern PHP framework that mimics Other platforms (I believe most of them are inspired by JAVA), you are having a big overhead because PHP is not designed to behave like this.
Another question, with those modern PHP frameworks you are already learning and applying almost every concept that you can use with (let's say) JAVA. Then why not to use that powerful platform which inspires PHP? It is like you have driving licence for a truck and you can drive a truck almost perfectly after 3 months of practice, but still you prefer your old minivan to carry 10 tons of load. The minivan was not designed for 10 tons of load but there are some modifications allowing that, but if you spend 30% more fuel.
Don't come with the argument of "php is easy". It is as hard as other similar languages.
The language is as hard or as easy as any other similar language, yes, but the platform is much more easy to learn and use. Usually it is the platform, community and the environment that takes time to learn for any language.
Large PHP frameworks I think is starting to reach end of line. Seems like a micro framework trend has started with Zend Expressive and similar middleware based frameworks.
There was a trend of making PHP into Java, I think that is the wrong path, as you say, Java already exists. That trend also existed in JavaScript a long time ago. Seems like a natural instinct by some developers to do so when trying to create structure from a chaos like world.
Much better to build on PHP strengths. Dynamic, stateless, fast development cycle.
> When you use proper opcode caching, you avoid the startup hit.
In a setup with nginx, php-fpm and symfony here is how i understand the whole process.
1. A request hit nginx
2. Nginx parse the request and send it as fastcgi protocol specify to
php-fpm.
3. Php-fpm looks it's pool of php processes if there is none
available, it starts a php process (so some code is run).
4. Php-fpm fill the $_GET,$_POST etc... variable of the running php
and give it a file to execute.
5. The php process check if the file is in opcache load the bytecode
from it otherwise compile the file to bytecode and store it to
opcache.
6. The process run the script and write back to php-fpm who write back to nginx.
So now more on 6. from the point of view of a Symfony app.
1. the app.php will include an autoloader, this mean during the
lifetime of the php process every time a new
\Some\Class\Or\Function\Or\Whatelse is encounter the autoloader
code will be run. To mitigate this composer could generate an
autoload that is an associative array of \ClassName\And\The\Like =>
filename.
2. Then it include the bootstrap.cache.php this file is a
concatenation of the Symfony classes (all or the most used) in
order to reduce autoloader calls.
3. Then it create the kernel the it load more file (from app/cache)
like the service container definition+configuration and the
routing (and maybe more stuff but i don't know).
4. Then it put $_GET,$_POST etc... on it's own abstractions
(HttpFoundation\Request etc...).
5. At this point the bootstraping is done.
And i also want to remind that a class declaration like "class House
{}" is a code, that create a datastruct that has to be run on every
request, this is also what people call bootstraping.
The bootstraping is take seriously enough to have :
1. composer -o (generate the associative array)
2. bootstrap.cache.php
3. the whole app/cache directory of symfony which i find pretty
terrible as comp. sci. point of view (choose a limited language and
build compilers to work around) even if they do a great job at
error reporting.
4. php-fpm pool of thread
5. opcache
Golang isn't a bad option...but neither is (modern) PHP, Python, or Ruby. (Or .net, JVM, nodejs...) Each has some specific advantages, and that absolutely includes PHP.
PHP right now is in an interesting space: It's very stable, it has an enormous ecosystem, it has some extremely strong frameworks and tooling, the syntax has stopped being egregiously bad, it's starting to get quite fast, and the PHP request/response model is very attractive for some purposes, and avoids an entire class of bugs which crops up with, eg, nodejs.
If you're doing something where PHP is appropriate (which is a lot of stuff), and you're familiar with it, you're going to be extremely productive. Switching to golang (especially if not familiar with it) is like deciding that instead of going to the supermarket and buying a loaf of bread, you're going to buy a farm and figure out how to grow wheat. You have the ability to end up with a better product, but there's no promise you will, and it'll be a lot more work.
> Apparently the client has some server side operations which are particular heavy and mentioned that php/python/ruby are just too slow
Of course if the client requires you to use golang, then sure, use golang. But it makes me wonder about the design the client is imagining. If your web server is trying to do very intensive calculations as part of the request/response cycle, you're probably doing something very, very wrong. But if you're not doing that, why does your need to do intensive calculation impact your choice of frontend? What's stopping them from having a lightweight frontend which queues up jobs in a task queue, and then have workers written in golang or C or whatever? And then maybe a websocket server to feed results back to the browser as they arrive? Where did they get the idea that a project needed a single language for every feature?
As someone who uses both Go and PHP, I think they're separate use cases.
The up-side to PHP is that it is super-flexible. The down-side to PHP is that it is super-flexible. You can work fast with it, which also allows you to be extremely sloppy with it. The programmer has to wield all the discipline, because the language sure isn't going to help.
The up-side to Go is that Rob Pike is older, wiser, and learned all of the mistakes of C and C++. Rather than have it be all things to all people, he made some very opinionated design choices with crystal-clear trade-offs. More code will have to be written. It will be in an imperative style. Errors will need to be handled explicitly rather than through a catch-all exception. Elbow grease! Elbow-grease that results in more robust code that is easier to understand and reason about.
So, why PHP? Sometimes quick and workable is preferable to slow and great.
No reason really to use PHP for a new project in 2016. Then again, no huge reasons not to use it, either. Sure, it's slightly sub-standard in many small ways, but your success or failure is probably not hanging on those things.
So if Go looks better to you, you should use that.
- easy deploy
- large community
- anyone can code PHP and become productive fast
- No built in shared state.
- PHP is available almost everywhere
- proven
- simple development cycle
Guess that depends on whether you take the client's word at face value. If they've done the necessary profiling and analysis, sure - but if not it's also possible they're performance constrained by their DB layer or some badly structured code. No way for me to know though, of course :)
> I miss the inquiring, helpful Net of increasing yore. Enough other people do, too, that I haven't given up hope it may find a home somewhere.
Not sure how old you are, but I used to use 300 baud modems. I was pre-internet. I remember then 1997 on irc, then when the masses really woke up to the Internet around 1999-2001.
Anyway, people around that time really had hope for the internet.
Nowadays, well millennials just don't seem to have the same feeling. I figure they are in their bubbles happy to have whatever sandbox they are in keep the status quo and everything else, as long as their wants and needs are met, doesn't matter.
Give it a generation or two and we'll be just like Wall-E. Drones on basic income, with smartphones incorporated to our brains with all the corporations telling us how to live, work and think.
Seriously, this dystopia is not that far away. Just a few key ingredients for this to happen.
I trace the death of the Web I loved to around 2007-2010. That's about when it seemed like it stopped getting better and started getting worse.
- Google seemed to give up the spam war and start just returning only major sites for the top of most results around that time.
- Youtube started to become a way to make money, which was the beginning of the end for it. Google advertising IIRC started to get big on it around that time, too.
- Facebook started to expand beyond college networks and the recently-graduated to grandma and grandpa.
- Google generally started to Be Evil in a real way, fairly consistently.
- Amazon started to get all crapped-up with 3rd party retailers and print-on-demand garbage infecting even their book results, making it worse overall.
The main difference now is that instead of sorting through some small-time spam and ad-junk material to find the good stuff, the whole damn thing, practically, is spam and ad-junk. Local news sites look like click farm ad spam sites from the early 2000s. Ads in google results. Wading through disguised and explicit advertising and self-promotion on Youtube to find anything good. "1 weird trick!" on once-respectable sites. "Buy my (shitty) ebook to learn my secrets!" everywhere. We didn't beat spam—it ate the Web. It is the Web. The weird-but-good still exists but is harder to find. The Web kinda sucks now, unless you like advertising.
I'm pessimistic about it ever getting better. Maybe some new frontier will follow it, and that'll be OK for 1-2 decades before it gets ruined, too.
>> We didn't beat spam—it ate the Web. It is the Web.
That hits the mark for me. It feels as though the entire web is one big advertisement for stuff you don't need. It's made people apathetic. They don't even see it though it enters their subconsciouses.
IM-ing (in its then form) with "Sleepy" in the Netherlands (me in the U.S.) in 1987. Locally in a development environment in oh, '82, '83.
Sneakernetting SEDIT from an employer, a state over to campus tech support, who welcomed it.
Due to my circumstances, I missed most of the BBS phenomenon. But I experienced plenty of "we're in this together" in other venues.
Early Google was magical. Quality, helpful pages and sites at the top of the results.
"Early" Web bulletin boards had "real", de facto (by the general capabilities and sophistication of the time), often helpful anonymity (including for "survivors" of various sorts), and focus all too often missing from today's milieu.
Now -- trying not to sound elitist, but rather just particular -- the noise and banality washes out the quality that was once much more evident and prominent.
The extant Net is lost to the general population and the organizations that seek to control it and exploit it. Fine, for what that is, I guess -- today's television.
But not what I want.
And, free and cooperative communication (even in and supporting lively but intelligent and informative dispute) I also find to be essential to a functioning society. And to those who really move that society forward -- technically and otherwise.
The increasingly gated, panopticon fiber and IP address internet is less and less suited to serving this.
Nowadays, well millennials just don't seem to have the same feeling. I figure they are in their bubbles happy to have whatever sandbox they are in keep the status quo and everything else
Also, they think it's right and good that they bully, shout-down, and ban whatever they don't like. After all, it's the way of the online forums, and all that stuff is progressive and advanced, right?
I upvoted you. Please do not downvote, if you have never been with someone who is seeking specialised help with anxiety issues. You simply don't realise the enormity of the problem.
I was with someone who had very very high anxiety issues. She also had ADHD and I'm sure some other disorders. She was on lexipro, lorazepam, clonazepam, diazepam, zoloft and other medications.
Thankfully I was with this person for just 1 year.
I was able to get out, but at such cost to my own mental health. Even after 6 years, I still don't have my own pieces together. It's like they say, once something has broken. You just can't put it back together the way it was.
> My best advice is to get out NOW
Best advice ever. You have my admiration if you are able to work it out and have an understanding partner. Unfortunately, I did not have an understanding partner. Even though, I moved heaven and earth to be there for her in every way, it just was not enough.
Although I should be saying, I hope she finds happiness. Except, I really feel bad for the guy she is with now. As her baggage is enormous. Instead, I hope she is getting the professional help she needs!
To the OP: I also purchased this at $10, thank you!
-------
I did a search for coupon codes and I found the exact coupon code from [1].
Can I ask, what would the problem be if the code was affiliated with an affiliate promotion?
The end user pays $10, which I think we can both agree on. It's a "NET" benefit for HN users to learn something new very cheaply.
If couponkoo negotiated with the vendor of the product, so that they can advertise a coupon and get some kick back, you know because they too have to keep the lights on.
Is that such a big deal now on HN? Can you please explain yourself because I don't see an issue here personally!
I live in the UK. I think it's really only a matter of time before they outlaw VPN or at the very least, they break the encryption so that if you do use it. They can still see what you are doing.
-------
First they came for the Porn Sites, and I did not speak out—
Because I didn't watch Porn.
Then they came for the Torrent Sites, and I did not speak out—
Because I didn't torrent.
Then they came for the Bitcoin Sites, and I did not speak out—
Because I didn't pay with bitcoin.
Then they came for me for using VPN and there was no one left to speak for me.
According to other parts of the Digital Economy Bill, it's not actually ISPs that bear the burden, it's Connection service providers, i.e. any service that provides you with a connection - including VPNs. What they'll do to VPN providers that don't comply I don't know - probably they'll find their powers rather limited.
About how developers should stand up and rail against their managers/CEOs when the company has asked them to build something unethical.
Where are all the developers now? That's right, underneath their desks coding away. The great ZUCK has spoken and as true CUCKs they bowed down and did his bidding.
No one on the development team is going to speak out. They need their lifestyle maintained.
The hipocrasy is not unexpected. To the world, developers will scream ethics. In private, they will cave, back to their safe spaces no doubt!
I have to somewhat disagree with this. Sure, I give the point that you can just throw more hardware at the problem of scaling. However, there are some problems that do not linear scale and rewriting gives much more of a boost.
For example. Just last year I was at a company where they had a backend product system in just under a million lines of code. I'm not going to say what language it was because I know someone will say oh it didnt scale because it's X.
In addition, it was starting to get cumbersome by having multiple developers write in it. So the agreement was to rewrite it in GO.
What was the net effect?
- Less servers, much less.
- Faster processing times, significantly more so.
- Less code cruft.
- Faster feature push.
- 1 developer let go of, saved $90k
I think all in all, they saved $150k-200 a year by switching to GO.
I know it's trendy to say, don't rewrite something in production. But seriously, if the developers agree and the business WILL BE better off with it.
The usual reason is that people tend to want to fix/add a bunch of other things beyond just rewriting in language X.
Sure, if it's a straight port for speed (I'm currently doing something similar from TypeScript/Node.js to C++), and you're not adding a bunch of new stuff in the process, that's relatively safe.
But generally, rewrites are expensive and businesses don't like spending a lot of money for something without any new "features" (beyond cost, ironically). If you find yourself with that kind of group, IMO, incremental improvements are a better choice for that business most of the time.
But, for a brand new greenfield application. Why would someone choose PHP for their backend, when Golang is available?
I was at a developer meeting with a company who were reviewing what to use for a client project. The developers are from PHP/jQuery shop, however they felt it necessary to be with the times so to speak, for the future to get other projects. They opted for Vuejs and Golang with server side processing.
Apparently the client has some server side operations which are particular heavy and mentioned that php/python/ruby are just too slow with their own internal testing.
Many thanks!