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).
Why does Ruby get its own color?
Bbut netcraft confirmed it! I go tell!
CLI paste? paste.pr0.tips!
What comedic timing: Is Ruby Dying.
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."
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.
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!
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.
I sense something here... is it possibly sarcasm?
About metaprogramming...
https://www.destroyallsoftware.com/talks/wat
Everyone knows only node.js is webscale.
http://saveie6.com/
While vid that was amusing... what is it about metaprogramming that is so taboo, specifically?
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?
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 --?
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".
You mispelled LISP
Gold! Wish I had mod points to give you.
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
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.
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.
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.
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.
ooop I need glasses.
FTFY
Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
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
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
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
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.
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,
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
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.
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.
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.