Welcome to SpellCoder Sign in | Join | Help

For the past 5 years agile development mantra have been drilled into programmers heads and great, now the meme says “no, it’s not working” (read: Decline and Fall of Agile Development)

Do you know what this means?

  • A new round of books written why Agile wasn’t that good anyway.
  • A replacement for Agile Development is imminent. How about Kaizen for software development?
  • A new round of books about how Kaizen is different from Agile development methodology and why the authors used it and it works 10 times better than Agile (and it’s based on Toyota lean manufacturing system – which makes lots of good cars, with robots!).

 

And the cycle goes on and on. We are all fashionistas, changing fads and fashion every a couple of years.

 

Check out this excellent Windows Azure overview by Dare.

 

The infrastructure looks nice and it makes available a lot of stuff that needed to be configured by hand. But still, the biggest work in making RESTful oriented application in .NET (cloud or no cloud)  is still the mind numbing work required to properly provide support for REST APIs  via proper error messages etc. Right now the work for parsing XML messages will have to be done by hand (LINQ for XML helps) if you care about your document format (which you should); and the XSD only validation support in .NET is disappointing. This is where Mono comes the rescue with its RELAXNG support (including Compact Syntax)

element card {
  element name { text },
  element email { text }
}

instead of the mind numbing exercise of editing XSD or yet another XML based document validation markup.

There are still a big room of opportunity for less suck DocumentValidation/DataQuery technology on the XML front.  If you ever dealt with document heavy architecture like what I’ve been doing for the past 9 months, you’ll realize that document format design is just a small slice of the overall work required to develop a scalable application that play wells with the web.

I am excited about two things in Microsoft PDC 2008, no it’s not Windows Azure or Windows 7. The cloud infrastructure is nice but cloud is just an infrastructure architecture problem – and frankly I trust Amazon to get this right than Microsoft.  I am more interested in technologies that helps making software construction faster and more reliable, either in the way of libraries that bring useful capabilities or new languages that implement concepts that makes programming more fun and productive.

The Oslo programming ecosystem (MGrammar, MSchema and MGraph) and C# 4.0 Dynamic are the two newest development that really make a difference. C# 4.0 dynamic system reduce certain stupid patterns that we have to deal with as C# programmer in dealing with multiple domain problems (I will address this is another post). C# 4.0 dynamic however represents something that is familiar for people that are already dabbling in DLR based languages such as IronPython and IronRuby. M is something else altogether.

Oslo technology is defined as a tool, a language and a repository. In this post I’m talking about the language part of Oslo, because that’s the part that I think makes the biggest difference. Yes, the “quadrant” visual tool allow you to use pictures, etc – but really, if you want to get something done in programming, a paragraph of text is worth a thousand pictures.

Essentially M  enables people to create their own languages in the form of Domain Specific Languages (from simple to highly sophisticated one) in much straightforward manner. Yes, you can create your own DSL already right now in various  multitude of ways (just google for DSL toolkits – XText for example) in variety of different languages and platform. Ruby is well known as DSL friendly language and so is Boo; they make creating Internal DSL more pleasant due to certain characteristic in their language (such as no requiring bracket for method passing or the support for meta programming). For external DSL, you have to resort to the nitty gritty work of creating your own lexer and parsers using the excellent ANTLR and then execute the resulting AST to your runtime system.

M takes care of this lexer and parsers part in an elegant way by create a specific language dedicated for it which they call MGrammar. They also provide an editor called Intellipad  so you define your DSL in an interactive way. With M, you define your language in M Grammar, pass a DSL source file and it will return you an AST graph that you can do whatever you please with it. It’s three steps DSL. No more messing around with code generated lexers and parsers for most scenarios and that’s something to celebrate about.

Check this simple tutorial on how to define a DSL for todo  list in MGrammar.

Watch Don Box’s presentation about MSchema in PDC. This is a must watch presentation to get a  grasp on the concept of MSchema in building model.

Join MSDSLs if you are interested to learn more about M.

Microsoft is killing LINQ To SQL and apparently WF 4.0 will not be compatible with WF 1.0.

