Technologies to Watch: A Look at Four That May Challenge Java’s Development Dominance
Subject:   Seaside link
Date:   2005-10-20 13:16:56
From:   ikayak
Response to: Seaside link

Which part? The 10.times? Seems like English to me...

Or the x1, x2 = x2, x1 + x2

versus having the temporary variable? No thanks...I'll take the parallel assignment.

I think you've got Java on the brain.

Full Threads Oldest First

Showing messages 1 through 12 of 12.

  • Seaside link
    2005-11-03 13:28:38  evoke [View]

    > Which part ?

    Well, the puts part for one. It's like grammar erroring: 'I writes well in English' for one. If it's going to flow like readable English, couldn't it have been closer to grammatically correct.

    Second, Java on the brains of code monkey everywhere or not, did it have to have a highly unfortunate overlap with the put and get collection methods of map collections.

    Thirdly, ok, it's a convention, I get that. And I'm not saying that I love typing out System.out.println or writeBytesToFile() or suchlike, but it ought to be pointed out that when I write something like one of the above that it's clear what happened. i.e. I wrote bytes to a file. Puts is vague. Put to which output stream, to file, as bytes or chars or unicode, etc. Obviously one becomes familiar with the Ruby conventions quickly, but then again, one becomes familiar with the Perl conventions disturbingly quickly as well in some cases, and Perl's love of shorthand conventions is not exactly endearing to the literate programming movement.

    10.times is elegant though, I'll give you that. I'd love to see a response to another poster's question of how you hop a 10.times Ruby loop 'for loop i += 2' style, btw, but the partial innovation of first-class ranges is interesting.
  • Not maintainable or english
    2005-10-20 16:40:58  kgelner [View]

    I didn't much care for the parallel assignement either, all fun and games until you accidentially delete something from one side and then have to remember the order they were in (or worse yet accidentally put it back wrong).

    Also, how can you claim that line is english? People do not talk like:

    I'll put the ketchup, car keys in the fridge, drawer.

    Although really in Ruby would it not be more like:

    In the fridge, drawer I'll put the ketchup, car keys.

    It is consise, but claiming it reads like english is a stretch.

    It's not having Java on the brain to dislike a feature like this, it can also be from seeing years of the kinds of mistakes that syntactic shortcuts can cause. I like some of them but they have to be used with care.
    • Not maintainable or english
      2005-10-20 16:50:38  ikayak [View]

      10.times reads very much like English. As does print hello if not i == 10. As does has_many :cars. Ruby lets me introduce verbs.

      To your example, how about: use the red and yellow bowls for ketchup and mustard. The intent is very clear, without the need for temporary variables.

      If the assignments are not related, don't use them together. It's a very useful high level abstraction. And yes, it's one that we use in English. I can't believe you're actually arguing for

      for (i=0, i<10, i++).

      The only reason that makes any sense at all is that you've done it for 30 years in C, C++ and now Java. In Ruby,

      for i in 1..10

      1..10 is a first class range.

      Ruby may not be to your liking, but it's a pretty clean language, and it's much closer to English than Java.

      • A question
        2005-10-29 08:52:49  ttfkam [View]

        What is the equivalent of the following?

        for (i=0; i<100; i+=4) {}

        Not attacking; I'm honestly curious.
        • Sorry, I should have been more specific
          2005-10-29 08:55:51  ttfkam [View]

          How can you write the equivalent without introducing a temporary variable?
          • Sorry, I should have been more specific
            2006-01-01 14:21:56  ck1125 [View]

            No one has answered the question about
            for (int i = 0; i < 100; i+=4)
            Can this be done in Ruby?

            • Sorry, I should have been more specific
              2006-01-23 04:49:11  jzabiello [View]


              Any questions?
      • Not maintainable or english
        2005-10-23 20:20:32  jimothy [View]

        I'll agree with the others on the parallel assignments; this introduces a lot of confusion that could be eliminated with just an extra line of code.

        The loop (10.times), however, I think is rather intuitive. I'll also note, that while you're quick to jump to its defense, nobody has complained about this loop syntax as far as I can tell. It's those darn parallel assignments that are catching flack.
      • Not maintainable or english
        2005-10-21 09:11:50  greg_barton [View]

        To your example, how about: use the red and yellow bowls for ketchup and mustard.

        In English, strictly speaking, this is ambiguous. Can I use a yellow bowl for ketchup? Maybe. If you say, "You didn't understand..." I just come back with, "Well, you said I could use red and yellow bowls for both ketchup and mustard." You say, "I didn't mean BOTH!" And I say, "Well, why did't you say so?"

        Anyway, I don't see the appeal for making a programming language more like English. English must be one of the least precise languages on the planet. That's great for rhetoric, poetry, and prose, but not for programming. I see nothing wrong with using a few more lines to get your point across as precisely as possible.
        • Not maintainable or english
          2005-11-01 17:30:19  kenliu [View]

          "Anyway, I don't see the appeal for making a programming language more like English."

          I have to agree with this sentiment. COBOL anyone?

          I've seen the "Englishness" of ruby (and Rails) mentioned a in various places as a Good Thing, but isn't this sort of a narrow view to be taking in today's world? Sure, English is still the lingua franca of the computing world, but surely all those native Hindi and Chinese speakers don't find English-like grammar to be nearly so intuitive.

          It's interesting to note in this context that ruby was designed by a Japanese guy. Good thing it didn't come out looking like Engrish ;)
        • Not maintainable or english
          2005-10-24 06:56:44  ikayak [View]

          Then red and yellow bowls for ketchup and mustard, respectively. Parallel assignments are useful here because you're eliminating the need for a temporary variable, and thus quite useful. To me, it's more expressive and elegant.
          • Not maintainable or english
            2005-11-03 12:50:13  evoke [View]

            With no offense intended, the 'to me' portion of your ending remark is illuminating, and reveals a major weakness of the use of parallel assignments in general. Secondarily there's a proounced use in the overly simple examples of strong cultural bias.

            When your team is diverse and includes someone from a country where, Murphy forbid, they store ketchup in purple bottles and mustard in red bottles, it's expressive and elegant indeed...

            It's similiar to contriving that blue and pink pay phones are for boys and girls. And forgetting that pay phones in some Asian countries are uniformly pink... Nice...

            Try thought experimenting that your wife has asked you to help at cooking dinner by leaving a stickypad note specifying the parallel assignment of: add salt and butter to the fish and potatoes, respectively. Which, you, of course, like all men magically competent in the kitchen are going to know which is for which, or was it for both, or aren't potatoes supposed to have both eventually and which first. Etc. A recipe for disaster, or perhaps oddly flavored dish.

            How about the more realistic example of: associate daily level yield and straight line amortizations to the payment and monthly balence schedules. Because you know automatically which are for which, right. Right ??

            (And all of your maintainence coders are going to know too ?? Or does your team not include anyone from other cultures, or maintainence coders, or domain experts who crossed over to be junior level coders, etc.)

            As far as Java is concerned, I find that parallel assigments feel much like nesting tertiary operators. You can do it, but you frelling shouldn't.

            It's like scribbling down a paragraph or chapter of a novel in shorthand under the influence of inspiration or efficiency. It's ok for protoypes or personal projects, but you wouldn't pass raw shorthand, or mostly text with bits of shorthand interspersed, to your test readers or editors.

            Please stop using parallel assignments - I'm tired of fixing the bugs you're doing so causes later.