PHP Scales As Well As Java 627
mactari writes "Jack Herrington at the O'Reilly Network has had the audacity to claim that
both PHP and J2EE architecture... are converging on the same design [regarding scalability]. Can it be that he's disproven the idea that 'Java scales and scripting languages don't' when he says, 'The idea that PHP does not scale is clearly false at the performance level'?
Even if a little oversimplified (ignores horizontal scaling), it's an interesting comparison that takes a peek at the architecture beneath both hypes."
What's the PHP equivalent to Java NIO? (Score:2, Insightful)
Scaling (Score:2, Insightful)
Re:Scaling (Score:3, Insightful)
as a corollory, it is much easier in php to write code that itself does not scale well. contrary to popular belief, php is not a language for sloppy or new programmers - to write a robust, secure, scalable app in it you have to know what you are doing!
Re:What's the PHP equivalent to Java NIO? (Score:4, Insightful)
PHP is perfect for small projects, but when you have huge requerements and a ton of lines to mantain, that's when the real scalability shows off. You can build a 1,000,000+ lines project in PHP and run it on a distrubuted server and whatnot. But who the hell is going to mantain it??
They scale differently (Score:5, Insightful)
If you're trying to run on a budget where you can't add a ton of servers and are limited to aging technology, Java will not scale to that environment very well. PHP can do quite well there.
Sun isn't interested in that market, which is a shame because there are a lot of companies still cutting budgets. I'd love to buy a server newer than a P2 1ghz, but it's not going to happen until at least next fiscal and even then, unlikely. We don't all work for technology companies who understand or care.
IF you accept the underlying assumptions... (Score:5, Insightful)
"PHP can use the database as the back-end session store."
and
"The ideal multi-server model is a pod architecture, where the router round-robins each of the machines and there is only a minimal session store in the database."
are pretty tough assumptions to swallow. Storing session state in a database only works when you have a small amount of session state to store. Otherwise the database quickly becomes the bottleneck for any operation you need to perform. The alternative is that you have to have your session state distribuited in a cluster, which is something that, AFAIK, you cannot do in PHP. You can, however, do it Java. In fact, some of things that JBoss is trying to do [jboss.org] will make session replication across a cluster fairly easy.
PHP can be very useful. I think PHP as a view layer sitting on top of a a J2EE controller and object model would be a wonderful idea. But to say "PHP scales as well as Java" is a huge oversimplification of the extremely complex problem that is enterprise computing.
Comment removed (Score:3, Insightful)
where I stopped reading (Score:5, Insightful)
Sure if it was coded by former vb guy w/o a clue.
Even naive J2EE applications I saw would be smart enough to use a view object (containing all twenty business objects and their fields) to come back from the buisness layer in one call.
A person to use argument like this about J2EE scalability has no credibility whatsoever.
What is your point? (Score:1, Insightful)
Re:What's the PHP equivalent to Java NIO? (Score:3, Insightful)
Maybe with dynamic typing, that would only be a 30,000 line project.
Re:Some facts (Score:5, Insightful)
Hrm (Score:5, Insightful)
PHP offers us no way to build an application server (unless you write one in C or C++ and send commands to it via a cli or directly through sockets). If you embed Tomcat in your application server, you can simply create contexts and mount them with mod_jk. Quite simply, you can take any server that you've written in Java and web enbale it fairly quickly. PHP lacks persistence, and I'm not talking about sessions.
Let's say that we want to add a request to our application from the web. With Java I can toss the request on a queue which a thread picks up and balances to several other worker threads who interpret the request and works with it. With PHP I would have to enter data into a flat file, or a database, and have a cronjob setup to run every minute or so and do something with data in the database. Even then, at that point, I can only have one thread unless I want to mix and match several cronjobs to run at seperate times (or unless I want to fork the process off very uncleanly using exec() or system()). In any case, does PHP scale as well as Java? Maybe, I'd need to do more tests. Is it nearly as useful? No, not right now, probably not ever. Unless you are willing to write your own custom PHP module in C and play with PHP that way, I think big jobs should be left to the heavyweight in this discussion.
Re:What is your point? (Score:1, Insightful)
Apples to Oranges. (Score:3, Insightful)
With Java you have easy access to a lot of OOP features that are very difficult to implement in Php, and the function base is simple to expand. Yea it's big and beefy, but that's what you need sometimes.
They're both just tools. Use the one that's appropriate. People scream about Java being bad for small pages. What kind of idiot is using Java on a small page? Conversely I've never even heard the Java vs Php agrument for a big site--it's always Java vs VB, and that's another no brainer.
Just my opinion.
Re:Props to PHP (Score:2, Insightful)
Then start your own company, or become an independent consultant and take the contracts you are interested in.
There is more at stake in any given project then what YOU can do faster since there are probably other people that can do it faster with the tools they want to use. If you are in a company and have an opportunity to promote the technology or language you think is best, do it--but don't make "because I can do it faster" one of your arguments. Unless you *ARE* the development team it really doesn't matter what you can do faster. Maybe you're not the right person for this job.
I'm an independent consultant and I often peruse job sites to see if there are any interesting consulting jobs out there. I've actually never found one using those sites, but I often see lots of entries for ASP work, etc. I obviously don't bother contacting them and try to convince them, "No, I don't do ASP. But what you REALLY want to do is..." That won't work. I just move on and find a company that coincides with what I agree is the better solution. Fighting the powers-that-be to use a different language is a high-stress, tiring proposition and what I want to do is develop, not campaign.
Re:of course it does... (Score:2, Insightful)
Maybe he doesn't want to spend lots of hours to change his code every time a minor release of Resin comes out. And then discovering new problems many weeks later.
Re:Not exactly... [Re:Java owns PHP] (Score:2, Insightful)
strict/loose dynamic/static explicit/inferred (Score:3, Insightful)
The problem with PHP isn't dynamic typing, it's loose typing.
Scheme has strict dynamic typing. You get more concise code, but not so error prone as PHP.
Java has strict static typing, possibly somewhat less error prone, but less convenient.
Languages like ML have strict static typing, but type inference makes the code more concise.
Re:of course it does... (Score:3, Insightful)
PHP has it's place, its great for multi-user web hosting companies where Java's architecture is a poor choice. It's not great for enterprise development, and every time someone who is fresh off writing their forum site suggests it I just have to pull out the long list of security problems PHP has/does have and the discussion ends immediately.
Why do PHP people feel the need to get into enterprise development? Java people aren't out there pushing for fansites and homepages to switch over, because they know its a bad choice.
Re: Could someone explain instead of just flaming? (Score:3, Insightful)
On the other hand, if you're talking about just scaling to larger numbers of users, you're probably talking about load balancing more than anything else. One server will basically be handing off requests to other servers based on how busy they are. That has nothing to do with Java Vs. PHP. You can use either with that. The only gotcha is you should make your pages stateless (no session variables, etc). If you pass data from one page to the next, do it the old-school way using hidden form elements, because then no matter which server gets handed the current request, you'll have the passed-along data and you don't have to futz around with the session.
My thinking is, as long as your scalability has to do with load, just worry about load-balancing, make your pages stateless (there IS state, but you're passing it along on form posts rather than trying to store it on the server), and use whichever language has been working for you up until now. Don't touch J2EE (or
Re:What is your point? (Score:1, Insightful)
Strict Typing (Score:2, Insightful)
That's not a language issue, it's a programmer issue. Learn good habbits.
Re:Perl (Score:3, Insightful)
I've been having a great deal of broken pages lately.
I also have been having a lot of problems with the RSS feeds lately.
Overall, I like using slashdot as an example of why mySQL and perl are bad ideas for busy sites.
Any language can be used to write bad code, but I've rewritten really perl projects (2M line range) that were impossible to maintain into java (for example) applications that were not only easier to manage, but performed better.
Whether raw perl is faster than raw java, who knows or cares? When I want raw speed, I write apps in ocaml (or C if I need slightly more speed). When I want to prototype something quickly, I write apps in python. When I want to build a large scale application, I use java (and python for parts). With a proper design, going from one application server to two doesn't double the strain on my database server (not even close), but usually doubles my capacity. It also doesn't require a rewrite of the app.
Then I start making things happen asynchronously with threads and message queues. These days, my apps are looking more like mainframe apps from performance monitors. We maintain a pretty high load here, and I watched it triple during some event for a few minutes. Processing speed was constant due to surge protection I was able to make using a simple thread and a linked list. For our most common type of database work, there is no more than one insert/update occuring per application server instance. That makes such a huge difference.
Re:Here's why... (Score:3, Insightful)
I'm not sure if your post was a troll or not, but it is pretty arrogant to assume any one language, especially one as widely used as VB, is for "kiddies."
Re:Here's why... (Score:2, Insightful)
and
Can I create a class and inherit from it?
So your Fortune 500 company obviously hasn't heard of VB.Net, I take it?
I have no dog in the language semantics fight here, but most of your points are valid pre-.Net days, which means your points are invalid.
Look at the perl guy flame microsoft..wow. (Score:1, Insightful)
You have no clue what enterprise class means. I am a developer for a fortune 500 company with 110,000+ employees.
I work for an Ivy league medical college, and the application that is used to track all of the medical students in the US is written in VB. Plus the hospital we are affilliated with writes some apps in VB also. Maybe you don't use VB for large apps, but that doesn't mean no one does.
Personally, I like VB but I work with Java. It is a waste of bandwith to write posts flaming away at people and personally attacking them based on your own personal preferences. Yet that is half the posts on slashdot. Yes I know, I must be new here. (here comes the guy with the "new here" handle).
you're not referring to vb.net (Score:1, Insightful)
I am a developer for a fortune 500 company with 110,000+ employees.
That means absolutely nothing in terms of credibility-- Fortune 500 companies do hire idiots, too.
However, many "enterprise" applications consist of a simple program running on the client (like a VB program) and all it's doing is transferring data to and from a back end database. You don't NEED a powerful language on the client side, if all of the magic is done with stored procedures and you're just displaying it.
But being from a Fortune 500 company with 110,000+ employees, you probably knew that.
running perl can handle the load that many other sites out there just crock on
Maybe it has something to do with the fact that Slashdot is hosted on 8 load balanced web servers (3 of which are dedicated to images). And you're comparing slashdot's ability to handle load compared to some dinky little server that gets slashdotted easily? I've got news for you... even cgi/perl boxes get slashdotted. It's all about the hardware. Sorry.
Thats part of the problem right there. If you dumb down a language too much such as VB, you loose all the power features that comes with a language such as C, C++. It also contributes to all the headaches in the world of IT when you have tons of piss poor code written by sup-par "programmers" that cannont grasp anything harder then VB. Trusting a VB-only developer to write an Enterprise class application is like having the "tire change boy" be your machanic. It is a stupid choice to make.
You are obviously an intern, or fresh out of school, and haven't had a lot of real world work experience yet.
Yes, VB makes it easy to write bad code that still somehow manages to work. Many languages do. Believe it or not, it is possible to be a GOOD programmer and write in VB.
If you were a real programmer, you would know that good programming is about HOW you use a language vs. whether you use it, because often you simply don't have a choice in the matter (unfortunately).
Re:What is your point? (Score:2, Insightful)
Just for once, I'd like to see someone explain why strong typing is so important. I develop most of my code in Python, and I have yet to see any problems. Hell, I find strong typing restrictive as it prevents me from doing things I otherwise should do. I'm currently working on a project of (according to cat | wc -l) 320812 lines, an god knows how many classes. I've yet to have one bug related to the lack of strong typing.
So heres my challange to all you strong typed zealots. Explain why it's so important!