Here’s a rule of thumb of using Microsoft technologies.

Trust the language guys and run time guys,  be wary of everybody else especially the bloody data access team.

Man, Matt Warren must be pissed. This is his second or third ORM effort got cancelled for the past 7 years.

Download this video of Don Box and Chris Anderson running through M language (mp4)

They discussed the high level concepts behind M. This is a must watch to get a traction in understanding the M language.

So you have your OSLO SDK installed and your Intellipad running smoothing on your screen.  Well, let’s get busy.

Let’s remember a simple factoid: module is the basic organization structure in M language. The following code is the smallest unit of M language

module Commerce

{

 

}

In your Intellipad, press ctrl \ and type SetMode(“MMode”) to start your model mode.

Off course right now it does nothing. In M, you define a type by using the type keyword and in this example, we are going to create an enumerator type.

module Commerce

{

     type CustomerLevel {“Exclusive”, “Bargain Hunter”, “Frugal”};

}

That’s it for now;you have created your first M enumerator.

Finally there is a way on how to use tuple as it ought to be.

In C# 4.0, you can do the following

dynamic GetTuple()
{
   return new { FirstName : “John”, LastName : “Adams” };
}

dynamic myTuple = GetTuple();

Console.WriteLine (myTuple.FirstName); //Look at this beauty

 

Update:

Remember that anonymous type is an immutable type. Once you set the value at creation, they cannot be changed.

One word, wow.

 

class C 

{ 

  public dynamic myField;      

  public dynamic MyProp { get; set; } 

  public dynamic MyMethod(dynamic d) { return d.Foo(); } 

   public delegate dynamic MyDelegate(dynamic d); 

} 

 

You can find more https://blogs.msdn.com/cburrows/archive/2008/10/27/c-dynamic.aspx, https://blogs.msdn.com/cburrows/archive/2008/10/28/c-dynamic-part-ii.aspx and https://blogs.msdn.com/cburrows/archive/2008/10/29/c-dynamic-part-iii.aspx

Join Mdsls group for in depth discussion about Microsoft M language (as part of Oslo technology), including mgrammar, mschema and mgraph. We'll talk smack about Intellipad there as well.

http://groups.google.com/group/MDSLs/

M Language team blog is located here http://blogs.msdn.com/mlanguage

The Oslo technology is revolutionary. There I said it. I will dedicate the next four weeks dissecting the capabilities of the M language and the MGrammar languge for DSL buildling. I have been reading through the early language specification furiously and man, this is a real deal. For now, check out the marketing kids' word at http://www.modelsremixed.com/. Download the SDK (a tiny 15MB download) at http://code.msdn.microsoft.com/oslo
Check out the new C# 4.0 language features here.

They are dynamic type keyword, optional and named parameters, dynamic import and variance.

They are nice but the biggest surprise maybe the IDynamicObject which allows an object to respond to dynamic properties/methods like method_missing in Ruby.


 

Well, DLR hosting API has been all over the place and some of the obvious convenient methods in IronPython 1.1 such as CreateMethod disappears. The latest DLR hosting spec was released on Jan 3, 2008 and it was out of sync from the latest IronPython 2 Beta 1.

 

I spent a couple of hours yesterday to investigate the new DLR hosting implementation in IronPython 2 Beta 1 and have successfully figured out the "new ways" of DLR hosting API.

 

Copy these codes and run it in your environment. Replace the "X2" or "2" suffix in some of the namespace. I had to do this because I am working on a CMS that works on ASP.Net Futures 2007 release with IronPython 2 Alpha 1 as the implemenation for the asp.net support  and I have a code execution engine that I want to upgrade from IronPython 1.1 to the latest beta. Naturally those two IronPython runtime clashed and I have to recompile the IronPython Beta 2 with new namespace and assembly name.

 

The following codes demonstrate of the capabilities for the "hosting scenario level 2" (per DLR hosting spec). Enjoy.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Scripting2.Hosting;
using IronPythonX2.Hosting;
using IronPythonX2.Modules;
using IronPythonX2.Runtime;
using IronPythonX2.Runtime.Exceptions;
using MbUnit.Framework;
using Microsoft.Scripting2;
using Microsoft.Scripting2.Runtime;

