You are previewing Programming F# 3.0, 2nd Edition.

Programming F# 3.0, 2nd Edition

Cover of Programming F# 3.0, 2nd Edition by Chris Smith Published by O'Reilly Media, Inc.
  1. Programming F# 3.0
  2. Preface
    1. Introducing F#
    2. Who This Book Is For
    3. What You Need to Get Going
    4. How the Book Is Organized
      1. Part I
      2. Part II
      3. Part III
    5. Part IV
    6. Conventions Used in This Book
    7. Using Code Examples
    8. Safari® Books Online
    9. I’d Like to Hear from You
    10. Acknowledgments
  3. I. Multiparadigm Programming
    1. 1. Introduction to F#
      1. Getting to Know F#
      2. Visual Studio 11
      3. F# Interactive
      4. Managing F# Source Files
    2. 2. Fundamentals
      1. Primitive Types
      2. Comparison and Equality
      3. Functions
      4. Core Types
      5. Organizing F# Code
    3. 3. Functional Programming
      1. Understanding Functions
      2. Pattern Matching
      3. Discriminated Unions
      4. Records
      5. Lazy Evaluation
      6. Sequences
      7. Queries
    4. 4. Imperative Programming
      1. Understanding Memory in .NET
      2. Changing Values
      3. Units of Measure
      4. Arrays
      5. Mutable Collection Types
      6. Looping Constructs
      7. Exceptions
    5. 5. Object-Oriented Programming
      1. Programming with Objects
      2. Understanding System.Object
      3. Understanding Classes
      4. Methods and Properties
      5. Inheritance
    6. 6. .NET Programming
      1. The .NET Platform
      2. Interfaces
      3. Object Expressions
      4. Extension Methods
      5. Extending Modules
      6. Enumerations
      7. Structs
  4. II. Programming F#
    1. 7. Applied Functional Programming
      1. Active Patterns
      2. Using Modules
      3. Mastering Lists
      4. Tail Recursion
      5. Programming with Functions
      6. Functional Patterns
      7. Functional Data Structures
    2. 8. Applied Object-Oriented Programming
      1. Operators
      2. Generic Type Constraints
      3. Delegates and Events
      4. Events
    3. 9. Asynchronous and Parallel Programming
      1. Working with Threads
      2. Asynchronous Programming
      3. Asynchronous Workflows
      4. Parallel Programming
      5. Task Parallel Library
    4. 10. Scripting
      1. F# Script Files
      2. Directives
      3. F# Script Recipes
    5. 11. Data Processing
      1. Indexing
      2. Querying
  5. III. Extending the F# Language
    1. 12. Reflection
      1. Attributes
      2. Type Reflection
      3. Dynamic Instantiation
      4. Using Reflection
    2. 13. Computation Expressions
      1. Toward Computation Expressions
      2. Computation Expression Builders
      3. Custom Computation Expression Builders
    3. 14. Quotations
      1. Quotation Basics
      2. Generating Quotation Expressions
    4. 15. Type Providers
      1. Typed Data Versus Typed Languages
      2. Type Providers
  6. IV. Appendixes
    1. A. Overview of .NET Libraries
      1. Visualization
      2. Data Processing
      3. Storing Data
    2. B. F# Interop
      1. .NET Interop
      2. Unmanaged Interop
  7. Index
  8. About the Author
  9. Colophon
  10. Copyright

Chapter 6. .NET Programming

The .NET platform is a general-purpose programming platform that can do more than just object-oriented or functional programming. This chapter covers some additional concepts available when using .NET that will offer advantages when you put them to use in your F# code.

In this chapter, you will learn how to use interfaces to build better abstractions, how to create enums and structs that can help performance, and how to use F#’s object expressions for boosting programmer productivity.

The .NET Platform

Let’s begin our look at .NET-specific concepts by examining the runtime on which .NET applications execute. This will help you understand how to take full advantage of the platform by seeing the features F# gets for free.


The foundation of the .NET platform is the CLI, or Common Language Infrastructure. This is a specification for a runtime system that actually runs your F# code. The F# compiler produces a binary file called an assembly, which is composed of a high-level assembly language called MSIL or Microsoft Intermediate Language.

An implementation of the CLI compiles this MSIL to machine code at runtime to execute the code faster than if it were just interpreted. The compilation happens “just-in-time” as the code is needed, or JIT.

Code that is compiled to MSIL and executed through the JITer is referred to as managed code—as opposed to unmanaged code, which is simply raw machine code (typically from programs written in C or C++).

There are several ...

The best content for your career. Discover unlimited learning on demand for around $1/day.