Showing posts with label Boo. Show all posts
Showing posts with label Boo. Show all posts

There is new project on codeplex called BooLangStudio that adds Boo as supported language in Visual Studio 2008. It is still in it's infancy but the basics are there, Class Library and Console Application projects are support, as is basic syntax highlighting. The project was created by Jeff Olson, but there are other contributors, for example James Gregory who has begun porting over some intellisense support from his Boo Visual Studio plugin.

The progress is looking good:

image 

 

I have been wishing for some Boo visual studio integration for a long time. I thought I would try to contribute to BooLangStudio, however the source is on github. That means I had to learns some Git :)

It wasn't that bad actually, I downloaded msysgit and followed this Guide. The cool thing about Git is it's distributed nature which makes it very different from Subversion. The first thing I did, since I wanted to contribute was to fork Jeff Olson's repository. This is very simple, just register on github and you click the fork button:

image

When you fork a github repository you get your own remote repository that you can push commits two. After I had created my fork I could ask git to create local clone of that repository. Git does not have local "working copies" but local full repositories. This means that you can view history logs, do commits, merges, branching all locally, without any network connection.

When I had done a commit I did a push to my github remote repository. Github has very nice commit/diff visualizations:

 image

 

In your local repository you can configure a list of other remote repositories that you can pull from (pull = fetch+merge). I noticed that James Gregory had a fork where he committed his initial work on intellisense, and I wanted to try this out. So I created a local branch, added James Gregory's fork as a remote repository and pulled his changes into that branch. The cool thing is that merging in git keeps the complete history of the commits you merge, it almost looks like James Gregory committed directly to my repository.

Everything is done at the command line, there is a TortoiseGit in the works I think but I am not sure what state it is in. Here is an example of how you can merge changes from a remote repository:

$ git remote add jagregory git://github.com/jagregory/boolangstudio.git
$ git checkout -b jagrefory/master
$ git pull jagregory master
$ git checkout master
$ git merge jagregory/master

Github has a very cool network graph that shows forks and commits and where they came from:

image

The red dots on my line represents the commits that I merged from the jagregory branch. If you hover over a a dot it will show the commit info! Git and the whole concept of a distributed source control system is very cool and interesting. The usability aspects are not quite there yet, it's a lot of git commands and parameters to learn, and it takes some time to get how the concepts work.

The ideas and concepts that the Microsoft research team has realized in spec# are too great not to be included in a future version of C# !

Just look a this example:

public static int Subtract(int x, int y)
     requires x > y;
     ensures result > y;
{
     return x - y;
}

It is not only the runtime aspects of spec# that are exiting. It is the amazing level of static analysis that they have implemented that at compile time validates (across many method boundaries) that requirements are uphold.

C# has really evolved a lot in the last two iterations (especially in 3.0), and think this fast evolution has given it a good edge compared to other static languages (java). But why stop now? Here are a few more things I would like in C# 4.0 :)

Extensible compilation pipeline:

The Boo .NET language has this concept of an extensible compilation pipeline that allows for really powerful usage scenarios. With it you can extend the language with new keyword constructs and attributes that actually manipulate the abstract syntax tree (AST). Here is an example where I have extended Boo with some constructs for design by contract:

[ensures(total > 0)] 
def Add(int value):
    requires value > 0
    total += value

Extending the Boo language like this is very trivial. For example the requires keyword is implemented like this:

macro requires:
  return [|
    if $(requires.Arguments[0]) == false:
        raise ArgumentException("requires precondition failed")
    |]

This is just a simple example, you can do more powerful stuff. A Boo macro is very different from C++ macros. The Boo macros operate on the compiler's AST and can query the object model and modify it in very powerful ways. The open compiler architecture makes Boo a language suitable for writing domain specific languages. I doubt that something like this will be implemented in C# though since new compiler features are more likely to break existing implementations. Something I think the C# team are not allowed to do.

Dynamic method invocation and duck typing:

If a class implements the IQuackFu interface in Boo you can call methods on it that are resolved at runtime. This is similar to method missing in ruby. The IQuackFu interface looks like this:

public interface IQuackFu
{
  object QuackGet(string name, object[] parameters);
  object QuackSet(string name, object[] parameters, object value);
  object QuackInvoke(string name, params object[] args);
}

This interface can for example be used as front to an xml document, allowing you to access elements as properties. I think the C# team is actually considering something like this if you are to believe the rumours from the MVP Summit.

Anyone else having ideas or a whish list for C# 4.0?