News for hackers. Stuff that matters.
Re:Ruby 2.1 Released by daGrevis on Wednesday December 25, 2013 @02:49PM (#6964015)
Please stop posting links to file locations. Announcements or changelogs would be more useful! If I would like to download it, I'll just use package manager. Personally, I just want to read what's new.
Re:Ruby 2.1 Released by teeray on Wednesday December 25, 2013 @03:41PM (#6964168)
OP here: The announcement hadn't been written at the time I posted this link. I figured people would rather install it, and when the announcements became available, I'd add them as comments. They are both posted here if you scroll down.
Re:Ruby 2.1 Released by cmelbye on Wednesday December 25, 2013 @06:53PM (#6964747)
Do that many people install Ruby through a source code package that they manually download? Why not just hold off on posting until there's useful information?
Re:Ruby 2.1 Released by sbarre on Wednesday December 25, 2013 @09:59PM (#6965104)
Because karma
Re:Ruby 2.1 Released by teeray on Wednesday December 25, 2013 @11:40AM (#6963333)
Re:Ruby 2.1 Released by thinkbohemian on Wednesday December 25, 2013 @03:15PM (#6964098)
Re:Ruby 2.1 Released by killercup on Wednesday December 25, 2013 @11:23AM (#6963274)
Re:Ruby 2.1 Released by trustfundbaby on Wednesday December 25, 2013 @05:54PM (#6964598)
in unofficial benchmarks with Rails (running different rake tasks and benchmarking them). 2.1.0 seems to be 20% faster than 2.0.0 and 2.0 was about 60/70% faster than 1.9.3 so that would make 2.1.0 about twice as fast as 1.9.3.
Re:Ruby 2.1 Released by brianhempel on Thursday December 26, 2013 @12:32AM (#6965360)
Rails was only about 5-6% faster in the last few nights of development builds (based on what is installed with rvm reinstall ruby-head). I would be surprised if the released 2.1.0 is more than one percentage point different from that.

Pretty graphs here: http://www.isrubyfastyet.com/ (I run a nightly benchmark.)

I will add 2.1.0 right now and hopefully we will have confirmed data in the morning.

EDIT: You mention 20% improvement on Rake tasks. Simple Rake tasks are dominated by Rails' startup time. My benchmark reads about a 15% improvement in startup time, which agrees with what you are saying.

However, the 1.9 series was a significant step back from 1.8.7 for out-of-the-box Rails startup time. Ruby 2.0.0 pretty much matched Ruby 1.8.7. Now with 2.1.0, Ruby is finally categorically faster than 1.8.7 for starting Rails. (Rails itself has also made improvements; but my benchmark has been locked at Rails 3.1.3)

Re:Ruby 2.1 Released by trustfundbaby on Thursday December 26, 2013 @01:42AM (#6965463)
Thanks for adding that information, I didn't know about slower Rails startup times with Ruby 1.9 v 1.8.

And, you were right, I put Ruby 2.1.0 live on one of my web apps last night, and didn't really get any kind of significant speed boost, what I did get was a significant decrease in garbage collection. here's the new relic graph, ruby 2.1.0 went live at 17:45 on the chart https://cloudup.com/ifosPh4rX4v

Re:Ruby 2.1 Released by VeejayRampay on Thursday December 26, 2013 @03:43AM (#6965665)
I find it strange that JRuby would be the worst of all for all 4 categories though. Startup time I can understand, but given the right conditions, it's known to be pretty damn fast.
Re:Ruby 2.1 Released by lobster_johnson on Friday December 27, 2013 @09:52AM (#6970768)
The JVM most likely hasn't been tuned. If I recall correctly it's also a very old JVM that is being used.
Re:Ruby 2.1 Released by Argorak on Thursday December 26, 2013 @09:38AM (#6966352)
Which JVM are you running JRuby on? AFAIK, the one included in OS X 10.6 is not really the best performing one.

Running with a more modern VM might yield better results.

Re:Ruby 2.1 Released by polysics on Thursday December 26, 2013 @05:20AM (#6965845)
I understand the importance of Rails in the Ruby ecosystem, but at the same time, I would really like it not being the only measure of Ruby's performance.
Re:Ruby 2.1 Released by brianhempel on Thursday December 26, 2013 @08:59AM (#6966259)
I agree. However, when I sat down two years ago to make a benchmark, I couldn't think of anything better to benchmark than Rails. Micro-benchmarks don't predict large application performance very well. I don't like micro-benchmarks.

A micro-benchmark suite is better than a few micro-benchmarks, but really I would like a suite of real-world micro-applications.

I'm willing to add more benchmarks so it's not just Rails, but I simply don't know what to add.

Re:Ruby 2.1 Released by oddx on Wednesday December 25, 2013 @11:34PM (#6965265)
And 1.9 was about twice as fast as 1.8. So it should be 400% percent improvement compared to 1.8.
Re:Ruby 2.1 Released by whalesalad on Wednesday December 25, 2013 @11:07AM (#6963241)
Wow best Christmas present ever. Thank you Ruby team!
Re:Ruby 2.1 Released by mrinterweb on Wednesday December 25, 2013 @02:24PM (#6963930)
When I woke up to this news, I rushed past the presents straight to my laptop to install 2.1. Thank you ruby team for the great Christmas present. PS. Thanks RVM for getting the stable ruby 2.1 ready so fast.
Re:Ruby 2.1 Released by mikkelewis on Wednesday December 25, 2013 @12:40PM (#6963558)
Other than the new generational GC, I'm most excited about String#scrub and String#freeze.

String#scrub: https://github.com/ruby/ruby/blob/1e8a05c1dfee94db9b6b825097...

String#freeze example:

https://github.com/rails/rails/pull/12879

Re:Ruby 2.1 Released by jrochkind1 on Wednesday December 25, 2013 @12:51PM (#6963603)
I am pleased someone else is excited about String#scrub.

For those who need #scrub behavior in ruby 1.9 or 2.0, I wrote a gem a while ago to do this -- I wrote it before I was aware of the upcoming String#scrub api -- I'll maybe change it to provide a String#scrub 'backfill' now, with monkey patching even?

https://github.com/jrochkind/ensure_valid_encoding

Re:Ruby 2.1 Released by ibrahima on Wednesday December 25, 2013 @03:54PM (#6964205)
Oh wow, I actually ran into this recently, I couldn't figure out what to search for to fix it though. Nice to see that it's built in now.

(It was for a tiny weekend project where I was reading logs from the ZNC IRC bouncer to present a nice web UI for them, for some reason sometimes there were invalid characters and I didn't really understand why - possible that I was just reading them with the wrong input encoding but I think I tried a few different ones.)

Re:Ruby 2.1 Released by MrBra on Thursday December 26, 2013 @01:48AM (#6965468)
Same here, had the same issues when working on a simple irc client. Basically what I did to make it work was: read the string with a given encoding(say UTF8), them check if the read string was a valid string with said encoding (no invalid characters). If this was the case, that means it found the correct encoding otherwise loop again and try with another encoding (I used cp1252 as a second guess), until the resulting string had no invalid characters. Used to work pretty good and didn't crash anymore when facing "unexpected" characters... I am curious on whether String#scrub is implemented in a similar way?
Re:Ruby 2.1 Released by jrochkind1 on Thursday December 26, 2013 @09:33AM (#6966342)
String#scrub does not try to identify a proper encoding from a mystery encoding.

Rather, Strin#scrub simply removes invalid bytes from the input, by default replacing them with the unicode replacement char � (or simply "?" if not in a unicode encoding).

This is, for instance, what many editors and other software I've used will do too -- if you say to open a file in encoding X, and some bytes in it are invalid for encoding X, they will be replaced with � or ? in display.

I find it a pretty useful thing in my own software, where input is _supposed_ to be a given known encoding, but upstream providers sometimes provide data with corrupt bytes, errors, or sub-passages in wrong encoding. It's not really my software's job to come up with the 'real' encoding -- and there may be no 'correct' encoding, often the error is corrupt bytes or mixed encodings -- but it is my software's job to show what can be shown without raising.

I think I've seen other gems that try to use heuristics to guess or discover an appropriate encoding for text with no known encoding. But String#scrub is not that. Here's some gems that say they'll do that (I have no experience with any of tem): https://github.com/brianmario/charlock_holmes ; https://github.com/jmhodges/rchardet ; https://github.com/janx/chardet2

Re:Ruby 2.1 Released by MrBra on Saturday January 04, 2014 @10:14AM (#7011268)
Thanks for the clarification on #scrub. With regards to guessing a given encoding, I remember trying some (or probably all) of those gems or those that were around at the time I was writing the app, but for a reason or another (I think some were not recently updated) I couldn't get them working so I came up with my own little solution. Anyway, thanks for taking the time to list them.
Re:Ruby 2.1 Released by shanemhansen on Wednesday December 25, 2013 @08:55PM (#6964990)
Irc has a weird encoding by default. I think it's called Latin1/irc hybrid.
Re:Ruby 2.1 Released by radq on Wednesday December 25, 2013 @03:36PM (#6964154)
Looks like there is already a gem backporting String#scrub: https://github.com/hsbt/string-scrub/

It was mentioned in the changelog.

Re:Ruby 2.1 Released by jrochkind1 on Wednesday December 25, 2013 @04:18PM (#6964285)
awesome, thanks. Looks like that backport may be only for ruby 2.0 (not 1.9), and is a compiled C extension.

It won't take many lines of pure ruby code to do it for ruby 1.9 too, although presumably not performing quite as well as a C version.

At any rate, this is definitely something I and people I know need to do all the time, although apparently most ruby devs never need to do it; but I'm glad it's finally made it into stdlib.

Re:Ruby 2.1 Released by jrochkind1 on Thursday December 26, 2013 @11:32AM (#6966742)
That backport works on MRI 2.0.

I've completed a pure-ruby polyfill that should work on 1.9 as well as 2.0, any ruby interpreter including jruby. (It does have some issues mentioned in the readme).

https://github.com/jrochkind/scrub_rb

Re:Ruby 2.1 Released by hackfanatic on Saturday December 28, 2013 @02:28PM (#6976001)
Results of a Seige tests to my production API which does a lot of complex querying and processing, seems to have improved slightly

Ruby 2.0-p353

Transactions: 934 hits Availability: 100.00 % Elapsed time: 76.66 secs Data transferred: 0.43 MB Response time: 3.19 secs Transaction rate: 12.18 trans/sec Throughput: 0.01 MB/sec Concurrency: 38.92 Successful transactions: 934 Failed transactions: 0 Longest transaction: 3.93 Shortest transaction: 0.67

Ruby 2.1 Transactions: 1136 hits Availability: 100.00 % Elapsed time: 76.41 secs Data transferred: 0.53 MB Response time: 2.64 secs Transaction rate: 14.87 trans/sec Throughput: 0.01 MB/sec Concurrency: 39.30 Successful transactions: 1136 Failed transactions: 0 Longest transaction: 3.18 Shortest transaction: 0.56

Re:Ruby 2.1 Released by pselbert on Wednesday December 25, 2013 @11:27AM (#6963284)
Excellent! I've been looking forward to the improved GC. Nice to see they kept the Cheistmas tradition alive.
Re:Ruby 2.1 Released by ksec on Wednesday December 25, 2013 @11:36AM (#6963324)
Nice, On a Side note Rubinius 2.2.1 was out and i didn't notice they had a 2.2 release at all. Wasn't even a announcement from Rubinius Twitter or any news on HN either.

Now i am waiting for someone doing some benchmarks with the two ( & JRuby ).

Re:Ruby 2.1 Released by steveklabnik on Wednesday December 25, 2013 @01:09PM (#6963673)
Rubinius is releasing so often these days it really just isn't a big deal.
Re:Ruby 2.1 Released by andyl on Thursday December 26, 2013 @12:45PM (#6967038)
Rubinius 2.2.1 is still only compatible with MRI 1.9. (no support for keyword arguments)
Re:Ruby 2.1 Released by lbarrow on Wednesday December 25, 2013 @03:05PM (#6964067)
I'm super excited about the new GC and profiling tools. I actually feel like I can't wait to get back to work and try them out =)
Re:Ruby 2.1 Released by jamesbritt on Wednesday December 25, 2013 @12:08PM (#6963416)
Side question: Does anyone know why the svn repo does not include a minor version number?

    http://svn.ruby-lang.org/repos/ruby/branches/ruby_2_1/

while there are branchs such as ruby_1_9_3 and ruby_2_0_0.
Re:Ruby 2.1 Released by cremno on Wednesday December 25, 2013 @12:24PM (#6963482)
Re:Ruby 2.1 Released by reinhardt on Thursday December 26, 2013 @02:47AM (#6965566)
Another sidenote question: what's a good resource/tutorial to get into ruby (both the language and the ecosystem) for an experienced Python dev?
Re:Ruby 2.1 Released by turingbook on Thursday December 26, 2013 @01:46AM (#6965465)
Chinese article on the new features with some links to the materials: http://geek.csdn.net/news/detail/4112
Re:Ruby 2.1 Released by amccloud on Wednesday December 25, 2013 @08:06PM (#6964894)
Has anyone been able to install it with rbenv/ruby-build?
Re:Ruby 2.1 Released by tmilewski on Wednesday December 25, 2013 @09:54PM (#6965094)
brew upgrade ruby-build --HEAD && rbenv install -l | grep 2.1.0
Re:Ruby 2.1 Released by elsurudo on Saturday December 28, 2013 @10:00AM (#6975105)
Strange, I only see 2.1.0-dev and 2.1.0-preview1, even after I do this... Any tips?

EDIT: rbenv-update'='(cd ~/.rbenv/plugins/ruby-build && git pull) did the trick.

Re:Ruby 2.1 Released by amccloud on Friday December 27, 2013 @01:11AM (#6969589)
Yup, that's what I needed to do.
Re:Ruby 2.1 Released by silasb on Wednesday December 25, 2013 @08:47PM (#6964978)
Installed fine for me.
Re:Ruby 2.1 Released by tvon on Wednesday December 25, 2013 @08:38PM (#6964957)
Yes, on three machines (10.9 and 10.8).
Re:Ruby 2.1 Released by andyl on Wednesday December 25, 2013 @09:12PM (#6965015)
Yes working for me in dev and production
Re:Ruby 2.1 Released by ksec on Wednesday December 25, 2013 @09:50PM (#6965081)
Ok, what next for Ruby 2.2 :P

Merry Xmas.

Re:Ruby 2.1 Released by ballard on Thursday December 26, 2013 @01:01AM (#6965403)
Unsigned tarballs: Security fail.
Re:Ruby 2.1 Released by ddebernardy on Thursday December 26, 2013 @05:46AM (#6965890)
Re:Ruby 2.1 Released by ballard on Thursday December 26, 2013 @08:38AM (#6966204)
That's md5 and sha256 hashes, not a gpg signature.

There's a world of difference when something is unsigned because it's impossible to prove that it was what the developer(s) signed off to release.

Re:Ruby 2.1 Released by UNIXgod on Wednesday December 25, 2013 @08:38PM (#6964958)
2.1.0p0 :001 > x = def foo() puts "hello"; end

=> :foo

2.1.0p0 :002 > def eval_it_now_bitch! lulz

2.1.0p0 :003?> eval lulz.to_s

2.1.0p0 :004?> end

=> :eval_it_now_bitch!

2.1.0p0 :005 > eval_it_now_bitch! x

hello

=> nil

Re:Ruby 2.1 Released by UNIXgod on Thursday December 26, 2013 @02:06AM (#6965498)
I actually thought that the new feature of def yielding the symbolic name of the newly defined function was interesting, if for anything to open up new areas where there was a limit before on building lookup tables for macro and meta programming techniques with either DSL creation and|or basic ruby hacking for fun.