124 points · by romainneutron · 14y ago · 111 comments
Is this meant to be run on a web hosting service that supports PHP in the 'traditional' way or do you need permission to run this as a daemon?
If it's the former, I can definitely see its benefits, but if it's the latter I can only imagine the target audience being people who refuse to program in anything but PHP and people who are by some bizarre policy required to use PHP but are allowed to run their own HTTP server.
There is no question that the PHP implementation of these APIs (think: Socket, SystemV, POSIX, etc) is very underwhelming compared to something you'd get in Python, Java, or nearly any language. And it's partly because of that that I felt it would be irresponsible for me not to include a disclaimer at the top of my github readme:
For many reasons PHP is not an optimal language choice for creating servers or daemons. I created this library so if you must use PHP for these things, you can do it with ease and produce great results. But if you have the choice, Java, Python, Ruby, etc, are all better suited for this.
So that being said:
With a general-purpose daemon library, there's a 3rd use-case to what you described: People who need to create daemons/servers/etc that use a large existing codebase: maybe it needs to share the 80 models that run your primary website. Maybe you've written a large domain-specific library. That sort of thing.
While it's a little more difficult for me to apply those reasons to a Tornado port, I'd like to hear from the developers first before I dismissed their work.
However, for existing projects and/or existing teams there might be another reason to stick with PHP: As a common denominator across all team members.
Blanket statements like yours reek of elitism and have no real value behind them, other than "this language sucks you should use this one".
There are many reasons to pick/use PHP, indispite its (lack of proper) language design. Easy to find extremly cheap programmers. Easy and cheap to host. Good and fast c based libraries.
But in no reality is its language design considered competitive by any one except by uneducated hobbyists.
That being said there definitively good frameworks out there for PHP and having good libraries is much more important than the syntax of the language, so becoming familiar enough with another language until you are as productive as with PHP might not be worth the effort for you.
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
Previous discussion:
Here's another scenario where I could imagine using PHP. Suppose I'm starting a company, and I'm starting it solo. I've been using PHP successfully for many years, and I know it and the environment (Apache, etc.) really well. I know what libraries are good, what libraries are not good, I have a framework that I like, and that I know how to set up to my liking. By the way, I'm really excited about this company.
Now, PHP is pretty awful as a programming language. I really don't like it. But the reality is, I am going be dramatically more efficient with it. If I were to use Rails, it would take me at the very least a week or two to really be able to use it without checking documentation constantly, and it would probably take me months to be at a proficiency where I was totally comfortable with it, and the environment it lives in, and figured out which libraries to use with it and so on.
During those months, when I should be focussing on building my business, talking to customers, getting feedback, learning more about marketing, I am instead dealing with the friction of learning a new programming environment. If I had stuck with PHP, all I have to do is sit at a terminal and let the code flow out of my fingertips. All of my actual thinking could go into the important stuff.
I don't deny that PHP is pretty terrible as a programing language. I do however deny that there are no reasons to use it for a new project.
It also wraps Silex and includes Guzzle (some sort of API consuming thing). Trying to gain credibility from using Node's name seems a little disingenuous given that it's microframework with an event loop of some sort plugged in, and an analogous 'hello world'.
All a "server" is, is a daemon that listens on a port. That's what it does. And it uses LibEvent thus the "node" comparisons.
Though I agree with whomever said that it would be better to compare this to Tornado.
I can imagine any event-based library will now warrant a comparison to Node. However, I've not seen things like EventMachine calling itself Node.Ruby, or Tornado calling itself Node.Python. Or NginX calling itself Node.Server.
That's my bugbear. It feels like linkbait.
Re: the server stuff. I was poorly trying to make the point you made further up, about PHP not being well suited to long running processes or being daemonised. I may well be wrong, but each request will get its own event loop, no?
Such people exist in every language community. You name the famous language and there you will fine people wanting to do everything in that language. This is nothing to specific to php.
There are various reasons for that, Once a person learns a language it becomes an investment- In time and other things and, as time grows out a person begins to think in that language, its paradigms, its idiomatic way of working. He may learn more than one language. But he will bear allegiance to one specific language.
Anyone have experience running PHP-based daemons or things like that? If your React/NodePHP-application crashes on a 'Allowed memory size exhausted' every two days, it'll get old quick.
We chose PHP because it was the only technology supported in the company, who didn't want to invest on consultancy, research, just do it now, you know.
It was fun, but eventually PHP bad memory management became the main issue, so we were restarting daemons that would crash at random times, often in the middle of some tasks, other times while idle.
Today, I would never create a new project like that using PHP, it doesn't make sense. PHP is great for templating, scripting, and there are some nice frameworks for the classic web applications. However each language has some limitations, an engineer should know much better than that.
https://github.com/hinathan/edges-php#summary
For some these php-but-like-node.js projects are abominations but there are a few reasonable use cases.
Of course the vast majority of php and the php 'class library' isn't appropriate for this programming model but neither was most of the existing js corpus before people built an ecosystem around node.js.
The libevent extension for event driven non-blocking I/O has been added some time ago. Together with many nice new features since PHP 5.3, including improved garbage collection and speed improvements, it naturally follows that php will be used for these things.
Btw, the libevent extension is really fantastic. If you're doing server programming, take a look at it, it will turbo-charge your server http://php.net/manual/en/book.libevent.php
Perhaps php lost some if its sexiness, but it's still rapidly evolving and improving.
(It isn't.)
The other neighboring competitors of Php, namely Python and Ruby are in the web development market with the help of frameworks. I have yet to see a serious programming shop that would bet its billion dollar business on frameworks built by others. Small libraries I can understand. But building the spirit of your business and betting its survival on a Frameworks is just out of the question.
Php is the DSL for the web. And it does its job far too well. It can be learned quickly and you can build things quickly with it. Its installed everywhere, you can get cheap hosting. Tons of document and help available.
Even the majority of PHP development uses frameworks these days.
You didnt answer the questions at all. Nor did you provide any of your qualifications with actual arguments.
And you dont "experience raw power" of a language, instead one can actually meaure it and formally classify it.
Here is a question for you to put things in perpective. Whats the order of complexity of adding an element in the middle of "an array" in PHP?
I think you are confusing "raw power" with the sound an idiot makes, when they write bad algorithms, in languages with questionable language design.
People building stuff in PHP use frameworks as standard too, even if it's one they built themselves.
I've recently converted a high traffic personal project from PHP to Python with no impact in performance. I also didn't feel like I was being slowed down by Python or Flask.
What does it mean to be a DSL for “the web”?
I do some work in C# now but for many reasons I don't want to do web with .NET.
I've done significant work in C, C++, Perl, C#, over the years. If my brain was wiped clean of all knowledge of PHP, I'd probably end up doing most work in Python.
I really wanted to try Python, I've heard many good things about it, but it's another one of those slow interpretive languages.
I'm thinking Go will be the next one I learn, it looks like a sane alternative to server-side C++.
http://shootout.alioth.debian.org/u64q/which-programming-lan...
But I can't understand this elitism. Programming language choice must not be a cult. Anyone should be free whatever language they like to use whatever they want to do.
So bringing something good or seemingly good to any ecosystem should not get bad responses. They are trying to combine two worlds into a "new choice". Let them do even if yo do not like it. Nobody asks you to praise but just don't give uninformative bad responses.
Our doctors no longer use voodoo dolls. They've moved on. And nobody with any relevant educational background would promote much of phps language design. We've moved on.
Unfortunately, PHP lives on as well, as some kind of eternal september of web development.
I've used many languages in my 25+ years in software development, and I've seen very little relation between language and either overall quality or simply getting stuff done.
I have however observed a strong negative relationship between that and people bitching about their and other people's tools.
There are reasons that this may be a joke, yours isn't valid.
Don't get me wrong, I like Vert.x's API quite a lot and it's why I'm looking at using it. But it's not really "new", it just has a nicer coat of paint. And claiming that node.js is "revolutionary" because of it is a fairly criminal disservice to the ridiculously smart people behind Netty, Mina, and similar projects that have been around for a long time.
Then you have the fact that any good developer who knows PHP is also going to know enough Javascript to get by already.
The only reason I can think of for this to be a good idea is to allow you to use your existing PHP libraries in an evented system. React does not (and cannot) do this.