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:
  • PHP is great stuff (Score:2, Insightful)

    by ReformedExCon ( 897248 ) <reformed.excon@gmail.com> on Friday October 21, 2005 @10:11AM (#13844104)
    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.

    I suppose that's true in most jobs, though.
  • J2EE won't fail... (Score:5, Insightful)

    by _undan ( 804517 ) <dan@undumb.com> on Friday October 21, 2005 @10:12AM (#13844108)
    ... until companies who need mission critical systems have someone they can phone when something goes wrong, and some form of developer accreditation. Don't kid yourself. J2EE isn't picked because of the language, it's because it's got Sun and IBM (through Websphere) behind it.
  • PHP can do allot (Score:1, Insightful)

    by fak3r ( 917687 ) on Friday October 21, 2005 @10:14AM (#13844125) Homepage
    I'm neither a java or php programmer, but I do work with both. While java is nice and portable, I'm very impressed with how far PHP (Personal Home Page) has gone. There are acclerator projects out there that cache php scripts, making them much more responsive. I use eAceelerator [eaccelerator.net] (formerly MmTURKE Cache or something like that) and it's obvious that php performance can be improved. For many a simple LAMP setup is very powerful, I've been using it for a website, as well as webmail, for over 4 years now.
  • Will be? (Score:3, Insightful)

    by bhirsch ( 785803 ) on Friday October 21, 2005 @10:14AM (#13844129) Homepage
    I thought PHP was already more popular. Granted PHP-Nuke, etc aren't exactly banking apps.
  • Help me out here (Score:5, Insightful)

    by wren337 ( 182018 ) on Friday October 21, 2005 @10:15AM (#13844138) Homepage
    Doesn't PHP tend to be embedded in the page? I thought it was a more direct comparison to JSP than to Java. And like JSP I expected it violated the seperation of logic and presentation that I love so dearly. I've been avoiding PHP for the same reason I don't do JSP pages, I don't like code in the presentation layer.

    I am prepared to have my mind blown here, can someone enlighten me?

       
  • PHP Desktop Apps?! (Score:4, Insightful)

    by luiss ( 217284 ) on Friday October 21, 2005 @10:17AM (#13844145)
    Java "failed" on the desktop. I didn't know PHP desktop apps were taking over.
  • by Anonymous Coward on Friday October 21, 2005 @10:18AM (#13844154)
    "Java is much more programmer-friendly than C or C++, or was for a few years there until they made just as complicated. It's become arguably even harder to learn than C++," Andreessen said. And the mantle of simplicity is being passed on: "PHP is such is an easier environment to develop in than Java."

    This is just silly. PHP is far from "simpler" than Java. PHP *is* better suited to basic page generation tasks. Its syntax is easy to learn, and it's quick to get a page running. However, any sort of complexity thrown at the system starts making PHP look difficult and Java look easy. For example, I often write web applications that require that user sessions communicate with each other. Now this is stupidly simple in Java thanks to the use of Singletons or named derivitives. One can easily build a chat room, for example, whereas PHP begins to get a bit more tricky. Now throw really complex needs like PDF generation, Dynamic Excel Spreadsheets, XML/SOAP/XML-RPC/EDI communication, mainframe interfaces, off-brand databases, performance caches, and other large scale features, and suddenly Java doesn't look so hard anymore. PHP, OTOH, begins screaming for mercy.

    One would think that Andreessen would understand how to use the right tool for the right job, but apparently not. He should be kept away from the press. He always manages to sound 50 IQ points dumber than he actually is. (A common problem when dealing with the press.)
  • No, I agree. PHP is just a scripting language. Would you use C/C++ on a website? I wouldn't
  • by Anonymous Coward on Friday October 21, 2005 @10:19AM (#13844170)
    I've done programming in PHP and in Java.

    PHP is straightforward and easy, and most distributions have their own packages for it. Whereas with Java, the initial set up is overwhelming for beginners.

    I learnt PHP years ago by myself, and it wasn't really that hard. Yet a few months ago when I was finally required to learn Java, the complexity of the Java frameworks (Hibernate, Spring, etc) tortured me for days before I actually knew what was going on. And it doesn't help when all the frameworks gives such a "bulky" feeling.

    The learning curve of Java is definitely much higher than PHP.

    Of course, I do agree that Java is much better suited for large scale web programming than PHP. It's much easier to do things cleanly in Java, and although PHP's loose typing is great for a simple 1 page script, I'd rather have the strict typing of Java when it comes to large scale projects.
  • by SatanicPuppy ( 611928 ) <SatanicpuppyNO@SPAMgmail.com> on Friday October 21, 2005 @10:19AM (#13844171) Journal
    Well, as a Java coder who's been coding almost exclusively in php for a year or so, I have to say it makes me feel better about my time spent. Php is definitely easy to work with, though that creates the opportunity for some seriously scary code.

    I have to say, just not working with Tomcat is a plus (though I give major Props to the Fedora team for the option to install Tomcat right off the install disks)...When gcj finally catches up, I'll be a happy puppy.
  • by tertullian ( 669393 ) on Friday October 21, 2005 @10:24AM (#13844209) Homepage
    Don't fool yourself, I've seen much Java code with "real Java" embedded into the pages. I've worked on projects that make use of BroadVision, Weblogic, etc... and there seems to always be a need to have logic on the presentation layer. With PHP, I've been using Smarty, and I've been able to accomplish everything I need to do without the having to put PHP logic on the page. This argument of presentation/logic separation is hypocritical when it comes from Java developers, because they don't practice what they preach.
  • Here we go... (Score:2, Insightful)

    by Naikrovek ( 667 ) <jjohnson.psg@com> on Friday October 21, 2005 @10:25AM (#13844223)
    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.

    J2EE has a very well-respected place in larger organizations. The support is fantastic, the tools are fantastic, and the language is actually very nice, once you truly get to know it.

    I used to think that Java was slow and useless, but when I actually started writing a lot of it, I found that its really not as bad as everyone told me it would be. Java is becoming the new COBOL as far as business acceptance goes, its everywhere that it needs to be, from what I've seen.

    PHP is good for its own uses as well. I started programming in PHP, and I've written dozens of website backends in PHP, but the Java families (and other OO languages like C++ or C#) are just more elegant for the larger projects, web-based and otherwise.

    I wish PHP and PHP programmers the best. Go, spread to anyone you can, but stay away from me. I've found a new girlfriend, and her name is Object Orientation.
  • PHP, or Ruby? (Score:3, Insightful)

    by tcopeland ( 32225 ) * <tom&thomasleecopeland,com> on Friday October 21, 2005 @10:26AM (#13844227) Homepage
    Seems like Ruby on Rails [rubyonrails.org] is competing for web apps too - lots of comparisons are floating around out there [robbyonrails.com]. Some large sites are converting over, too, like Derek Siver's "CD Baby" - he blogged on the conversion here [oreillynet.com].

    I've certainly found Rails to be a good fit with interfacing with a Jabber PostgreSQL backend [blogs.com]. Good times!
  • by Dekortage ( 697532 ) on Friday October 21, 2005 @10:26AM (#13844230) Homepage
    I work with PHP and Java (and JSP and XML and enough other acroynms to choke a hippo). Andressen's comments seem so clearly aimed at server-side Java. PHP doesn't do client side, though there are projects underway like GTK [php.net] and WinBinder [hypervisual.com]. But still... Java was supposed to kill C, and it didn't. PHP won't kill Java either.
  • by Anonymous Coward on Friday October 21, 2005 @10:28AM (#13844241)
    If hiring managers were looking for specialization, you were hiring at the wrong kind of company.. i would kill for developers that could develop and not just plug crap into .net or java
  • by CousinLarry ( 640750 ) on Friday October 21, 2005 @10:29AM (#13844248)
    Yes, both PHP and Java are free - i'm not talking about the monetary cost of either platform.

    I'm talking about the network effects [wikipedia.org] of PHP being available on every shared host in the world.

    Try to find a cheap, reliable tomcat hosting service. Then throw a dart at a google search for "web hosting." You'll find that outside of enterprise, PHP is the lingua franca.

    So if you're a poor student or struggling entrepreneur looking to make an experiment or prototype, you will naturally gravitate toward PHP (same argument works for mySQL/postgre v the world). And guess who will populate the next gen of enterprise?
  • by sbma44 ( 694130 ) on Friday October 21, 2005 @10:29AM (#13844253)
    I primarily work in ASP.NET, and have done some work with JSP. Those are nice environments (well... ASP.NET is, anyway) -- but for many, many things, they're overkill. A robust OO model is nice for making programmers feel comfortable, but until recently the web has been an inherently procedural undertaking. ASP.NET and AJAX are putting an end to this, but the underlying technology remains stateless.

    PHP is procedurally oriented, works well, and -- most important -- is free. I can't convince my boss to touch it, of course, but if some names get behind it, it might become a much easier sell.
  • by Philodoxx ( 867034 ) on Friday October 21, 2005 @10:33AM (#13844280)
    I'll come straight out and admit that I'm a Java programmer, but I've used PHP and I will admit it is simple to use.

    I find the comparison that the article makes between them is very one dimensional, it's saying that PHP is better than JSP, which I suppose is debatable (I prefer JSP ;) ). The problem is that Java is so much more than just JSP on the server side, it has an entire framework of technologies (some part of J2EE, some not) that make it a complete package. If they want to compare Java and PHP, it should bring in not only ease of development, but scalability, interoperability and security. I would have also liked to see the number of commerical websites running PHP vs the number of commercial websites running Java. For instance my home page has TorrentFlux on it, which is php based. So I guess I fall into that 22 million, although that's not really by design.

    I won't try and say Java is better (because of my limited PHP experience) but if an author wants to convince me that PHP is better than Java, it's going to have to talk about more than simplicity and hype.
  • by tertullian ( 669393 ) on Friday October 21, 2005 @10:33AM (#13844284) Homepage
    Let's see In Java: import some.crap; import some.more.crap; import yet.some.crap; class SomeMailClass { create object 1 create object 2 create object 3 call object 1.somefunction(); call object 2.somefunction.bloated(); call object 3.somefunction.Ihave.lost.interest.already(); blah, blah, blah } now, let's do this in PHP. mail('me@mydomain','Subject',$message,$headers); In Java: For the above code, I'll bill out an hour to my client just for writing and compiling the class. Oh wait, there was a compile problem, let's debug...recompile, wait, wait, wait... ok, let's get started on the next part In PHP: I sent an email, ok, let's get started on the next part. I'll bill an hour to my client have something to show for it.
  • flamebait! (Score:2, Insightful)

    by Anonymous Coward on Friday October 21, 2005 @10:39AM (#13844325)
    There should be an option to moderate a whole article as flamebait!
  • by KiroDude ( 853510 ) on Friday October 21, 2005 @10:46AM (#13844379)
    Can you give me the name of those companies that do not ask for specialization??
    I totally agree with the parent post, people mistake syntax with logic. I might be able to tell you every single reserved word, function, operand and whatnot of one language, but if I do not have the necessary logic to put all these words together in the right order, it is useless.
    Language syntax can be picked up pretty quickly, logic not.
  • by Snowhare ( 263311 ) on Friday October 21, 2005 @10:47AM (#13844387)

    PHP is and will be continue to be popular with the masses simply because, like HTML, the entry barrier is very low. It will fail to make deep inroads at the high end for the same reason: The entry barrier is very low.

    Sounds like a contradiction? Not really. The entry barrier for PHP is so low that we are seeing zillions of poorly written, insecure and unscalable PHP apps written by amateur programmers. Resulting in numerous security scares about PHP and contributing more than slightly to the infamous Slashdot Effect where a site that gets a sudden traffic surge craters as it runs out not of datapipe but simple CPU power. This scares the hell out of anyone who considers using PHP in the enterprise.

    Don't get me wrong: It is possible to write good, secure, scalable code in PHP. It just isn't very common.

  • by TheSpoom ( 715771 ) * <{ten.00mrebu} {ta} {todhsals}> on Friday October 21, 2005 @10:50AM (#13844413) Homepage Journal
    And because I'm bored and I like PHP, my reply to all of the above:

    * PHP sucks.

    PHP has functions for practically anything you can imagine. Of course, I'll get into why it doesn't suck in the replies below, as this is a bit too general.

    * PHP is for n00bs.

    PHP is for developers who want to get something done quickly. The syntax is very easy to learn, and variables are loosely typed, but in my experience this doesn't mean that the language is flawed; it means that one can code up something without having to worry about unnecessary things like pointers, variable conversion and the like. And to be honest, in website scripting I've never come across a need for more advanced syntax than PHP provides in my five or more years of using it.

    * PHP is usually poorly written.

    This, unfortunately, is usually true. Because PHP is easy to use, it is often used by people who don't want to worry about writing good code either. But like everything else, there are varying grades of professionalism. PHP *can* be written well, it's just a case of taking the time to do so.

    * PHP is a scripting language and you can't do anything but write web pages with it.

    Scripting language, yes. But it most certainly can [php.net] be used for things other than websites.

    * PHP sucks because the function names are inconsistent.

    True, but this is why one has a manual. I've never been all that concerned about it.

    * PHP is slow.

    Actually, it's really not. Take a look at this comparison between different CGI modules for Apache [dmst.aueb.gr]: PHP actually outdoes Perl here.

    * PHP isn't capable of working in a real enterprise.

    I haven't had experience with integrating PHP into an "enterprise" situation personally, but I'll refer you to Zend's Enterprise PHP [zend.com] page for various reasons why PHP is indeed ready for the enterprise.

    * Real coders use Perl.

    Real coders use the tool that best fits the problem.

    * PHP doesn't scale.

    Now THIS is something I can definitely refute. I work for a company that creates mods for a PHP / Smarty-based online shopping cart known as X-Cart [x-cart.com] and I can tell you, PHP scales wonderfully, otherwise stores wouldn't use it as a base of their business operations. X-Cart is on the order of hundreds of thousands of lines of PHP code, and very commonly has tens of thousands of customers accessing it concurrently.

    And yeah, I know you were joking, but hey, I was bored. ;^)
  • by xtal ( 49134 ) on Friday October 21, 2005 @10:54AM (#13844454)
    Applets, apps.. whatever, Java never seemed to flow as an extension of the browser in the way that PHP did. It always seemed to be a better C++ (flame suits on) with one hell of a standard library built in.

    Unfortunately, the answer to "it's not fast enough" always seemed to involve a very heavy, expensive machine from Sun. Hrmm.

    Microsoft's solutions always seemed inelegant to me.

    PHP always was, and is, about making web applications and database interfaces very efficiently.

    Why is it suprising then, that it would be adopted?
  • by helix_r ( 134185 ) on Friday October 21, 2005 @10:55AM (#13844464)

    Web apps all have the same problem. They use a goddamn BROWSER as the application platform. This sucks.

    I'm looking at a typical jsp right now. Its an awful demoralizing conflation of xml, css, jstl, html, and javascript-- all in one file. As developer, it sucks to work with and it is a major hassle to create a nice user experience with this trash y stuff.

    I have not worked with PHP, but looking at the source from the browser page, I imagine the same problems apply.

    Whatever happened to the "applet" concept? True, there were problems with it initially, but one would think that these problems could have been solved by now. Instead, the industry turned away from nice clean designs to the brutal mess that is today's web app.
  • by pico303 ( 187769 ) on Friday October 21, 2005 @10:58AM (#13844499)
    ...I can honestly say I avoid PHP at all costs. PHP feels like it was built by committee: there's no consistency in the language. Even with 5 I still feel like I'm hacking together web pages.

    I feel like there's a lack of standardized libraries for PHP. I've used PearDB, but it's sure not ActiveRecord or Hibernate. Smarty's o.k., but I'm already developing in a template language for HTML pages, why do I need another one? It's like working with JSP tag libraries (which I find equally wasteful).

    Fundamentally, I think the tight coupling between view, controller, and model that PHP naturally engenders is bad. Practically, I've seen where Ruby on Rails has gone in just a single year, and it's further than PHP's gone in the last 5. Things you can do in Rails in a few days take weeks of coding in PHP, even with the help of third-party libraries.

    PHP has a strong foothold with small, inexpensive ISPs, which is the only reason I think that people still use it. Unfortunately, the "war" between 4 and 5 has really hurt the credibility of PHP moving forward. Does any ISP support PHP 5?

    If PHP wants to compete against Ruby on the low end and J2EE and .NET on the high end, it's going to need new development tools--both for writing the code and useful libraries, stronger leadership, and a clear plan for the future. I don't see any of this happening in its current state. I consider myself to be a PHP outsider these days, and looking in it doesn't look so fun in the pool.

  • by KiloByte ( 825081 ) on Friday October 21, 2005 @10:59AM (#13844501)
    As someone impartial to the Java-vs-PHP debate (and a soldier to a third side), I would describe PHP as Visual Basic of server-side development. It's very easy to use, but most code is monstrously sloppy and/or insecure -- I might have been unlucky, but the three times I fixed problems in php code (and usually rewrote things in Perl), the code had glaring holes and was totally unreadable. You're reading this right -- I rewrote things to Perl to make them readable.

    The problem with Java is that you can't really integrate it with anything other than Java itself -- Sun can teach Microsoft a lot when it comes to blocking third-party improvements. Until, as you say, gcj or any other piece of free software catches up, Java won't be usable. It died as a client-side language, and is struggling on the server as well.

    Thus, the bottom line is: long live Larry Wall!
  • by orasio ( 188021 ) on Friday October 21, 2005 @11:01AM (#13844524) Homepage
    I was a student in 1996, and I learned ASP for a specific project. Some time later, I found PHP, and liked it. I did some stuff with PHP. I really admire Rasmus, I met him when he came to Uruguay, and he is great. I believe PHP is a great idea, and works great.

    But now I use Java, because I think it's much easier to work with, when you have teams of more than two people. PHP gives you too much freedom to be easily managed. It's nice for experimenting, for stuff you want to see right away, for complex stuff you don't have to maintain for others, too.
    I like better the ability to have interfaces, standards, Struts, lots of things that make Java better for developer teams.

    The same that the guys who start right now with PHP, they might or might not change.
  • by bobdinkel ( 530885 ) on Friday October 21, 2005 @11:22AM (#13844680)
    I find it strange how people recommend Smarty for separation of code from content. Smarty implements its own while loops and if then statements. I have yet to come across a web application using Smarty that was easily readable. I would think if the goal was to separate code from content, one would use a templating engine more akin to QuickTemplates. It does not make you relearn a whole new programming language syntax for while loops and if then statements like Smarty does.

    People recommend Smarty because PHP feels pretty incomplete without it. And it's not about separating code from contentit's about separating business logic from display logic. And the syntax is really easy.

  • Re:Java failing? (Score:3, Insightful)

    by bloo9298 ( 258454 ) on Friday October 21, 2005 @11:23AM (#13844689)
    It's not quite clear from the article where Java is failing.

    On the contrary, the article makes it very clear: Java is failing to provide income for Marc Andreesen.

  • by Anonymous Coward on Friday October 21, 2005 @11:28AM (#13844744)
    PHP already is a templating language! You don't need the extra overhead of these 'template engines'. PHP is already doing it for you. You wouldn't go and build a templating engine via Smarty now would you?
  • Re:Will be? (Score:1, Insightful)

    by Anonymous Coward on Friday October 21, 2005 @11:36AM (#13844835)
    I thought PHP was already more popular

    PHP's popularity is partially due to cost of hosting a PHP web site. PHP is just easier for hosting providers to setup and not as resource-hungry as a JVM. Shared JVM's are also a pain, because often times you really need to restart the whole JVM to get things to work (OutOfMemoryExceptions). So for a serious site, you'd want your own JVM, and that costs even more.

    If Java hosting didn't cost 2.5 times as much as PHP hosting (and that's just for shared JVM), we'd probably see more Java-based sites. I know I'd like to have some place to host the Java web apps that I've written for fun. I'm just way too paranoid to host them on my home connection.

    As for the languages themselves, I like Java for working on big projects. PHP I use for little hacks and simple web pages (as well as extending Drupal [drupal.org], or whatever blog software I happen to be using). Of course I've never been paid to work with PHP so I don't know the full extent of its capabilities.
  • by LDoggg_ ( 659725 ) on Friday October 21, 2005 @11:51AM (#13844968) Homepage
    The problem with Java is that you can't really integrate it with anything other than Java itself

    Huh?
    Not sure what you mean here. If by integrate you mean communicate with other languages there's things like CORBA and SOAP, if you mean call other shared libraries there's always JNI if you can't find a java lib to do something.

    Until, as you say, gcj or any other piece of free software catches up, Java won't be usable.

    Strange, I'm using it every day at work. Have been in one way or another professionally for 8 years now.

    It died as a client-side language, and is struggling on the server as well.

    You do realise that is no better than a BSD is dying troll right?
    Just checked Moster.com. 105 java positions available within 50 miles of my house, 18 for PHP, 42 for perl

    Now I'm saying that as someone who also uses PHP. I've been using it quite a bit lately and don't mind it at all, but we're talking apples and oranges here. Sure PHP can be used to write monstrously sloppy and/or insecure code, but so can any language. PHP can also be used to write clean easily maintable secure code.
    PHP wasn't even close to java in terms of object oriented coding until PHP5 came out, which unfortuneatly has been very slow to appear on most 3rd party hosting servers and distros.

    My only real gripes with PHP are the lack of a standard DB connectivity layer like JDBC. PEAR:DB and ADODB are close, but they still rely on non-php libraries so setting up a connection to oracle or sql server is painful. The other thing is a lack of type hinting for primatives. Seems kinda silly to have to do a check if something is an int or double in the method instead of just putting it in the method's signature. I'm know its a loosely typed language, but type hinting is there as an option for objects, why not primatives too?

    I'm looking forward to PHP5.5 its going to have some real nice features that will bring it little closer to server side java and a little further from something like .asp where most of the business logic is in the presentation layer.
  • by thePowerOfGrayskull ( 905905 ) <marc...paradise@@@gmail...com> on Friday October 21, 2005 @12:20PM (#13845249) Homepage Journal
    However, you can use the Smarty templating library to separate code and presentation (and I recommend this to anyone learning PHP, because embedding PHP in HTML makes for very sloppy and nigh unreadable code).

    Come again? You're saying that {$value} somehow separates presentation from code more than does <?=$value;?>?
  • by rsheridan6 ( 600425 ) on Friday October 21, 2005 @12:21PM (#13845267)
    Is this because PHP is inherently unreadable, or because it's so easy to learn that a lot of incompetent people who barely deserve the title "programmer" use it? People say the same things about Perl, but when I dabbled in Perl I concluded that its alleged unreadability had more to do with its users than the language itself, because the code I found was pretty readable (I happened to have an interest in a project written by MIT CS grads). I have no experience with PHP (besides looking at the manual and finding it unappealing), but maybe the same thing is going on with PHP. PHP was, after all, designed to be used by, let's just say, non-alpha-geeks.

    The existence of badly written code that nonetheless works would be sign of PHP's success in that regard.

  • by hoggoth ( 414195 ) on Friday October 21, 2005 @12:35PM (#13845369) Journal
    > One would think that Andreessen would understand how to use the right tool for the right job, but apparently not

    Andreessen knows exactly how to use the right tool for the job, like a surgeon. His tool is the media, and his job, as a new member of the board at Zend, is to promote PHP.

  • Programming tools? (Score:3, Insightful)

    by Mike McTernan ( 260224 ) on Friday October 21, 2005 @12:36PM (#13845381)
    > 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.

    Bleh. Windows doesn't even come with a compiler.

    I think that's probably why a lot of developers like Unix so much - most systems come with a compiler as standard and the man pages give you all the APIs you need. Grab your favourite editor and off you go!
  • by Anonymous Coward on Friday October 21, 2005 @12:38PM (#13845395)
    Whether code is written in good style or not, has very little to do with whether it is written in PHP or not, and has everything to do with the habits of the programmer. Also, last time I checked, comments are generated by the programmer, not the parser, nor are they inherent or dependent to the language itself. Evaluating a language based on how bad a programmer bad form and then making a comparison to your Perl coding styles seems like you are just posting to make yourself feel good. It would be a far more useful comparison to compare how intuitive the language is to write and how
    flexible and capable the language is in the hands of a capable programming team.

    PHP having a decent (not grade compared to say Lua) object oriented model for a scripting language and a gazillion different libraries and extensions, can be compared much better to Java and JSP or even ASP; however I don't think it can be usefully compared to Perl without being unfair to either side. Note: I work with both PHP and Perl and find that on a day to day basis, these two are complementary to each other since they each do things very well that the other doesn't.

    Just my 2 cents.
    Frank
  • by Anonymous Coward on Friday October 21, 2005 @02:59PM (#13846679)
    Something that many people do not seem to realize is that every website running ColdFusion is using Java. There are an awful lot of those out there.
  • by SatanicPuppy ( 611928 ) <SatanicpuppyNO@SPAMgmail.com> on Friday October 21, 2005 @03:27PM (#13846890) Journal
    I don't think Php is inherently unreadable. With good formatting, well-named variables, and intelligent use of functions, it's just as readable as anything else.

    I think it's a bit more readable than Perl, simply because Perl lets you get away with things that php does not. $_ leaps to mind.

    But Perl gets a bad rep from people who write sloppy Perl code. If you break things out into packages and functions and aren;t afraid to use linebreaks, the code doesn't become an illegible snarled mess. The things I see that make most people throw their hands up are undocumented regular expressions...If you're good with regex you look at it and go, "eh, email address validator", but if you're not it looks like someone wiped their nose on the number bar while alternately whacking the shift key.

  • by moof1138 ( 215921 ) on Friday October 21, 2005 @03:39PM (#13847013)
    It's not about exactly separating presentation from code - the presentation is also code. It's about separating business logic from display logic. Your example overlooks the key piece, where the business logic to determine $value is done.
  • by jcoleman ( 139158 ) on Friday October 21, 2005 @03:43PM (#13847050)
    We can have several programmers affecting changes in one codebase in real time.

    I'm not sure why you think
    a) this is a good idea to do in PHP, and
    b) this can't be done in Java.

    And, for a program which took us six months to develop in PHP, it would have taken at least fifty percent longer with Java.

    And now it will take you at least two hundred percent as much time to maintain.

  • by Anonymous Coward on Friday October 21, 2005 @04:36PM (#13847590)

    Why doesn't variable interpolation within an HTML page do htmlspecialchars()

    OH BOY I totally agree with this. Passing data into the HTML without HTML-escaping by default is a STUPID design choice. It's liking building a DB access layer that doesn't auto-quote placeholders.

    And on top of that, they make the name htmlspecialchars() so LONG. And PHP doesn't have function aliasing, so you can't give it a different name, you have to create a new function that calls it (waste of cycles).

    I really wish PHP would get it's head out of it's ass and make the HTML escaping the default. Or at least give me an easy way to write my own template system (no, Smarty and bloat like that isn't what I mean.. I mean a *low-level* way to plug into the existing template system), OR a way to reliably audit existing templates and point out unescaped tags..

    Think about it: If escaping is the default, and you forget to unescape, you get visible HTML in your page. Easy to spot.

    If UNESCAPED is the default, and you forget to escape, you don't see ANYTHING wrong. Until a XSS attack is found in your app and posted to Bugtraq.

    Dumb dumb dumb.

    PS, another HUGE problem with PHP is that it's very difficult to cache the compiled bytecode (wait does it even compile to bytecode??) and/or keep data in RAM between hits. You have to download a third-party tool or hack something yourself with shared memory. If I write a big PHP app, I want to keep the compiled classes in RAM or on disk for more speed, like I do with mod_perl or Rails. What is the *reliable* way to do this in PHP?? I think it might even be impossible, due to the massive dependence on a global namespace..

  • by robla ( 4860 ) * on Friday October 21, 2005 @05:03PM (#13847899) Homepage Journal
    It's harder to enforce separation without something like Smarty. Disclaimer: I haven't used Smarty, but I've used a homegrown templating system with PHP.

    It's nice to be able to give the people responsible for content and layout access to the files of the website, without giving them access to the code that actually contacts the database, has access to server globals, etc. You can enforce that sort of separation via policy rather than code, but if its only policy, there's a temptation to bend the rules, especially if you have a page designer who knows just enough PHP to be dangerous. Better to have a template system that doesn't give raw database access, and then have a backend that exposes the pieces of database data to the designers that they need.

Always draw your curves, then plot your reading.

Working...