Ruby could be wildly more popular if it had ...

Discussion in 'Ruby' started by Jeff Mitchell, Jul 29, 2003.

  1. Brackets.

    Huh? What do you mean "brackets"?

    Brackets. Ruby doesn't have enough brackets.

    Hmph! I think ruby has the exact right amount of brackets!

    But not enough to become popular. Brackets are a prerequisite, didn't
    you know?

    That's preposterous! Ruby's great design, its expressiveness, its
    clarity, its generally grand way of doing things -- all these
    strengths and you are saying brackets are more important?

    Yes. To be popular.

    You keep saying "popular." But who cares about popularity anyway? As
    if the measure of a language is its popularity. Are you a
    card-carrying member of the ignorant masses who follow whatever is
    "hot" at the moment, disregarding what may really be better?

    No.

    Then screw popularity. We don't need whimsy programmers who are
    attracted to the simulated familiarity which brackets give. Such
    shallow programmers we can do without, thank you.

    Then you shall continue basking in the lonely sunshine of relative
    obscurity, secure in your knowledge of what programmers should be
    like. Good luck with all of that.

    [brief pause]

    Surely you are a troll.

    Nope.

    What about Python? It doesn't have brackets.

    Um, Python isn't popular. Perhaps relative to ruby it is. All Python
    programmers rode the short bus anyway.

    Huh?

    Python programmers -- they rode the short bus to school.

    Short bus?

    It's the bus for the special -- oh nevermind.

    [end conversation]

    Exhibit A.
    ----------
    Ruby as it exists presently.

    class IO
    def expect(pat,timeout=9999999)
    buf = ''
    case pat
    when String
    e_pat = Regexp.new(Regexp.quote(pat))
    when Regexp
    e_pat = pat
    end
    while true
    if IO.select([self],nil,nil,timeout).nil? then
    result = nil
    break
    end
    c = getc.chr
    buf << c
    if $expect_verbose
    STDOUT.print c
    STDOUT.flush
    end
    if mat=e_pat.match(buf) then
    result = [buf,*mat.to_a[1..-1]]
    break
    end
    end
    if iterator? then
    yield result
    else
    return result
    end
    nil
    end
    end

    "Oh great another language trying to be different."

    "Pascal sucks. I hate the 'end' keyword."

    "My editor isn't set up to handle this language. I don't understand
    why they can't just use brackets."

    "A garbled mess, looks like. It's confusing without brackets to guide
    my eye."


    Exhibit B.
    ----------
    Ruby as it exists in an alternative universe where it supplanted perl.

    class IO
    {
    expect(pat,timeout=9999999)
    {
    buf = ''
    case pat
    {
    when String
    e_pat = Regexp.new(Regexp.quote(pat))
    when Regexp
    e_pat = pat
    }
    while true
    {
    if IO.select([self],nil,nil,timeout).nil?
    {
    result = nil
    break
    }
    c = getc.chr
    buf << c
    if $expect_verbose
    {
    STDOUT.print c
    STDOUT.flush
    }
    if mat=e_pat.match(buf)
    {
    result = [buf,*mat.to_a[1..-1]]
    break
    }
    }
    if iterator?
    {
    yield result
    }
    else
    {
    return result
    }
    nil
    }
    }

    "Wow cool language. I see what's going on immediately."

    "I like how it's familiar. My eye is trained to follow brackets, so I
    can size up this code with one glance."

    "Hey this looks just like Java! I know Java! I can't wait to start
    using ruby as my no-separate-compile-step language!"

    "Dude this is gonna kick perl's ass."

    ----

    I am being more serious than it may or may not appear. I think ruby
    missed out on a big chance here. It is absurd, but it's true.

    cheers,
    Matt
    Jeff Mitchell, Jul 29, 2003
    #1
    1. Advertising

  2. Jeff Mitchell

    Aredridel Guest

    --=-HzaPtuRR/nEsk7TGiIgj
    Content-Type: text/plain
    Content-Transfer-Encoding: quoted-printable


    > Exhibit A.
    > ----------
    > Ruby as it exists presently.


    Nice, clean, reads like english. Flexible indentation, but language
    constructs keep it fairly obvious how to indent.

    >=20
    > Exhibit B.
    > ----------
    > Ruby as it exists in an alternative universe where it supplanted perl.


    Oy vey, that is the single ugliest variation of the bracketed coding
    style I've seen -- so little code in a screenful that you need a huge
    screen and tiny font to read a program in the abstract.

    --=-HzaPtuRR/nEsk7TGiIgj
    Content-Type: application/pgp-signature; name=signature.asc
    Content-Description: This is a digitally signed message part

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (GNU/Linux)

    iD8DBQA/Jzs/tP09exA3hooRAhlQAJ40EIohTHk55fDCzqdsqC5Agof+kwCfUspc
    DdCIBqsurtGvqtHetCx0S2s=
    =fCO/
    -----END PGP SIGNATURE-----

    --=-HzaPtuRR/nEsk7TGiIgj--
    Aredridel, Jul 30, 2003
    #2
    1. Advertising

  3. Jeff Mitchell

    Jim Weirich Guest

    On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:

    > My solution is to use {} for one line blocks and do..end for more
    > complicated things.


    I tried this style for a while. But then every time I added lines to a
    one-line block, I had to change {} to do/end.

    Today I normally used {} on all blocks, except in Rake files.

    --
    -- Jim Weirich http://onestepback.org
    -----------------------------------------------------------------
    "Beware of bugs in the above code; I have only proved it correct,
    not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
    Jim Weirich, Jul 30, 2003
    #3
  4. > On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:
    >
    >> My solution is to use {} for one line blocks and do..end for more
    >> complicated things.

    >
    > I tried this style for a while. But then every time I added lines to a
    > one-line block, I had to change {} to do/end.
    >
    > Today I normally used {} on all blocks, except in Rake files.



    My take is: {} are for functional blocks; do..end for procedural blocks.
    That shows me which expressions are important for their results, and which
    are not.

    Gavin
    Gavin Sinclair, Jul 30, 2003
    #4
  5. .... a look like javascript on steroids.

    Casual PHP programmers and designer that are forced to write javascript
    would feel at home. This is of course not the sort of elite programmers
    that follows this group normally (having learned lisp, haskell, ocaml,
    having read/written books about patterns etc.).

    A lot of people don't trust python because of indentation (at least i
    do) and moreover don't trust a language where newline separates
    statements. They want a language where program logic survives
    reformatting in a wordprocessor.


    --
    Fritz Heinrichmeyer FernUniversitaet, LG ES, 58084 Hagen (Germany)
    tel:+49 2331/987-1166 fax:987-355
    Fritz Heinrichmeyer, Jul 30, 2003
    #5
  6. On Wed, Jul 30, 2003 at 03:26:12PM +0900, Fritz Heinrichmeyer wrote:
    >
    > .... a look like javascript on steroids.
    >
    > Casual PHP programmers and designer that are forced to write javascript
    > would feel at home. This is of course not the sort of elite programmers
    > that follows this group normally (having learned lisp, haskell, ocaml,
    > having read/written books about patterns etc.).
    >
    > A lot of people don't trust python because of indentation (at least i
    > do) and moreover don't trust a language where newline separates
    > statements. They want a language where program logic survives
    > reformatting in a wordprocessor.


    Maybe it would be more popular with Perl programmers, but you wouldn't have
    any Ruby programmers left.

    Sorry, but this is one of the great things about Ruby: no semicolons! If you
    put your code through a wordprocessor, you deserve everything you get...

    Regards,

    Brian.
    Brian Candler, Jul 30, 2003
    #6
  7. Jeff Mitchell

    Guest


    > Sorry, but this is one of the great things about Ruby: no semicolons! If you


    Ruby does have semicolons, but they are optional...

    ruby -e "print 4;print 5"
    , Jul 30, 2003
    #7
  8. Hi,

    Javascript's semicolon is also optional. Javascript is one of my
    favorate language because of it's object creation mechanism.
    Unfortunately the language itself is too much limited.

    I have used PHP... it is Sh*t... mainly because of the ";". A lot of
    runtime errors because I am used to ruby. And it is not like Delphi,
    which has lightening fast compilation, php's debug cycle is terrible.

    Shannon


    On Wed, 30 Jul 2003 15:26:12 +0900
    Fritz Heinrichmeyer <> wrote:

    >
    > ... a look like javascript on steroids.
    >
    > Casual PHP programmers and designer that are forced to write javascript
    > would feel at home. This is of course not the sort of elite programmers
    > that follows this group normally (having learned lisp, haskell, ocaml,
    > having read/written books about patterns etc.).
    >
    > A lot of people don't trust python because of indentation (at least i
    > do) and moreover don't trust a language where newline separates
    > statements. They want a language where program logic survives
    > reformatting in a wordprocessor.
    >
    >
    > --
    > Fritz Heinrichmeyer FernUniversitaet, LG ES, 58084 Hagen (Germany)
    > tel:+49 2331/987-1166 fax:987-355


    --
    Xiangrong Fang <>
    Xiangrong Fang, Jul 30, 2003
    #8
  9. At 12:29 PM +0900 7/30/03, Aredridel wrote:
    > > Exhibit A.
    >> ----------
    >> Ruby as it exists presently.

    >
    >Nice, clean, reads like english. Flexible indentation, but
    >language constructs keep it fairly obvious how to indent.


    The one nice thing about brackets is that editors know how
    to match them up. Ie, I can select a section of code by
    just double-clicking on the initial or ending bracket.

    Other than that, I don't see much point in pushing for more
    brackets. If people can't figure out 'do...end' and *must*
    have brackets to like ruby, then they will also complain
    about every single thing where ruby differs from whatever
    language they prefer...

    Just MO.

    --
    Garance Alistair Drosehn =
    Senior Systems Programmer or
    Rensselaer Polytechnic Institute or
    Garance A Drosihn, Jul 30, 2003
    #9
  10. Saluton!

    * Jeff Mitchell; 2003-07-30, 13:49 UTC:
    > Brackets.


    If that is true why isn't LISP the most popular language on this
    planet?

    Gis,

    Josef 'Jupp' Schugt
    --
    N'attribuez jamais à la malice ce que l'incompétence explique !
    -- Napoléon
    Josef 'Jupp' Schugt, Jul 30, 2003
    #10
  11. Jeff Mitchell

    james_b Guest

    Josef 'Jupp' Schugt wrote:
    > Saluton!
    >
    > * Jeff Mitchell; 2003-07-30, 13:49 UTC:
    >
    >>Brackets.

    >
    >
    > If that is true why isn't LISP the most popular language on this
    > planet?


    Becauae of the obvious criitcal differences between ( ) and { }.

    :)

    James

    >
    > Gis,
    >
    > Josef 'Jupp' Schugt
    james_b, Jul 30, 2003
    #11
  12. We could all be wildly more popular if we had ...

    Moustaches and goatees.

    Brackets of the mouth.

    _why
    why the lucky stiff, Jul 30, 2003
    #12
  13. On 2003-07-31 05:59:42 +0900, james_b wrote:
    > Becauae of the obvious criitcal differences between ( ) and { }.


    I don't like either of them. Because of the motto "Ruby makes
    programming fun again", we should opt for something like that instead:

    class Example (-:

    def initialize(*args) (-: @ary = args :)

    def sum(start = 0) (-:
    s = start
    each (-: |x| s += x :)
    s
    :)

    def sqare_sum(start = 0) (-:
    s = start
    each (-: |x| s += x ** 2 :)
    s
    :)

    def each(-: @ary.each (-: |x| yield x :) :)

    :)

    --
    You can create art and beauty on a computer.
    -- Steven Levy, Hackers: Heroes of the Computer Revolution
    Florian Frank, Jul 31, 2003
    #13
  14. On Thu, 31 Jul 2003 09:50:11 +0900
    Florian Frank <> wrote:

    > On 2003-07-31 05:59:42 +0900, james_b wrote:
    > > Becauae of the obvious criitcal differences between ( ) and { }.

    >
    > I don't like either of them. Because of the motto "Ruby makes
    > programming fun again", we should opt for something like that instead:
    >

    [snip "all the fun stuff"]

    ROFLMAO!
    Brilliant, but wouldn't it make Ruby be just a little too much like languages
    like Whitespace, BrainFuck and the likes?

    /Madsen

    --
    - - - - - - - - - - - - - - + - - - - - - - - - - - - - - +
    | Anders K. Madsen
    http://lillesvin.linux.dk |
    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | There are 10 types of people in the world... |
    Those who understand binary - and those who don't.
    | - http://bash.org |
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
    Anders K. Madsen, Jul 31, 2003
    #14
  15. Hi,

    A programmer's feeling is important to him/herself... It does not mean
    that PHP is bad because I think it is bad :)

    I don't know any PHP debugger. I write A LITTLE php directly on Apache
    and debug in IE.

    Your reason defending the ; is not well established :) Please note ruby
    also support ; if you want to write multiple lines of code on one line.
    Javascript also support OPTIONAL ;

    So it is better on this regard. By the way, I have never seen a
    programmer who write code in Microsoft Word, so, the statement that a ";"
    is usuful to the program that it will "survive a word processor" sounds
    strange to me.

    Shannon


    On Thu, 31 Jul 2003 13:33:45 +0900
    "" <> wrote:

    > > I have used PHP... it is Sh*t... mainly because of the ";". A lot of

    >
    > Have you used a PHP debugger? Or do you just click the refresh button in
    > Mozilla? You cant say a language is s**h just because you use ; . In PHP
    > the ; is very useful eg.
    >
    > <h1><?php $result=$db->getOne(); echo $value+$othervalue ?></h1>
    >
    > as opposed to
    >
    > <h1><?php
    > $result=$db->getOne()
    > echo $value+$othervalue
    > ?></h1>
    >
    > "Nothing is more stubborn than a programmer defending a language" ;-)
    >


    --
    Xiangrong Fang <>
    Xiangrong Fang, Jul 31, 2003
    #15
  16. Jeff Mitchell

    Guest


    > I don't know any PHP debugger. I write A LITTLE php directly on Apache


    http://dd.cron.ru/dbg/

    > Your reason defending the ; is not well established :) Please note ruby
    > also support ; if you want to write multiple lines of code on one line.


    Maybe so, but then if you care to use the ; in ruby, that defeats your
    whole argument that

    > > PHP... it is Sh*t... mainly because of the ";". A lot of
    , Jul 31, 2003
    #16
  17. "Arthur" <> schrieb im Newsbeitrag
    news:...
    > "Gavin Sinclair" <> wrote in message

    news:<>...
    > > > On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:
    > > >
    > > >> My solution is to use {} for one line blocks and do..end for more
    > > >> complicated things.
    > > >
    > > > I tried this style for a while. But then every time I added lines

    to a
    > > > one-line block, I had to change {} to do/end.
    > > >
    > > > Today I normally used {} on all blocks, except in Rake files.

    > >
    > >
    > > My take is: {} are for functional blocks; do..end for procedural

    blocks.
    > > That shows me which expressions are important for their results, and

    which
    > > are not.
    > >
    > > Gavin

    >
    >
    > This sounds very interesting. Can you expand upon this a little?
    > What do you take as the difference between procedural blocks and
    > funcitonal blocks? Can you provide an example?


    I guess he means

    (0..10).each do |i|; puts i; end
    (0..10).map {|i| i+i}

    robert
    Robert Klemme, Jul 31, 2003
    #17
  18. When ruby paragraphs are auto filled accidentally

    Xiangrong Fang <> writes:

    > Hi,
    >
    >
    > So it is better on this regard. By the way, I have never seen a
    > programmer who write code in Microsoft Word, so, the statement that a ";"
    > is usuful to the program that it will "survive a word processor" sounds
    > strange to me.


    maybe there is a code snippet somewhere at the home of a programmer and
    his/her non programming wife/husband sends you the snipped pasted in a
    html email or pasted into word as attachment?

    Isn't independence of white space treatment also an argument for
    SGML, XML?

    Of course IMO it can be masochistic to program/write in space ignoring
    languages (i.e. XSL).


    --
    Fritz Heinrichmeyer FernUniversitaet, LG ES, 58084 Hagen (Germany)
    tel:+49 2331/987-1166 fax:987-355
    Fritz Heinrichmeyer, Jul 31, 2003
    #18
  19. On 29 Jul 2003 10:22:38 -0700
    (Jeff Mitchell) wrote:

    > Then screw popularity. We don't need whimsy programmers who are
    > attracted to the simulated familiarity which brackets give. Such
    > shallow programmers we can do without, thank you.
    >
    > Then you shall continue basking in the lonely sunshine of relative
    > obscurity, secure in your knowledge of what programmers should be
    > like. Good luck with all of that.


    Okay, I will.

    > Exhibit A.
    > ----------
    > Ruby as it exists presently.


    <snip>

    > "Oh great another language trying to be different."
    >
    > "Pascal sucks. I hate the 'end' keyword."
    >
    > "My editor isn't set up to handle this language. I don't understand
    > why they can't just use brackets."
    >
    > "A garbled mess, looks like. It's confusing without brackets to guide
    > my eye."


    "If you find this hard to read, maybe you should use a higher
    indentation level"

    > Exhibit B.
    > ----------


    <sniped evil bracket example>

    > "Wow cool language. I see what's going on immediately."
    >
    > "I like how it's familiar. My eye is trained to follow brackets, so I
    > can size up this code with one glance."
    >
    > "Hey this looks just like Java! I know Java! I can't wait to start
    > using ruby as my no-separate-compile-step language!"
    >
    > "Dude this is gonna kick perl's ass."


    "Wow, this language's syntax is incredibly brain-damaged!"

    Seriously, the brackets _do_ make it a _little_ easier to read. But, what if
    you had formatted it like so:

    class IO
    expect(pat,timeout=9999999)
    buf = ''
    case pat
    when String
    e_pat = Regexp.new(Regexp.quote(pat))
    when Regexp
    e_pat = pat
    end

    while true
    if IO.select([self],nil,nil,timeout).nil?
    result = nil
    break
    end

    c = getc.chr
    buf << c

    if $expect_verbose
    STDOUT.print c
    STDOUT.flush
    end

    if mat=e_pat.match(buf)
    result = [buf,*mat.to_a[1..-1]]
    break
    end
    end

    if iterator?
    yield result
    else
    return result
    end

    nil
    end
    end

    Or what if you used a higher level of indentation?

    class IO
    def expect(pat,timeout=9999999)
    buf = ''
    case pat
    when String
    e_pat = Regexp.new(Regexp.quote(pat))
    when Regexp
    e_pat = pat
    end
    while true
    if IO.select([self],nil,nil,timeout).nil? then
    result = nil
    break
    end
    c = getc.chr
    buf << c
    if $expect_verbose
    STDOUT.print c
    STDOUT.flush
    end
    if mat=e_pat.match(buf) then
    result = [buf,*mat.to_a[1..-1]]
    break
    end
    end
    if iterator? then
    yield result
    else
    return result
    end
    nil
    end
    end

    Both options, are, I think, better than adding "brackets". And both can
    be done without hacking the interpreter.

    > I am being more serious than it may or may not appear. I think ruby
    > missed out on a big chance here. It is absurd, but it's true.


    I disagree. (The part about it being true, not the part about it being
    absurd. :) )

    Jason Creighton
    Jason Creighton, Jul 31, 2003
    #19
  20. >>
    >> But then you get some larger ones:
    >>
    >> set.map { |e|
    >> if something
    >> e.x
    >> else
    >> e.y
    >> end
    >> }

    >
    > [Robert:]
    > Know your ternary operator: :)
    > set.map { |e| something ? e.x : e.y }



    I know my ternary operator, but:
    - in my code snippet, "something", "e.x", and "e.y" were placeholders
    for something far bigger than you or I could imagine
    - sometimes there is multi-part processing do be done before arriving
    the "return value" for the block

    Gavin
    Gavin Sinclair, Aug 1, 2003
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Y29vbHRlY2g3Nw==?=

    VB.net or C# more popular for aspnet?

    =?Utf-8?B?Y29vbHRlY2g3Nw==?=, Apr 26, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    807
    Kevin Spencer
    Apr 27, 2005
  2. worzel
    Replies:
    16
    Views:
    449
    worzel
    Jan 6, 2005
  3. Replies:
    0
    Views:
    332
  4. badger_nz
    Replies:
    1
    Views:
    394
  5. Jason Hsu
    Replies:
    24
    Views:
    595
Loading...

Share This Page