KEMBAR78
Can F# make us better as .NET developers? | PPTX
CAN F# MAKE US BETTER
AS .NET DEVELOPERS?
KEVIN AVIGNON
COMPANIES USING F# IN THEIR TOOLSET
KEY POINTS OF THE LANGUAGE
Conciseness
• Less coding noise: No curly braces, semicolons and so on
Convenience
• Many tasks are simpler in F# such as list processing, comparison & equality and state machines
Correctness
• Powerful type system backing up the language which prevent common errors such as nulls.
Completeness
• Although F# is functional, it supports other styles making it easy to communicate with websites, databases and so on.
Concurrency
• Asynchronous programming is very easy as is parallelism because of the nature of functional programming
TESTIMONIALS
RACHEL REESE – SENIOR SOFTWARE ENGINEER @ JET
We’ve compared C# and F# solutions to
decide with which to move forward. (F# won)
Easier to work it. Can solve issues in 3-4 lines and make
the code cleaner.
Moved from 30k to 2.5 M users in three
months
Barely stressed our systems
DOM SYME – PRINCIPAL ENGINEER @ MICROSOFT
F#’S POWERFUL TYPE INFERENCE
MEANS LESS TYPING, MORE
THINKING
TYPE-INFERRED CODE IS EASILY
REFACTORED
IMMEDIATE SCALING TO MASSIVE
DATA SETS
PRODUCTIVITY
GAINS FROM
RUDIMENTARY
FEATURE SET
OUT-OF-THE-BOX BEHAVIOR FOR TYPES
• F# types have built-in immutability
• To have mutable values, you need to use the mutable keyword
• Most F# types have built-in pretty printing
• No need to override ToString() -> Pretty printing is given for free
• Most F# types have built-in structural equality
• No need for IEquatable to validate equality between types
• Most F# types are automatically comparable
• No need for IComparable to sort types
LOW OVER-HEAD FOR TYPE DEFINITION
• Every time you need a structure, you create a type
• Not reusing strings and list for instance.
• Systems are more type-safe, more self-documenting
• Changing those types would cause compile-time errors
• Small visual footprint to create a type
POWERFUL PATTERN MATCHING
• More flexible than a simple switch/case statements
• Match expressions, values, conditions
• Assign and extract values at the same time
• Identify design issues to the developer
• Missing case – New choice because of a change of requirement for instance
• An impossible case – Existing choice has been removed
• Not handling a case is a compile-time error, not a run-time error.
ADVANCED REWARDS
FROM F#
UNITS OF MEASURE
• It’s a type
• Operations can happen only with types with the same unit (float<m/s>)
• Values can be added/subtracted/multiplied/divided
• They’re not a part of .NET type system
• C# & VB.NET don’t have access to units of measure
TYPE PROVIDERS
• Component that provides types, properties, and methods
• Match a specific interface
• Loaded as .NET type at design time
• The provider can adapt to change to its data source
• Input can come in different form
• JSON file, URL point to a service, connection string to a data source
• Uniform mechanism for data access
• Ex: SQL, CSV, XML, JSON, R & Powershell
WHY SELECTING F# IS A GOOD IDEA
Variables should not be
allowed to change their
type.
1
Objects containing the
same values should be
equal by default.
2
Comparing objects of
different types is a
compile-time error.
3
Objects must always be
initialized to a valid
state. Not doing so is a
compile-time error.
4
Once created, objects
and collections must be
immutable.
5No nulls allowed.6
Missing data or errors
must be made explicit
in the function
signature.
THANK YOU!

Can F# make us better as .NET developers?

  • 1.
    CAN F# MAKEUS BETTER AS .NET DEVELOPERS? KEVIN AVIGNON
  • 2.
    COMPANIES USING F#IN THEIR TOOLSET
  • 3.
    KEY POINTS OFTHE LANGUAGE Conciseness • Less coding noise: No curly braces, semicolons and so on Convenience • Many tasks are simpler in F# such as list processing, comparison & equality and state machines Correctness • Powerful type system backing up the language which prevent common errors such as nulls. Completeness • Although F# is functional, it supports other styles making it easy to communicate with websites, databases and so on. Concurrency • Asynchronous programming is very easy as is parallelism because of the nature of functional programming
  • 4.
  • 5.
    RACHEL REESE –SENIOR SOFTWARE ENGINEER @ JET We’ve compared C# and F# solutions to decide with which to move forward. (F# won) Easier to work it. Can solve issues in 3-4 lines and make the code cleaner. Moved from 30k to 2.5 M users in three months Barely stressed our systems
  • 6.
    DOM SYME –PRINCIPAL ENGINEER @ MICROSOFT F#’S POWERFUL TYPE INFERENCE MEANS LESS TYPING, MORE THINKING TYPE-INFERRED CODE IS EASILY REFACTORED IMMEDIATE SCALING TO MASSIVE DATA SETS
  • 7.
  • 8.
    OUT-OF-THE-BOX BEHAVIOR FORTYPES • F# types have built-in immutability • To have mutable values, you need to use the mutable keyword • Most F# types have built-in pretty printing • No need to override ToString() -> Pretty printing is given for free • Most F# types have built-in structural equality • No need for IEquatable to validate equality between types • Most F# types are automatically comparable • No need for IComparable to sort types
  • 9.
    LOW OVER-HEAD FORTYPE DEFINITION • Every time you need a structure, you create a type • Not reusing strings and list for instance. • Systems are more type-safe, more self-documenting • Changing those types would cause compile-time errors • Small visual footprint to create a type
  • 10.
    POWERFUL PATTERN MATCHING •More flexible than a simple switch/case statements • Match expressions, values, conditions • Assign and extract values at the same time • Identify design issues to the developer • Missing case – New choice because of a change of requirement for instance • An impossible case – Existing choice has been removed • Not handling a case is a compile-time error, not a run-time error.
  • 11.
  • 12.
    UNITS OF MEASURE •It’s a type • Operations can happen only with types with the same unit (float<m/s>) • Values can be added/subtracted/multiplied/divided • They’re not a part of .NET type system • C# & VB.NET don’t have access to units of measure
  • 13.
    TYPE PROVIDERS • Componentthat provides types, properties, and methods • Match a specific interface • Loaded as .NET type at design time • The provider can adapt to change to its data source • Input can come in different form • JSON file, URL point to a service, connection string to a data source • Uniform mechanism for data access • Ex: SQL, CSV, XML, JSON, R & Powershell
  • 14.
    WHY SELECTING F#IS A GOOD IDEA Variables should not be allowed to change their type. 1 Objects containing the same values should be equal by default. 2 Comparing objects of different types is a compile-time error. 3 Objects must always be initialized to a valid state. Not doing so is a compile-time error. 4 Once created, objects and collections must be immutable. 5No nulls allowed.6 Missing data or errors must be made explicit in the function signature.
  • 15.