namespace HostingRunner
{

    public class Simple
    {

        ScriptEngine _engine;
        ScriptScope _scope;
        public Simple()
        {
            _engine = ScriptRuntime.Create().GetEngine("py");

            var sy = new SymbolDictionary()
            {
                { SymbolTable.StringToId("n"), 10}
            };
            _scope = _engine.CreateScope(sy);
        }

        public string ExecuteBLOCKED EXPRESSION
        {
            _scope.SetVariable("n", 10);

            var code = @"
x = 1 + 1
";
            var compiledCode = _engine.CreateScriptSourceFromString(code, Microsoft.Scripting2.SourceCodeKind.Statements);

            try
            {
                compiledCode.Execute(_scope);
                return _scope.GetVariable<int>("x").ToString();
            }
            catch (Microsoft.Scripting2.SyntaxErrorException e)
            {
                return e.Line + " : " + e.Column + " : " + e.Message;
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }

        public string CreateMethod()
        {
            var code = @"
def function():
    return 1 + 1 + 200

";
            var sourceCode = _engine.CreateScriptSourceFromString(code, Microsoft.Scripting2.SourceCodeKind.Statements);

            sourceCode.Execute(_scope);

            return _engine.GetVariable<Func<int>>(_scope, "function")().ToString();

        }

        public string CallOneCodeMultipleScope()
        {
            _scope.SetVariable("n", 16);

            var code = @"
def function():
    return 1 + n

";
            var compiledCode = _engine.CreateScriptSourceFromString(code, Microsoft.Scripting2.SourceCodeKind.Statements).Compile();
            compiledCode.Execute(_scope);

            var firstResult = _engine.GetVariable<Func<int>>(_scope, "function")();

            var secondScope = _engine.CreateScope();
            secondScope.SetVariable("n", 10);

            var secondResult = _engine.GetVariable<Func<int>>(_scope, "function")();

            return (firstResult + secondResult).ToString();
        }

        public string CallMultipleExecutionOverASingleScope()
        {
            var code = @"
def function():
    return 1 + 1";

            _engine.CreateScriptSourceFromString(code, Microsoft.Scripting2.SourceCodeKind.Statements).Execute(_scope);

            var code2 = @"
def function2():
    return 10 + function()
";
            var compiledCode = _engine.CreateScriptSourceFromString(code2, SourceCodeKind.Statements).Compile();

            compiledCode.Execute(_scope);

            return _engine.GetVariable<Func<int>>(_scope, "function2")().ToString();
        }

        public string CallLoadExternalAssembly()
        {
            _engine.Runtime.LoadAssembly(System.Reflection.Assembly.LoadWithPartialName("SK.Framework"));

            var code = @"
import clr
clr.AddReference(""SK.Framework"")
from SK.Framework import Unique
";

            _engine.CreateScriptSourceFromString(code, Microsoft.Scripting2.SourceCodeKind.Statements).Execute(_scope);

            var code2 = @"
def function2():
    return Unique.Empty.Value
";
            var compiledCode = _engine.CreateScriptSourceFromString(code2, SourceCodeKind.Statements).Compile();

            compiledCode.Execute(_scope);

            return _engine.GetVariable<Func<int>>(_scope, "function2")().ToString();
        }
    }
}

namespace HostingRunner
{
    [TestFixture]
    public class SimpleTest
    {
        Simple _simple;
        [SetUp]
        public void Setup()
        {
            _simple = new Simple();
        }

        [Test]
        public void TestScope()
        {
            var value = _simple.ExecuteBLOCKED EXPRESSION;

            Assert.IsTrue(value == "2", "value must be equal 1 + 1 instead of " + value);
        }

        [Test]
        public void TestDelegate()
        {
            var value = _simple.CreateMethod();

            Assert.IsTrue(value == "2", "value must be equal 1 + 1 instead of " + value);
        }

