views:

70

answers:

2

Do all Ruby interpreters follow the same Ruby syntax defined in www.ruby-lang.org?

  • MRI
  • YARV
  • Rubinius
  • JRuby
  • IronRuby

Cause it is the interpreter that defines the Ruby language. Does that mean one interpreter could add a feature/syntatic sugar that other interpreters haven't?

If that is the case, do all interpreters have their own API documentation?

Cause I'm using: http://ruby-doc.org/ruby-1.9/index.html.

Which interpreters are implementing that one?

Could someone shed a light on this topic.

Thanks!

+3  A: 

Do all Ruby interpreters follow the same Ruby syntax defined in www.ruby-lang.org?

Yes, they all use the same syntax. In fact, they actually all use the same parser, or at least a parser that was automatically generated from the same source file.

Cause I'm using: http://ruby-doc.org/ruby-1.9/index.html.

Which interpreters are implementing that one?

At the moment, the only production-ready Ruby execution engine that implements Ruby 1.9 fully is YARV.

JRuby itself is production-ready, and it implements both Ruby 1.8.7 and Ruby 1.9.2, but the Ruby 1.9.2 implementation is not yet complete. IronRuby and Rubinius are also working on implementations of Ruby 1.9.2. MacRuby has a fairly complete Ruby 1.9 implementation, but it is still far from a 1.0 release. MRI doesn't implement Ruby 1.9 and probably never will.

But I don't understand why you are so concerned about the syntax. Syntax differences are trivial to spot: if there were a difference in the syntax, the engine would simply refuse to parse your file and you would know immediately that there is something wrong. Differences in semantics on the other hand are much more dangerous.

Jörg W Mittag
But I need to know what language syntax and syntatic sugar I should follow. All the tutorials out there, which interpreter are they using? I did "rvm install 1.9.2-head". Which interpreter is used?
never_had_a_name
Btw, isn't MRI Ruby's de-facto interpreter? Why wouldn't it support 1.9.2 then? It is built for reading it right?
never_had_a_name
A: 

Which bit of "syntactic sugar" are you referring to?

Keep in mind that ruby has a very small set of keywords. A lot of stuff that seems to be a keyword at first is actually implemented by Kernel (eg require, puts, and raise).

http://apidock.com/ruby/Kernel

Rob