Ruby 2.0.0 Released 121
An anonymous reader writes "Today version 2.0.0 of Ruby has been released. This is a stable release, and the Ruby team has done their best to make it compatible with 1.9, making it easier to migrate than it was to switch from 1.8 to 1.9. New core language features include: 'Keyword arguments, which give flexibility to API design; Module#prepend, which is a new way to extend a class; A literal %i, which creates an array of symbols easily; __dir__, which returns the dirname of the file currently being executed; and UTF-8 default encoding, which make many magic comments omissible.' There are also new built-in libraries for lazy stream and for an asynchronous exception handling API. The release includes a number of performance improvements and debug support for DTrace."
Yay! (Score:1)
But when will it be available in my apt-get?
Re: (Score:3, Funny)
Re: (Score:2)
"Rubyist hipsters down at Starbucks"? Are you joking me? Maybe you just go to a better Starbucks than mine -
Re: (Score:3, Informative)
Use RVM:
rvm get head && rvm install 2.0.0
Re: (Score:1)
Why? Yet Another Fscking Package Manager. I've got a perfectly working apt-get, and until ruby 2.0.0 is in there it doesn't count.
Re: (Score:1)
Until you have 2 apps on different versions that require mutually incompatible libraries due to said version difference.
Re: (Score:2)
$ rvm
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
it doesn't seem like a package manager but more like ruby's own tool; Ruby Version Manager
http://manpages.ubuntu.com/manpages/precise/man1/rvm.1.html [ubuntu.com]
http://rvm.io/ [rvm.io]
Re: (Score:2)
on debian [lucas-nussbaum.net], there are better alternatives to rvm:
apt-get install ruby-build
rbenv install 2.0.0-dev
In addition, with rbenv, no-one is encouraged to use gemsets instead of bundler.
Re: (Score:2)
Ask your debian/ubuntu package maintainer. You could just use RVM or rbenv-build.
Re: (Score:3)
in Ubuntu or Linux Mint or Debian, get the prerequisites
sudo apt-get install libyaml-dev ncurses-dev libreadline-dev bison libgdbm-dev libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline6-dev zlib1g-dev libyaml-dev gcc
then download the ruby2 source from ruby-lang.org. then untar it and make/install it: ./configure
tar xvfz ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
make
sudo apt-get install
see if it works:
ruby 2.0.0p0 (2013-02-24) [x86_6
Re: (Score:2)
wow, slashdot formatting sure mangled some of that. let's putsome explicit < br / > in there:
tar xvfz ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
./configure
make
sudo make install
Review Ruby for the perl enthusiast please (Score:2, Interesting)
Could someone offer a comparison of ruby to perl in terms of replacing perl as a command line quickie or short admin or text processing. I use python for writing serious programs. But for getting quick things done like say shredding some text copied off a telephone directory web page to pull out a list of telphone numbers and peoples names, or parsing the text output of some unix right on the command line, perl is the right tool, python is not. If you don't know that that is true then you are not an experie
Re: (Score:2, Insightful)
Your message is basically a trap. In order to answer, one has to accept the implied assertion that "Ruby is not something serious".
If you enjoy Perl, keep using it, man. Lots of ex-perlists are now doing ruby. Ask them why. You might want to control your tone though; ruby is what puts food on their children's table. You might not want to call it "not serious" on their face.
Re: (Score:1)
Or what, they're going to nerd rage all over you?
ROR is still a toy, and that's the lion's share of the Ruby deployments.
Re: (Score:1)
PHP deployments = ROR deployments * 10^4
Re: (Score:1)
PHP deployments = ROR deployments * 10^4
Ah, the "goodness == popularity" argument. Argumentum ad populum is a logical fallacy, you know...
Re: (Score:3, Insightful)
Or just don't worry about flattering the ego of people so insecure and unskilled that they require you to pretend that Ruby is a widely used, mature, stable language.
You want the advice of someone who learns languages effortlessly, and therefore has no insecurity about anyone else's preferences or prejudices. Anyone who needs you to "control your tone" about a language "because it puts food on their children's table" - I fear for those children. And for anyone who gets advice from their parents, who apparen
Re: (Score:2)
You probably shouldn't treat gossip as reliable. The Ruby GVL (the Ruby equivalent of the Python GIL) is an artifact of the conversion to the native-threading YARV VM (originally, one of the alternative runtimes) from the old original green-threaded implementation, Matz has never (at least that I've seen, and it w
Re: (Score:2)
Could be.
I did heard it directly from a pretty credible source, someone famous in the Ruby community that I will not embarrass by drawing into this thread, so feel free to say, from no one. Is it written anywhere? I haven't found it in 30 seconds, so I give up. :) What I did find was implication:
http://merbist.com/2011/10/03/about-concurrency-and-the-gil/ [merbist.com]
http://tonyarcieri.com/2012-the-year-rubyists-learned-to-stop-worrying-and-love-the-threads [tonyarcieri.com]
"Data safety" - meaning, Ruby is not a threading language, threa
Re: (Score:2)
The particular comment regarding the effect of removing the GVL that I refer is directly attributed to Matz at Rubyconf here [jstorimer.com], but isn't a direct quote.
Re: (Score:2)
"Data safety" has nothing to do with "easy".
It can be interpreted that way, because eliminating the GIL and allowing threading makes it "hard" for your data to be "safe" from races.
The idea of making MRI even slower is hilarious. But I'm sure you could do it by introducing even more locking behavior. Ditching MRI for one of the other, newer RVMs sounds like a fine idea. :)
Re: (Score:3)
I cited a comprehensive survey. You just talked about github. Yes, a particular open-source repository (Github) is popular among Ruby developers. The fact that you confuse this with language popularity is another hint about your critical thinking skills.
There is indeed economic merit in choosing developer productivity over runtime performance. However, there is no need to choose one or the other. Many other languages exist that are fine competitors to Ruby in terms of developer productivity, and most will n
Re: (Score:2)
Let's see. What did I say?
Although some very clever Ruby runtime implementers have come along to pick up the slack left by the language's founder (who still pretends the global interpreter lock is a virtue, or so I am told)...
In other words, Ruby's scalability concerns come from a designer with so little care for performance as to sell the GIL as a virtue - scarcely any smarter than this Anonymous Coward. :) By now others have written superior Ruby interpreters, in part because of how bad Matz's is. To this exact point, I linked to a blog post, by the author of JRuby, a Ruby environment which incidentally has no GIL, discussing many serious performance challenges which can never be easily addressed, bec
Re: (Score:1)
I won't use ruby for the sheer fact that in order to code ruby you have to be a smug self righteous hipster ass who just barely was talked out of getting a "degree" at Devry..
You've nailed the smug self righteous hipster ass part. Couldn't get into Devry?
Re: (Score:1)
ROR is still a toy, and that's the lion's share of the Ruby deployments.
At its height Twitter's Rails stack was serving 170,000 requests per second with three nines success rate.
RoR might be a toy in your hands.
Re: (Score:2)
It's hard to gauge exact numbers, but pointing to Ruby on Rails as the whole of the Ruby ecosystems is a bit of a chestnut these days. Ruby is become an increasingly important systems language. See, for example - vagrant, chef, puppet, mcollective, capistrano, aeolus, logstash, beanstalk, facter, buildr, etc etc.
Even within the realm of web applications, Rails isn't the only game in town. Sinatra has rocketed in popularity, inspiring inspiring similar micro-frameworks in a dozen other languages (see: dan
Re: (Score:1)
So, you want someone to spend their time writing something to try and convince you of something? If you're such an "experienced perl person", why not do the research yourself and post it here? You know the kinds of tasks that you typically use perl for - take one or two of them and convert them to ruby and see the results yourself.
Not only that, but it sounds like you've already pre-judged ruby by putting in the same category as perl for you i.e. a language for "non-serious programs".
TL;DR: do it yourself
Re:Review Ruby for the perl enthusiast please (Score:5, Funny)
the O'reily nut shell book is the thinest book (even thinner than C++)
You're right, O'Reilly's C++ In a Nutshell [oreilly.com] is a mere 810 pages long, whereas their Perl in a Nutshell, 2nd Edition [oreilly.com] is a scant 768 pages.
When I think C++ and Perl, I think lean.
Re: (Score:1)
Re: (Score:2)
That's not really true, you can easily write code without OO setup in ruby, in fact you could write code without defining functions if you wish for one liners. e.g. here's a little one liner to count the words in a file.
It can be used very like perl if you wish.
Re: (Score:1)
Kids these days with their fancy pants crap.
wc -w test.txt
Re: (Score:2)
: )
Re: (Score:2)
add shell scripting and it is all you need for "shredding text files" really.
Re: (Score:1)
Java also sports the "everything is an object" mentality. If you were going to make a point about that model, you should have picked a better example.
And anyway, in Perl everything is still an object. Do you think the variables are actually stored like they are in C? No, they have scope and reference counting info. They are objects. Don't talk about performance and Perl in the same sentence.
Re:Review Ruby for the perl enthusiast please (Score:5, Informative)
Java also sports the "everything is an object" mentality.
Say what?!?!?! Java explicitly distinguishes between primitives and objects! You can't send messages to primitives or literals in Java, only to objects and classes. Contrast with Ruby, where "5.times {p rand}" is a perfectly legitimate way to print five random numbers because the literal "5" is an Integer object which can respond to any message Integers implement.
Re: (Score:1)
And every primitive has a class version, to which the primitives are automatically boxed when they need to be treated like objects. There are only a few places where the distinction matters at all (arguments by value being the chief of these).
Re: (Score:3)
And every primitive has a class version...
Which emphasizes the point - they are different things, or the duplication wouldn't be necessary.
...to which the primitives are automatically boxed when they need to be treated like objects.
Auto-boxing/unboxing is an unbelievably ugly kludge which exists specifically because Java distinguishes between primitives and objects. After enough programmers kvetched about the ugliness and extra code that was needed, Sun threw auto-boxing in somewhere around Java 1.4 or 1.5.
Languages with a true "everything is an object" model don't need such an awful hack. They also don't require umpteen implementat
Re:Review Ruby for the perl enthusiast please (Score:2)
Languages with a true "everything is an object" model don't need such an awful hack. They also don't require umpteen implementations of containers or sorting (one for Objects and one apiece for each of the primitive types), with all the library bloat that entails.
That's also a feature of languages with proper generics support: you don't need everything to be an object to have single implementations of containers.
Re: (Score:1)
And every primitive has a class version, to which the primitives are automatically boxed when they need to be treated like objects. There are only a few places where the distinction matters at all (arguments by value being the chief of these).
That's not true at all. you can't say 'a'.toLowerCase() in Java. You have to do something like Character('a').toLowerCase(). That's not transparent at all. And God forbid you want to add methods to the Integer class in java.
Re: (Score:2)
Fair enough. Java still otherwise wants to follow the everything is an object model. The primitives do stick out like a sore thumb, you are right. Thankfully, .NET fixed this problem.
Re: (Score:2)
Java still otherwise wants to follow the everything is an object model.
I don't think that means what you think it means.
The primitives do stick out like a sore thumb, you are right.
Who'da thunk this was such a hard concept? Look, if there are primitives in a language, then pretty much by definition not everything is an object.
Re: (Score:1)
Everything is not an object in Java. It has primitives. Methods/functions are not first class. In Ruby, almost everything is an object, but not quite. Methods/functions have to be turned into procs/lambdas. A function defined in the global main space is not an object and can't be passed around like you do with JavaScript (although you can pass the symbol for that function around and call send on main). SmallTalk and Self are the standard bearers for pure OO.
Re: (Score:2)
"Everything is an object" is purely about semantics, it does not define how those objects are represented, and does not have to "Add a tremendous amout of overhead".
I don't know the specifics about Ruby, but e.g. int in C# is an object (a value-type instance, to be specific), with methods etc - and its representation is exactly the same as int32_t in C. Dynamically typed languages have historically used tagged references to achieve similar performance (i.e. when the object reference has a bit that distingui
Re:Review Ruby for the perl enthusiast please (Score:4, Informative)
Perl's speed is pretty similar to Ruby, it's nowhere near the Java VM nowadays, plus Ruby is available on the JVM if that's what you prefer to use. But the parent was talking about system admin scripts and little one liners run on the command line. If you're expecting them to be 'webscale' you're talking about something else entirely. I don't know about you but my system admin scripts are not expected to scale past the few machines I work on and run by precisely one user at a time, they're not user-facing scripts and therefore performance is not critical - they could be in any language really, I don't really use one-liners but it is quite possible to do them in all those languages, even Python.
Finally, re Twitter, if you try to reinvent a messaging server using a CRUD web app (a la twitter), you can expect all kinds of pain, even if you write it in enterprise ready Java in the first place. I imagine their problems were more down to entirely the wrong architecture, though now that they are one of the biggest sites on the internet, things like language choice will become very important for them. It's interesting though that a site like Facebook compiles PHP to C++ and then to one big binary in order to stay up and still use one of the slowest languages available - if they wished twitter could easily have done something simliar with Ruby or moved to using the ruby on the JVM, but the new people brought in to make it work were probably coming from Java backgrounds and as it need a rewrite, they thought why not, and why not indeed, it's worked out pretty well for them. They were still on Ruby 1.8.7 till the end I think, which was pretty insane given the improvements in Ruby 1.9 and points to serious problems with the older code.
Re:Review Ruby for the perl enthusiast please (Score:5, Insightful)
1. Ruby is not a toy not suitable for 'serious' programs, it's very similar to Python in fact, it's not as strong on science or math though as python because of libraries available in Python, if that's what you mean, say that, it's far more convincing.
2. Python could easily replace Perl for system admin tasks - come up with specific criticisms if you have met with any roadblocks - you would likely find similar problems with Ruby to Python if you somehow couldn't manage sysadmin or text scripting with Python.
3. Ruby, Python and Perl are actually quite interchangeable and could all be used for 'serious' tasks, or for short admin or text processing - all 3 are ideally suited to these things, and frankly the differences are not huge, Perl is slightly gnarlier, Python slightly stricter, Ruby slightly more anarchic, all 3 would get the job done easily.
4. WTF has Rails got to do with any of this? Troll much?
5. Why should we waste our time trying to convince someone with such trenchant and at the same time wildly inaccurate preconceived ideas?
Re: (Score:2)
Python could easily replace Perl for system admin tasks
Probably not. Python's not king of the one-line trick in the same way that Perl is, and probably can never become so because of its reliance on the use of whitespace to indicate program structure. Not that I'm complaining about the use of whitespace; just pointing out that it makes things impractical for muscling in on Perl's core territory.
Re: (Score:3)
Python's not king of the one-line trick in the same way that Perl is
I know a lot of people one-line perl, but I never do. Every perl script I've ever written has been commented and readable and basically looked a lot like C without the torture. But I still have little interest in learning python and none in learning ruby, and what interest I have is based solely upon popularity.
Point is, that's not why python didn't get traction.
Re: (Score:2)
This double negative tripped me up a little. Once I put my glasses on I understood you meant to say "Ruby is not a toy. It is as suitable for 'serious' programmers as Python". ;)
Anyway I really want to reply to this:
Perl is the "strictest". I love "use strict" (more accurately: use strict "vars") and wish that Python and Ruby
Re: (Score:3, Informative)
Ruby has maths libraries (but not as extensive as Python here IMHO), threading, has had Unicode and UTF support for years (since 1.9), and has good support for the best scripting language UI if you ask me (HTML displayed in a browser with the built in web server). I suppose if your idea of 'serious program
Re: (Score:1)
Re: (Score:2)
The Ruby language has fine support for multithreading. The current main implementation uses a Global VM Lock that only allows one Ruby thread to run at a time (native extensions can release the GVL to run in parallel with Ruby threads), but that's an implementation issue, not a language issue. Other implementations (JRuby, IronRuby, MacRuby, now, and Rubinius is aiming for this) have native threads without a GVL.
Unicode support has been in Ruby sinc
Re:Review Ruby for the perl enthusiast please (Score:5, Informative)
(sorry if this is double-posted - slashdot is choking)
Perl is way faster. Like twice as fast. Check out my test:
% time (echo | ruby)
( echo | ruby; ) 0.01s user 0.00s system 91% cpu 0.016 total
% time (echo | perl)
( echo | perl; ) 0.00s user 0.00s system 84% cpu 0.007 total
Though this is ruby 1.9.3. I don't think 2.0 is twice as fast as 1.9.3.
But I've looked at ruby syntax a bit and it looks like it might have the advantage perl has for quick ad hoc text parsing but an overall cleaner syntax.
What I don't care a lot about is fancy pants modules like rails. If I want to do something serious there's python.
If you're happy shredding text with perl, I see no reason to change. If you're happy doing serious work with python, I see no reason to change.
Ruby is a, dynamic, duck-type OO language with closures, exceptions, and a debugger.
It has nice library infrastructure: http://rubygems.org/ [rubygems.org]
It is generally a little less popular than Python and Perl, depending on your yardstick: http://www.langpop.com/ [langpop.com]
There are a few implementations of ruby, including one in java (with great bridging to java classes), one for iOS (with great bridging to iOS libraries), and one based on .net (with great bindings there). So if you have a particular target platform, one of those may interest you.
But here's the cononical answer to your question:
http://c2.com/cgi/wiki?PythonVsRuby [c2.com]
You might be interested in JRuby and Jython and their ability to communicate...
I code in Ruby for a living (Rails), and I think it's a really fun language. Which is something a fair number of rubyists say, and which is something you don't hear a lot of other folks say about their language of choice. For what that's worth...
Re:Review Ruby for the perl enthusiast please (Score:5, Interesting)
I code in Ruby for a living (Rails), and I think it's a really fun language. Which is something a fair number of rubyists say, and which is something you don't hear a lot of other folks say about their language of choice. For what that's worth...
This. So much this.
Over the years I've used various languages to some degree... C, C++,Java, PHP, Perl.... and Ruby is simply the most fun and most expressive. I'll allow that all these languages have their strengths. (ok, not PHP [veekun.com]). Python, too has many valid proponents and use cases, but I just can't have fun in a whitespace sensitive language. Java - I think is nice for people that like to type a lot. The modern day COBOL. But if IIRC, the fastest ruby interpreter is currently JRuby, so I can't entirely fault Java. C and C++ is obviously best for kernels and libraries where speed matters a lot, but obviously horrible for web application development.
For my own interests in web application development, Ruby on Rails is a sweet spot... I can make a lot of money doing something really fun. What's not to like about that?
Re: (Score:2)
Java - I think is nice for people that like to type a lot. The modern day COBOL.
The only way Java even gets close to fun is with an IDE so that you don't need to type everything out in full by hand. No, the big advantage of Java is the assload of third-party libraries for doing interesting stuff. ("The modern day COBOL" is spot-on.)
Re: (Score:1)
He actually was benchmarking how quickly he could get moderated up by posting trivial unix command output.
Re: (Score:3, Insightful)
So if I tolerate an additional 9 ms of startup time, I could write slightly faster interpreted code in a language with enough syntactic sugar to make mixing OO code with functional code less painful? Cool. ;)
Re: (Score:2)
This application is also not particularly well designed. This is not a problem specific
Re: (Score:2)
I'm sorry you got handed a poorly written project.
If you do a lot of number crunching, you might want to check out JRuby. Porting is often trivial, and number crunching (or adding pure java functionality) may speed things up a lot.
But the first thing I'd do is write a bunch of unit (and integration) tests so that you know where you stand.
Good luck!
Re: (Score:2)
Re: (Score:2)
Yeah, sounds like the project is a rewrite.
As for syntax changes, I think that 1.8 is forward compatible to 1.9 (though strings became UTF compliant?), so maybe some edges in there. Last time I tried my 1.9 app in 2.0.alpha/beta/whatever, it just worked. In general the language has been very forward compatible and the revs have only happened every few years. Rails has a history of slapping developers around for major releases, but for the progress they're making and with the historical support, I don't m
Ruby is for when you want to enjoy yourself (Score:1, Interesting)
Ruby can be used for both serious projects as well as providing quick prototyping.
Ruby is probably _the_ best language to refactor code, but with some minimal care, projects will actually rarely need much heavy-lifting because of Ruby's design-choices, powerful flexibility and lack of syntactic bloat.
So if you're into Agile, Ruby will grow on you, indefinitely.
You don't have to use Rails at all. Ruby is ALL INDEPENDENT LIBRARIES, even more so than Perl.
You SHOULD take a look at *ActiveRecord* though. It roc
Re: (Score:1)
You espouse performance as a benefit of Perl (maybe it is, I have no clue) and then talk about using Python for "something serious."
I love Python, but I'm under no disillusion about how slow it is. It's also imo horrible for large-scale and medium-scale development because its tools to manage complexity aren't very good for larger projects. Most of this stems from its type system. In my experience, you have to keep all parts of the system in your head even if it's designed well. For some reason, I always en
Re: (Score:1)
For some reason, I always end up spending more time in debugging than in programming with Python. This could be because I don't use much of an IDE for Python (and there aren't very many compelling options...)
You are doing it wrong. There is a first-class IDE for Python (I mean, really first-class, by all standards), PyCharm [jetbrains.com]. Give it a try and see the your productivity go way up.
Re: (Score:2)
I use Perl and Ruby extensively. The comparisons are: Ruby is slightly faster than perl; It is easier to make C bindings in Ruby; Ruby's object oriented features doesn't involve Moose (Moose isn't necessary, in perl you can still use hash/dictionary type and bless into an object but still is a kludge); Ruby's library packaging system is an improvement over cpan (you can uninstall as easily as you installed); and unlike Perl with Ruby you will never have to debug or maintain code from a colleague who thought
Re: (Score:2)
That's interesting. I've almost always heard the opposite that Perl is faster than Ruby. Though looking at the recent results that is no longer true.
As for Perl 6, I agree that's been a badly badly mishandled project.
Re: (Score:2)
I switched to Ruby from Perl back when Perl 6 was in the early stages of development. I haven't regretted it at all. There are more Ruby Gems than CPAN packages now, the regexps are just as good, and the language syntax is so much cleaner.
Back on Ruby 1.8, Perl was about twice as fast, but these days Ruby has improved a lot, and there are also options like JRuby and Rubinius.
Re: (Score:3)
Python way is not too keen on conciseness to the point of unreadability - so it's not good for Perl-style one-liners. Ruby, on the other hand, retains a lot of Perlisms (like $_ etc) solely for that purpose.
Re: (Score:2, Funny)
Your code indentation is wrong.
Too early! (Score:5, Funny)
Should have been released on Tuesday. Ruby Twosday. :D
OP omits biggest item (Score:1)
Refinements, which allows meta programming to be scoped to a particular namespace. This addresses a lot of concerns about meta programming code having too much global impact if done as a "monkey patch" or module include/prepend (which is just a glorified name for a monkey patch that can subclasses from, and can invooverride arched class'smethods instead of rewriting the method on the patched class).
However, it's released as "experimental" probably because they still haven't figured out how implement this in
Re: (Score:2)
What bothers me is that they don't say that it's truly parallel yet. This probably means that they've still got that fake parallelism in there to keep the libraries happy. They *REALLY* need to solve that.
It's true that what they introduced in 1.9.? was a lot better than nothing, but it's not good enough with MPUs becomming so dominant. And doing parallelism at the gross level of processes isn't very satisfactory. Threads should have a means of multi-tasking.
2.0 released as Ruby turns 20 years old (Score:4, Interesting)
Happy birthday to Ruby! Pretty cool the way that numeric coincidence worked out.
2.0 looks like a nice step forwards. I'm not sure where I stand on Refinements yet. I hate the method overriding of base classes that goes on in Ruby land, and Refinements is supposed to minimize the bad affects of that by offering scoped alterations, but from what I've heard there's a lot of side effects. Frankly, I think Ruby needs a 'protected' type; any other solution is just monkeys all the way down. But I could say this about a lot of the popular languages right now.
Ruby vs Node.JS (Score:1)
Skillset momentum aside, why would anyone choose Ruby over Node.JS [wikipedia.org]?
Node is *significantly* faster [debian.org] right out of the box (while Ruby JIT is still in its infancy [infoworld.com]). With so many well-funded implementations (Google [wikipedia.org], Mozilla, Opera, Microsoft) competing to be a tiny bit faster in any way possible, JavaScript is very likely to remain the fastest dynamically-typed language. Node is also built with a specific emphasis on scalability / parallel performance.
Node.JS also has the advantage of using the same language o
Re: (Score:2)
Please Python was a hipster language 17 years ago. Today stuff like Scala, Clojure are the hipster languages. Even Haskell is getting post hipster.
Re: (Score:2)