        [Test]
        public void TestCompiledCode()
        {
            var value = _simple.CallOneCodeMultipleScope();

            Assert.IsTrue(value == "34", "value must be equal 1 + 1 instead of " + value);
        }

        [Test]
        public void TestMultipleExecution()
        {
            var value = _simple.CallMultipleExecutionOverASingleScope();

            Assert.IsTrue(value == "12", "value must be equal 55 instead of " + value);
        }

        [Test]
        public void TestReference()
        {
            var value = _simple.CallLoadExternalAssembly();

            Assert.IsTrue(value == "-12", "value must be equal 12 instead of " + value);
        }
    }

}

"@Lawrence: IronRuby is 4 people depending on how you measure it. IronPython is less than that depending on how you measure it (which we intend to fix).

@Darren: The Paul Revere anecdote is wonderful. Thanks for the ptr!" (John Lam - IronRuby PM)

"

One of the most powerful features of the ASP.NET MVC framework is its URL routing engine (I covered some of these features here).

This upcoming ASP.NET MVC preview release contains even more URL routing features and enhancements.  You can now use named routes (enabling explicit referencing of route rules), use flexible routing wildcard rules (enabling custom CMS based urls), and derive and declare custom route rules (enabling scenarios like REST resources mappings, etc).

We have also factored out the URL routing infrastructure from the rest of the MVC framework with this preview, which enables us to use it for other non-MVC features in ASP.NET (including ASP.NET Dynamic Data and ASP.NET Web Forms).

"

(MVC Framework Road Map)

 

I'm looking forward to a refactored routing infrastructure so that I can use it on the VPP level instead of using it on the ASP.Net processing level.

 

There have been some talks suggesting Microsoft to stop developing C# and simply move on to a new shiny language based on a reason that C# is becoming more complex and its development is approach a diminishing return.

 

Bleh.

 

I can agree with the sentiment but I think it's a bad idea to stop development for C# at this point because there's a couple of more features that can be added to C# 4.0 that will make it "oh, the greatest programming language of all". People always complain for complexity and only need 20% of the language most of the time; except that everybody uses different 20% of all available facilities in a language. I use IronPython extensively but I use only function, array, hash and tuples most of the time - I haven't defined a Python class for a long long time.

 

1. Add Design by Contract.

I don't know why this hasn't  been implemented yet. Implementing Design by Contract eliminates the need to write a kazillion of stupid kind of Unit Tests and have Unit Tests frameworks to access the meta information made available by DBC to verify the code automatically. Go check Spec# to see what I'm talking about.

2. Add Facility for  Macro support.

C# 3.0 already has Expression Trees and right now people only use it to support creating LINQ provider. I think Anders is preparing some new nemerle Macro facilities to make it easier to do meta programming. I bet you  a gallon of beer on this. There's little sense to present Expression Trees if they just stop here. Why would you have an ability to treat Code as Data and not use it to enable Macro?

3. Introduce Fine Grain Immutability construct - side effect free medicine.

We are already moving to Functional style programming with all the LINQ facilities and stuff, it's time to make one of the core idea of functional programming to be included in the language, immutable data structures. Check out Eric's trial balloon on the idea of new fine grain immutability support or Joe's immutability posts.

4. Instant Data Type

Yeah, I know we are all craving for multiple function return values using anonymous class.  Why not introduce some facility to make the local anonymous type to namespace level, pretty much C# capable of declaring JSON style class definition.

public static var ReturnSomething()
{
   return new { FirstName = "Hello", LastName = "World"};
}

named public InstantType returnVal = ReturnSomething()
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

This way it solves the problem of C# inability to handle heterogeneous data type (other than using casting all over or long generic statement)  - I would kill for a Tuple support but that's less likely.

5. Mixin would be great, maybe Traits too.

6. Add Duck Typing please.

7. Pattern matching.

 

The goal of above features are:

  • Increase software safety by making programmers intent verifiable by compiler.
  • DSL
  • Less typing.
  • Add new ways to do software composition.

 

That's all :)

More Posts Next page »