SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 67

Thread: PHP Rant

  1. #26
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plus, this is the most-read thread on the PHP forum's first page. People ARE reading it.
    Ryan

  2. #27
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally, I liked some of the things that PHP's loosly-typed nature provided. But that was back when I was a wee-little kid(read:13) 2 years ago. And fresh done programming in C with an incredibly outdated compiler for 3 years.

    I saw advantages in not having to declare types, I mean I could do whatever I wanted with my variables(like you described with the string, etc). But now, as I have attempted to master PHP's OO functionality, no comments on progress here, and learned C++ I've found myself wishing for some type definitions, and php5 provided. Unfortunately, I also want virtual functions, overloaded functions, pointers to functions*, etc. This really isnt the point though. The point is, although php is loosely typed, and uses weird keywords(extends), perhaps it is somehow related to PHP's internal datatype when run as C code, or however it is done, that it is simply better for the developers to leave variables without a type. And it doesnt actually cause any problems, because you can check type qualities at runtime, with isint() isreal(), etc. and check for classes with php5's new pseudo-types, or with get_class() and control structures.

    *call_user_func() really doesn't count imo. but thats just my opinion.

  3. #28
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, pointers can be useful.

    One other point: Too many things in PHP are ambiguous. It's a "Try it, see if it works" as opposed to being written in rock. The way arrays are handled, the way references are, a lot of other things I can't thin of.. you either know it or you don't, you can't look it up. Trial and error is what they teach you is bad... imagine coding PHP for a hardware chip Takes 30 minutes to compile, if you get it wrong you throw the chip out (costing you money), and then fix it and try again. I said PHP'ers should know C - and this is probably pushing it - but PHP'ers should develop for hardware It'll give them a feel that you shouldn't ever have bugs. Learn to program properly the first time.

    I must say, PHP is fun to mess around with - it's funny when you've got in depth functions manipulating a dynamic number of arguments, and by the middle of the function you've got like 15 indents.

  4. #29
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, PHP doesn't have functions to support hardware I/O I believe(not sure about Direct I/O lib, i think that requires linux OS). <muse>Perhaps an interesting hack involving using fopen on stdin(on linux) and coding a command line interfacing script that has user input?(with fread() of course)</muse>

    Yeah it IS rather fun to mess around with, I've grown father fond of messing with PHP-GTK. Much, much nicer than the C interface(all those typecastes to deal with :-(). Thats probably why i prefer(ed) PHP over C. I don't prefer it over C++, but as my skills are much higher in PHP, I code in it mainly.

  5. #30
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well since no-one else has

    1. Proper type definitions

    Honestly, is it so hard to implement types?

    in the Zend core ? yes , remember PHP is dynamically typed , it is not typeless , regardless , some interesting thoughts from unexpected places
    This became a puzzle to me: if strong static type checking is so important, why are people able to build big, complex Python programs (with much shorter time and effort than the strong static counterparts) without the disaster that I was so sure would ensue?
    Bruce Eckel on dynamic types ..

    leading to ...
    I also realized that the flexibility of dynamically typed langauges makes writing code significantly easier. Modules are easier to write, and easier to change. There are no build time issues at all. Life in a dynamically typed world is fundamentally simpler.
    Robert C. Martin's take on things


    2. Way too simple

    Heard that one before & I class it in the 'its too cheap' category, sorry Nathan but thats a non-issue at best , yes its easy to write sloppy insecure code but I can do that in PERL, ASP & even a bit of JAVA.. it just takes longer to do so , if I want to write crap code I want to write it quickly .


    3. Lack of security
    4. Stubborn people
    Misused OOP/Functions
    5. Lack of scalability

    3,4 & 5 (& partially 2) are all nothing whatsoever to do with PHP but to do with people.

    We have all written dodgy/hacky code from time to time , indeed I still do it all depends on the situation & the application of such

    And some of it is subjective , you mention lack of scalability & at the same time recommend forced OO abstraction regardless of the situation something that does not compute for me personally.

    The root fact is that whilst its quite possible to write 'proper' code in PHP (moreso perhaps with PHP5 depending on your definition of 'proper') , it is not even always desirable to do such

    I reply mainly because I would not like anyone to read this post , look at thier non-OO-pattern'd-abstracted-painted&decorated code and give up.

    I too have many times had to rewrite awful code [sometimes my own], but blame the contractor , chances are (9/10) that they decided to take cousin-joes offer of a full e-commerce website for $50 + a packet of chips over a proffessional quote costing prehaps 20-100 times as much ... in the short term

    In other words people often get exactly what they pay for , thats not PHP's fault (I have rewritten plenty of dodgy ASP as well ].

  6. #31
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is superfast to develop for, and i suppose part of that could be the types, since i dont have to plan out what i want to do with each variable very well. good point.

    I reply mainly because I would not like anyone to read this post , look at thier non-OO-pattern'd-abstracted-painted&decorated code and give up
    is it so wrong that i find sarcasm about design patterns funny?

    Oh and I am a master at dodgy code. I don't even like to read over my code after i finish. I just pray that it works right.

  7. #32
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selatos
    extends
    This is actually a more logical keyword than the (imho) b.s. syntax that "C++" (some great OO language my ****) provides. Inheritance is believed to "extend" the type (and in many horrible cases the funtionality) of the class or interface.

    Quote Originally Posted by Selatos
    pseduo-types
    What? I didn't know there was an in-between for types. I don't get it.
    Ryan

  8. #33
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I'm not going to say much because you hurt me with my own stupidity

    However the few arguments you had with PHP as a language were really nothing. That what PHP is meant for. You want a stronly-typed language you have Java and C#. Hell you could probably even write ASP.NET in C++.NET if you really wanted!

  9. #34
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would kill myself and destroy every computer I've ever touched before I would program in C++ for a large project again, or program in C++.NET EVER.

    Ryan

  10. #35
    SitePoint Addict Brak's Avatar
    Join Date
    Jul 2004
    Location
    Central Coast, CA
    Posts
    321
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with DJP@CkMaN, I was just about to type the same thing. All of your points are completely valid, however I think you've neglected to think about one word - why.

    Why does it matter that PHP is this or isn't this? It's done exactly what it's accomplished - become a widespread, open-source, server-side scripting langauge. I doubt the forefathers of PHP ever intended to take over Java, C++, etc. It's supposed to do simple things, intereact with databases and XML with elegance and simplicity. It's along the same reasons that advanced computer games aren't written in JavaScript.

    Sure, some sites use PHP to power advanced web applications - but these sites also have people that know what they're doing and code properly (most, defiantely not all).

    I'll be the first to admit I am by no means an expert programmer. I've dabbled in C for school purposes, and I'm not into that whole "serious" programming stuff if you will. However, if I a client of mine asks for a task to be completed on the web, I am more than capable. Will the soccer league sign up form be bombarded with a network of 10 computers trying to hack it? Hardly, there's no need for me to go balls-out on it. It just needs to work.

    I believe that's the point of PHP - get it done with the least amount of effort.
    Studio Rockstar's Blog - A journey to quitting the dayjob.

  11. #36
    SitePoint Addict Chillijam's Avatar
    Join Date
    Nov 2003
    Location
    England
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am inclined to agree with you, someonewhois. The things you ranted about made a lot of sense.

    As a relatively recent n00b, I can try to justify my coding "style" with phrases like "I was learning", but they really don't cut it any more.

    Let me tell you a couple of things about myself.

    1) The first project I created was a resource tracking and management system for my company. This very morning, I was required to go back to implement some changes, and looking back through my code, I am struggling to remember how I did things, or even why, in some cases.
    2) I have recently been required to learn C#. Initial difficulties with getting my head round strong typing, and all the other "restrictions" of C# are now starting to sink into my thick skull, and if I am honest I should say that it all makes a great deal of sense.
    3) I bought Harry Fuecks' PHP Anthology specifically to try to learn OOP. While I don't claim to be a guru (I'm far from it), I can tell you that that knowledge has been extremely useful in C#

    In short, I think if a lot of people followed the advice given in your post, the PHP community would be much better off.

    </ 2c>
    Your mind is like a parachute. It works best when open.
    (HH The Dalai Lama)

  12. #37
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I thought pseudo-types was the term php.net used for the Type guessing that it does(ie. function someFunc(Object $a) {}) Let me go look that term up on php.net

    [later]
    Yeah I can't find the article which I'm talking about, perhaps you know where it is. The one that was on php.net talking about all the new features of php5. Anyways, even if its not the right term, pseudo-types fits(well in my mind at least), because it doesn't cause an error when it parses the script for errors, but instead at runtime when that point in the script is reached. So it is kinda sorta a "half-typing" effect.

  13. #38
    SitePoint Enthusiast
    Join Date
    Mar 2003
    Location
    Fredericton NB
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    One other point: Too many things in PHP are ambiguous. It's a "Try it, see if it works" as opposed to being written in rock. The way arrays are handled, the way references are, a lot of other things I can't thin of.. you either know it or you don't, you can't look it up. Trial and error is what they teach you is bad... imagine coding PHP for a hardware chip Takes 30 minutes to compile, if you get it wrong you throw the chip out (costing you money), and then fix it and try again. I said PHP'ers should know C - and this is probably pushing it - but PHP'ers should develop for hardware It'll give them a feel that you shouldn't ever have bugs. Learn to program properly the first time.
    Yeah but I'm NOT coding for hardware, and that is not what PHP is designed for. I'm building web applications, and that is something that PHP is great at it. Part of the reason it is great for this is BECAUSE it is so flexible. I'm not saying it's perfect, but come on...

    And if you don't like it, well, it is open source...why don't you go develop your own version.
    Red Cow Technologies, Inc
    RealAdmin - Software For Real Estate Agents
    myBusinessAdmin - Affordable CMS and web design solution.

  14. #39
    SitePoint Zealot patrikG's Avatar
    Join Date
    Aug 2003
    Location
    Sussex, UK
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dynamic type-casting is one of the great strengths of PHP - I hear your criticism, someonwhois, but I fail to see your point. What's wrong with the machine doing what it does best, computing, while I continue working on the API or code a function?

    Regarding PHP being "too easy to learn" - yes, it is, which, as has been said above, adds greatly to its popularity. However, with the OO-capabilities and general improvements of PHP5 PHP itself becomes extremely scalable. My neighbour can set up a "dynamic webpage" with Dreamweaver MX easy, while more serious developers can build large-scale applications with it (best arguments for this are made in Schlossnagle's book) - and that entails adhering to coding-standards, documentation, proper OO etc. This scalability works greatly to the benefit of PHP's popularity.

    To me it sounds very much as if your complaining that PHP is not C++. Why should it ever try to be? PHP does what it does and is becoming better at it. No need to be something it isn't. It's a language in its own right.

  15. #40
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the Zend core ? yes , remember PHP is dynamically typed , it is not typeless , regardless , some interesting thoughts from unexpected places
    Well static type casting would involve being done from the begining, as opposed to now

    Heard that one before & I class it in the 'its too cheap' category, sorry Nathan but thats a non-issue at best , yes its easy to write sloppy insecure code but I can do that in PERL, ASP & even a bit of JAVA.. it just takes longer to do so , if I want to write crap code I want to write it quickly .
    Quickly is the keyword - nobody sits down to learn Java only to do it sloppily. Because PHP has an online manual and everything's so accessible you don't need to read books etc. I've never read a PHP book in my life (though I am interesed in seeing how the PHP Anthology was done, but don't really feel like paying, so). With java you need to etiher buy or rent (library) a book on it, sit down, read it, learn it, and then to screw it up? I know people will do it, but not in the large scale. People don't code Java as a toy (or few do..)


    For the rest of your stuff Firepages - sure, I'll go for that. Point is it's killing the freelane and contract PHP market, and that's unfortunate.

    Yeah but I'm NOT coding for hardware, and that is not what PHP is designed for. I'm building web applications, and that is something that PHP is great at it. Part of the reason it is great for this is BECAUSE it is so flexible. I'm not saying it's perfect, but come on...

    And if you don't like it, well, it is open source...why don't you go develop your own version.
    Because I'm practicle. I'm not going to go and write my own language and hope people use it (for free at that, and if I made it paid nobody would use it either). I use computers for something called money. That's why I hate open source, is the people don't know what money is - some open source projects are great, PHP, MySQL, I'll even say Linux... but until they can learn to make money, they're the stupidest people alive. Surely if Linux charged $50 (and all distros, not just a few, but all of them so you HAD to pay $50) people would still buy it. People who are anti-MS for nor reason what so ever (the bandwagoners) would go back to MS, the hardcore Linux fans would buy it, and Linux developers wouldn't be spending hours and hours developing for nothing. Anyway, I don't feel like getting into an Open Source/Closed Source or Linux/Windows debate, so let's keep it on topic

    I am inclined to agree with you, someonewhois. The things you ranted about made a lot of sense.

    As a relatively recent n00b, I can try to justify my coding "style" with phrases like "I was learning", but they really don't cut it any more.

    Let me tell you a couple of things about myself.

    1) The first project I created was a resource tracking and management system for my company. This very morning, I was required to go back to implement some changes, and looking back through my code, I am struggling to remember how I did things, or even why, in some cases.
    2) I have recently been required to learn C#. Initial difficulties with getting my head round strong typing, and all the other "restrictions" of C# are now starting to sink into my thick skull, and if I am honest I should say that it all makes a great deal of sense.
    3) I bought Harry Fuecks' PHP Anthology specifically to try to learn OOP. While I don't claim to be a guru (I'm far from it), I can tell you that that knowledge has been extremely useful in C#

    In short, I think if a lot of people followed the advice given in your post, the PHP community would be much better off.

    </ 2c>


    Dynamic type-casting is one of the great strengths of PHP - I hear your criticism, someonwhois, but I fail to see your point. What's wrong with the machine doing what it does best, computing, while I continue working on the API or code a function?

    Regarding PHP being "too easy to learn" - yes, it is, which, as has been said above, adds greatly to its popularity. However, with the OO-capabilities and general improvements of PHP5 PHP itself becomes extremely scalable. My neighbour can set up a "dynamic webpage" with Dreamweaver MX easy, while more serious developers can build large-scale applications with it (best arguments for this are made in Schlossnagle's book) - and that entails adhering to coding-standards, documentation, proper OO etc. This scalability works greatly to the benefit of PHP's popularity.

    To me it sounds very much as if your complaining that PHP is not C++. Why should it ever try to be? PHP does what it does and is becoming better at it. No need to be something it isn't. It's a language in its own right.
    Static type casting would work better simply because it closes so many questions. There are too many open ends in PHP, too many things that you can do that other languages don't let you (and almost shouldn't be done), yet people aren't quite sure if it works (as it doesn't make sense from a technical side). That's just how I see PHP.

  16. #41
    SitePoint Zealot mrWoot's Avatar
    Join Date
    Jan 2004
    Location
    Wisconsin
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the same with mostly all languages.

  17. #42
    SitePoint Zealot patrikG's Avatar
    Join Date
    Aug 2003
    Location
    Sussex, UK
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're bemoaning the fact that so many people are learning PHP and are doing badly at that?

    That's quite elitist, someonewhois. The more people know about the internet, how things work in general, the better. I don't want to (and wouldn't ever) be revered as a living god of whatever, just because I can code PHP well. Is that what you want to when coding C++ or Java? No? Well, then go out and share knowledge. Which is, btw., the spirit of open source.

  18. #43
    SitePoint Evangelist Andrewaclt's Avatar
    Join Date
    Dec 2003
    Location
    Raleigh, NC
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really see why you would have problems with types? Don't try to do weird things to the varibles you use as strings (i.e. */+-) and if you have problems label your variables... $intVariable, $strVariable...

    That makes more sense anyway and is a good practice especially if you plan on moving to more strongly typed lanauages.

  19. #44
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew, in my C++ book that I have here, the author says that although widely used, that form of naming convention is being abandoned because you have a type already, no need to reinforce it for your own benefit. Its much better to give them a meaningful name without the type included as a prefix or postfix.

  20. #45
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After doing some coding for other people and other jobs, I can fully understand where you're coming from.

    I really hate people not using a set standard of tabulation.

    My "2 cents" are that, please add in your comments what tabulation settings you've used.

    Code:
    /*
    ...comments for file...
    @tabulation: 8
    */

  21. #46
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selatos
    Andrew, in my C++ book that I have here, the author says that although widely used, that form of naming convention is being abandoned because you have a type already, no need to reinforce it for your own benefit. Its much better to give them a meaningful name without the type included as a prefix or postfix.
    He's saying use that in PHP, since PHP doesn't have types.


    As for tabbing, it's pretty obvious. Just do a tab and figure it out. I think my defualt settings are 4 spaces, and acts like a tab (as opposed to acting like spaces).

  22. #47
    SitePoint Zealot Selatos's Avatar
    Join Date
    Aug 2002
    Location
    USA
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, worchyld, if you use an editor, you can set it to display the tab character with a certain number of spaces, so that shouldn't be too much of a problem for you.

    someonewhois: Yeah I suppose in PHP it might be useful, but with php5's new pseudo-types(yes i will continue to use the term) I think it could potentially be eliminated or reduced, i never used it anyways

  23. #48
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    MN
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by someonewhois
    As codename49 said - Coding style has 2 aspects - proper defined by efficiency and practicality, and preference defined as to how you want to do braces, spacing (if ( substr ( $var , 'test' ) ) { or new line for bracket, or no spacing on the function etc.).

    Proper coding style example: Don't do queries within a loop You can't tell me your personal preference is to do queries in a loop (and if you tell me that, you should definately stop coding PHP, unless it's local host only.. save the servers!)
    There is nothing wrong with using queries in a loop, but there is something wrong with not reducing the number of queries it takes to accomplish a task.

  24. #49
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's nothing wrong with doing queries in a loop? Ermmm... if that's the way you have to do it, you should change what your script does. Having more than 10 queries on a page (admin doesn't count, do whatever you want in there..), then you need to consider redoing your site... okay, 15-20 is accessible, but to have a dynamic count (ie. the more categories you have the more queries) is just plain idiocy. If you do that, your server will die. Rewrite your code.

  25. #50
    SitePoint Zealot patrikG's Avatar
    Join Date
    Aug 2003
    Location
    Sussex, UK
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Having more than 10 queries on a page (admin doesn't count, do whatever you want in there..), then you need to consider redoing your site... okay, 15-20 is accessible, but to have a dynamic count (ie. the more categories you have the more queries) is just plain idiocy. If you do that, your server will die. Rewrite your code.
    Could you back that up with some hard data or sound reasoning, someonewhois?


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
  •