SitePoint Sponsor

User Tag List

Page 2 of 7 FirstFirst 123456 ... LastLast
Results 26 to 50 of 174
  1. #26
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, not very healthy to have such an oppinion towards the world's most used enterprise language.
    Exactly. This is why I cannot understand the attitude from MiiJay Sung? Java is just about the most expressive, competent programming language that there ever has been put on the green Earth.

    I don't use it day to day but I have used it for a short period in the past, and it's like a whole religion in it's own right.

    Worship it

  2. #27
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ryan Wray
    In regards to post #14, by MiiJaySung, I find the PHP the most readable. Fair enough, I am not a Ruby developer, but here are 2 good reasons why I find this:

    • You have the condition after the action. In the mindset of a programmer, it is usually the other way round (ie. if condition is true, print person name).
    • The question mark after the ?, adds to the confusion.
    In ruby, you are not tied to one particular coding style, you can always use more verbose control stucture, if you want. And any core method can be redefined, renamed or extended at any time:

    Code:
    class Object
    	alias is_a instance_of?
    end
    
    if someone.is_a Person then
    	puts someone.name
    end
    However, using of postfix operators (like "readability" as a whole) is a matter of habit, even for a programmer used to c-style languages. Compare
    Code:
    if(!input.isValid)
       return false;
    and
    Code:
    return false unless input.isValid

  3. #28
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In ruby, you are not tied to one particular coding style, you can always use more verbose control stucture, if you want. And any core method can be redefined, renamed or extended at any time:
    Whole problem I got with Ruby is that, you aren't tied to a specific syntax. You can make shortcuts i.e. %w etc. Not good for the readability, it also makes the syntax "ugly" in my humble opinion.

  4. #29
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, as said it's a matter of taste and habit. Imagine there are people who find this nice, readable and transparent:
    Code:
    (defmethod Concat ((L1 list) (S1 string))
       (Concat (apply #'concatenate 'string
           (mapcar #'princ-to-string L1))
        S1))

  5. #30
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do see what people are getting at with Ruby's readablity. It does take getting used to as the syntax is quite different from mainstram languages. Once you get used to it, it can be very powerful and you can do very short code. The example with instance of here is not a good example. The ablity to have more than one way to skin a cat in Ruby is probably the biggest thing setting it apart from Python. I guess the way code reads in Ruby is like whitespace in python, you love it or hate it and normally if you use the language enough you generally grow to like it

  6. #31
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ablity to have more than one way to skin a cat in Ruby is probably the biggest thing setting it apart from Python.
    But I don't want more than one approach. If you have the option of doing something different, then yes, if it's for example, a design method or such like, but a completely different syntax altogether.

    That is much like using object oriented programming mixed with procedural programming, which isn't very smart is it now... You have one half of an application designed beutifully with OOP, and then you go and screw it all up with prodecural programming.

    That is much like what your talking about with a languages variable syntax in my view. Yuk

  7. #32
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ablity to have more than one way to skin a cat in Ruby is probably the biggest thing setting it apart from Python.
    No, those code block Ruby has is setting it appart from Python. And that's the only important thing.

    One problem with your claim: If you have more than 1 way to do a thing with the language syntax, how can Ruby's pride lay in "the priciple of least surprise" ? The Perl heritage is actually a bad thing IMO. Python is more elegant from this point of view.

  8. #33
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ryan Wray
    In regards to post #14, by MiiJaySung, I find the PHP the most readable. Fair enough, I am not a Ruby developer, but here are 2 good reasons why I find this:

    • You have the condition after the action. In the mindset of a programmer, it is usually the other way round (ie. if condition is true, print person name).
    • The question mark after the ?, adds to the confusion.


    However, I think anyone (with appropiate OO knowledge) would understand the PHP code.

    It could be biased, or simply my opinion though.
    Point 1...in Ruby, you could also have the condition first if you prefer it that way. It's a matter of choice...

    Point 2...I like the convention of adding ? to boolean methods. Again, its a matter of taste, and whilst you probably can't escape it when using the standard library, there isn't anything that says you have to use the convention in your own modules (I think...somebody correct me if I'm wrong).

  9. #34
    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 bonefry
    No, those code block Ruby has is setting it appart from Python. And that's the only important thing.
    I thought they'd had some implementation of blocks in Python, or at least they have certainly been discussing it. Certainly when it comes to features, both ruby and python seem to be converging as they use each other's ideas

  10. #35
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    Highlly debatable and innacurate your point of view. Don't forget everyone thinks in the language he knows.

    I actually wasn't really complaining about Ruby's readibility, but rather I found the Ruby example provided was not more readable than the PHP one. It was more readable than the C++ one. I know many languages, at least to the point of reading them and implementing basic control structures, statements, etc. Hence, how I read something is not limited to any particular language. I think my first point was a very good point. When programming, we think in a sequential state. I think my second point was valid too.

    puts person.name if person.instance_of? Person
    puts person.name if person.instance_of Person? -- The question is not complete until after the class 'Person'. It is not a question like this: If person is an instance of? Person.

    I did mention I may be biased, but do you mind telling me why the statement was highly inaccurate. Are my points valid? If I am highly inaccurate, then so is anyone who says Ruby is more readable.

  11. #36
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to agrue about reabablity, then have a look at

    Code:
         def duration_as_text(duration_secs)
           case duration_secs
             when 0                   then "0 seconds"
             when SECOND              then "#{duration_secs/SECOND} second"
             when SECOND+1..MINUTE-1  then "#{duration_secs/SECOND} seconds"
             when MINUTE..2*MINUTE-1  then "#{duration_secs/MINUTE} minute"
             when 2*MINUTE..HOUR-1    then "#{duration_secs/MINUTE} minutes"
             when HOUR..2*HOUR-1      then "#{duration_secs/HOUR} hour"
             when 2*HOUR..DAY-1       then "#{duration_secs/HOUR} hours"
             when DAY..2*DAY-1        then "#{duration_secs/DAY} day"
             when 2*DAY..WEEK-1       then "#{duration_secs/DAY} days"
             when WEEK..2*WEEK-1      then "#{duration_secs/WEEK} week"
             when 2*WEEK..MONTH-1     then "#{duration_secs/WEEK} weeks"
             when MONTH..2*MONTH-1    then "#{duration_secs/MONTH} month"
             when 2*MONTH..YEAR-1     then "#{duration_secs/MONTH} months"
             when YEAR..2*YEAR-1      then "#{duration_secs/YEAR} year"
             else                          "#{duration_secs/YEAR} years"
           end
         end
    In PHP, Java, C++ that method would not be half as readable as these languages lack any form of range construct, so you end up resorting to nasty series of if this or that style blocks.

    I do agree with bonefry, Java style namespaces is not what PHP really needs, but rather modules + mixins like Ruby or however Python does them. PHP is going totally down the wrong route by copying Java for everything, such as using static typing and binding, which are totally counter-constructive in web applications, not to mention Java is a butt ugly as hell really with all the C/C++ style typing and casting all over the place.

  12. #37
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For those not familiar with ruby syntax, the two dots are the range operator, the #{} in the strings evaluates the expression between the curly braces, and methods return the value of the last expresion executed (although you can explicitely return if you want to)...

    As for punctuation in method names, I think it's great; along with using the ? for methods that return booleans, another convention is to use a ! after methods that modify their arguments.

  13. #38
    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
    I did mention I may be biased, but do you mind telling me why the statement was highly inaccurate. Are my points valid? If I am highly inaccurate, then so is anyone who says Ruby is more readable.
    Because you are comparing 2 languages like English vs Spanish or something. And of course you understand what you know best. And the reason you find PHP more natural is because it inherits the C++ syntax which you claim that you know.

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

    Off topic first...

    This is pure opinion (and yes I also come from a C++ background, but also a Perl background), but I think that PHP is more readable than Ruby. Does someone want to hold a quick poll on the topic? That would put the issue to bed.

    Back to PHP namespaces...

    What does the patch look like in practice? What sort of code do you write with the namespace patch?

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

  15. #40
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do agree with Marcus that in the end it boils down to opinion. Cerainly some things in PHP are more readable, but at the same time are more tedious to write, which is probably why I favour Ruby as I'm a lazy person who can't type more than 30 wp/m

    All I can say is that C++ and PERL are two of the worlds most *unreadable* languages (generalisation before anyone decides to joke and mention languages like "whitespace"). The only realistic exception is ASM

    As for the name space patch, all I remember was there was some discussion on the internals mailing list about this. It could mean there's a off chance that it will make it into the 5.2 branch

  16. #41
    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 lastcraft
    What sort of code do you write with the namespace patch?
    Here's some code from the testcases:

    basic:
    class1.php
    PHP Code:
    namespace ns
    {
            class 
    class1
            
    {
                    public 
    $mem1 1;
            }

    More advanced:

    class3.php
    PHP Code:
    namespace ns
    {
        private class 
    class3
        
    {
            public 
    $mem3 3;

            public static function 
    staticFunc()
            {
                echo 
    "static called\n";
            }
        }

    class3_child.php
    PHP Code:
    require_once( dirname__FILE__ ) . '/class3.php' );

    namespace 
    ns
    {
            class 
    class3_child extends ns:class3
            
    {
                    function 
    printValue()
                    {
                            echo 
    $this->mem3"\n";
                    }

            function 
    callStatic()
            {
                
    class3::staticFunc();
            }
            }


    As for PHP vs Ruby... well, I don't like curly brackets, mandatory semi colons, and '$this->' * 100. Guess which one I like more

    Douglas
    Hello World

  17. #42
    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 Dr Livingston
    Really?? Is there anything that Ruby doesn't have, or isn't capable of? Can it make me a cup of coffee huh?
    Well, some people are using Ruby to make a cup of java... does that count as a cup of coffee?

    I don't know how anyone can complain about using an @@ prefix for class variables when PHP needs a $ before every variable, and $this-> before every instance variable.

    Later,
    Douglas
    Hello World

  18. #43
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    I do agree with Marcus that in the end it boils down to opinion. Cerainly some things in PHP are more readable, but at the same time are more tedious to write, which is probably why I favour Ruby as I'm a lazy person who can't type more than 30 wp/m
    You aren't serious I hope? Are you using Ruby because it saves you time in typing? If so, please please consider the use of a good editor that will do all the typing for you. I am using CodeRush in C# and Delphi, and really increased my productivity because I can do shortcuts too. For example you type in iif<space> it will then complete it. I think it ridiculious to make the syntax of language "ugly" (imho) only because it saves typing, while it also cause a serius readability when you aren't an expert in the language. For example I having a serious pain to read RoR code...

  19. #44
    ********* 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 DougBTX
    Here's some code from the testcases:
    [snip]
    More advanced:
    That's not namespaces, that's packages! Oh, joy, they cannot even get that right.

    Namespaces means that I can import a library and in so doing change the public API. It's about preventing nameclashes. What's all this "private class" nonsense (the "private" keyword should have been killed off at the Java stage anyway, but I digress)?

    I want something like this...
    PHP Code:
    require_once_in('a_library.php''A');
    require_once_in('a_library.php''B');

    $a = new A:Thing();
    $b = new B:Thing(); 
    ...or this...
    PHP Code:
    require_once_in('simpletest/reporter.php''SimpleTest');

    class 
    HtmlReporter extends SimpleTest:HtmlReporter { ... } 
    You don't need a "namespace" keyword for namespaces. We just need to import multiple libraries and not have to type vey long MyPackAge_MyClass names when writing code.

    I doubt that this would have been hard to implement (there is no need for nested namespaces for example) and everything is done at parsing time so the performance hit is zero.

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

  20. #45
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Ireland
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    Because you are comparing 2 languages like English vs Spanish or something. And of course you understand what you know best. And the reason you find PHP more natural is because it inherits the C++ syntax which you claim that you know.
    Yes, I know the syntax of C++. But I also know syntaxes of Perl, Python, JavaScript, VB and to a lesser extent langauges like LISP/Scheme which I have only really glanced at.

    Oh well, I'll let this get back to a discussion of name-space support in PHP, not Ruby readibility vs. PHP readibility.

  21. #46
    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 wdeboer
    I think it ridiculious to make the syntax of language "ugly" (imho) only because it saves typing
    MiiJaySung's example feels cleaner* to me because return is optional, you only add it when you need it. You probably feel the opposite way about exactly the same thing, but that doesn't make it ridiculious

    *cleaner: using less code to do the same thing with the same or better readability. (I'd be surprised if someone didn't understand that duration_as_text returned a string, even though there is no explicit return.)

    Later,
    Douglas
    Hello World

  22. #47
    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 DougBTX
    *cleaner: using less code to do the same thing with the same or better readability. (I'd be surprised if someone didn't understand that duration_as_text returned a string, even though there is no explicit return.)
    Just one thing to add here. When you encounter in the someone else's code:
    a = b + c
    that's not clean, that's dangerous. Clean is when it's your code, or when you trust the programmer who did it like you trust God.

  23. #48
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Clean as in neat and tidy, and at best, elegant.
    Hello World

  24. #49
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    def duration_as_text(duration_secs)
           case duration_secs
             when 0                   then "0 seconds"
             when SECOND              then "#{duration_secs/SECOND} second"
             when SECOND+1..MINUTE-1  then "#{duration_secs/SECOND} seconds"
             when MINUTE..2*MINUTE-1  then "#{duration_secs/MINUTE} minute"
             when 2*MINUTE..HOUR-1    then "#{duration_secs/MINUTE} minutes"
             when HOUR..2*HOUR-1      then "#{duration_secs/HOUR} hour"
             when 2*HOUR..DAY-1       then "#{duration_secs/HOUR} hours"
             when DAY..2*DAY-1        then "#{duration_secs/DAY} day"
             when 2*DAY..WEEK-1       then "#{duration_secs/DAY} days"
             when WEEK..2*WEEK-1      then "#{duration_secs/WEEK} week"
             when 2*WEEK..MONTH-1     then "#{duration_secs/WEEK} weeks"
             when MONTH..2*MONTH-1    then "#{duration_secs/MONTH} month"
             when 2*MONTH..YEAR-1     then "#{duration_secs/MONTH} months"
             when YEAR..2*YEAR-1      then "#{duration_secs/YEAR} year"
             else                          "#{duration_secs/YEAR} years"
           end
         end
    I'm sure that it would be entirely possible in any language (maybe except Ruby huh? ) to work out the about with a simple mathematical formula? Isn't that what Mathematics is all about

    That's not namespaces, that's packages! Oh, joy, they cannot even get that right.
    +1 to Marcus

    PHP Code:
    class HtmlReporter extends SimpleTest:HtmlReporter { ... } 
    If we could do that with PHP, that is something I'd look forward to using.

    does that count as a cup of coffee?
    That is not a specific Ruby language trait. Any language that you get nowadays at the very least knows how to parse an XML file. Don't even know why you'd use that is an arguement? It has no legs...

  25. #50
    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 Dr Livingston
    Don't even know why you'd use that is an arguement?
    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
    Hello World


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
  •