DECLARATIVE PROGRAMMING

Functional programming is generally regarded as a style of declarative programming. The target of declarative programming is to specify the goal, the logic of what a program, or a part of a program, should do, without describing the steps necessary to achieve that goal. In other words, it is about leaving choices to the computer when it comes to the details of executing a program, instead of requiring the programmer to specify these. Many types of declarative programming have been accepted into the mainstream over the years.

Domain-specific languages are one example. HTML, XML, and XAML can be regarded as languages that describe documents and data as well as execution instructions. Regular expressions describe complex input and their engines effectively parse and manipulate data. Querying languages such as SQL and the in-code querying functionality of LINQ are variations of declarative programming, as are the code contracts available in .NET 4.0. Functional programming is a less specific type of declarative programming, compared to these examples, but it is still just an extension of ideas that are already quite common today.

Get Functional Programming in C#: Classic Programming Techniques for Modern Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.