This document discusses F# and functional programming. F# is a multi-paradigm language from Microsoft that supports functional, object-oriented and imperative programming. It provides powerful and flexible syntax that allows for shorter, more elegant code and increased programmer productivity. Functional programming emphasizes declaring what computations should be done rather than how to do them, and it enables easy parallel and asynchronous programming for scalability. The document provides examples of code in F# compared to C# and outlines some benefits of functional languages.
3. What is F# About?
New functional language from Microsoft
Why is Microsoft investing in functional
programming?
F# and functional programming ‐ Radek Míka 3
4. What is F# About?
New functional language from Microsoft
Why is Microsoft investing in functional
programming?
Powerful language
Simplicity
Programmers productivity
Scalability
F# and functional programming ‐ Radek Míka 4
5. What is F# About?
F# is multi‐paradigm .NET language
Functional programming
Object oriented programming
Imperative programming
.NET ‐> built on CLI
Statically typed language
F# and functional programming ‐ Radek Míka 5
7. Functional Programming
SAYING “WHAT” RATHER THAN “HOW”
“how” = imperative way
“what” = declarative way (better readable)
Immutability
Parallel & async. programming (scalability)
F# and functional programming ‐ Radek Míka 7
8. Functional Languages
Expressible languages
But why?
Easy testing
Scalability
Processing large sets of data
Effectiveness
F#, C#, Haskel, Erlang, Scala, Lisp
F# and functional programming ‐ Radek Míka 8
9. Code
//F# //C#
open System using System;
let a = 2
namespace ConsoleApplication1
Console.WriteLine a
{
class Program
{
static int a()
{
return 2;
}
static void Main(string[] args)
{
Console.WriteLine(a);
}
More Noise }
Than Signal! }
F# and functional programming ‐ Radek Míka 9
10. F# Pleasure C# Pain
abstract class Command
type Command = Command of (Rover ‐> unit) {
public virtual void Execute();
}
let BreakCommand = abstract class MarsRoverCommand : Command
Command(fun rover ‐> rover.Accelerate(‐1.0)) {
protected MarsRover Rover { get; priv
let TurnLeftCommand =
Command(fun rover ‐> rover.Rotate(‐5.0<degs>)) public MarsRoverCommand(MarsRover rov
{
this.Rover = rover;
}
}
class BreakCommand : MarsRoverCommand
{
public BreakCommand(MarsRover rover)
: base(rover)
{
}
public override void Execute()
{
Rover.Rotate(‐5.0);
}
}
class TurnLeftCommand : MarsRoverCommand
{…
F# and functional programming ‐ Radek Míka 10