Re.Mark

My Life As A Blog

Archive for June 2009

AIC 2009 Slides available

leave a comment »

As Matt announced, the slides from the Architect Insight Conference 2009 are all now online.  The keynote videos are there too.  As Marc notes, there’s something there for most architectural interests – including my session on Dynamic Languages and Architecture (with what could become my trademark use of translucent black.)

Advertisements

Written by remark

June 16, 2009 at 5:18 pm

Posted in .NET, Architecture, Events, Python, Ruby

Tagged with

Ruby Tuesday #30 : Thoughtworks and Ruby

leave a comment »

I know it’s Friday, but it’s a shame to waste a good title. ..

I thought this article by Martin Fowler about the use of Ruby at Thoughtworks was interesting.  Right at the end there’s an insight into how valuable Ironruby will be to Thoughtworks.  Speaking of Martin Fowler and dynamic languages, it’s also worth checking this post out – it contains some empirical data about how often Thoughtworks developers have to do type checks in Ruby.

Written by remark

June 12, 2009 at 4:54 pm

Posted in Ruby

How to embed IronPython

leave a comment »

I’ve just posted an article about embedding IronPython into your apps as a scripting language. Read it here.

Written by remark

June 10, 2009 at 7:27 pm

Use .NET classes in IronRuby

leave a comment »

Having posted how to use .NET classes in IronPython, I thought I should repeat the exercise in IronRuby.  I figured I’d use the same assembly I built for the IronPython example.  To start IronRuby (which, again, I’m assuming you have already installed) type ir at a command prompt.  You should see something like this:

image

First thing is to require the SampleClasses assembly.  Here’s how:

>>>require ‘c:/lib/SampleClasses.dll’

and you should the following output:

=> true

Let’s import the namespace:

>>>include SampleClasses

and the output this time should be:

=> Object

Next, create an instance of the User class:

>>>a = User.new

which should lead to this reponse:

=> SampleClasses.User

Time to set a property:

>>>a.Name = ‘Bob’

and you’ll see that worked from the response:

=> “Bob”

Of course, you can check if you like:

>>>puts a.Name

which will duly report that our user is called Bob:

Bob
=> nil

It really is that easy.   Now you can go and have some fun with IronRuby and .NET assemblies.

Written by remark

June 4, 2009 at 5:11 pm

Posted in .NET, Ruby

Use .NET classes in IronPython

leave a comment »

It’s really simple to use a .NET class in IronPython.  The first thing to remember is that you’ll need to add a reference (just like you would in .NET).  To do that you use the AddReference method of the clr module.  In the case of an assembly you’ve written, IronPython needs to be able to find it, which means it needs to be in sys.path.  It turns out that you can add the path to your assembly by using the append method of sys.path.  Here’s a simple example.  First, let’s create a simple class called User in C# in a solution called SampleClasses:

namespace SampleClasses

{

    public class User

    {

        public string Name{ get; set;}

        public DateTime DateOfBirth { get; set; }

    }

}

For the sake of simplicity, let’s copy the dll to a folder called lib on the C drive.  OK.  Time to fire up IronPython (which I’m going to assume you’ve already installed.)  Open a command prompt and type “ipy”.  You should see something like the following:

image

Next, let’s ensure the SampleClasses assembly is available to IronPython:

>>>import sys
>>>sys.path.append(‘C:\\lib’)

Once we’ve done that we can add a reference:

>>>import clr
>>>clr.AddReference(‘SampleClasses’)

Now, we need to import the User name from the SampleClasses namespace:

>>>from SampleClasses import User

We’re all set.  Create an instance of user and set one of the properties:

>>>a.User()
>>>a.Name=’Bob’
>>>a.Name
‘Bob’

That’s all there is to it.  Now you can go and experiment with IronPython and classes you’ve already written in .NET.

Written by remark

June 4, 2009 at 2:49 pm

Posted in .NET, c#, Python, Software

Architecture Stuff on MSDN

leave a comment »

Maybe I should have spent more time on the title for this blog post.  Anyway, if you take a look at the Architecture Center on MSDN, you’ll see a new section about projects we have worked on here in DPE in the UK.  So, if you’re interested in some architecture stuff, I’d suggest you take a look.

Written by remark

June 4, 2009 at 1:31 pm

Posted in Architecture

Tagged with