A New Web for .NET: FubuMVC and Chad’s Response to AR Considered Harmful

I caught a few interesting posts this week that reminded me of an unfinished series on .NET web frameworks I started in 2009. The series, as it was initially planned, ties in very well with a recent post from Chad Myers, who responded to another post claiming the ActiveRecord (and Rails) Considered Harmful.

Before I go any further, I want to make very clear that I’m a fan of Rails and think that it is an incredibly useful framework for building certain applications. I think the same is true of ASP.NET MVC. I’ve used and use both. However, I don’t think that means these are the best approach for tackling HTTP.

Chad’s post was very good. I agree with almost all of his points. In particular, I think he hit several very important points, the biggest of which was his emphatic quote:

INHERITANCE IS FAIL FOR MOST DESIGNS, BUT NEVER MORE SO THAN IN WEB/MVC FRAMEWORKS!

Then from his list of criteria for a “perfect” web framework:

  • Completely compositional: 100% agree
  • [Resource]-based: I take a slightly different direction here. We talk about “models”, but if you are really thinking about HTTP, you should be thinking in terms of resources. They are similar in many ways, notably in the sorts of “behaviors” (in FubuMVC terms) that should be composed with the “model.” Honestly, it’s the “model” term itself that seems totally overloaded or at least at the wrong layer when talking about a framework. If you have a model, you’re probably really dealing with something more like DDD than the HTTP application layer.
  • Not have any notion of controllers: Agree. In MVC-style frameworks, they are sort of necessary, but if you break away from MVC, you’ll find there are better alternatives.
  • Action-based: I’m all about using functions, or delegates, as 'Request -> 'Response handlers. I also agree that these should generally be kept simple, relying on compositional helpers, middlewares, or whatever you want to call them to perform model-binding and response generation. Granted, this is slightly different than what Chad is talking about, and I’ll cover my thoughts on this in more detail below.
  • Minimized code-in-view: templates are helpful, but the ability to add a lot of logic is just asking for trouble. I really like the tags-as-code approach taken by WebSharper and Wing Beats.
  • Independent of other frameworks: Definitely limit other dependencies and play nice with others.
  • Testing as a first-class citizen: At least allow whatever the consumer writes to easily write real unit tests. Generally, the only reason you can’t do this is related to hosting, so make sure the hosting model is not necessary to test the application.

Okay, so I obviously skipped some items. I don’t think the other items are bad; I just don’t think they are necessary for a “perfect” web framework.

  • Total adherence to principles: This sounds really good. I don’t disagree, really, but exactly which principles? Principles sometimes change. Some make sense in one approach to software development and are sort of non-issues in others. Look at the description of SOLID and its relevance to F#. You’ll note that many of the principles are sort of non-issues.
  • Statically typed: I don’t really see this as a requirement. HTTP is inherently dynamic. You could build a useful, fairly complex HTTP application using only dictionaries. Reliance upon type serialization is misguided. How do you generate accurate Atom or HTML from a static type? You don’t. You need a template or some other custom output. At the same time, I have grown to like static type-checking, espeically in F#, and F# 3.0’s Type Providers prove you can do a lot, even type check regular expressions. I just don’t see this as a strict requirement.
  • Based on IoC: I love IoC in C# applications. I can’t imagine life without it. However, I’ve found that I don’t even think about IoC when writing F# applications. It’s just not a concern. Higher-order functions, computation expressions, and other functional-style approaches generally render IoC a non-issue. So again, I don’t really see this as a requirement but a case of “use the right tool for the job.”
  • Mostly model-based conventional routing: This is a totally fine solution. I take issue with having any single prescription for routing. There are so many ways to handle this, and in the end it doesn’t matter. If you stick to a resource-oriented approach, which perhaps is the goal Chad is getting at, then your routing should be pretty straightforward and simple. One thing many routers miss is the connection between different methods assigned to a single uri. So far as I know, OpenRasta and Web Api are the only frameworks that return the appropriate HTTP status codes for missing methods on an uri or unmatched Accept header, among other things. FubuMVC may allow this through a convention.
  • One Model In, One Model Out: When using MVC, I generally like this approach. However, I again don’t see this as a requirement. I’m not convinced a model is always necessary. Again, HTTP is quite dynamic, and it’s sometimes easier to work directly with a request or pull out several different “objects” from a request to help generate a response. Though perhaps 'Request and 'Response are models and the point is moot. 🙂

