Microsoft’s first step in WPF/E?

I saw this today over on ZDNet: “Hints of support for WPF/E on Mac”. One of Microsoft’s developers, Nathan Herring, has announced he’s moving from the CoreCLR team to work on what’s called miniCLR for the Mac. Supposedly it’ll be just enough of the CLR to run WPF/E. Hey, maybe they’ll come out with a miniCLR for Windows clients as well. I’m sure a lot of people don’t like having to download and install 20 Meg. for the complete .Net Framework just to run a GUI application.

You can see some video of WPF/E here.

I look forward to what Microsoft will do with this. It will be nice to be able to run .Net rich clients on another platform besides Windows. My guess is that Microsoft will only port WPF/E to the Mac. In my opinion they don’t really have an incentive yet to port it to any other platform.

Discovering Ruby

I’ve heard about the Ruby programming language off and on for a few years. Recently I happened upon an online tutorial for it. The tutorial runs a Ruby interpreter inside your browser. It takes you through a series of steps to introduce you to the language. It keeps track of what you’re doing so that when you finish a step, it automatically moves on to the next one. Pretty slick.

I gave it a try, and I must say I’m impressed. By the end it had me setting up a rudimentary blog that displayed inside an HTML popup window. It basically took all of 10 lines of code (with some library support)! The language packs power in a simple-to-program structure. I saw quickly that the language was designed to be intuitive. Rather than giving the runtime environment a bunch of types to manipulate, in order to get the result I want I just basically tell it what I want. It can figure out what types things need to be.

I’ve heard some people say that the syntax looks like Scheme. I don’t understand this. As I explain below, the language operates in a way that is Scheme-like, but the syntax looks more like Smalltalk to me.

It contains properties of an imperative, object-oriented language, and of a functional language. By “functional language” I mean a language that operates on the rule that the value of a variable, or input to a function, is always the result returned from a function, though symbols or data elements have their own intrinsic values. There are some built-in functions to get things going.

All variables in Ruby are dynamically typed. A variable’s type is determined by what value is assigned to it. This is like what’s done in Javascript. All data has its own intrinsic object type, and it has methods associated with it. .Net programmers will be familiar with this, but Ruby takes it a little bit further. For example, you can do something like the following in Ruby:

today – 2.weeks

to get the date from 2 weeks ago. It’s possible to do something almost as simple in C# (from .Net 1.1), but it’s not as concise:

DateTime.Today() – TimeSpan.FromDays(14.0);

You can do things with numeric constants in C# similar to what you can do with them in Ruby, such as “2.toString()”, since “2” resolves to an Int32 type, which has this method. However, there’s nothing like “2.weeks” in C#, converting “2” to a time-span object with a value representing 2 weeks time.

You can also construct your own classes in Ruby.

Every expression or command returns some kind of value automatically. This enables you to string together nested statements where each “feeds” off the other.

There’s been a lot of news in some circles about Ruby on Rails. “Rails” or “RoR,” as it’s called for short, is a web application framework for Ruby. It adds some capabilities to Ruby that make it more of a web application platform that web developers would be familiar with. I’ve heard that the meaty contribution it makes is database connectivity.

.Net projects

I did a little research and found some .Net projects that allow .Net developers to use Ruby.

There’s the Ruby/.Net bridge. This provides an interoperability layer between the .Net runtime and the Ruby runtime. You can program in Ruby, using the Ruby interpreter, and use .Net Framework classes. It says that this works “vice versa” as well, but I don’t see how that’s done, from their documentation.

(Update 9/23/08 – Apparently the Ruby/.Net bridge is gone. Maybe it was mirrored on another site and is still available, but the official site at “SaltyPickle” is gone.)

There’s the open source Ruby.Net compiler from Gardens Point at the Queensland University of Technology in Brisbane Australia. It actually compiles Ruby code into MSIL that’s runnable on the .Net 2.0 runtime. It doesn’t produce optimized code, nor does it guarantee interoperability with other .Net languages, at this point. It was released recently in its first beta.

There’s also RubyCLR, which currently operates similarly to Ruby/.Net bridge.

I haven’t used any of them yet (just found them). From the looks of things, I would consider all of these projects as works in progress. In other words, use at your own risk if you’re planning on using any of them for production software projects. They might be fun to play around with though.

Though there is much excitement in some circles in the software world about Ruby, I did just a quick survey on Dice of Ruby programming jobs nationwide, and the number is paltry. I suspect one reason it hasn’t gotten more popular is due to its unorthodox programming style. Most programmers are used to imperative, Algol-like languages, like C/C++, Java, C#, VB 6, VB.Net, etc. It takes some work to get used to a functional language. In the case of Ruby the effort to understand it might be worth it.