F# Ignite - DNAD2010

1,444 views

Published on

F# Ignite presentation realized at DotNetArchitects Day 2010, in Brazil.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,444
On SlideShare
0
From Embeds
0
Number of Embeds
649
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

F# Ignite - DNAD2010

  1. 1. { F#ture and F#nctional Programming
  2. 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. 3.  Old Paradigm  52 years old  Ignored by MainStream until now. Functional Programming
  4. 4.  New Challenges  Process big amount of data  Escale to Clusters and Cores Functional- Why now?
  5. 5.  Think out of the box  Functional Programming is “safe”  MultiCore and Cloud Computing applications  Functional Programming is obtaning market Why learn another language?
  6. 6. Imperative Vs. Declarative What rather than How
  7. 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. 8. Functional Paradigm  Immutable Data  Ability to compose functions  Functions can be thread as data  Lazy Evalution  Pattern Matching
  9. 9. Immutability “Values are immutable by default” let x = 3 let x = 4 error FS0037: Duplicate definition of value ‘x'
  10. 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. 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))
  12. 12. #Inception Lambda Calculus LISP ML Ocaml Haskell F#
  13. 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. 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. 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
  16. 16. F# 2.0 Functional + Objects + .NET + Async + Parallel + Interactive + Scripting
  17. 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); } } }
  18. 18. let fim = “Obrigado”

×