by Edootjuh · 14y ago · 0 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.
I write in PHP not because it is my hobby, but because I know it very well and it makes me a lot of money. The companies I work for use PHP because they can find many talented developers. Using a proper framework, being very strict about unit testing, and following other best practices makes our codebase a joy to work with.
I'm sorry if you feel this isn't possible with PHP, but my point of elitism still stands. Who cares if PHP isn't "competitive", whatever that means? It works, we can create applications that are used by thousands of people a day to do important things (online education in my case), and most of all it brings in money.
I did not claim one cannot run succesfull projects in PHP. I stated the exact opposite. And im doing that again now, in the hope your reading is just suddenly improved.
PHP has a legacy. It started off as a template language, and slowly got more and more control structures. So, its an accidental programming language.
Language are not competitive, but language design features sure are. Nobody with the actual skillset to design and implement a programming language would consider, for example, merging vectors and dictionaries into some kind of mutated frankenarray.
This does not make the language unusable. And language design features are not the most crucial arguments to pick one language over the other in the short term. But they are, for a community and industry in the long term.
To my surprise, i read in this thread that PHP now finally has a cyclic garbage collector. That's a good example of a competitive language design feature, which utility is not in any way subjective. A large range of algorithms and design patterns couldn't be implemented efficiently or effectively without this particular feature.
And its too easy to cry "elitism" every time somebody points this out.
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.
Seriously ...
It doesn't matter which language is "objectively better as a programming language", just use whatever you enjoy the most. If it's PHP, then have fun coding in it rather that use something else because some people on the internet think you should. There are tons of very successful project in PHP, including giant ones, because at some point you stop circlejerking and start coding.
Just make sure you know what else exists out there and try other things here and there to discover new languages and other ways to do things, but that's a general programming rule, not something limited to php.
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
Previous discussion:
You're saying “Don't use PHP, it sucks.” He's saying, “I don't care, it lets me turn code into money and that's all I want.”
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.