and functional programming
Presentation Agenda
1. Motivation & history

2. Features of F# language

3. Abilities of functional programming

4. F# code examples

              F# and functional programming ‐ Radek Míka   2
What is F# About?
 New functional language from Microsoft

 Why is Microsoft investing in functional 
  programming? 




                F# and functional programming ‐ Radek Míka   3
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
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
About History
 Project since 2002 at Microsoft Research

 January 2008 – first CTP

 Full support in Visual Studio 2010




                F# and functional programming ‐ Radek Míka   6
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
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
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
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
Summary
 F# is multi‐paradigm language, mainly functional

      Powerful
      Flexible syntax
      Shorter & elegant code
      Increase productivity
      Parallel & async. programming = extremely easy




                     F# and functional programming ‐ Radek Míka   11
Sources
                             http://www.fsharp.net




•   Real World Functional Programming               •    Programming F# (Chris Smith)
    (Tomas Petricek, John Skeet)



                             F# and functional programming ‐ Radek Míka                 12
Questions


 F# and functional programming ‐ Radek Míka   13
The End


 Radek Míka
 radek@radekmika.cz

Microsoft F# and functional programming

  • 1.
  • 2.
    Presentation Agenda 1. Motivation & history 2.Features of F# language 3. Abilities of functional programming 4. F# code examples F# and functional programming ‐ Radek Míka 2
  • 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
  • 6.
    About History  Project since 2002 at Microsoft Research January 2008 – first CTP  Full support in Visual Studio 2010 F# and functional programming ‐ Radek Míka 6
  • 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
  • 11.
    Summary  F# is multi‐paradigm language, mainly functional  Powerful  Flexible syntax  Shorter & elegant code  Increase productivity  Parallel & async. programming = extremely easy F# and functional programming ‐ Radek Míka 11
  • 12.
    Sources http://www.fsharp.net • Real World Functional Programming  • Programming F# (Chris Smith) (Tomas Petricek, John Skeet) F# and functional programming ‐ Radek Míka 12
  • 13.
  • 14.
    The End Radek Míka radek@radekmika.cz