News for hackers. Stuff that matters.
Re:Ruby 2.1.0 preview1 released by twelvechairs on Monday September 23, 2013 @04:15AM (#6429623)
I'm still waiting (4 years now) for method#to_source. sigh

http://bugs.ruby-lang.org/issues/2080

Re:Ruby 2.1.0 preview1 released by cronin101 on Monday September 23, 2013 @09:29AM (#6430684)
I feel your pain, I (part)implemented a lambda parser that will spit out C-style expressions when given basic mathematical ruby expressions if that helps you: https://github.com/cronin101/HaDope/blob/master/lib/parsing/...

E.g. calling with ->(i){ i * (2 + i / 4) } returns 'x * (2 + (x / 4))'

Re:Ruby 2.1.0 preview1 released by cheald on Monday September 23, 2013 @02:22PM (#6433068)
For what it's worth, if you're just looking to get at the innards of a method, Pry does this job admirably.

https://gist.github.com/cheald/6674718

https://github.com/pry/pry/wiki/Source-browsing

Or to get the source as a string:

    > require 'pry'
    > Nokogiri.method(:HTML).source
      => "    def HTML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block\n      Nokogiri::HTML::Document.parse(thing, url, encoding, options, &block)\n    end\n"
Re:Ruby 2.1.0 preview1 released by VeejayRampay on Monday September 23, 2013 @03:02PM (#6433396)
Pry is awesome. You can even navigate your source shell-style and do all sorts of fancy things with it. Great little gem.
Re:Ruby 2.1.0 preview1 released by dkubb on Monday September 23, 2013 @12:17PM (#6431994)
It's not perfect, but I've used sourcify [1] to get Proc#to_source. I would much rather see this built into ruby itself, since there are a bunch of tools I would build with it available, but this works fairly well in practice.

[1] https://github.com/ngty/sourcify

Re:Ruby 2.1.0 preview1 released by transfire on Monday September 23, 2013 @05:24AM (#6429766)
Ha! I have you beat! I've been waiting 7 years for to be able override autoload's require.

https://bugs.ruby-lang.org/issues/7716

In fact, after 10 years of dedication, b/c of this and a few other issues (and attitudes) I don't use Ruby any more.

Re:Ruby 2.1.0 preview1 released by lectrick on Monday September 23, 2013 @08:52AM (#6430451)
Autoload is fundamentally broken because it makes your app state nondeterministic by making state loading and logic interdependent.

I work on a large Ruby software project and we've had to move away from any autoload except for very specific cases for this reason- troubleshooting autoload bugs are the WORST.

Maybe this is the reason it hasn't been looked at.

Re:Ruby 2.1.0 preview1 released by transfire on Monday September 23, 2013 @12:22PM (#6432023)
I wish. There was a window of time when Matz said autoload would be deprecated. But he took that back after Yahuda (I think) addressed some threading issue. I agree with your assessment, but too many big names project use it --RubyGems, Psych, Rails, etc.

I wrote my one load system but have never been able to use it 100% with other projects b/c I could not override autoload require. Though I've begged for years Matz just keeps blowing it off.

Re:Ruby 2.1.0 preview1 released by virtualwhys on Monday September 23, 2013 @07:19AM (#6430081)
What language(s) did you move on to?
Re:Ruby 2.1.0 preview1 released by transfire on Monday September 23, 2013 @12:14PM (#6431972)
I am not 100% settled yet. I am evaluating Elixir and Go right now. There are things I like and don't like about both. I gave Haskell a shot but rejected it altogether --I have better things to do then stare at my monadic navel. But all those aside, I've concluded that the ultimate fallback is simply Javascript/Coffeescript --the syntax isn't as nice as Ruby, but you can't go wrong for interoperability. Oh, also [Crystal](https://github.com/manastech/crystal) looks very promising, but it's too immature as of yet.

Beyond that I've decide it's also time to step up work on my own language. Something I've always wanted to do for a while.

Re:Ruby 2.1.0 preview1 released by virtualwhys on Monday September 23, 2013 @12:48PM (#6432210)
Haskell does indeed look not at all like a language that one "gets" right off the bat, although statically typed monadic operations are, for me, a must have now -- transitioned from Groovy, a poor man's Ruby (as far as MOP is concerned), to Scala a couple of years ago.

Crystal looks pretty interesting, statically typed Ruby with extreme type inference. Of course that begs the question, why not JRuby?

As for JS/CS, I love me some coffeescript, just a drag to debug the fat fingered typos, indentation mishaps, etc. wtf is going on moments.

A TypeScript/Coffeescript hybrid would be truly awesome.

Re:Ruby 2.1.0 preview1 released by transfire on Monday September 23, 2013 @04:55PM (#6434088)
You know what put me over the edge with Haskell? Monads were difficult enough, but one of the first things I wanted to do was randomly shuffle a list. That led me to this: http://www.haskell.org/haskellwiki/Random_shuffle. I knew right then that this was not the kind of language I was interested in.

As for JRuby, fair point, but I'd rather steer clear of Java as much as possible. I have to use Java for Android development and it makes me cry big hippo tears every day.

Re:Ruby 2.1.0 preview1 released by virtualwhys on Tuesday September 24, 2013 @12:40AM (#6436020)
Scala collections library covers pretty much everything you can think of, usually in a concise manner a la Ruby, Python, etc.

scala> Random.shuffle(List(1,2,3)) res7: List[Int] = List(2, 3, 1)

Scala-Android google group may be of interest: https://groups.google.com/forum/#!forum/scala-on-android

Obviously I've been converted to the static side, only client-side remains dynamic for me at present, and that's only because there's not yet a statically typed Coffeescript-like language available.

Re:Ruby 2.1.0 preview1 released by vorg on Monday September 23, 2013 @04:40PM (#6433987)
> Groovy, a poor man's Ruby (as far as MOP is concerned)

...and as far as its static typed mode introduced in version 2, written by only one person but bundled with the dynamic compiler as if it was part of the same software. is concerned. Grales doesnt use any of it and Gradle still ships with Groovy 1.x.

...and as far as a lot of other stuff about Groovy such as its lexer/parser imlemented in Antlr 2.7, two major releases behind Antlr 4, the latest version. is concerned.

Re:Ruby 2.1.0 preview1 released by virtualwhys on Tuesday September 24, 2013 @12:53AM (#6436058)
I spent the better part of 6 months in pure Groovy, getting my feet wet on the JVM, was quite enjoyable to hack around in, the syntax is nicely terse.

The lack of static typing became an issue when I spent 6 months in the underworld (aka Grails in the v1.3 days) attempting to decipher voluminous stack traces whose origins lay somewhere deep in 10 layers of Grails MOP, far from one's reach.

Anyway, I was frustrated with Grails, deeply so; one day on the Grails user group someone mentioned Scala. Had no idea what that was, checked it out, bought the stairway book, started hacking around in the REPL and was quickly sold.

Re:Ruby 2.1.0 preview1 released by MrBra on Monday September 23, 2013 @09:40AM (#6430749)
What have you used Ruby for in these 10 years?
Re:Ruby 2.1.0 preview1 released by transfire on Monday September 23, 2013 @12:22PM (#6432026)
Among other things http://github.com/rubyworks.
Re:Ruby 2.1.0 preview1 released by ksec on Monday September 23, 2013 @05:00AM (#6429707)
It changed from 2.0.0 to next minor. And this is 2.1 already.

What is the course of this delay?

Re:Ruby 2.1.0 preview1 released by steveklabnik on Monday September 23, 2013 @02:25PM (#6433094)
> What is the course of this delay?

Is there a patch?

Re:Ruby 2.1.0 preview1 released by lectrick on Monday September 23, 2013 @08:54AM (#6430465)
How about method(:methodname) returning the actual method object instead of a newly instantiated wrapper class containing the method metadata?
Re:Ruby 2.1.0 preview1 released by zimbatm on Monday September 23, 2013 @09:24AM (#6430661)

    irb(main):001:0> RUBY_VERSION
    => "2.0.0"
    irb(main):002:0> class Foo; def hello; puts "hello"; end; end
    => nil
    irb(main):003:0> X = Foo.new.method(:hello)
    => #<Method: Foo#hello>
    irb(main):004:0> X.class
    => Method
    irb(main):005:0> class Bar; define_method(:hello, &X); end
    => #<Proc:0x007f93d087a2d8 (lambda)>
    irb(main):006:0> Bar.new.hello
    hello
    => nil