2. Rodrigo Vidal
Twitter: @rodrigovidal
Blog: www.rodrigovidal.net
Focus on Software Architecture
F# and IronRuby/Ruby enthusiast.
.NetArchitects – Rio de Janeiro , user group member
Professional Scrum Developer
Quem sou eu?
3. Old Paradigm
52 years old
Ignored by MainStream until now.
Functional Programming
4. New Challenges
Process big amount of data
Escale to Clusters and Cores
Functional- Why now?
5. Think out of the box
Functional Programming is “safe”
MultiCore and Cloud Computing applications
Functional Programming is obtaning market
Why learn another language?
7. Another way of thinking
List<string> res = new List<string>();
foreach(Product p in Products) {
if (p.UnitPrice > 75.0M) {
res.Add(String.Format("{0} - ${1}",
p.ProductName, p.UnitPrice));
}
}
var res = from p in Products
where p.UnitPrice > 75.0M
select string.Format("{0} - ${1}",
p.ProductName, p.UnitPrice);
return res;
8. Functional Paradigm
Immutable Data
Ability to compose functions
Functions can be thread as data
Lazy Evalution
Pattern Matching
10. Side-Effects
A side effect
Modifies some state
Has observable interaction with calling functions
Has observable interaction with the outside world
Example: a function or method with no return value
let mutable x = 3
let y = x*3
x <- 4
let z = x*3
11. Composing Functions
f(x) = 3x+2
g(y) = 4y-1
Z = g(f(2)) = ?
f(x)
g(x)
let f x = 3*x + 2
let g y = (4*y) - 1
let z = g(f(2))
13. Languages Evolution
0
2
4
6
8
10
12
0 2 4 6 8 10 12
Usefulness
Safety
C#
Nirvana
Haskell
LINQ
C#, VB,
Java
LINQ Nirvana
Haskell
http://channel9.msdn.com/posts/Charles/Simon-Peyton-Jones-Towards-a-Programming-Language-Nirvana/
C#, VB, Java, C are
imperative
programming
languages. Very
useful but can change
the state of the world
at anytime creating
side effects.
Nirvana!
Useful and
Safe
Haskell is Very Safe, but
not very useful. Used
heavily in research and
academia, but rarely in
business.
F#
14. What´s is F#?
Functional language developed by Microsoft Research
By Don Syme and his team, who productized Generics
Based on OCaml (influenced by C# and Haskell)
15. F# Evolution
2002
F# language
design started
2005 January
F# 1.0.1 releases
to public
2005 November
F# 1.1.5 with VS
2005 RTM support
2009 October
VS2010 Beta 2,
CTP for VS2008
& Non-
Windows users
2010
F# is
“productized”
and baked into
VS 2010
17. F# 2.0
//F#
open System
let a = 2
Console.WriteLine a
//C#
using System;
namespace ConsoleApplication1
{
class Program
{
static int a()
{
return 2;
}
static void Main(string[] args)
{
Console.WriteLine(a);
}
}
}