Ruby 1.9.0 Released 199
sciurus0 writes "The 1.9.0 development version of the Ruby programming language has been released. This version has many changes, including a new virtual machine that provides great speed improvements."
news: gotcha
Firehose blurp (Score:2)
Re: (Score:2)
It goes without saying that an open source project is always fixing bugs, hopefully at a slightly higher rate than they are introduced.
Benchmarks mean nothing, specially these ones. (Score:2, Insightful)
Re:Benchmarks mean nothing, specially these ones. (Score:5, Informative)
Re: (Score:2, Informative)
Why Ruby? (Score:2)
Alright, I know this is going to be flame fodder, but I'm genuinely curious: does Ruby have anything to offer for someone who's already very proficient in Python (and Django, so Rails is already covered)? Basically, I've been using Python for quite a while and work with a largish codebase at the office. Is there any reason why I should give Ruby a try other than the standard - and very valid - "because it's there"? From what I've heard it seems that the two languages occupy roughly the same niche and are
Re:Why Ruby? (Score:4, Insightful)
Speaking as a ruby developer, if you're happy with python - not really! Python's also great. It's just a matter of which suits your style. Personally, I couldn't get over Python's syntactically significant whitespace - many people would laugh at that, but for me it's just unthinkable. So Python was just ruled out for me totally because of that.
Python and Ruby are both competing to be the most beautiful next-gen languages
Re: (Score:2)
I find myself adding additional if/loop statements around a block of code often enough that I just couldn't imagine working with python where it isn't trivial to automatically indent the block of code, since the indent is the block of code. Copying/pasting code is another case where the indentation is not necessairly correct. I am not talking about duplicating code here, but something like taking a chunk of code and making it into a function call.
I really like how
Re: (Score:2)
I really like how quite often the single-line if/then statements in Ruby could be read aloud directly and they would make sense
I don't like Perl so much anymore, but it had a really cool feature where instead of writing "object.method(args)", you could write "method object args". Instead of a construct like
you could write
It was kind of a pain in the ass for maintenance because if you want to change the test for value from false to true, you'd have to re-write that as "unless not value" and mentally parse the double-negative each time,
Re: (Score:2)
This is called "indirect object" syntax, and it's really frowned upon in modern perl code due to the ambiguities it causes. Construction with my $x = new Foo was one of the last holdouts, but even that has largely given way to my $x = Foo->new.
Re: (Score:2)
That's not so hard in a proper editor. I'm sure Emacs has its own sensible way to replace text, too.
Re: (Score:2)
Re: (Score:2)
The 'lightbulb' moment for Guido was when he said "well, if everyone indents, why not codify it?"
No one is out to force anyone to use anything (with the possible exception of MicroSoft).
Re: (Score:2, Interesting)
Re: (Score:2)
It's absolutely asinine to *require* proper indentation when it's so *easy
Re: (Score:2)
Well put! And that's why every programmer's editor supports Python's indentation so that you never have to think about it.
Re: (Score:2)
From what I've seen developers use Python in *spite* of the indentation, not because of it. It's a bug, not a feature. And you needlessly work around it.
Re: (Score:2)
Agreed! Why in the *hell* in the 20th century should I worry so much about spacing? Let the editor handle that for me. Python developers have to create all sorts of tricks (emacs bindings mostly) to work around this flawed design just to work with the language. Frankly no modern language should have 'column' constraints.
Fortran is dead! Long live Python!
Re: (Score:2)
Love it or hate it, it's simply not a show-stopper.
Haskell, too, has significant whitespace, though, unlike Python, you can relax the whitespace significance in Haskell.
Re: (Score:2)
That definitely falls under "WTF where they thinking?!?" where a single, invisible, space can bork up your code.
OK, does anyone really write significant amounts of code in Notepad? That's the only editor I'm aware of that doesn't have any form of Python syntax highlighting available. Emacs or Vim or Kate or Eclipse will cheerfully steer you around that single, invisible space so this only seems to be a problem in the minds of people who want to invent reasons to dislike it.
FFI (Score:3, Funny)
Re: (Score:2, Insightful)
I think Ruby is really an evolution of Perl. There are a lot of Perlisms in its syntax, and I bet it'd be ve
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Are you perhaps thinking of ruby-lang.org? Ruby.com has nothing to do with the Ruby language.
IIRC, ruby-lang.org used PHP before Radiant CMS was developed, and rubyonrails.(org/com) uses, or used, PHP for some peripheral roles, but is mostly (maybe entirely now) Rails.
Re: (Score:2)
If you can no longer see them it's because they have show_php turned off in their php.ini. You can still spot what they are running on Netcraft and ask them why they are running PHP and they will tell you; they have responded in the past to such inquiries with what I am telling you.
Netcraft confirms it: you're wrong (Score:2)
Yes, I can. And when I do, I find that contrary to your claims, neither the Ruby language site (which is www.ruby-lang.org, not www.ruby.com) nor 43things.com is running PHP. Rubyonrails.(org/com) is. www.ruby.com doesn't show PHP on Netcraft either, but isn't really relevant to the Ruby programming language in the first place.
Re: (Score:2)
I'm constantly amazed at the state of denial in the RUBY community when even the maintainers state that they use other languages that their commnity just puts their fingers in their ears and starts going 'LALALALALALA I CAN'T H
Re: (Score:2)
You stated specifically that one could verify that those sites were running PHP with Netcraft. Checking Netcraft shows that you are wrong for all but one of the three. You stated specifically that the reason those sites gave for using PHP was scalability. The one site that uses PHP (rubyonrails.org), in fact, gives an explanation that has nothing to do with scalability.
Yes, I can. And I'll be right, because yo
Netcraft confirms it: you're ignorant (Score:2)
Re: (Score:2)
Bad try - Ruby 1.9.0 does not "handle Requests", as it has nothing to do with web. It is a general purpose scripting language like python (not PHP).
You are talking about RAILS - which is something completely different.
So true. Ruby is used for scripting in many applications. One example is the RPG Maker Series. RPG Maker XP uses the Ruby Game Scripting System (RGSS), which is a modified version Ruby for the specific task of RPG creation. With such scripting, the possibilities are endless depending on someone's coding skills in RGSS. RPG Maker VX will use RGSS2. Although RGSS scripts can be used in RPG Maker VX, RGSS2 scripts can't be used in RPG Maker XP.
Ruby on Rails, much like RGSS, is a modified version of Ruby
Re:Why Ruby? (Score:5, Interesting)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I work with a large number of folks who don't seem to think that anything useful can be done unless it's done in Java, irrespective of the number of worked counter-examples presented.
Re: (Score:2)
It's trollish to claim that requirements have ever been completely defined, and that development is ever actually finished (you never finish, you simply pick a time to 'stop' writing more). Though perhaps 'fla
Re: (Score:2)
Your point that it is trollish/flamebait to claim that requirements are ever completely defined is well taken, but actually argues in favor of a scripting language like Ruby. The fatter runtime supports a more flexible approach to following those flexible requirements, especially when the customer can't differentiate between his bottom and a hat rack. (Oh god, th
Re:Why Ruby? (Score:4, Informative)
Alright, I know this is going to be flame fodder, but I'm genuinely curious: does Ruby have anything to offer for someone who's already very proficient in Python (and Django, so Rails is already covered)?
Re: (Score:2)
Python currently has larger library support.
Personally I see no need for you to reinvent your wheel, but you'll probably not be gratified as to the validity of your decision until you dig a little.
Re:Why Ruby? (Score:4, Interesting)
* The built-in classes support functional-style programming. That is, the default action is generally to return a modified copy of the object being acted upon, so you can chain method calls together. This doesn't work well in Python, because methods frequently act like "procedures", modifying the object and returning nothing. Sometimes, Python programmers work around this by explicitly copying objects and then calling such methods. Other times, modifying the persistent object is just what they wanted; in Ruby, you would use a method which ends in "?", which is how Ruby identifies (by convention) methods that modify the object.
Thus, to combine two dictionaries in Python, without modifying either of them:
dcombined = d1.copy()
dcombined.update(d2)
In Ruby:
dcombined = d1.merge(d2)
Obviously the Python code is fine, but from a functional programming viewpoint, it looks awkward.
* It's entirely predictable whether a built-in class's method will modify the object, because of the "?" suffix convention. In Python, you don't have such an explicit convention, which can sometimes make more work for the programmer.
* Ruby doesn't rely on global functions as much, or "builtins" as they're called in Python. If you want to know the length of something, or convert a string into a list of characters, you call a method of the object rather than a global function. Some people find this to be easier, given that you only need to focus on one paradigm (object-oriented) and not two (e.g., object-oriented and imperative).
* The print statement in Ruby prints only what you tell it to, rather than adding whitespace in various cases. Since this is the behavior of print or printf in most languages, this is nice. Ruby offers the puts method for those times you want whitespace helpfully added (like Perl 5.10's say).
* regular expressions are more tightly integrated. Some people consider this a disadvantage of Ruby though, because you can write less explicit code.
* Ruby gives you fewer types of quotes to learn, because ' and " are multiline.
Re: (Score:3, Informative)
Re: (Score:2)
Re: (Score:2)
This is indeed a useful feature, but it's not really functional programming, just a different style of object oriented design. The complete absence of any functions in your example might have served as a clue. :)
Re: (Score:2)
Re: (Score:2)
Sorry.
Re:Why Ruby? (Score:4, Insightful)
Ouch. Try this one:
It scales easily (add "+ c.items()" to mix in another dict) and doesn't have any restriction's on the keys' datatypes.
Re: (Score:3, Insightful)
You've got me there. Ruby could stand to clean up its act and be more consistent here. It still has quite an advantage, though.
Re: (Score:2)
The string literal types in Ruby, then they are single-quoted (', %q), double-quoted (", %Q, %), non-indentable here document with double-quoting rules (<<), non-indentable here document with single-quoting rules (<<'), indentable here document with double-quoting rules (<<-), and indentable here document with single-quoting rules(<<-'). That's either 6 or 4
Re: (Score:3, Interesting)
Re: (Score:2)
You don't write Ruby programs. You write Ruby programs that write Ruby programs.
I have a Python class that contains a list of functions that must all eval to True before certain actions can take place. If a test failed, I wanted to return an explanation to the user, and decided to store that in the function's docstring. In Python that's an unlinked string at the very beginning of a function definition:
By the way, Python's self-documenting system uses the
Different style of programming (Score:3, Insightful)
If you look at it from a features and libraries perspective, then you really won't find much different. But you shouldn't look at it that way.
There's a significant programming style difference between the Python and Ruby communities. Python programmers, as a general rule, tend to be more inclined towar
Re: (Score:2)
Anytime you define a new function you are changing the semantics. Are you talking abo
Re: (Score:2)
Yes, almost all, perhaps all, of the things (including with regard to DSLs) that Ruby is noted for being good for, one or more of those languages is also good at. So what?
As far as I can tell, no one in the Ruby co
Re: (Score:2)
In fact, he doesn't even imply "invented".
In the first, he discussed his view of Ruby's superiority to Perl in the area of "language-powered" (i.e., internal) DSLs, and some discussion of the advantages of internal DSLs and when using internal DSLs is appropriate vs. external DSLs that (except for the specific examples of the author's experience) isn't particularly Ruby-centric but fairly broadly applicable to most languages where both internal and external D
Re: (Score:2)
I don't know why you suggest that looking up his coherent response to what appears to be you (or at least, someone in the Perl community who uses the same handle you do here) on the topic, which is focussed on external DSLs here [cosine.org]. And, of course, the posts you pointed to earlier discussing Cosine's view of Ruby's superiority are further developments of that post focussing more on internal ("Language-powered") DSLs.
So, apparently, you are a Perl-fan upset becaus
Re: (Score:2)
Even so, the examples you've posted are all the same one person, and none of them exhibit anything even remotely resembling the behavior you have described. None of them involve even so much as an implicit suggestion that Ruby invented any of the practices or features described. They simply argue that Ruby supp
Re: (Score:2)
To program in for fun, yes. To do things you'd never have thought of doing, yes.
Blocks and iterators: [1,2,3].collect {|x| x ** 3 }.each {|x| puts x.to_i }
It's like specifying arguments that contain code. Functions you otherwise would have to pass a ton of arguments to, or provide a call-back function for, take an anonymous block.
Ruby's a very quick language. You can get something done quickly like Perl, and it has nice shortcuts like "foobar" =~
Re: (Score:2)
Methods can receive blocks of code, or not, and call them whenever they want, however many times they want, pass them around, whatever. With Ruby2Rub
Re: (Score:2)
bla {|a,b| b.frob!(a) }
OK, time for the original poster to interject a pet peeve. Please do not optimize your examples for inscrutability! As a non-Ruby programmer, I have no idea whatsoever where to begin deciphering the above. Maybe, |a,b| is a list and you're calling b.frob! with a as an argument, then passing the results to bla? Or assigning them to bla? I have no idea.
It has nothing directly to do with Ruby (as far as I know), but its proponents seem to pick the most obtuse examples imaginable, at least for people w
Re: (Score:2)
The block of code in {..} is passed to bla as an argument; bla(&foo) says "If you're passed a block, turn it into a Proc object and put it in the variable foo". foo.call then calls the block with whatever arguments you pass it. The example is just to show that block passing is a general purpose construct, not a special case for list processing, hence all the nonsense variables.
e.g. if you add:
Re: (Score:2)
The example was perfectly normal idiomatic ruby, not obfuscated in any way other than the fact that it doesn't actually do anything (as you'd expect from examples using metasyntax like "foo", "bar", "blah" etc).
I totally disagree. How hard would it have been to write that like:
or similar where an experienced programmer can at least figure out which parts of speech are involved? Metasyntactic variables are fine, but not to the point that you can't tell which are objects, methods, and parameters - especially when the syntax involved doesn't closely mirror other popular languages.
Re: (Score:2)
Not much in my opinion: while I was looking for a language I'd like I found both Python and Ruby and had quite some difficulty to find one that I'd like better than the other one: in fact those language are very similar.
So as you're already using Python, I doubt that you'd see much benefit going to Ruby.
Myself finally I chose Ruby, unfortunately I'm doing much more Perl (bleach) than Ruby..
Re: (Score:2)
Bleached Perl [cpan.org]?
Re:Why Ruby? (Score:5, Interesting)
The heart of Ruby is its use of idiom. It's a difficult thing to describe, and I don't know how you'd find some metric to measure it, or to compare it to another language. But it's very clean, and very sensible, and surprisingly simple, at least on the surface.
There's a kind of aesthetic pleasure to be had in the syntax of Ruby. I was about to write that in that sense it's kind of an anti-perl, but that's flame bait, and I never connected with perl, and lots of people probably find perl beautiful. But Ruby is really great.
You can do things like:
1.upto(10) {|x| puts x }
Which does:
1
2
3
This thing looks a lot like an old fashioned for/each loop, but it's an iterator, and the code in the curly brackets is a closure. So under the hood, it's fairly different from a for/each loop.
There are a few things to mention about this.
First, because there are lots of iterators on the shelf, and because you can write your own iterators if you want, this thing is a lot more powerful than looping constructs in many other languages.
Second -- and this is the sort of thing I was trying to get at above -- the syntax for closures is tweaked so it makes human intuitive sense when you're using closures with iterators. In your head, you might be thinking in for/each terms, and the syntax colludes with you if you want to hang on to that useful fiction.
In Lisp, you can never forget about the lambdas. In Ruby, you just sort of do what you want, and the lambdas are there under the hood, but they're not jumping out at you in the same way. Ruby's syntax fits the way a lot of people think, and it hides the stuff that it makes sense to hide, and exposes the stuff that it makes sense to expose.
And when you write out that line of code, its meaning is very clear and easy to grab a hold of, and it turns out that it's usually very concise and compact as well.
This is a little redundant, but I want to stress it, that line of code really is a pretty thing, in a sense. It's not so remarkable if you think of it as a for/each loop, but it's not a for/each loop -- it's an iterator and a closure, and that's a somewhat complicated thing, but here it isn't complicated, or opaque. It's clean, and it makes sense, and it's concise, but most of all, the shape of the code conforms to the shape of the idea in your head. That's what Ruby is all about, and you see that over and over and over again.
Third, this approach to idiom is a real dual edged blade for me, because there's a culture in Ruby books that sort of says, "You know what this line of code is doing, so don't worry too much about the lambdas." For a long time, I felt lost in Ruby -- like, I kind of knew what the code was going to do, but I wasn't exactly sure what was going to happen under the hood. That's a really uncomfortable place to be. I had to watch the SICP lectures to really grab hold of Ruby.
It's always dangerous to talk about some other culture -- I could be way off base here, and I hope I don't say anything really dumb. But it feels Japanese to me -- it reminds me of a drawing where there aren't many lines, but all the lines are kind of perfect and clean. It's got that same sense of elegance to it. Let's boil this big thing down to its essence, and make it beautiful and sparse.
I can't tell you that Ruby is better than some other language. But I can tell you that it's very beautiful, and that the beauty lives in lots of small little details. The experience of learning and using Ruby is one of noticing these little things and saying, "Wow, how great is that?"
I used to live in an apartment building that had been designed by a famous architect -- Mies van der Rohe. The design made a difference -- I can't tell you why or how, exactly, but it d
Re: (Score:2)
It is? What does it close over?
The binding of given block, particularly the binding of x? When the upto calls the block for each number in the range, it can't see the implementation or any of the variables in the block. It only knows the block takes a single variable, it doesn't even know the name of it, and the variables in the block scope stay bound to the. This might be a better example:
Re: (Score:2)
I regret that I couldn't think of a non-contrived example that worked in the context of the GPs post. But the principle is right: when you pass a block to a method in ruby, using the block_given?/yield idiom, it's captured as a Proc and retains its original binding, so it can always refer to names in its originating scope.
Re: (Score:2)
Something particularly hazardous is the difference in ruby between a proc and a lambda. A Proc will execute using its creating context's binding, and if you use a return keyword, the return is bound to the creating continuation, not the calling one, more like an exception throw than a return (I guess this is why people rarely use a return in a Proc, and just let the last evaluated line speak for itself!) The return keyword in a lambda, however, is bound to the lambda's local continuation, and simply make
Re: (Score:2)
Alright, I know this is going to be flame fodder, but do you program for a paycheck, or do you program to get great at writing programs? If the former, don't bother with Ruby, because your company has already picked Python and you probably won't get fired for not knowing Ruby.
Actually, my company picked Python because I kept insisting that it was better suited for us than FoxPro or VB.NET.
It's been said that programmers should learn a new language every year.
I learned enough Lisp to write my son's birth announcement [honeypot.net] in it a few months ago. Previous announcements were in Python, Perl, and C - pretty much following my career path. We're not having another kid, but if we did I promise you the announcement wouldn't be called "baby.4th". Dang, actually that might've been cool for the fourth kid. Rats.
Re: (Score:2)
Probably true. I'd picked up "Practical Common Lisp" about two weeks earlier and hadn't had a chance to really field-test it yet.
I'd like something else. (Score:3, Insightful)
Is parallelization the only niche that isn't supported well? No. There are other areas languages generally do badly in. There are very few languages which handle internationalization efficiently. There are very few languages which handle graphical interfaces efficiently or logically. Languages are typically either good at handling very complicated data structures OR handling structures that are defined just-in-time, typically not both.
My interest in Ruby would be greatly increased if I saw it do something that very few other languages could do, preferably no language that was in mainstream use.
Re: (Score:2)
Re: (Score:2)
I'm waiting for somebody to write a Ruby to Erlang-bytecode compiler. Heck, even a Parrot compiler would be welcome, so I can write in Ruby and use CPAN. *That* would be something no languages can do now (efficiently, anyway). It wouldn't be for just one language, though, they'd all win.
Re: (Score:2, Informative)
There's a Ruby implementation on Parrot called Cardinal. It stalled for a while until the Parrot 0.5.0 release in November, but that should have cleared the next few roadblocks.
Re: (Score:2)
Linkage [tewk.com] for [perl.org] others [blogspot.com]. Status: "Parser is pretty complete. Generates PIR for basic Ruby programs"
Re:I'd like something else. (Score:4, Interesting)
If you want the evidence, the data, the background, I've no objections to stating it. Well, with the exception of commercial projects still covered by non-disclosure agreements. Even if the company betrayed not only me but also the other software engineers there, resulting in engineers being deprived of rightful wages, forced out or removed under false pretenses. I have ethics, even if they do not. The bulk of my experience is NOT covered by any NDA, but is a little on the lengthy side. People get paid good money for writing books with less content. If you actually want to know, I have no objections, but it's not something anyone would be willing to read on Slashdot as a reply or even as a main article.
Re: (Score:3, Interesting)
Re: (Score:2)
Re: (Score:2)
I don't know about LWN or Freshmeat, but for Slashdot the "good", "news", and "that people want to read" features all seem optional.
Re: (Score:3, Interesting)
Now, I would not call myself remotely qualified to write an article (or a
where's unicode? (Score:3, Interesting)
Re:where's unicode? (Score:4, Informative)
Re: (Score:2)
Ruby isn't a web development language. It's been used to write a web development framework, which isn't the same thing. And Japan has not picked up Unicode since it has some rather dumb issues with Japanese (missing characters and the like). You preferentially use other encodings.
Re: (Score:2)
Ruby's slow adoption of Unicode is largely because it was developed by a Japanese developer. See, for an overview of the issues, here [jbrowse.com]. And, indeed, that's probably why, while Ruby is gaining more Unicode support, Ruby will probably not be as Unicode-centric as some languages are in the fo
Re: (Score:2)
Similarly, Ruby's now using O
Speed Improvements Are Nice, But Not Enough (Score:2)
Last I measured, Ruby was about a factor 300 slower than C on low-level code (measuring the performance of high-level functionality implemented in the interpreter is not so interesting, becau
Re: (Score:2)
Perhaps Ruby is not the language for you?
(Ruby is a dynamic language, static/manifest typing is pretty much 180 degrees opposite the philosophy of the language).
Re: (Score:2)
You seem to be thinking of Rails, which is a framework for Ruby used for making web apps.
Ruby itself is quite nice for general development work.
Re: (Score:2)
But RUBY always seems to have to rely upon other languages to scale. The RUBY website uses PHP. The Rails website uses PHP.Seems every place that RUBY has to scale requires it to use another language and the RUBY maintainers have not tried to excuse this but the RUBY community ha
Re:Scalability? (Score:5, Insightful)
I use it heavily as my general scripting language; where I would have used Perl for small utilities, file munging or what have you before, I now use Ruby. Not because Perl is bad - it isn't - but Ruby really is in many respects Perl done right, with many of the benefits and without the syntactic quirkiness. Scaling just isn't a factor for most uses of a script language.
Re: (Score:2)
I think my two favorite things about Ruby when compared to Perl (which, like you, I used to use for scripting) are:
1) I can actually *read* it because it doesn't look like I rolled my head around on the keyboard
2) It behaves in Windows the same way it does in Linux (with the obvious exception of having to change any hard-coded filenames you
Re: (Score:2, Insightful)
Excuse me but http://www.ruby-lang.org/ [ruby-lang.org] runs on Radiant CMS [radiantcms.org], which is written in ruby, not on php.
Re: (Score:2)
Re: (Score:3, Insightful)
Re: (Score:2)
2) Granted. Yet the Ruby community seems more cohesive than other languages. JRuby and Rubinius are intentionally staying close to Ruby. Of course, in JRuby, much of what you do wouldn't work without the J, so it's not back-portable, but technically would be.
3) See 1. A ruby process only wastes the time interpreting and garbage collectin
Re: (Score:2)
Scalability today means using the multiple cores that my processor has. Ruby provides no real means for doing this (e.g., native threads). Sure, you can launch multiple ruby processes, and chat between them with IPC, but look at the overhead of a ruby process ...
Umm, you seem to be confusing performance with scalability here.
I'd say that a program based on processes communicating via IPC is far far more scalable that a program based on threads sharing memory.
The processes + IPC program can be distributed across several machines; the threaded program cannot. The fact that the threaded application is slightly faster is irrelevant since it cannot scale beyond a certain point.
It's easy to forget that hardware costs very little compared to developers' time.
Di
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Also, languages are not by themselves slow, the virtual machines or interpreters are, so saying a language is slow is nonsensical.
Well, yes and no. One can meaningfully say that "Language Foo is harder for an implementation to optimise than language Bar". In practice "harder" will often been completely infeasible.
Here's some examples I've plucked out of the air:
Re: (Score:2)