thinking in geek tagline’s are so web2.0

Posted
18 April 2007 @ 5pm

Tagged
c#, ruby, smalltalk

Turtles all the way down and the CLR (or JVM)

Avi makes some comments here about the differences between scripting languages and “real” languages. His main point is that real languages (or maybe their VM’s) are fast enough to be extended in themselves. Now while I think I understand his underlying point - which is to attempt to clarify why smalltalk rocks (which it does) - I’m not sure I agree with his analysis.

As far as I’m aware - there’s no C required to run ruby on rails applications1. Rails is 100% ruby - aka Ruby extended in Ruby. It might be that thats not the kind of extension he’s talking about - and in fact it’s not - he gives a Ruby example of the problem he’s talking about - creating a custom array subclass. Here’s an example of his code in C#.

public class MyArray : Array {} //error CS0644: 'MyArray' cannot derive from special class 'System.Array'

  • You can’t extend C# (or Java) in the way he’s trying to in Ruby.
  • You can’t add methods to java.lang.Object or System.Object - although extension methods in C# 3.0 will let you add behaviour - but not state.
  • You can’t modify the language syntax, add keywords etc… (no macro like features) the way you can in LISP or smalltalk.

Conclusion: C#/Java (well - the JVM/CLR) are not turtles all the way down. In fact - Ruby is more deep turtle wise than C# or Java (ruby supports modules/mixins which are somewhat like extension methods in C# 3.0).

Update: Ayende likes what Avi says - looks like we might not agree on this.

  1. I’m aware mongrel - a http server which is used for serving rails apps - has pieces written in C. This is equivalent to IIS for ASP.NET apps (and webrick == casinni - the VS.NET built in webserver vs Ruby’s pure Ruby webserver). []

2 Comments

Posted by
David V.
19 April 2007 @ 10am

Your C# example is flawed. Ruby’s Array is equivalent to the C# ArrayList, the C# array is a low-level system class, and isn’t extensible just like you can’t directly access most interpreter data structures in Ruby.


Posted by
josh
20 April 2007 @ 8pm

I’m not suggesting that Ruby’s and c#’s array classes are equivalent.

The fact that you can’t extend low-level system “things” (classes or interpreter data structures) in either ruby or C# is my point.

In smalltalk - you can modify the VM with smalltalk. Avi exploits this fact to add continuations to Squeak so that Seaside can support very sophisticated flow control. This is an extremely low level system modification - and one that is trivial in smalltalk.


Leave a Comment

Rails as the Visual Basic of the Web Monorail + URL Rewriting