SitePoint Sponsor

User Tag List

Page 3 of 7 FirstFirst 1234567 LastLast
Results 51 to 75 of 174
  1. #51
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    You asked

    Actually, it is a real question. I wish Ruby could make a cup of coffee. The VM isn't there yet, still too slow and too big for embedding in a coffee machine. I think someone did get it running on a PDA though, which is heading in the right direction.

    Douglas
    If ya want coffee then Sun Java has lots of pretty coffee mugs :P Sure enough, you could even use Java for real coffee machine. Of course it would need to be powered by a Quad processor SPARC server. Which I guess ain't too bad if you're a multi billion dollar corporation with shed loads of cash to throw away.

    Returning back to namespaces, I agree with Marcus, I don't understand the point of the private class cack, it's much like the final keyword, it's totally evil and no one has any use for it in PHP anyway

  2. #52
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    Sure enough, you could even use Java for real coffee machine. Of course it would need to be powered by a Quad processor SPARC server.
    Had no idea that my mobile phone is powered by a Quad processor SPARC server...

  3. #53
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    If ya want coffee then Sun Java has lots of pretty coffee mugs :P Sure enough, you could even use Java for real coffee machine. Of course it would need to be powered by a Quad processor SPARC server. Which I guess ain't too bad if you're a multi billion dollar corporation with shed loads of cash to throw away.
    I see you developed some kind of Ruby sindrome were you bash Java with every opportunity. The problem is you ussually don't know what you are talking about (joke or not). And I have to defend it because I love it.

    For raw performance take a look here: http://www.bytonic.de/html/benchmarks.html
    I couldn't find a recent benchmark, but a good example is always http://www.walmart.com/ which handles according to them 7 million sessions and 106 million page views per day and it is based on Tomcat and Apache (no fancy websphere or weblogic or jboss).

    Next time please provide some real arguments to support your claim.

    Ruby doesn't even compile to bytecode (at least Python does, and PHP does too with some help). So you can't expect features like just in time compiling or a HotSpot compiler pretty soon.

  4. #54
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Had no idea that my mobile phone is powered by a Quad processor SPARC server...
    +99 to BerislavLopac. Cool...

  5. #55
    SitePoint Addict pachanga's Avatar
    Join Date
    Mar 2004
    Location
    Russia, Penza
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    For a start, why does everything need strict static typing in a bytecode / "scripting"
    Sometimes i find static typing very useful when reading someone else's code.
    I'm currently studying Hibernate code(i think it's a glory of OOP) and this Java verbosity helps to understand its internals much better.

    I really miss static typing in PHP, especially when i need to make some major refactoring(e.g changing method signature, etc) which spans many files. All modern editors simplify some tedious refactoring analyzing the code and using static types as helpers, i wonder if PHP type hinting would allow that.

  6. #56
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, weak typing is just bad, I hope they will throw that support away in PHP 5.1 or make weak typing only available through a flag, which is off by default.

  7. #57
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind, I see a limitation in what I posted.
    Last edited by Ryan Wray; Jul 25, 2005 at 01:34. Reason: A mistake

  8. #58
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wdeboer
    Well, weak typing is just bad, I hope they will throw that support away in PHP 5.1 or make weak typing only available through a flag, which is off by default.
    PHP has strong typing, not weak typing. On the other hand, it has dynamic typing as opposed to static typing.

  9. #59
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    PHP has strong typing, not weak typing. On the other hand, it has dynamic typing as opposed to static typing.
    What ? Strong Typing ?
    That's sweet !

    a = 12 + "24"
    it's not strong typing
    also

    a = b + c
    where b and c haven't been initialized, that's not strong typing either.

  10. #60
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    What ? Strong Typing ?
    That's sweet !

    a = 12 + "24"
    it's not strong typing
    also

    a = b + c
    where b and c haven't been initialized, that's not strong typing either.
    That's dynamic typing, not weak typing. Look http://en.wikipedia.org/wiki/Strong_typing -- especially point 1.

  11. #61
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    What ? Strong Typing ?
    That's sweet !

    a = 12 + "24"
    it's not strong typing
    also

    a = b + c
    where b and c haven't been initialized, that's not strong typing either.
    In the first example, it still has the types, it is just dynamic (ie. automatic type casting). Hence, what BerislavLopac said can apply to that statement (although, I would agree with you and say that PHP is not a strongly-typed language). As for the second example, well, I agree.
    Last edited by Ryan Wray; Jul 25, 2005 at 02:08. Reason: forgot a word

  12. #62
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    That's dynamic typing, not weak typing. Look http://en.wikipedia.org/wiki/Strong_typing -- especially point 1.
    No dude, you got it ALL wrong.

    In a dynamic typed environment, messages sent to objects are not checked on compile-time, but rather on runtime.

    And yes, your example is very good, and proves my point. Read it carefully one more time.

  13. #63
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ryan Wray
    In the first example, it still has the types, it is just dynamic (ie. automatic type casting). Hence, what BerislavLopac said can apply to that statement (although, I would agree with you and say that PHP is a strongly-typed language). As for the second example, well, I agree.
    The first example is actually the most important one. Quote from the Wikipedia link BerislavLopac gave:

    "A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed."

  14. #64
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, the most important quote on that page is definitely:
    Programming language expert Benjamin C. Pierce has said:

    I spent a few weeks . . . trying to sort out the terminology of "strongly typed," "statically typed," "safe," etc., and found it amazingly difficult. . . . The usage of these terms is so various as to render them almost useless.
    bonefry, I admit that I have fallen into the same trap you seem to and believed that the way I use those terms are the en-all and be-all definitions. But, like so many things in software industry, same things mean different things to different people. I have accepted a certain terminology and yes, it would be nice if everyone would agree with me, but I have to accept the fact that they don't.

    In my usage:

    • Strongly typed (or simply "typed"): when a language has types internally (examples: PHP, Python, Java, C).
    • Weakly typed (or "untyped"): when a language stores the values without caring about types (e.g. all values are strings); each operation must internally resolve the implicit type to work with a variable (examples: TCL, Net.Data).
    • Statically typed: when a type is bound to the variable as well as to its value. (examples: Java, C).
    • Dynamically typed: when a type is bound to values only, and the actual type required for an operation is determined and the value is dynamically converted to it (examples: PHP, Python).

  15. #65
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    However, the most important quote on that page is definitely:
    Yes, but that does not mean they don't matter.
    Because in Python 12 + "24" isn't allowed. Also in Python, you can't use a variable if it wasn't initialized.
    And PHP is definitelly weak typed from all points if view if such term exists.

  16. #66
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    PHP has strong typing, not weak typing. On the other hand, it has dynamic typing as opposed to static typing.
    PHP has loose and dynamic typing.

    Loose:
    $seven = 3 + '4';

    Strong:
    seven = 3 + '4'.to_i

    Static:
    seven := "seven";
    seven := 7; // exception

    Dynamic:
    $seven = 'seven';
    $seven = 7; // no exception

    PHP, Ruby, Delphi, PHP respectively.

    Later,
    Douglas
    Hello World

  17. #67
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Each of us is correct. And each of us is incorrect. Nobody is the final authority. Pot-a-to, potato.

  18. #68
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So let's return this discussion to the topic of PHP namespaces. Would it really be so difficult to make an extension with namespaces as proposed by Marcus?

  19. #69
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    So let's return this discussion to the topic of PHP namespaces. Would it really be so difficult to make an extension with namespaces as proposed by Marcus?
    Hmm, as Marcus says, "everything is done at parsing time". So, a proof of concept could just be a function like this:

    PHP Code:
    function require_in($file$namespace) {
      
    $content file_get_contents($file);
      
    $content str_replace('all_class_names',
                             
    "$namespace_all_class_names",
                             
    $content);
      eval(
    $content);

    The tricky line is line 3, any ideas?

    Once we have that, we can worry about adding the _once_ in require_once_in, then we can worry about caching the whole lot to the file systm so we can do require $file if file_exists.

    Douglas
    Hello World

  20. #70
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't be easier to use a Register/ObjectFactory and store the registered objects under a common array key that would function as a fake namespace?

  21. #71
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Hmm, as Marcus says, "everything is done at parsing time". So, a proof of concept could just be a function like this:

    PHP Code:
    function require_in($file$namespace) {
      
    $content file_get_contents($file);
      
    $content str_replace('all_class_names',
                             
    "$namespace_all_class_names",
                             
    $content);
      eval(
    $content);

    The tricky line is line 3, any ideas?

    Once we have that, we can worry about adding the _once_ in require_once_in, then we can worry about caching the whole lot to the file systm so we can do require $file if file_exists.

    Douglas

    I don't imagine the overhead of doing like that would be worth it. But, if that was the way, maybe regular expressions could probably be used to work it all out.

    PHP Code:
    preg_replace('/^class (.*)/''class '$ns .'_$1'$content); 
    Not a powerful enough expression (and probably not even proper syntax) , but you get what I mean.

    Too much of a hack for my liking.

  22. #72
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    Wouldn't be easier to use a Register/ObjectFactory and store the registered objects under a common array key that would function as a fake namespace?
    No, because that isn't the problem. Example:

    index.php
    PHP Code:
    require('foo.php');
    require(
    'bar.php'); 
    foo.php
    PHP Code:
    class Klass {
      function 
    hi() {
        echo 
    'hi';
      }

    bar.php
    PHP Code:
    class Klass {
      function 
    bye() {
        echo 
    'bye';
      }

    That will cause a fatal when you get to the second "class Klass" due to a "redeclared class". You need to get in before the require for it to work.

    I wonder if anything in the Simple Test mock library could handle this?

    Douglas
    Hello World

  23. #73
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ryan Wray
    Not a powerful enough expression (and probably not even proper syntax) , but you get what I mean.
    It would work if you have a single class in each file which doesn't reference any other classes. Say you have two classes which reference eachother, and you want to import them both under the same namespace, you'll have to update internal $foo = new Foo(); lines of code too. But can you assume that you can update all new Klass() lines?

    A better fix would be to extend the extension so that this code works:

    PHP Code:
    namespace ns {
      require(
    'foo.php');
    }
    $foo = new ns:Foo(); 
    I've not looked closely enough to see how that would work with the current code.

    Douglas
    Hello World

  24. #74
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    No, because that isn't the problem.
    You're absolutely right, my mistake. I was trying to avoid the ugly eval function ...

  25. #75
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    A better fix would be to extend the extension so that this code works:
    PHP Code:
    namespace ns {
      require(
    'foo.php');
    }
    $foo = new ns:Foo(); 
    I've not looked closely enough to see how that would work with the current code.
    Somehow I understood it would - there's no point to the whole thing if it doesn't.


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
  •