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).

65 comments

  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 Anonymous Coward · · Score: 0

      "I'm not dead... I'm getting better!" (http://www.youtube.com/watch?v=Sh8mNjeuyV4)

    5. Re:For a dying language Ruby is doing great by blue+trane · · Score: 2

      Isn't there something you can do?

    6. Re:For a dying language Ruby is doing great by Anonymous Coward · · Score: 0

      > What comedic timing: Is Ruby Dying [slashdot.org].

      Looks like straightforward hype, not comedic timing.

    7. 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: 0

      They remind me of Blackberry.

    2. 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.

    3. Re:Too bad by Anonymous Coward · · Score: 0

      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.

      Is this how I'm supposed to be salting my password hashes? I better try it now:

      Is a2e0ee4198523ccd2fb9f6b9dc4f1836f94a00ed dying?

      Now that my password hash is salted, I can go back to this

  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 Anonymous Coward · · Score: 0

      I hope you mastered it better than English.

      Automating Firefox? To do do what? And was it a year ago, or two years ago? Such vague ideas of values are not good when programming!

    6. Re:Ruby is a great language by Zero__Kelvin · · Score: 0

      "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."

      I can appreciate your love for the Ruby language, but out of curiosity, why do you hate English?

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    7. 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

    8. 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.

    9. 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.

    10. Re: Ruby is a great language by Anonymous Coward · · Score: 0

      Bullshit

      There were a few breaking changes between 1.8 and 1.9 and none at all for 2.0 and 2.1. I have programs that I started writing when 1.8.7 was the current version, when 1.9.1 came out, I had to spend 3 hours or so fixing the few things that broke, mostly a few methods in Hash started returning something sane. Since then, nothing has broken and can easily support 1.9.1, 1.9.2, 1.9.3, 2.0.0 and 2.1.0 with zero extra effort.

    11. Re: Ruby is a great language by Anonymous Coward · · Score: 0

      WTF?

      1.9-2.1 has no breaking changes.

  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. Trendy no more? by Anonymous Coward · · Score: 0

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

    1. Re:Trendy no more? by Anonymous Coward · · Score: 0

      Ruby has been around since 95.

    2. 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.

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

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

      About metaprogramming...

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

    4. Re:Trendy no more? by Anonymous Coward · · Score: 0

      > Screw it, you're right. Why people don't just code in C
      You mispelled LISP

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

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

    6. 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?

    7. 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 --?

    8. 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".

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

      You mispelled LISP

      Gold! Wish I had mod points to give you.

    10. 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

    11. 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.

    12. 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.

    13. 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.

    14. 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.

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

      ooop I need glasses.

    16. Re:Trendy no more? by Anonymous Coward · · Score: 0

      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

      Better "thought out" is the only part I disagree with. Ruby is purely object-oriented, consistent and beautiful.

    17. 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
    18. 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
    19. 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
    20. 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.

    21. 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

    22. 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.

    23. 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.

    24. 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.

    25. Re:Trendy no more? by Anonymous Coward · · Score: 0

      He's joking. Try it and you'll see.

    26. Re:Trendy no more? by Anonymous Coward · · Score: 0

      Only if you are a retard.

      Metaprogramming done right is makes for manageable code and is easy to use.

    27. Re:Trendy no more? by Anonymous Coward · · Score: 0

      Ruby makes the easy things very easy and the hard thing doable in a easy to read, clean way.

      Python has a lot more boilerplate and doesn't deal with iteration in a very good way. List comprehensions are an ugly, limited kludge compared to Ruby's Enumerator module.

  8. We all know it! by angel'o'sphere · · Score: 0

    Ruby is dead!

    Proof: was on /. yesterday!

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    1. Re:We all know it! by Anonymous Coward · · Score: 0

      Ruby's death has nothing to do with stories posted. This includes a new version announcement and the marketing salt. Ruby isn't a distinctively useful tool over other available choices for scripting. Perpetuating itself by leveraging other Ruby has always been its sole value.

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

    Everyone knows only node.js is webscale.

  10. This must be the crap that comes when you're dead. by Anonymous Coward · · Score: 0

    How embarrassing.

  11. 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