Overview: Understanding Functional Concepts
Applies to: Functional Programming
Published: January 2010
Summary: This overview explains the most important concepts of functional programming. It demonstrates what they look like in F# and how they change the way code is written.
This topic contains the following sections.
This article is an excerpt from Real World Functional Programming: With Examples in F# and C# by Tomas Petricek with Jon Skeet from Manning Publications (ISBN 9781933988924, copyright Manning Publications 2009, all rights reserved). No part of these chapters may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—electronic, electrostatic, mechanical, photocopying, recording, or otherwise—without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.
Functional programming is, in many ways, different from what developers are used to in C# or other imperative object-oriented languages. To become a great F# developer, you need to understand just a few basic concepts. The concepts are quite simple but they are needed when thinking about almost everything in F# and functional programming.
The following overview articles discuss the fundamental functional concepts in depth.
This overview looks at one of the important functional concepts—immutability. It explains how immutable programs are written and introduces F# concepts such as functions and recursion.
Functional programs are written as expressions rather than as a sequence of statements. This overview shows examples of this style and demonstrates how this simplifies reasoning about code.
F# is a statically-typed language where every expression has a type. This overview explains why we don't need to write types explicitly in F# and also introduces most important types used in functional programming.
To download the code snippets shown in this article, go to http://code.msdn.microsoft.com/Chapter-1-Introducing-F-c967460d