SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 59
  1. #1
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)

    What I want for PHP 6 Christmas...

    When PHP 6 comes out I really only want one thing. Admittedly it's a major thing, but I believe it would help the language out a hell of a lot. That one thing - place all existing functions in a legacy namespace and then rebuild the function library with consistently named functions in an object oriented fashion.

    The existing functions would still be around - they just would have to be imported and for backwards compatibility a flag would be placed in the php.ini file that would do this automatically. It could even ship with the value set to true.

    But if it's set to false the scatterbrained php function library goes away replaced with one planned out from the start and itself divided into namespaces.

    So this weird situation of string functions sometimes having underscores and sometimes not -- strpos, strchr, str_replace, str_split; or not even referencing strings in the name; explode and implode; goes away. Instead.

    PHP Code:
    $a "The quickbrown fox jumped over the lazy dog";

    $a->position('dog'); // Find the position of dog in $a
    $b $a->explode(' '); // Explode $a into an array and return it to $b.
    $a->explode(' '); // As above, but since there is no var to assign it to $a will become an array and hold the result of the explode.

    $a->shuffle(); // Shuffle the order of the elements.. 
    And so on. Functions could also be rewritten to throw exceptions for exceptional circumstances, not merely return false as many do right now.

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    I agree...it is a mess, and is inconsistent, but I sure give it props for backwards compatibility.

    I knew a programmer once who worked on some extensions for PHP (and has since given up after many hair pulling problems). From what he said, the underlying code for PHP was a complete mess.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then it would be more like a Javascript where a string is an object.
    Basically you want a string and function to be an object.

    They are already adding things that were available in Javascript for many years, since the beginning of Js actually, like closures and passing function as an argument and late binding.

    Some day php will be more like Java with some of the best features borrowed from Javascript. We are getting there.
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2009
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really care about any features. I would only wish that people won't stay on PHP4 and move onto newer versions of PHP. That way, developing a php script won't be that hard.

    But, if you place a lot of things in a legacy namespace, then it would be hard to make scripts that work on PHP4 and also PHP6.

  5. #5
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Funny that I actually planning to write a class that represents a basic string and move all the php string functions to that object, so you would be able to do things like $String->strpos('needle');

    also will be possible to type hint a string by requiring an argument to be a String object
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Primitives aren't objects in PHP. So your essentially requesting PHP become a true OO language. Not going to happen any time soon…

  7. #7
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way it may happened in php is if someone writes an extension or even better if object that represents a string is added to SPL
    Then we could just extend that class to add any new methods we may want a string to have, for example some sort of charset converter built in the string object would be nice.
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  8. #8
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Well, we'll see. Then again, there is a project out there to effectively do server-side Javascript. If that was done correctly, I'd switch.

    Even if functions aren't mapped to objects as above there are still compelling reasons to remap the function library into namespace collections, including I would imagine performance reasons. For example if I'm working in mysql I don't need the mssql or postogre functions, or any of the other db libraries. I could just import the database library I need into my namespace and use it.

  9. #9
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,000
    Mentioned
    101 Post(s)
    Tagged
    0 Thread(s)
    PHP6 seems to have gone very quiet, I've not heard anything about in a while, will it ever come out (has anyone heard of any possible release date for it)?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  10. #10
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I though of another feature today, I think the session should be an object and not an array in php. Maybe an object of type ArrayObject from SPL, so it can still work with most existing php codes, but giving the user the ability to extend the session class would be great.
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  11. #11
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to be able to get through an hour without having to lookup the argument order of a function at php.net

  12. #12
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Ain't that the truth - hence the legacy namespace to shove all this crap into for backwards compat and then start again.

  13. #13
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The whole point of backwards compatibility is to support legacy applications. Making legacy applications have to change to use a namespace makes the whole idea completely pointless.

  14. #14
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    F*** legacy apps, if you need to support phpX only code then put them all on a phpX server.

  15. #15
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    The whole point of backwards compatibility is to support legacy applications. Making legacy applications have to change to use a namespace makes the whole idea completely pointless.
    And that would be why it would ship with the php.ini directive import_legacy_namespace set to true?? Duh. Legacy aps would only break if you change that setting. Besides, a lot of legacy aps are already going to break with register_globals and magic_quotes goes buh-bye.

  16. #16
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is simply no point in doing this at all. What advantages would it serve? Whilst we're at it why not convert all datatypes to objects? The great thing about PHP is that it's data types are so flexible. I don't have to piss around converting between data types like in more strict languages such as Java

  17. #17
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Dean C View Post
    There is simply no point in doing this at all. What advantages would it serve? Whilst we're at it why not convert all datatypes to objects? The great thing about PHP is that it's data types are so flexible. I don't have to piss around converting between data types like in more strict languages such as Java
    But I like the strict datatypes!
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  18. #18
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Force Flow View Post
    But I like the strict datatypes!
    Then use a different language!

  19. #19
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One advantage of strict datatype is to catch error early by using type hinting.
    If you make a mistake and pass a string where integer is expected, you get an error right away. This usually helps with debugging. Of cause this is more important in compiled languages like Java where compiler will catch all the wrong datatypes and will refuse to compile untill you fix the errors.

    In php there is no compiling stage so nothing will catch your error until something goes wrong with your script somewhere down the line.

    I think making datatypes objects is not a bad idea. I think Java got that right, php did not, it will get there eventually.
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  20. #20
    SitePoint Enthusiast
    Join Date
    Dec 2009
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lampcms.com View Post
    One advantage of strict datatype is to catch error early by using type hinting.
    If you make a mistake and pass a string where integer is expected, you get an error right away. This usually helps with debugging. Of cause this is more important in compiled languages like Java where compiler will catch all the wrong datatypes and will refuse to compile untill you fix the errors.

    In php there is no compiling stage so nothing will catch your error until something goes wrong with your script somewhere down the line.

    I think making datatypes objects is not a bad idea. I think Java got that right, php did not, it will get there eventually.
    thank you for this sir, may I ask do you learn this on you own? I remember my professor told us this once.

  21. #21
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    There have been a few incidents through the course of debugging where loose datatypes have been the source of problems, which never would've occurred under a strict datatype environment

    (yes, I used Java before eventually turning to PHP. While PHP is easier in the long run, the two things I do dislike about it are the lack of strict datatypes and the inconsistencies in function naming and behavior)
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  22. #22
    SitePoint Evangelist Dave Morton's Avatar
    Join Date
    Sep 2003
    Location
    Carson City, NV
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The answer here, IMHO, is not bemoaning the lack of strict data types, but rather developing within ourselves the discipline to more strictly code our pages. If you want to avoid issues with mis-cast data types, then code in such a way that this is not an issue. And to those who say "Use a different language", that doesn't help, other than to inflame emotions. PHP is a great scripting language, and is powerful and flexible. However, it's so forgiving in some ways that it almost encourages us to become lazy. I say that WE are the keys to eliminating these potential problems, in the way that we code.

    Ok, done with the soapbox. Next?
    Making a difference, one little psychotic episode at a time
    Geek Cave Creations
    Beta testers needed for pChat
    Dave's Gallery

  23. #23
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by countkenshin View Post
    thank you for this sir, may I ask do you learn this on you own? I remember my professor told us this once.
    I learn from books mostly. Just books and hands-on practice.
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  24. #24
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by lampcms.com
    I think making datatypes objects is not a bad idea. I think Java got that right, php did not, it will get there eventually.
    My prediction for that is about when IE8 phases out…

  25. #25
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP will never have strict data types, because that is part of PHPs identity. It isn't hard to avoid problems with it.


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
  •