Now for the biggest divergence: I generally prefer to be explicit rather than lean on conventions. In C#, I typically go for conventions because of the amount of noise required by the C# syntax. With F#, I’m able to be explicit without suffering syntax noise overload. The same is true for many dyanmic languages like Ruby and Python. So I disagree with both the Conventional top-to-bottom and Zero touch points. Again, I’m not fully opposed, but I definitely don’t see these as requirements at the framework level. Sure, include it as an option, especially if, as in FubuMVC, you can redefine the conventions to suit your needs. This could just mean use the right tool for the job, or it could mean you should take a simpler approach and build your own conventions as wrapper functions.

If you think this sounds like a prescription to write a lot more code, I’ll show a comparison:


let echo _ (content: HttpContent) =
respond HttpStatusCode.OK (“Content-Type“ "text/plain")
<| new StringContent(content.ReadAsStringAsync().Result)
// This creates a resource, but echo2 is an application in itself.
let resource = route "/" <| post echo

view raw

echo.fsx

hosted with ❤ by GitHub


let echo2Core = id // This is the "input model -> output model" function.
let echo2MapFrom _ (content: HttpContent) = content.ReadAsStringAsync().Result
let echo2MapTo body =
respond HttpStatusCode.OK (“Content-Type“ "text/plain")
<| new StringContent(body)
let echo2 = echo2MapFrom >> echo2Core >> echo2MapTo
// This creates a resource, but echo2 is an application in itself.
let resource = route "/" <| post echo2

view raw

echo2.fsx

hosted with ❤ by GitHub

Two extra lines (in this instance) and it’s likely with a more complex example you wouldn’t see much of a difference in terms of line count. I doubt this is true with C#, so don’t take this as a statement that this is the “one, true way.” I like conventions when using C#, just as I like IoC in C#.

In any case, definitely check out FubuMVC as an alternative to MVC. There’s a lot to like, and the FubuMVC team has done an incredible job building a terrific platform. I’ll try to highlight a few others in the upcoming weeks, but while you’re looking at Fubu, also checkout OpenRasta and ServiceStack.

A New Web for .NET: FubuMVC and Chad's Response to AR Considered Harmful

I caught a few interesting posts this week that reminded me of an unfinished series on .NET web frameworks I started in 2009. The series, as it was initially planned, ties in very well with a recent post from Chad Myers, who responded to another post claiming the ActiveRecord (and Rails) Considered Harmful.

Before I go any further, I want to make very clear that I’m a fan of Rails and think that it is an incredibly useful framework for building certain applications. I think the same is true of ASP.NET MVC. I’ve used and use both. However, I don’t think that means these are the best approach for tackling HTTP.

Chad’s post was very good. I agree with almost all of his points. In particular, I think he hit several very important points, the biggest of which was his emphatic quote:

INHERITANCE IS FAIL FOR MOST DESIGNS, BUT NEVER MORE SO THAN IN WEB/MVC FRAMEWORKS!

Then from his list of criteria for a “perfect” web framework:

  • Completely compositional: 100% agree
  • [Resource]-based: I take a slightly different direction here. We talk about “models”, but if you are really thinking about HTTP, you should be thinking in terms of resources. They are similar in many ways, notably in the sorts of “behaviors” (in FubuMVC terms) that should be composed with the “model.” Honestly, it’s the “model” term itself that seems totally overloaded or at least at the wrong layer when talking about a framework. If you have a model, you’re probably really dealing with something more like DDD than the HTTP application layer.
  • Not have any notion of controllers: Agree. In MVC-style frameworks, they are sort of necessary, but if you break away from MVC, you’ll find there are better alternatives.
  • Action-based: I’m all about using functions, or delegates, as 'Request -> 'Response handlers. I also agree that these should generally be kept simple, relying on compositional helpers, middlewares, or whatever you want to call them to perform model-binding and response generation. Granted, this is slightly different than what Chad is talking about, and I’ll cover my thoughts on this in more detail below.
  • Minimized code-in-view: templates are helpful, but the ability to add a lot of logic is just asking for trouble. I really like the tags-as-code approach taken by WebSharper and Wing Beats.
  • Independent of other frameworks: Definitely limit other dependencies and play nice with others.
  • Testing as a first-class citizen: At least allow whatever the consumer writes to easily write real unit tests. Generally, the only reason you can’t do this is related to hosting, so make sure the hosting model is not necessary to test the application.

Okay, so I obviously skipped some items. I don’t think the other items are bad; I just don’t think they are necessary for a “perfect” web framework.

  • Total adherence to principles: This sounds really good. I don’t disagree, really, but exactly which principles? Principles sometimes change. Some make sense in one approach to software development and are sort of non-issues in others. Look at the description of SOLID and its relevance to F#. You’ll note that many of the principles are sort of non-issues.
  • Statically typed: I don’t really see this as a requirement. HTTP is inherently dynamic. You could build a useful, fairly complex HTTP application using only dictionaries. Reliance upon type serialization is misguided. How do you generate accurate Atom or HTML from a static type? You don’t. You need a template or some other custom output. At the same time, I have grown to like static type-checking, espeically in F#, and F# 3.0’s Type Providers prove you can do a lot, even type check regular expressions. I just don’t see this as a strict requirement.
  • Based on IoC: I love IoC in C# applications. I can’t imagine life without it. However, I’ve found that I don’t even think about IoC when writing F# applications. It’s just not a concern. Higher-order functions, computation expressions, and other functional-style approaches generally render IoC a non-issue. So again, I don’t really see this as a requirement but a case of “use the right tool for the job.”
  • Mostly model-based conventional routing: This is a totally fine solution. I take issue with having any single prescription for routing. There are so many ways to handle this, and in the end it doesn’t matter. If you stick to a resource-oriented approach, which perhaps is the goal Chad is getting at, then your routing should be pretty straightforward and simple. One thing many routers miss is the connection between different methods assigned to a single uri. So far as I know, OpenRasta and Web Api are the only frameworks that return the appropriate HTTP status codes for missing methods on an uri or unmatched Accept header, among other things. FubuMVC may allow this through a convention.
  • One Model In, One Model Out: When using MVC, I generally like this approach. However, I again don’t see this as a requirement. I’m not convinced a model is always necessary. Again, HTTP is quite dynamic, and it’s sometimes easier to work directly with a request or pull out several different “objects” from a request to help generate a response. Though perhaps 'Request and 'Response are models and the point is moot. 🙂

Now for the biggest divergence: I generally prefer to be explicit rather than lean on conventions. In C#, I typically go for conventions because of the amount of noise required by the C# syntax. With F#, I’m able to be explicit without suffering syntax noise overload. The same is true for many dyanmic languages like Ruby and Python. So I disagree with both the Conventional top-to-bottom and Zero touch points. Again, I’m not fully opposed, but I definitely don’t see these as requirements at the framework level. Sure, include it as an option, especially if, as in FubuMVC, you can redefine the conventions to suit your needs. This could just mean use the right tool for the job, or it could mean you should take a simpler approach and build your own conventions as wrapper functions.

If you think this sounds like a prescription to write a lot more code, I’ll show a comparison:


let echo _ (content: HttpContent) =
respond HttpStatusCode.OK (“Content-Type“ "text/plain")
<| new StringContent(content.ReadAsStringAsync().Result)
// This creates a resource, but echo2 is an application in itself.
let resource = route "/" <| post echo

view raw

echo.fsx

hosted with ❤ by GitHub


let echo2Core = id // This is the "input model -> output model" function.
let echo2MapFrom _ (content: HttpContent) = content.ReadAsStringAsync().Result
let echo2MapTo body =
respond HttpStatusCode.OK (“Content-Type“ "text/plain")
<| new StringContent(body)
let echo2 = echo2MapFrom >> echo2Core >> echo2MapTo
// This creates a resource, but echo2 is an application in itself.
let resource = route "/" <| post echo2

view raw

echo2.fsx

hosted with ❤ by GitHub

Two extra lines (in this instance) and it’s likely with a more complex example you wouldn’t see much of a difference in terms of line count. I doubt this is true with C#, so don’t take this as a statement that this is the “one, true way.” I like conventions when using C#, just as I like IoC in C#.

In any case, definitely check out FubuMVC as an alternative to MVC. There’s a lot to like, and the FubuMVC team has done an incredible job building a terrific platform. I’ll try to highlight a few others in the upcoming weeks, but while you’re looking at Fubu, also checkout OpenRasta and ServiceStack.

A New Web for .NET: WCF Web APIs

If the sight of “WCF” in the title makes you want to click your back button, stop. Just wait. I tell you that I have been there, too. This isn’t that WCF. Well, it is, sort of. If you listened to our last several podcasts, you heard Glenn Block talk about his transition from MEF to the WCF team and that he was going to be working on REST. Well, it’s here. Before you continue reading, I recommend you:

  1. Download the bits
  2. Read Glenn’s posts (yes, there is a link in that last one on how to wire up the Razor view engine)
  3. Watch the RESTFest keynote and video

I know, That’s probably asking a lot. I promise, you won’t be disappointed. The WCF team has done a bang up job on this, and it’s continuing to improve. For my part, I’ve been working on making the transition to F# smoother.

Why am I excited about this? I see the new Web APIs as a fantastic, Rack+Sinatra-like platform for .NET. No, it’s not exactly the same, but it fulfills a very similar function. The new Web APIs give you a to-the-metal experience, with control over everything in a statically-typed environment. (Yes, even the headers!) A lot of the WCF abstraction has been stripped away so that HTTP, the application protocol, is available in its fullness.

“Sounds great,” you say, but I already have MVC for that. True, and yes, you can do JSON services with MVC. However, HTTP is primarily a messaging protocol, which WCF fits nicely. MVC is primarily an abstraction for building web pages in HTML. So again, yes there is overlap. Give it a whirl, however, and you’ll probably start seeing, as so many in the Ruby community, that the simpler abstraction offered by the WCF Web APIs is more efficient for REST services and even web application environments. (More on that last part towards the end of the series.)

Simple, yes, but you can already see the same power offered by Rack. Middleware is just a step around the corner. A simple Sinatra-like DSL would make this trivially easy to compose application parts. The WCF Web APIs will offer a composition mechanism, though that is still in the works.

What do I mean? Well, let’s look at a trivial example:

For completeness, here’s the FuncHost wrapper and other type declarations I’m using:


module Main
open System
open System.Collections.Generic
open System.Net
open System.Net.Http
open Microsoft.ServiceModel.Http
open FSharp.Http
[<EntryPoint>]
let main(args) =
let app (request:HttpRequestMessage) = async {
// do some stuff with the request
return "200 OK", Seq.empty, "Howdy!"B |> Seq.map (fun b -> b :> obj) }
let processors = [| (fun op -> new PlainTextProcessor(op, MediaTypeProcessorMode.Response) :> System.ServiceModel.Dispatcher.Processor) |]
let host = new FuncHost(app, responseProcessors = processors, baseAddresses = [|"http://localhost:1000/&quot;|])
host.Open()
printfn "Host open. Hit enter to exit…"
printfn "Use a web browser and go to %sroot or do it right and get fiddler!" baseurl
System.Console.Read() |> ignore
host.Close()
0

view raw

FSharpServer.fs

hosted with ❤ by GitHub


namespace FSharp.Http
open System
open System.Collections.Generic
open System.Net
open System.Net.Http
open System.ServiceModel
open System.ServiceModel.Web
// NOTE: This is not the actual OWIN definition of an application, just a close approximation.
type Application = Action<HttpRequestMessage, Action<string, seq<KeyValuePair<string,string>>, seq<obj>>, Action<exn>>
module Owin =
let fromAsync (app:HttpRequestMessage -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>) : Application =
Action<_,_,_>(fun request (onCompleted:Action<string, seq<KeyValuePair<string,string>>, seq<obj>>) (onError:Action<exn>) ->
Async.StartWithContinuations(app request, onCompleted.Invoke, onError.Invoke, onError.Invoke))
/// <summary>Creates a new instance of <see cref="Processor"/>.</summary>
/// <param name="onExecute">The function to execute in the pipeline.</param>
/// <param name="onGetInArgs">Gets the incoming arguments.</param>
/// <param name="onGetOutArgs">Gets the outgoing arguments.</param>
/// <param name="onError">The action to take in the event of a processor error.</param>
/// <remarks>
/// This subclass of <see cref="System.ServiceModel.Dispatcher.Processor"/> allows
/// the developer to create <see cref="System.ServiceModel.Dispatcher.Processor"/>s
/// using higher-order functions.
/// </remarks>
type Processor(onExecute, ?onGetInArgs, ?onGetOutArgs, ?onError) =
inherit System.ServiceModel.Dispatcher.Processor()
let onGetInArgs' = defaultArg onGetInArgs (fun () -> null)
let onGetOutArgs' = defaultArg onGetOutArgs (fun () -> null)
let onError' = defaultArg onError ignore
override this.OnGetInArguments() = onGetInArgs'()
override this.OnGetOutArguments() = onGetOutArgs'()
override this.OnExecute(input) = onExecute input
override this.OnError(result) = onError' result
/// <summary>Creates a new instance of <see cref="FuncConfiguration"/>.</summary>
/// <param name="requestProcessors">The processors to run when receiving the request.</param>
/// <param name="responseProcessors">The processors to run when sending the response.</param>
type FuncConfiguration(?requestProcessors, ?responseProcessors) =
inherit Microsoft.ServiceModel.Http.HttpHostConfiguration()
// Set the default values on the optional parameters.
let requestProcessors' = defaultArg requestProcessors Seq.empty
let responseProcessors' = defaultArg responseProcessors Seq.empty
// Allows partial application of args to a function using function composition.
let create args f = f args
interface Microsoft.ServiceModel.Description.IProcessorProvider with
member this.RegisterRequestProcessorsForOperation(operation, processors, mode) =
requestProcessors' |> Seq.iter (processors.Add << (create operation))
member this.RegisterResponseProcessorsForOperation(operation, processors, mode) =
responseProcessors' |> Seq.iter (processors.Add << (create operation))
/// <summary>Creates a new instance of <see cref="AppResource"/>.</summary>
/// <param name="app">The application to invoke.</param>
/// <remarks>The <see cref="AppResource"/> serves as a catch-all handler for WCF HTTP services.</remarks>
[<ServiceContract>]
[<ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)>]
type AppResource(app:Application) =
let matchStatus (status:string) =
let statusParts = status.Split(' ')
let statusCode = statusParts.[0]
Enum.Parse(typeof<HttpStatusCode>, statusCode) :?> HttpStatusCode
let handle (request:HttpRequestMessage) (response:HttpResponseMessage) =
app.Invoke(request,
Action<_,_,_>(fun status headers body ->
response.StatusCode <- matchStatus status
response.Headers.Clear()
headers |> Seq.iter (fun (KeyValue(k,v)) -> response.Headers.Add(k,v))
response.Content <- new ByteArrayContent(body |> Seq.map (fun o -> o :?> byte) |> Array.ofSeq)),
Action<_>(fun e -> Console.WriteLine(e)))
/// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
/// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
/// <remarks>Would like to merge this with the Invoke method, below.</remarks>
[<OperationContract>]
[<WebGet(UriTemplate="*")>]
member x.Get(request, response:HttpResponseMessage) = handle request response
/// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
/// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
[<OperationContract>]
[<WebInvoke(UriTemplate="*", Method="POST")>]
member x.Post(request, response:HttpResponseMessage) = handle request response
/// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
/// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
[<OperationContract>]
[<WebInvoke(UriTemplate="*", Method="PUT")>]
member x.Put(request, response:HttpResponseMessage) = handle request response
/// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
/// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
[<OperationContract>]
[<WebInvoke(UriTemplate="*", Method="DELETE")>]
member x.Delete(request, response:HttpResponseMessage) = handle request response
/// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
/// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
[<OperationContract>]
[<WebInvoke(UriTemplate="*", Method="*")>]
member x.Invoke(request, response:HttpResponseMessage) = handle request response
/// <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
/// <param name="app">The application to invoke.</param>
/// <param name="requestProcessors">The processors to run when receiving the request.</param>
/// <param name="responseProcessors">The processors to run when sending the response.</param>
/// <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>
type FuncHost(app, ?requestProcessors, ?responseProcessors, ?baseAddresses) =
inherit System.ServiceModel.ServiceHost(AppResource(app), defaultArg baseAddresses [||])
let requestProcessors = defaultArg requestProcessors Seq.empty
let responseProcessors = defaultArg responseProcessors Seq.empty
let baseUris = defaultArg baseAddresses [||]
let config = new FuncConfiguration(requestProcessors, responseProcessors)
do for baseUri in baseUris do
let endpoint = base.AddServiceEndpoint(typeof<AppResource>, new HttpMessageBinding(), baseUri)
endpoint.Behaviors.Add(new Microsoft.ServiceModel.Description.HttpEndpointBehavior(config))
/// <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
/// <param name="app">The application to invoke.</param>
/// <param name="requestProcessors">The processors to run when receiving the request.</param>
/// <param name="responseProcessors">The processors to run when sending the response.</param>
/// <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>
new (app: HttpRequestMessage -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>, ?requestProcessors, ?responseProcessors, ?baseAddresses) =
let baseUris = defaultArg baseAddresses [||] |> Array.map (fun baseAddress -> Uri(baseAddress))
new FuncHost(Owin.fromAsync app, ?requestProcessors = requestProcessors, ?responseProcessors = responseProcessors, baseAddresses = baseUris)

view raw

FuncHost.fs

hosted with ❤ by GitHub

Go try it out. Let the team know what you think! If you want to show off what you are doing, consider sending a pull request to http://wcfhttpcontrib.codeplex.com/, where we’ll be adding middleware and other common components for your convenience. More on middleware next time.

A New Web for .NET

A number of things have been happening these last few years in the .NET community in relation to the Web. Specifically, OpenRasta and FubuMvc demonstrated 1) new approaches to web development in a static-typed world and 2) that other developers were growing tired of the existing options. Since then a host of new micro-frameworks, generally inspired by the Ruby dynamic duo of Rack and Sinatra, have popped up on github. In addition, several new server options have begun cropping up, most notably Kayak and Manos de Mono, both of which use an event loop a la node.js and primarily targeting Mono.

Microsoft has not be sitting idly by either. The WCF team is working on a new Web API to provide WCF developers simpler, more direct control over HTTP services. This is no slouch effort either. In fact, aside from OpenRasta, it may be the most thorough HTTP implementation available.

While exciting on their own, the best news, imho, is the .NET HTTP Abstractions group, started by Scott Koon. This group has been working on a standard, currently called Open Web Interface for .NET, or OWIN. It’s intent is to define a common interface by which any application can talk to any server. The idea comes from the Web Server Gateway Interface (Python) and Rack. The primary difference in this and other similar specs is the inclusion of asynchronous network I/O as a primary concern. Discussions are still underway and include nearly all of the developers of the aforementioned projects, as well as some members of the ASP.NET team.

If you are a F# fanboy, such as myself, you will be happy to know that F# is not silent in this space. WebSharper is now in its second iteration, and my own projects, Frack and Frank, are making nice headway. Frack is now a web server, similar in spirit to node.js. Frank is, as the name implies, a Sinatra-inspired clone that takes cues from the Haskell Snap framework. If you are interested in parsing and agent-based development, you’ll find more examples of how F# handles these things as these two projects progress.

Expect to find more posts (shock!) coming soon describing in more detail the WCF Web APIs, OWIN, Frack, Frank, and more. In the meantime, join the discussion on the .NET HTTP Abstractions group!

Framework Design

I’ve been spending some time lately reading and listening to talks on Framework Design and Language Design. In particular, I’ve found Krzysztof Cwalina’s blog and PDC talk very enlightening. I also rather enjoyed the PDC panel discussion on the Future of Programming Languages. I find this all very fascinating, but in a recent desire to apply pragmatism, I wondered how any of this could really help me in my day-to-day development tasks. Except to program to the framework’s design for efficiency and consistency, I had a hard time with that question.

However, with regard to my new hobby of extracting reusable patterns from apps I’m building, I really appreciate the idea of extracting these patterns into small, reusable and interoperable parts. In the Future of Programming panel, Jeremy Siek noted the importance of libraries working with other libraries (e.g., ASP.NET with ASP.NET MVC or ASP.NET AJAX with many Javascript libraries). Some libraries, however, implement their patterns too tightly around certain patterns to the exclusion of others. This can increase speed—Ruby on Rails comes to mind—but removes the ability to use other patterns or pluggable libraries–such as with Merb or Ramaze–to keep to the Ruby frameworks.

JB and I are attempting to extract patterns from our current project to enable faster development in future WPF/Silverlight projects. The current plan is to build our library around Composite WPF, an excellent library from Microsoft’s Patterns and Practices group for building rich client applications in WPF, and soon in Silverlight. We’re planning to build a business layer framework with service interfaces to the Composite WPF library and use the Repository pattern to allow for various data access methodologies.

That’s a loose description of our plan. What do you think? Do you see any flaws? For instance, we are currently not thinking about interchangeable UI libraries, even though a few, such as Silverlight.FX, have started to appear. Are we missing any existing business layer libraries? (I am not familiar with any myself, but I imagine someone has created one somewhere.) We are interested in your thoughts!

Anders Hejlsberg on the Future of C# (PDC 2008)

In case you are missing PDC like me, you can find some great videos of the sessions on Channel 9. I found Anders’ comments on the future of C# to be incredibly exciting. You can watch it here. I’d love to hear feedback on whether you to are excited about the new features he points out for C# 4.0:

  • Dynamically Typed Objects
  • Optional and Named Parameters
  • Improved COM Interoperability
  • Co- and Contra-variance

Update: You can now download and try out the CTP for Visual Studio 2010 and the .NET Framework 4.0 from Microsoft Connect!