Slashdot Mirror


Ruby 2.1.0 Released

Today marks the release of Ruby version 2.1.0. A brief list of changes since 2.0.0 has been posted, and file downloads are available. Here are some of the changes:
  • Now the default values of keyword arguments can be omitted. Those 'required keyword arguments" need giving explicitly at the call time.
  • Added suffixes for integer and float literals: 'r', 'i', and 'ri'.
  • def-expr now returns the symbol of its name instead of nil.
  • rb_profile_frames() added. Provides low-cost access to the current ruby stack for callstack profiling.
  • introduced the generational GC a.k.a RGenGC (PDF).

44 of 65 comments (clear)

  1. Red title? by c++ · · Score: 3, Insightful

    Why does Ruby get its own color?

    1. Re:Red title? by Anonymous Coward · · Score: 1

      Only until you commented. Red title means that there's no comments. Green title means the flamewar has started.

    2. Re:Red title? by Zero__Kelvin · · Score: 1

      "Why does Ruby get its own color?"

      It was a matter of inevitability.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  2. But..but.. by fisted · · Score: 1

    Bbut netcraft confirmed it! I go tell!

  3. For a dying language Ruby is doing great by ohnocitizen · · Score: 5, Funny

    What comedic timing: Is Ruby Dying.

    1. Re:For a dying language Ruby is doing great by Balinares · · Score: 1

      It was but a flesh wound!

      --

      -- B.
      This sig does in fact not have the property it claims not to have.
    2. Re:For a dying language Ruby is doing great by cold+fjord · · Score: 1, Offtopic

      For a dying language Ruby is doing great ..... What comedic timing: Is Ruby Dying.

      The key thing to understand is that Netcraft didn't confirm it.

      I think this submission, Warcraft confirms it - Iranian sanctions are trying, which turned into this story, Iranian Players Blocked From World of Warcraft Due To Trade Sanctions , is still one of my favorites for playing with that meme.

      Cheers

      --
      much of left-wing thought is a kind of playing with fire by people who don't even know that fire is hot - George Orwell
    3. Re:For a dying language Ruby is doing great by cold+fjord · · Score: 3, Funny

      He says he's not dead.

      --
      much of left-wing thought is a kind of playing with fire by people who don't even know that fire is hot - George Orwell
    4. Re:For a dying language Ruby is doing great by blue+trane · · Score: 2

      Isn't there something you can do?

    5. Re:For a dying language Ruby is doing great by lennier1 · · Score: 1

      These things take their time.
      ColdFusion is still around as well, even though Adobe is trying its hardest to kill it off for good.

  4. Too bad by filmorris · · Score: 4, Insightful

    Wow, just yesterday it was dying, and today they release a new version! I guess they didn't get the memo

    --
    "Hello, IT... Have you tried turning it off and on again? Yeah... No problem."
    1. Re:Too bad by Anonymous Coward · · Score: 1

      Wow, just yesterday it was dying, and today they release a new version! I guess they didn't get the memo

      Unless this is one of those unbelievably rare events, it has nothing to do with memos. It's an orchestrated marketing technique, sometimes referred to as salting.

  5. Ruby is a great language by Sarin · · Score: 1

    I started programming Ruby a year or two ago. I was using jruby and watir-webdriver to automating firefox. I love the syntax of Ruby.

    1. Re: Ruby is a great language by Sarin · · Score: 3, Interesting

      And I accidently sent my comment away. The syntax is great, but I don't like the way Ruby hasn't crystallized yet. Every new version they somehow remove compatibility with the old versions, that's bad. My scripts stop working and I have to fix everything, this is not userfriendly.

      Documation is scattered and incomplete. It's something that needs to fixed if they want to get to version 4

    2. Re: Ruby is a great language by Anonymous Coward · · Score: 1, Informative

      Are you sure you mean what you say? The last release to appreciably break compatibility was the jump from 1.8 to 1.9, when they replaced the interpreter with a JIT VM (this should have been called 2.0, IMO). That was back in 2007. Every release since then has preserved backwards compatibility.

      If you actually meant Rails, well, then I understand that. At least they're improving.

    3. Re: Ruby is a great language by kauaidiver · · Score: 1

      Ha, I feel your pain.

      This kills languages, Python took a hit with 3. Yes there is 2to3 and maybe other tools but Ruby may suffer the same fate if they keep mucking with common libs and grammar.

    4. Re: Ruby is a great language by Jane+Q.+Public · · Score: 3, Informative

      "My scripts stop working and I have to fix everything, this is not userfriendly."

      That's not a problem with Ruby, it's a problem with jruby.

      "Documation is scattered and incomplete. It's something that needs to fixed if they want to get to version 4"

      No, it isn't.

      And if you want more documentation get your hands on the book "Programming Ruby" (often incorrectly called "the pickaxe book"), like everybody else does. It is frequently updated for the latest ruby versions. Since it's from Pragmatic Programmers, purchase once and get the (pdf) updates whenever they come out.

    5. Re: Ruby is a great language by coolsnowmen · · Score: 1

      I can't speak to upgrading; I've been using ruby 1.9 the entire time. But, you are wrong, IMO, about documentation. First things I looked up in a modern scripting language, the data structures, and os interactions, were awesome. Take a look at these, and then, you can even click on them to see their c header!

      http://www.ruby-doc.org/core-2.1.0/String.html
      http://www.ruby-doc.org/core-2.1.0/Hash.html
      http://www.ruby-doc.org/core-2.1.0/Array.html

      http://www.ruby-doc.org/core-2.1.0/Dir.html
      http://www.ruby-doc.org/core-2.1.0/File.html

    6. Re: Ruby is a great language by coolsnowmen · · Score: 1

      Also, for my linux admin work, this ssh gem (http://net-ssh.rubyforge.org/) is awesome.

    7. Re: Ruby is a great language by mr_da3m0n · · Score: 1

      You make it sound as if Python 2.X was dead. They handled the major, breaking changes in a rather nice way. Python 2.7 is still supported to this day, has many backported features from 3, and doesn't break compatibility.

      In fact, you make it sound like the mere existence of Python 3.0 killed it. I wasn't aware it was dead.

  6. Re:This is god again by davester666 · · Score: 1

    So you are going to be more detail-oriented now?

    For the past while, you seem to have been more of a broad-strokes diety...

    --
    Sleep your way to a whiter smile...date a dentist!
  7. Re:Trendy no more? by anchovy_chekov · · Score: 1

    Ruby adds nothing to the existing languages, which already have the plus of having zillions of libraries and modules developed. Wasted effort.

    Screw it, you're right. Why people don't just code in C I don't know? I mean, you can do anything in that language. You can even simulate "classes", make use of those so-called "design patterns". Even Ruby's meta-programming model could be done with a bit of hackery with pointers. Who gives a toss over how readable a language is, or whether the language is optimised for "programmer joy"? What nonsense. I'm with you bro, if people can't learn to code in a real language they should just get off the bus.

  8. Re:Trendy no more? by kauaidiver · · Score: 1

    I sense something here... is it possibly sarcasm?

    About metaprogramming...

    https://www.destroyallsoftware.com/talks/wat

  9. Re:But ruby is not WEBSCALE! by Billly+Gates · · Score: 1

    Everyone knows only node.js is webscale.

  10. Re:Trendy no more? by hazah · · Score: 1

    While vid that was amusing... what is it about metaprogramming that is so taboo, specifically?

  11. Re:Trendy no more? by buddyglass · · Score: 3

    Out of curiosity, excluding Rails, why would one prefer to use Ruby over...say...Python? Is there an area in which Ruby is widely regarded to be superior?

  12. Re:Trendy no more? by kauaidiver · · Score: 1

    You are more likely to "shoot yourself in the foot" so to speak and code can get unmanageable.

    In short given too much flexibility you can make the language so different than the norm. 10 people with 10 different styles writing Ruby code on a 2+ year project...come back after a 6 month break take a look and you got a big mess on your hands :) Style guides help there but still.

    Bottom line and not just ruby avoid getting "cute" with the language. I got berated by a college prof. because I thought it was a good idea in C++ to overload the ++, -- operators on a stack class to do push and pop! He asked sarcastically why stop with just ++ and --?

  13. Re:Trendy no more? by anchovy_chekov · · Score: 2

    Python is a great language. I wouldn't want to fan the flames of the Ruby vs. Python debate as the intent behind both languages is essentially the same. Matz designed the language to be human-centric, following the "principle of least surprise". Python is similarly very friendly to coders. That's what I love about Ruby. When I started out coding in the language and had to figure out how to do something new it was often a matter of asking what's the most obvious way. And usually that worked. Plus you have all the best bits of PERL, Smalltalk and Lisp in a clean, easily readable syntax.

    As an aside, I'm surprised the "meta-programming" reference got targeted over "programmer joy".

  14. Re:Trendy no more? by anchovy_chekov · · Score: 1

    You mispelled LISP

    Gold! Wish I had mod points to give you.

  15. Re:Trendy no more? by kauaidiver · · Score: 1

    Python is a great language aside from the whitespace.

    But did you know you can add braces using the future module?

    Next major release of Python will include braces, so you can get ready by doing this in your code:

    >>> from __future__ import braces

  16. Re:Trendy no more? by anchovy_chekov · · Score: 1

    It's like any tool. Meta-programming, done well, lends to more readable code and neat shortcuts. See http://patshaughnessy.net/2010/2/20/getting-started-with-ruby-metaprogramming for an example.

    Meta-programming done poorly can drive your co-workers to drink, especially if you've taken to using some clever-clever idiomatic re-use of common methods or operators that's not apparent to anyone outside your own head (possibly what your college prof. was taking issue with). Some legacy code that I've had to deal with in Ruby overloaded the << operator for an array, silently filtering out objects you were pushing in based on obscure criteria. And the comment left by the previous coder? "Magic goes here". Thank you, prick.

    But I agree, using meta-programming to be "cute" should be frowned upon. I think of it as spice in your food. A sprinkle is good, too much will ruin your meal.

  17. Re:Trendy no more? by anchovy_chekov · · Score: 1

    Python is a great language aside from the whitespace.

    But did you know you can add braces using the future module?

    Next major release of Python will include braces, so you can get ready by doing this in your code:

    >>> from __future__ import braces

    Neat. Did not know this. Thanks for the clue.

  18. Re:Trendy no more? by buddyglass · · Score: 2, Insightful

    Not to be snarky...but what I'm hearing from you is this: "Ruby and Python occupy the same niche and there's no compelling reason to prefer Ruby over Python". This seems to jive with what the guy said who you were responding to: "Ruby adds nothing to the existing languages". If the only language that existed were C then I'd say that guy is full of shit because in that case Ruby would clearly "add something to the existing languages". But, given Python's existence, he kind of has a point. Python is more widely supported, has a larger base of developers, is generally thought to be a better "thought out" language in terms of design, and is well-suited to solving the same sort of problems Ruby is well-suited to solving.

  19. Re:Trendy no more? by kauaidiver · · Score: 1

    I don't know enough about Ruby to say anything positive or negative about it. I was just commenting on Python because that's what I know - it's just funny to hear people moan and whine about similar things, which I've heard re. Python. And the quote "Ruby adds nothing to the existing languages" is harsh, C certainly got slapped around in its early days. Who needs to get slapped around more now and kicked off the bus (or at least charged for taking up two seats) is Java.

  20. Re:Trendy no more? by kauaidiver · · Score: 1

    ooop I need glasses.

  21. Re:Trendy no more? by Zero__Kelvin · · Score: 1

    "especially if you've taken to using some clever-clever idiomatic re-use of common methods or operators that's not apparent to anyone including you 6 months down the line

    FTFY

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  22. Re:Trendy no more? by Zero__Kelvin · · Score: 1

    Why do I have this image of a troglodyte living in his Mother's basement struggling in vain as he has a thousand times before to say "C" without a LISP?

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  23. Re:Trendy no more? by Zero__Kelvin · · Score: 1

    "Python is more widely supported, has a larger base of developers, is generally thought to be a better "thought out" language in terms of design, and is well-suited to solving the same sort of problems Ruby is well-suited to solving."

    I have yet to discover a programming language that solves problems.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  24. Re:This must be the crap that comes when you're de by Zero__Kelvin · · Score: 1

    Not at all. You're dead remember? How the Fsck are you going to be embarrassed ? You're Fscking DEAD! *

    * Don't forget to read the subject line that GoogOle' Boy AC here spent a whole lotta his 'lowance to get the neighbor boy to write, I reckon!

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  25. Re:Trendy no more? by anchovy_chekov · · Score: 1

    Ah... but in my team we have a basic catch-cry: "Be nice to your future self". Plus all code is reviewed by other team members. So if you feel like doing something weird, someone will tap you and ask "what's all this mean?". But yes, thank you for the fix.

  26. Re:Trendy no more? by subreality · · Score: 4, Informative

    I've used both a fair bit. They are similar in many ways so it's mostly a matter of preference.

    I've found Ruby makes it easy to explore objects and see what can be done with them. The consistent OO model makes it easy to perform concise data manipulation. Here's a quick example:


    irb(main):001:0> arr = ["1", "2", "3", "4"]
    => ["1", "2", "3", "4"]
    irb(main):002:0> arr.methods - Object.methods
    => [:to_a, :to_ary, :[], :[]=, :at, :fetch, :first, :last, :concat, :>>, :push, :pop, :shift, :unshift, :insert, :each, :each_index, :reverse_each, :length, :size, :empty?, :find_index, :index, :rindex, :join, :reverse, :reverse!, :rotate, :rotate!, :sort, :sort!, :sort_by!, :collect, :collect!, :map, :map!, :select, :select!, :keep_if, :values_at, :delete, :delete_at, :delete_if, :reject, :reject!, :zip, :transpose, :replace, :clear, :fill, :slice, :slice!, :assoc, :rassoc, :+, :*, :-, :&, :|, :uniq, :uniq!, :compact, :compact!, :flatten, :flatten!, :count, :shuffle!, :shuffle, :sample, :cycle, :permutation, :combination, :repeated_permutation, :repeated_combination, :product, :take, :take_while, :drop, :drop_while, :bsearch, :pack, :entries, :sort_by, :grep, :find, :detect, :find_all, :flat_map, :collect_concat, :inject, :reduce, :partition, :group_by, :all?, :any?, :one?, :none?, :min, :max, :minmax, :min_by, :max_by, :minmax_by, :member?, :each_with_index, :each_entry, :each_slice, :each_cons, :each_with_object, :chunk, :slice_before, :lazy]
    irb(main):003:0> arr.pop
    => "4"
    irb(main):004:0> arr.join
    => "123"
    irb(main):005:0> arr.map { |i| i.to_i }
    => [1, 2, 3]
    irb(main):006:0> arr.map(&:to_i).reduce(&:+)
    => 6

    Here's the same thing in Python:


    In [1]: arr = ["1", "2", "3", "4"]

    In [2]: dir(arr)
    Out[2]:
    [(stuff removed, fucking lameness filter) 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

    In [3]: arr.pop()
    Out[3]: '4'

    OK, it's pretty sim

  27. Re:Trendy no more? by anchovy_chekov · · Score: 3, Informative

    In respect to our Python-coding brothers and sisters, both Python and Ruby are very developer-friendly. Anyway, here is a nice comparison of the two languages' features: http://stackoverflow.com/questions/1113611/what-does-ruby-have-that-python-doesnt-and-vice-versa

    Obviously I prefer Ruby and to touch on the meta-programming aspect (whether good or evil), IMHO Ruby does a better job in this area. Mutable classes might give some people the heebie-jeebies, but it's saved my bacon several times. Ruby's Smalltalk-like message passing is sweet. Writing DSLs in Ruby is much more straightforward than in Python. There are many things to like.

    Python gives you a nice sense of structure, but that can be a curse as well as it feels quite rigid. Most of the people I know who code in Python come from an engineering background, and that kinda makes sense to me. It feels like an engineering language. Ruby on the other hand is more fluid. It lends itself to more organic styles of coding.

    The original AC post about "Ruby adds nothing to the existing languages" is clearly a troll, though I'd say the poster is right in a way. Ruby doesn't necessarily introduce anything new - it just puts it all together in the one place. Plus it's a joy to code in.

  28. Re:Trendy no more? by hazah · · Score: 1

    You're describing inexperienced programmers not understanding the pros and the cons of the available constructs. That does not make the constructs inherintly bad. Attribute definition is done with metaprogramming in ruby, generally, but there's not a lot of confusion as to what the code is doing. It all has to do with conventions and applying them appropriately.

  29. Re:Trendy no more? by hazah · · Score: 2

    I like both. For different reasons. Python's mental model is a bit simpler to reason about usually. Equating modules to files and the like is very clean. With Ruby any object's definition is open, and can be continued in any part of the program. This does make it harder to reason about, but like with many advanced features, this is best used sparingly. It does open the door for other programming syles though. I've seen this applied to create AOP and SOP type programs. Another element I enjoy is the block parameter, which allows you to pass a block of code from the current context as a parameter to any method you're calling. This block could be called at any point within that method's call stack, referring back to objects from the call site.