Giraffe brings F# functional programming to ASP.Net Core
- 28 September, 2017 20:00
Giraffe, a micro web framework based on the F# language, is bringing functional-style programming to the development of web services on ASP.Net Core. Although F# is already supported in ASP.Net Core, Giraffe puts greater emphasis on the functional programming style by leveraging features such as higher-order functions.
Likened to the Suave web server but specifically designed to work with Microsoft’s ASP.Net Core web framework, Giraffe is described as a native functional framework for building rich web applications that draws on advanced F# features. F# is an open source functional-first language that Microsoft created to address complex computing problems while producing simple, maintainable code.
Microsoft recently blogged about how to use Giraffe to build a web service with F# and the .Net Core 2.0 development platform. Because Giraffe is built on top of ASP.Net, developers using Giraffe can benefit from Microsoft’s ecosystem while writing applications in a functional way, Giraffe developer Dustin Moris Gorski said. Giraffe currently is in a beta stage of release, with an initial “release to manufacturing” version anticipated in the near future. An improved routing model for Giraffe is being worked on by a contributor to the project but that is not expected to be a breaking change.
“One point which I would really like to stress is that Giraffe is really not meant to be a competing product to other web technologies and particularly not to ASP.Net Core,” Gorski said. “It’s quite the opposite. The single most important goal of Giraffe is to keep its tight integration with ASP.Net Core and heavily rely on it to give developers a broad spectrum of well-tested, well-working and very intuitive features.” The framework can be seen as the functional counterpart of the ASP.Net Core MVC framework, Giraffe documentation states.
While F# already was supported in ASP.Net Core MVC, Giraffe offers a different technical philosophy that leverages F# features such as F# types, higher order functions, and partial application of arguments, said Phillip Carter, who works on F# and .Net at Microsoft. Giraffe, he said, enables development of web API routes in a functional style.
Available under an Apache 2.0 license, Giraffe can be plugged into the ASP.Net Core pipeline via middleware. Formerly called ASP.Net Core Lambda, Giraffe was renamed to better distinguish it from Amazon’s AWS Lambda server-less compute service.