SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 40 of 40

Thread: Is PHP ugly?

  1. #26
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This bit worries me

    ...Stay with a nonthreaded Web server...
    Apache is a muti-threaded server, so now it is bad ? At the moment I use IIS, though given the opportunity, I'd switch to Apache in an instant.

    give yourself a chance to trace and debug any problems that may
    Isn't that what Unit Testing is for ? Looking briefly at the article in question, and noting that it is the same person of a certain book I bought a while back - which was not much use to me either - I'm inclined to take a disliking to this person

  2. #27
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by patrikG
    As much as I would like to have had the time, explaining to clients why you need to totally re-code their project and thus increase their costs, is very, very difficult.

    From my experience everyone brings in their own toolkit and codebase to a project - some are good, but they are all quite different. Many times coders do not want to compromise on what they perceive is best practice (or rather "their" practice) - and that's exactly the problem.
    The key is to be able to refactor the code slowly and incrementally. It's easier said than done, but it's possible and it means you can sneak in some improvement even on a very tight schedule.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  3. #28
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree that to go in and attempt to cleanup/recode/document say a 20+ file project is not practical, especially if it is not your code and time is a factor. I have been studying a book on OOP and it is drilled in to write clean code, proper docs and test cases from the start to minimize refactoring.

  4. #29
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rasmus Lerdorf
    Database abstraction is mostly a myth. There is nothing wrong with direct database calls' making use of all the tricks and cheats your chosen database has to offer, to tweak as much performance as possible out of it.
    There's a requirement for high performance assumed here. If we want to "tweak as much performance as possible" out of a Web app, we should never make Web pages like this discussion forum. The HTML code is far too voluminous to download quickly over a slow connection. But sometimes, other things are important as well.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  5. #30
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I find the things that mr. Lerdorf is saying rather simplistic, without proof or reasons for his statements and some of them are even contradicting. Take this one for example:
    Solving the Web problem is simple; don't try to make it hard.
    If it were really that simple, why are I-don't-know-how-many people developing I-don't-know-many 'solutions' to this simple problem?

    ...Stay with a nonthreaded Web server...
    For godsake, why? What are his reasons for saying this? And is it me, or is he advocating here that we abandon Apache (which is a threaded webserver), while PHP and Apache are almost like married partners?..

  6. #31
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are his reasons for saying this?
    I'm with you on this - I think Rasmus is speaking through a hole in his a**e.

    But that's just my personal thoughts

  7. #32
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I'm not saying that he's spreading bull****, just saying that there is no reason to treat what he is saying as "authoritive" (sp?), for the simple reason that he does not back up his claims at all.

  8. #33
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by dagfinn
    The key is to be able to refactor the code slowly and incrementally. It's easier said than done, but it's possible and it means you can sneak in some improvement even on a very tight schedule.
    The trouble I've had with refactoring is the way it can disrupt schedules. If you add a lot of new features you can move quickly, but the crud builds up. Suddenly it is painful to add something new and all that refactoring you should have done along the way comes back to bite you. This makes your schedule bullet points rather unpredictable. There are two solutions that I know of so far.

    The official XP solution is to refactor mercilessly as you go. We haven't found this all that easy. It is difficult to see what to refactor until you actually start adding the feature that causes the problems. Attempting to produce perfect code tends to be inefficient without the clear goal and things can thrash.

    We've had more success with identifying and scheduling rafactorings. It makes it clear how much time you spend doing it (about 40% in our case) and you can prioritise them like any other task.

    Just thoughts so far.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  9. #34
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For godsake, why? What are his reasons for saying this? And is it me, or is he advocating here that we abandon Apache (which is a threaded webserver), while PHP and Apache are almost like married partners?..
    PHP isn't officially supported under Apache 2.x (which is threaded) - only Apache 1.x. Apache 1.x uses process forking to cope with load (and it has proved a very effective approach - except it doesn't work on Windows - I guess because the various required Unix libraries have never been well ported to Windows and Windows was never designed that way). Otherwise I guess threading leaves a bunch of extra work for developers which you could do with out (is this object synchonized?) when knocking up web apps.

    As to database abstraction libraries, well he's talking on Oracles web site so they're probably very happy to hear it Guess the thing is with a db like Oracle is you can implement business logic quickly and effectively in stored procedures, leaving PHP nothing to do but render HTML on top of it. This is certainly the way to get a project done on time which seems to Rasmus's angle in general. It may cause you pain later but alot of commercial development is done with the idea of reaching point B as fast as possible, as that's where the money starts to flow in.

    That said, Rasmus comes across as being a little embarassed by PHP. CP is right - more time should have been alloted to let him explain the remarks in more detaul.

  10. #35
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From http://httpd.apache.org/docs-2.0/mod/prefork.html :

    Apache MPM prefork

    This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  11. #36
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Putting an article across over at Oracle would proberly be more embarrassing IMO

    Oracle may have the benifit of business logic in the database, but the planet certainly doesn't revolve solely around oracle

    If this is your take on the matter Harry, then IMO Rusmus is no more than a talking puppet, oracle pulling the strings of course

  12. #37
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    Oracle may have the benifit of business logic in the database, but the planet certainly doesn't revolve solely around oracle
    It does for most of the largest corporations in the world. I would like to see you name one of the Fortune 500 companies that uses something like MySQL for critical data. Heck one of the Fortune 1000 companies even.

    Heck, even Yahoo doesn't use it for critical data. While MySQL is great for small business wanting more out of a database than Access and non-critical web data it is nowhere near a mission critical application even to this day. Getting closer but still a ways to go. If I found out my bank was using MySQL as its primary database instead of Oracle, I would be switching banks in a heartbeat.
    Wayne Luke
    ------------


  13. #38
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    Hi...



    The trouble I've had with refactoring is the way it can disrupt schedules. If you add a lot of new features you can move quickly, but the crud builds up. Suddenly it is painful to add something new and all that refactoring you should have done along the way comes back to bite you. This makes your schedule bullet points rather unpredictable. There are two solutions that I know of so far.

    The official XP solution is to refactor mercilessly as you go. We haven't found this all that easy. It is difficult to see what to refactor until you actually start adding the feature that causes the problems. Attempting to produce perfect code tends to be inefficient without the clear goal and things can thrash.

    We've had more success with identifying and scheduling rafactorings. It makes it clear how much time you spend doing it (about 40% in our case) and you can prioritise them like any other task.
    For some reason I missed this post until now.

    You have an interesting point. In the book "Extreme programming in practice" there's a chapter called "A flurry of refactoring" which I think is the phenomenon you describe. I've mostly been working on my own lately, but one thing notice that refactorings tend to feed on one another. You do one, and a whole load of opportunities open up for doing more.

    My point in this thread was to suggest refactoring as an alternative to a complete re-implementation, which tends to be impossible as a result of time constraints.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  14. #39
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would be switching banks in a heartbeat.
    So would I But I never suggested in any way, shape nor form that MySQL could compete with Oracle at any level.

    My point was more about putting business logic in the database. Oracle way have a large user base of big businesses as you say, but so what ?

    There are other options available

  15. #40
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My point was more about putting business logic in the database.
    Guess it's a question of perspective and your understanding of words in the database. In it's rawest sense, Oracle is just a repository for relational data (and at this level, I don't like it much because it makes things like paged result sets, common to web apps, harder to implement than MySQL or Postgresql and if you're working with PHP and Oracle, recommend libraries like PEAR:B and ADOdb over the native oci8 functions, as they help you work round this).

    But when you add views (a layer of abstraction above tables) and stored procedures, it looks something more like an application server. "Querying" the stored procedures is more like making remote procedure calls - basically no SQL involved.

    If you're happy to accept Oracle as your only vendor, it's a fairly sane way to do things and pretty much guarantees performance. The short comings I guess are PL/SQL which is a simple procedural language (you often end up with massive procedures) and the temptation for application developers to bypass the procedures and access tables directly (although that can be prevented with database security).

    But PL/SQL is serious enough to have it's own unit test framework. There's even PL/SQL Server Pages I believe. And by using Views (which perhaps also call procedures), you could have something approximating to an object model, sat right above your data.

    Now Oracle have implemented Java in 9i, for writing stored procedures, it starts to make more sense to do things this way (though you'll still be tied to Oracle). That said, talking to some of our Oracle developers at work, most have had Java courses but after years of PL/SQL basically don't like it. Will be interesting to see how Oracle ends up using PHP (whether it will be available for writing stored procedures) - might make a much better fit for those coming from PL/SQL.

    All that said, the real competition for Oracle is PostgreSQL, not MySQL (at least not for many versions).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •