“Type More, Do Less” – F# ASP.NET MVC 3
19Jan11
EDIT: I had plans on making my own MVC3 project, either hybrid or complete F#, but alas, someone beat me to it.
I recently downloaded a Visual Studio project template enabling F# users to finally do a full-scale ASP.NET MVC3 development project. For those familiar with the default HomeController class (usually seen in the regular C# based ASP.NET MVC3 projects), here’s example code:
namespace FSharpMVC3.Web.Controllers
open System.Web
open System.Web.Mvc
[<HandleError>]
type HomeController() =
inherit Controller()
member x.Index () : ActionResult =
x.ViewData.["Message"] <- "Welcome to ASP.NET MVC!"
x.View() :> ActionResult
member x.About () =
x.View() :> ActionResult
Now, see, isn’t that a lot less code? This is what I’ve been on about regarding F#: It’s clean, gets to the point of the matter, and does more in less lines of code, and with less of the syntactical ceremony that comes with C#, even VB.NET.
Advertisement
Filed under: Programming | Closed

