Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming IT Technology

PHP Succeeding Where Java Has Failed 610

ficken writes "Web browser pioneer Marc Andreessen recently announced his prediction that PHP will be more popular than Java for building web-based applications." From the article: "Wooing programmers is nothing new in the computing industry, where players constantly jockey to establish their products as an essential foundation. Indeed, many credit Microsoft's success to its highly regarded programming tools, which make it easier for developers to write software that run on Windows. PHP has caught on widely. About 22 million Web sites employ it, and useage is steadily increasing. About 450 programmers have privileges to approve changes to the software. Major companies that employ PHP include Yahoo, Lufthansa and Deutsche Telekom's T-Online." Meanwhilie, Piersky writes "Zend has announced its rival to .NET and J2EE, with the Zend PHP Framework. In a press release, they stated that it will be 'A Web application framework which will standardize the way PHP applications are built. The Zend PHP Framework will accelerate and improve the development and deployment of mission-critical PHP Web applications'. This will for part of Zend's PHP Collaboration Project"
This discussion has been archived. No new comments can be posted.

PHP Succeeding Where Java Has Failed

Comments Filter:
  • by rovingeyes ( 575063 ) on Friday October 21, 2005 @10:14AM (#13844130)
    "If you are a web "programmer", it's definitely nice to have well-built tools that let you think even less about what you are doing and come up with something useful."

    Don't know about you, but it sounds dangerous to me.

  • Caching (Score:2, Interesting)

    by Anonymous Coward on Friday October 21, 2005 @10:18AM (#13844155)
    In asp and asp net there are extensive facilities to cache in to memory.

    I don't know much Php but as far as I can tell there is no way to do this natively. This is one of the reasons I don't use php. You see site like groklaw get overloaded when Slashdot hits them because they pull the freaking article out of the database every time it's requested.

    If somebody could show me some in process caching that'd take me a long way to ditching php. I don't mean caching to disk either. Caching to disk is much slower than memory.

    Ideas?

    AC.
  • Re:Help me out here (Score:2, Interesting)

    by Dukael_Mikakis ( 686324 ) <andrewfoerster AT gmail DOT com> on Friday October 21, 2005 @10:21AM (#13844187)
    Yeah, the PHP files will have code mixed in with your html, which can only somewhat be mitigated by things like CSS and function imports and such, which is actually a big reason why I'm not completely sold on PHP. The php files end up looking somewhat ugly and sometimes the code is pretty convoluted.

    On the flip side, I've been working with Ruby on Rails [rubyonrails.org] and it's beautiful. Scripts to generate the starting points for your web files, separation of design and implementation, a great framework. Only thing it lacks is a strong IDE (as far as I can tell) behind it and extensive documentation or resources on the web if you hit a wall (PHP sites are everywhere, for example).
  • lingo... overload (Score:2, Interesting)

    by jkind ( 922585 ) on Friday October 21, 2005 @10:24AM (#13844212) Homepage
    Is it just me, or is anyone else having "framework" and "standards" overload?
    Seems like every post mentions some form of standards or framework, and everyone wants to standardize everything within a framework. Or perhaps make a framework which will help standardize everything. I can't stop saying standards framework.......standards framework..... I miss the old days when "ware" was the hot term.. webware..awareware..opencourseware..cookware..
    On topic.. Php is just so much more fun then Java... (except when you're first loading it into Apache for Win and Apache just tells you "failed").. And I visit phpclasses.org almost daily, just because there is lots of cool stuff there to try and play with. Kind of like javaboutique, but not as stale..

    I do think it is an exaggeration to say Java is failing.. Although C#/.NET seems to peck away at the domination every quarter.. Way off topic: Does anyone have a website which lists the "top skills" as listed in job postings online? I used to visit such a site for jobs in the UK but can't find it anymore, and doing a search on google for "top skills job postings C# Java" is a fruitless endeavour.
  • Bitter (Score:2, Interesting)

    by cparisi ( 136611 ) on Friday October 21, 2005 @10:28AM (#13844243) Homepage
    Andreessen sounds bitter about Java and Sun in general. Maybe he attributes Netscape's ultimate "failure" with their misplaced focus on creating a browser written in Java. Netscape placed a lot of faith and resources in Java and perhaps he feels betrayed or disillusioned. Anyway, I agree that PHP is better (or at least easier to use) than Java for some things. But it is not a replacement for Java.
  • by netkid91 ( 915818 ) <netkid91@gmail.com> on Friday October 21, 2005 @10:31AM (#13844267) Journal
    Not a big fan of Java, slow, bulky, not user friendly. Best part about PHP is extensions, just write some C++ code(or C#/VB.NET on windows *frowns*) and make it a DLL, set it up and use it, not easily available as Java yet because no as many people use it yet. Honestly both preform well compared to ASP.NET and we should stop bashing each other, get a way for JSP and PHP to work together is what we need, simple page rendering stuff goes to the PHP engine, backend proccessing to Java, really, it might work.
  • by digidave ( 259925 ) on Friday October 21, 2005 @10:33AM (#13844277)
    Sure, that's what php-gtk (http://gtk.php.net/ [php.net]) is all about :)

    Actually, php-gtk is very useful when you have an existing PHP web app that you want to port into a desktop app. It's a great project, but is definitely not meant for large-scale apps.
  • by Pike ( 52876 ) on Friday October 21, 2005 @10:33AM (#13844286) Journal
    PHP might well succeed where java has failed, but it will be because:

    - it's used on its merits, not because of hype, or a New Gospel of Platform Independence
    - it's simpler and faster
    - it's not being touted by a huge company such that it shows up on MS's radar as a challenge ...which are also things that Ruby has going for it. Or Python. The point isn't that PHP succeeded, the point is that java failed (at becoming kingathehill) and why it failed.
  • by AVee ( 557523 ) <slashdot&avee,org> on Friday October 21, 2005 @10:40AM (#13844331) Homepage
    True, but it also explains why PHP will likely be more populair than Java for web apps. The resulting apps will also likely be of lower quality, but Windows is the most used OS as well...
  • Re:Help me out here (Score:3, Interesting)

    by digidave ( 259925 ) on Friday October 21, 2005 @10:40AM (#13844333)
    There is nothing in PHP that discourages you from mixing logic and presentation, but there is also nothing discouraging you from separating them either. This is exactly what makes PHP great for dirty hacks and large web apps alike.

    Templating is part of the solution, but so is good app design. If you don't want to mix your logic, you simply need to code it that way. Zend PHP Framework will help enforce some of the same separation as Java does, but it's not strictly necessary. You can do MVC app design without much trouble. Take a look at Sitepoint's PHP Application Design forum (http://www.sitepoint.com/forums/forumdisplay.php? f=147 [sitepoint.com]).

    There are also Ruby on Rails-type frameworks such as CakePHP (http://www.cakephp.org./ [www.cakephp.org]
  • by FedeTXF ( 456407 ) on Friday October 21, 2005 @10:50AM (#13844409)
    I teach PHP in college since 2001 and I use Java/JSP at work and at home since 2003.
    PHP is good for an admin to set up some forum, photo gallery, database administration front end, a CMS, whatever tool you can download form sourceforge and install in a few hours to give users/customers a service.

    When you need to develop a solution with specific needs and there's no tool to download and use right off the shelf, PHP gives you lots of headaches.

    The API changes a lot, very fast. This is not good. From PHP 3.0 to 4.0 things break and new stuff gets added so fast some sites have to keep using PHP 3 in order to avoid spending many hours recoding old code. Now PHP 5 is a new language altogether.

    Lots of changes are for good since PHP was really bad in some areas in early version so the rewrote everything form scratch, that forces developers to relearn and recode.

    The lack of abstraction in the PHP API leaves lots of stuff to the developer. For example, working with HTTP headers. The header function just sends whatever header you send in. You have to account for browser bugs on your code and maitain that. The manual is full of user comments regarding how to use certain function that give different results with different databases, browsers, platforms, Apache configurations, etc. Those things don't belong to API, there are bugs, but you have to work around them in your code.

    If you use a PHP CMS or a PHP forum, you know the people developping it will do the dirty work for you and release a quality product, but for a small organization with a few programers, migrating from PHP3 to PHP5 to get the new cool stuff they implemented is hard, painful and takes a lot of debugging time.

    In contrast Java has managed to keep backwards compatibility while adding new functionality and the API has been quite stable. Of course it has bugs, migration problems and imcompatibilities, but the java developers (SUN, Apache foundation, IBM, etc) make an effort to make developers' life easier. The PHP developers also try, but are less sucessful.

    At the same time in Java you don't have such a wide selection of free tools ready to use in a web site, but you do have tons and tons of libraries ready to be integrated in your java web app, which PHP has but in much smaller quantity.
  • If you have such problems in Java then write a really small little class that does all this work for you, generically, in one place, so you can access it by saying

    Mailer.mail(to,from,subject,message,header1 ... headerN);

    Many java frameworks are terrible, but that's a matter of API aesthetic. For instance, I hate the Java frameworks' APIs for reflection and dynamic method invocation and such. So I wrap it all in two methods

    public boolean canPerformMethod(String methodSignature);

    public Object performMethod(String methodSignature,Object param1 ... Object paramN);

    (Note: the above is pseudo-code so I don't have to explain how to do variable number of parameters in Java 5 - not all /.ers are Java coders.)
    (Note2: By using aspect-oriented programming, I can insert these methods high-up in the object-hierarchy)

    The point is that now, anywhere in my code I can dynamically invoke methods by:

    Foo result = null;
    if (target.canPerformMethod("processFoo:String:Foo")) {
          result = (Foo)target.performMethod("method:String:Foo","Pro ccessing Foo",aFoo);
    }

    That simple structure replaces about 10-20 lines of exception handling, method lookup, and all sorts of crap, because I (wait for it) encapsulated it.

    I'm not saying it's not convenient to have mail(...). Of course it is. But the point of languages like Java is that if you have a preferred API, you can wrap the complexity of a crappy API with a nicer convenient one in your own code. That's called good programming. No actualy need to whine.

    It's only when the raw functionality is not there, or when the raw langauge/runtime capabilities don't actually allow you to create the functionality you want in a convenient form - that's when whining is necessary. But modern Java, with Java 5 + aspectJ pretty much allows anything to be created in relatively convenient APIs.

    The only remaining issue is to convince someone at Sun to refactor their core APIs into something that provides some of this convenience out-of-the-box. Or go write Objective-C against the Cocoa APIs on MacOSX. They're pretty nice.
  • by the eric conspiracy ( 20178 ) on Friday October 21, 2005 @11:01AM (#13844520)
    This article is a crock. PHP is great for your $10 a month hosting service domain on a shared server, but Java has been and continues to be the market leader when it comes to writing web based functionality that integrates across an entire enterprise.

    Try doing this [verosystems.com] in PHP.

    There is a reason that eBay handles 1 billion transactions a day on Java.

  • Re:Here we go... (Score:2, Interesting)

    by Anonymous Coward on Friday October 21, 2005 @11:02AM (#13844534)
    PHP just isn't on the same standard in my eyes as Java or C#. Doesn't PHP have something like 3,000 built-in functions? That is not a sign of a well designed language.

    Doesn't Java have like 5,000 built-in classes, let alone functions? And then the web page support adds on more classes and more functions. This is not the sign of a well designed language...

    (And, yes, they are the same things. Most of those "3,000 built in functions" are actually libraries. You can strip them out if you really wanted to. I have no idea how you'd strip out the massive Java library bloat, though. Probably why Java's runtime comes in at like 400MB (410 MB on my machine, but that includes the docs), while PHP boasts a slightly trimmer and more functional 20MB or so runtime.)
  • by buddylee ( 413092 ) on Friday October 21, 2005 @11:05AM (#13844554) Homepage
    I'm running into this now, but to get wide acceptance, hosting for Java needs to come down in price. For instance, I can find a company to host my html website for $10/year. I can find a company to host my asp/asp.net website for $3.99/month and I can find a company to host my php site for about the same. The CHEAPEST java host I found was charging about $15/mo for fewer feature addons (bandwidth, space, etc) than the $3 php or asp hosts.

    It's not difficult to see why Java isn't in the mainstream as far as casual or moderate web developers go.

    And I really don't understand why the cost is so high since everything Java hosting uses is supposed to be free (compared to buying IIS & a windows server).
  • by SatanicPuppy ( 611928 ) <SatanicpuppyNO@SPAMgmail.com> on Friday October 21, 2005 @11:09AM (#13844580) Journal
    Yea. You can write good code in Php, but I've seen a lot of slop as well, and I've talked to a lot of "Php programmers" who don't know the first thing about datastructures---unsuprising since php really doesn't have anything besides a weird hash-array-stack thing with ad hoc support for multidimensions, and don't understand reusable objects or abstraction.

    Does definitely remind me of VB, though the syntax isn't as screwy.
  • by arkanes ( 521690 ) <arkanes@NoSPam.gmail.com> on Friday October 21, 2005 @11:11AM (#13844594) Homepage
    Java excels where you need to interface with legacy and/or disparate systems.

    This is exactly contrary to my experience. Java *sucks* at playing nice with other systems, unless you build up a "play nice with Java" layer in those other systems first. PHP, shitty as it is, is much better. Python and Perl are both much better (Python more than perl these days, imo) as glue code.

    Java works best when it can run in long running, memory hogging, monolithic processes, where it's development and execution model can really shine (these are the circumstances you get those "faster than C" benchmarks). Java doesn't play nice with other systems, and interop via JNI can kill the GC optimizations that let it beat manual memory management for performance.

  • by masklinn ( 823351 ) <.slashdot.org. .at. .masklinn.net.> on Friday October 21, 2005 @11:21AM (#13844676)

    AFAIK:

    • ASP.Net is NOT a language, it's a framework, it makes quite a number of modules and precreated functions available but it's not a language (while ASP was a language, more or less, created from VB).
    • You can use just about any language running on top of the CLR (.Net's equivalent of the JVM) in an ASP.Net environment. That includes VB.Net, C#, Boo, IronPython, ... or even your own language since the CLI itself is an open spec and you're completely free to create your language compiling in CLI (.Net's "assembly")
    • Mono implements ASP.Net 1.1 very well (completely in fact, I think) and even implements part of .Net 2 already, which means that ASP.Net actually is cross-platform (since Mono runs on Linux, OSX, Solaris, *BSD and Windows over s390, SPARC, PowerPC, x86, x86-64, IA64, ARM and HP-PA)
  • by Mateo_LeFou ( 859634 ) on Friday October 21, 2005 @11:47AM (#13844929) Homepage
    TFA has a perfect example of andreessen using the right tool for the right job: "Andreessen, who just helped launch a start-up called Ning for sharing photos, reviews or other content online, acknowledges that Java has its place. "'My new company is running a combination of Java and PHP. This is something I get no end of crap about,' he said of the technical decision. 'We have a core to our system that is built in Java. It is more like an operating system, like a system programming project. Then we have the entire application level--practically everything you see is in PHP.'"
  • by Anonymous Coward on Friday October 21, 2005 @11:55AM (#13845007)
    I dont understand why people never give coldfusion any love. If you want to be able to make rapid applications that are scalable, learn it. It's learning curve is low and because you can use Java to extend it, it can go a long ways. But if you want to write 12 lines of code to do what it takes 3 in Coldfusion thats your business, but you may also want to stay away from Ruby on Rails then also.

    Ohh but you got to pay for it so that may be the problem.

    Ok now you can continue and if anybody wants that can throw in the old "Coldfusion is not a real language."
  • by RAMMS+EIN ( 578166 ) on Friday October 21, 2005 @12:11PM (#13845152) Homepage Journal
    I have to wonder about the long run here. When I work with Java, I find it a pain to work with, because of all the required boilerplate and the inflexibility. Things have probably gotten better with Java 5, but Java has been a pain in all the years before it.

    When I work with PHP, I find it a pain to work with, because of its apparent lack of design. It feels like a cobbled-together heap of features and hacks, and so does the code written in it. I tend to write cleaner code than what I've seen from other people, but that doesn't make the final product any less messy when various people have worked on it.

    Neither language is absolutely horrible; comparing them to others, Java is a language with a relatively clean design, and PHP is a good choice in its niche of writing web applications. However, my pain in working with these languages is a direct result of these languages being poorly designed. I'm into programming languages, and I know many that have better designs than Java and PHP. I wonder if these languages won't take over in the future.

    Some changes are happening already. Various organizations are moving away from Java for web applications, and I know others that would do well to do so as well. Much of the work that went into PHP 5 comes from a realization that earlier versions were flawed (the same can be said of Perl 6). Ruby appears to be on the rise. Paul Graham and others have had good results employing Common Lisp for web applications.

    The only thing I can see standing in the way of better languages taking over the web application sphere is the fact that the decision making process is based more on fame than on qualities. I maintain that Java has become so successful largely because of the enormous hype surrounding it. PHP, Linux and MySQL have also risen largely due to hype. Of course, it's true that you won't overly disadvantage yourself if you use whatever most others use, but it would still be better if decisions were made based on sound knowledge of technical benefits.
  • by Mercano ( 826132 ) <.mercano. .at. .gmail.com.> on Friday October 21, 2005 @01:01PM (#13845654)

    [Java] died as a client-side language.

    Not sure how much this is worth, but as we speak the top item on the Most Active Projects list over on SourceForge (insert tinfoil hat disclaimer here), Azureus [sourceforge.net] is a client side Java app. For those of you keeping score at home, the #2 spot, GAIM [sourceforge.net], is in C and PHP comes in at #3 via phpMyAdmin [sourceforge.net]. Keep in mind this is looking at quality (and a pretty wierd messure of quality, at that), not quantity, but still intersting.

Kleeneness is next to Godelness.

Working...