IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New You lose a lot of power though
Avi talks about this on his blog this week.

[link|http://www.cincomsmalltalk.com/userblogs/avi/blogView?showComments=true&entry=3284695382|http://www.cincomsma...&entry=3284695382]

The Ruby distribution comes with a large amount of C code implementing the underlying language and library semantics: a parser, an interpreter, regular expressions, arrays, hash tables, a numeric tower, and so on. In some cases, like the parser, this code is kept hidden from the Ruby layer: there's no way with a stock Ruby interpreter to get at a Ruby parse tree from Ruby code. This makes certain tools much harder to write - the RDoc documentation generator, for example, has to include its own lexer because it can't access the one that comes with Ruby. It also makes the language much harder to extend, since any change to the way the parser works has to be done in C, and any code that relied on these changes wouldn't run on anybody else's Ruby installation.
...
This may sound like an academic quibble, like a desire for purity for its own sake, but the fact is that the tools available on a Smalltalk system, like the Refactoring Browser, the Debugger (which takes "edit-and-continue" farther than many people can imagine), the various inspectors and explorers and profilers are much, much better than those available for the "scripting" languages like Ruby. I would argue that a large part of the reason for this is the open, accessible, and extensible nature of the system: nobody wants to write those tools in C, and in Smalltalk, you don't have to.

Note that I'm necessarily talking about implementations here, not language specs: clearly in JRuby, the implementation is in Java instead of C, and clearly you could implement the Ruby language with a Smalltalk-style VM (hopefully one with a Smalltalk-style JIT as well, which would bring a 20x or so speed increase to the current Ruby interpreter). But really what I'm talking about is a philosophical difference, not a technical one: to Smalltalkers, it's essential that as much of a system as possible be implemented in Smalltalk, whereas this simply isn't a priority for the scripting language community, and it's the priorities rather than the individual implementations that draw me to Smalltalk.








"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
New Re: You lose a lot of power though
Quoting Avi: there's no way with a stock Ruby interpreter to get at a Ruby parse tree from Ruby code.

Using a stock Ruby interpreter and the ParseTree library (downloaded and installed with the single command "gem install ParseTree"), I can do this ...
require 'parse_tree'\nclass Example\n  def example(arg1)\n    return "Blah: " + arg1.to_s\n  end\nend\np ParseTree.new.parse_tree_for_method(Example, "example")\n
With the output (slightly formatted):
[:defn, :example, \n  [:scope, \n    [:block, [:args, :arg1], \n      [:return, \n        [:call, [:str, "Blah: "], \n                :+, \n                [:array, [:call, [:lvar, :arg1], :to_s]]]]]]]
The above is pretty cutting edge stuff coming from Ryan Davis. Ryan is building a compiler that will take a simplified version of Ruby and compile it directly to C. The goal is to do something pretty close to what Squeak does with its implementation language. Combine this with the MetaRuby project and you get pretty close to what Avi is talking about. We're not there yet, but I definitely see movement in that direction.

Again quoting Avi: the Refactoring Browser, the Debugger [...], the various inspectors and explorers and profilers [...] nobody wants to write those tools in C

I'm not sure why he thinks C is required for those projects. One of my first projects in Ruby was a simple class browser, Rails has an embedded interactive debugger where you can communicate with your web deployed code, all in just plain Ruby. And now that Ryan has made it easy to reify the Ruby parse information, a refactoring browser becomes a real possibility.

Grant, none of this stuff is comparable to what Smalltalk offers now, but I think real reason the two language cultures are so different is not because of the need for C, but because Smalltalk is image based and Ruby is not.
--
-- Jim Weirich jim@weirichhouse.org [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Is the parser written in Ruby?
Just curious. It does sound like Ruby is headed in the right direction in terms of having more and more of itself written in itself.



"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
New Just like C# and .Net
</runs for cover>
bcnu,
Mikem

Eine Leute. Eine Welt. Ein F\ufffdhrer.
(Just trying to be accepted in the New America)
New Re: Is the parser written in Ruby?
Ryan's ParseTree library uses the current Ruby interpreter parser that is written in C. In fact, he doesn't actually parse the data, but just pulls out the parse tree that Ruby has already parsed. It just reifies that parse data as as Ruby objects so they can be accessed and processed by Ruby code.

This is enough to do refactoring browser type of stuff. Not enough to play syntax god with the language itself.

I believe that Ruby 2.0 will have a full Ruby invocable parser (but I'm don't know how much will be C code and how much will be Ruby code).

AFAICT, Matz himself is not too interested in the MetaRuby stuff, but he has always been willing to "take what works well" and incorporate it into Ruby. I'm hoping that Ryan's work will eventually make it into the core. Ryan's goal is to be able to write the Ruby libraries (and perhaps the VM) in a simple subset of Ruby that can easily be compiled to C code. My understanding is this is that same approach Squeak uses. Ryan has some great examples where he dynamically grabs a method object and calls both "to_c" (producing C code) and "to_ruby" (reproducing the original ruby source ... sans comments). It's pretty cool.

--
-- Jim Weirich jim@weirichhouse.org [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
     The joys of .Net - (johnu) - (53)
         Ick. - (admin) - (18)
             It warn't me - (jb4)
             Here != IWETHEY in this case. -NT - (admin)
             So what's a good java IDE to use? - (drewk) - (15)
                 Intellij IDEA - (admin) - (14)
                     While learning, free is good - (drewk) - (10)
                         Checkout Eclipse - (johnu) - (9)
                             I despise that program - (tuberculosis) - (6)
                                 I'm no psychic... - (pwhysall) - (3)
                                     You ought to work in the circus -NT - (tuberculosis) - (1)
                                         I come here. Next best thing. -NT - (pwhysall)
                                     I think IDEA is good - I use it when I do Java - (tuberculosis)
                                 ICLRPD (new thread) - (ben_tilly)
                                 It's all relative - (johnu)
                             I am such a lUser - (drewk) - (1)
                                 Look at the pretty COLORS! -NT - (jb4)
                     Concur - (jb4) - (2)
                         As a rabid, frothing Emacs user - (admin)
                         Another vote for Intellij - (bluke)
         Listeners - (warmachine) - (1)
             Re: Listeners - (johnu)
         Crap and Double Crap -NT - (tuberculosis) - (10)
             Interesting thing is... - (johnu) - (9)
                 Umm... Squeak? -NT - (folkert) - (1)
                     Re: Umm... "up to date Windows UIs" -NT - (altmann)
                 Looked at Dolphin? - (tuberculosis)
                 Going farther afield - (ben_tilly) - (5)
                     You lose a lot of power though - (tuberculosis) - (4)
                         Re: You lose a lot of power though - (JimWeirich) - (3)
                             Is the parser written in Ruby? - (tuberculosis) - (2)
                                 Just like C# and .Net - (mmoffitt)
                                 Re: Is the parser written in Ruby? - (JimWeirich)
         #3 will be possible in C# 2.0 - (altmann) - (1)
             But it's gonna be great! -NT - (mmoffitt)
         C# 2.0 - (johnu) - (17)
             Strong typing bites itself in the gonads once again - (FuManChu) - (2)
                 Any production quality dynamic languages for .NET yet - (johnu) - (1)
                     Not that I've seen. - (FuManChu)
             Objects to the rescue - (johnu) - (13)
                 Sounds reasonable - (FuManChu) - (6)
                     Wibble, wibble... - (CRConrad) - (4)
                         Semantics - (FuManChu) - (3)
                             A) Almost everything is, when you get down to it; and B)... - (CRConrad) - (2)
                                 English is simply too flexible to be used well. - (FuManChu) - (1)
                                     Yeah, I know - but it makes for a funny contrast... - (CRConrad)
                     Re: Sounds reasonable - (johnu)
                 Same old bullshit. - (CRConrad) - (5)
                     I second that -NT - (warmachine)
                     Re: Same old bullshit. - (johnu) - (3)
                         And WTF does that have to do with anything? - (CRConrad) - (2)
                             Re: And WTF does that have to do with anything? - (johnu) - (1)
                                 OK, so what you originally said was only half the story. - (CRConrad)
         OT: Inner/outer classes. (new thread) - (pwhysall)

Pain is merely nature's way of hurting you.
142 ms