Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
F#nctional and MultiCore
Programming
Rodrigo Vidal
Quem sou eu?
Rodrigo Vidal
Twitter: @rodrigovidal
Blog: www.rodrigovidal.net
•Focado em Arquitetura de Software e Boas Prá...
Agenda
• MultiCore
• Functional Paradigm
• F# Language
Functional Programming
• Velho Paradigma
• 52 anos hoje
• Ignorado pelo MainStream até agora
Functional – Why now?
• Novo desafios
• Processar grandes quantidades de dados
• Escalabilidade para Cores e Clusters
• De...
Why another language?
• Programação Funcional está por ai a um
longo tempo.
– Não é algo novo
– Tem uma longa história
• P...
“What” rather than “How”
Imperativo Vs. Declarativo
Quem usa ForEach() ?
|
List<string> res = new List<string>();
foreach(Product p in Products) {
    if (p.UnitPrice > 75.0M...
Domain Driven Design
Foco no Core Domain, revelando a
intenção do seu código.
Interfaces Reveladoras de Intenções
Concurrency-Friendly
Imperative-Problems:
•É dificil tornar codigo sequencial em
paralelo.
•É dificil usar “Shared States”...
The Functional Paradigm
• Immutable Data
• Ability to compose functions
• Functions can be thread as data
• Lazy Evalution...
Immutability
“Values are immutable by default”
Side-Effects
– Also knowed as “The Butterfly Effect”
• A side effect
– Modifies some state
– Has observable interaction wi...
Composing Functions
f(x) = 3x+2
g(y) = 4y-1
g(f(2)) = ?
f(x)
g(x)
Motivação
#Inception
Language Evolution
http://channel9.msdn.com/posts/Charles/Simon-Peyton-Jones-Towards-a-Programming-Language-Nirvana/
C#, V...
F# Evolution
What is F#?
• Functional language developed by
Microsoft Research
– By Don Syme and his team, who
productized Generics
– B...
F# 1.0
Functional + Objects + .NET
F# 2.0
Functional + Objects + .NET +
Async + Parallel + Interactive +
Scripting
F# 2.0
Functional + Objects + .NET +
Async + Parallel + Interactive +
Scripting
F# 2.0
• Succinct, Expressive, Functional
– Productive, simple, powerful, and fun language
• Parallel, Explorative, Data-r...
let demo = “Code!”
Let’s Go Parallel
The Free Lunch is Over
Why not 10GHz?
Software
Matrix Revolution
Parallel
Pattern
Library
Resource Manager
Task Scheduler
Task Parallel Library
Parallel LINQ
Threads
Native Concurrency Ru...
Imperative Parallelism
Declarative Data Parallelism
CODE!
Amdahl’s Law (1 / percent of time spent in
sequential processing)
Limits of Parallelism
GPU – Beyond CPU
CODE!
The F#ture
Latest Books about F#
Upcoming SlideShare
Loading in …5
×

F# Functional and MultiCore Programming

2,456 views

Published on

ECODevelopers 2010 Presentation about F# Functional and MultiCore Programming - Rio de Janeiro - Brazil

Published in: Technology
  • Be the first to comment

F# Functional and MultiCore Programming

  1. 1. F#nctional and MultiCore Programming Rodrigo Vidal
  2. 2. Quem sou eu? Rodrigo Vidal Twitter: @rodrigovidal Blog: www.rodrigovidal.net •Focado em Arquitetura de Software e Boas Práticas. •Agilista e entusiasta de F# e IronRuby/Ruby. •Membro ativo do grupo .NetArchitects •Professional Scrum Developer •Presente no maiores eventos do tecnologia do país.
  3. 3. Agenda • MultiCore • Functional Paradigm • F# Language
  4. 4. Functional Programming • Velho Paradigma • 52 anos hoje • Ignorado pelo MainStream até agora
  5. 5. Functional – Why now? • Novo desafios • Processar grandes quantidades de dados • Escalabilidade para Cores e Clusters • Declarative Programming
  6. 6. Why another language? • Programação Funcional está por ai a um longo tempo. – Não é algo novo – Tem uma longa história • Programação Funcional é “safe” – Devemos nos preocupar principalmente quando lidamos com aplicações MultiCore e de Cloud Computing • Programção Funcional está crescendo!
  7. 7. “What” rather than “How” Imperativo Vs. Declarativo
  8. 8. Quem usa ForEach() ? | 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;
  9. 9. Domain Driven Design Foco no Core Domain, revelando a intenção do seu código. Interfaces Reveladoras de Intenções
  10. 10. Concurrency-Friendly Imperative-Problems: •É dificil tornar codigo sequencial em paralelo. •É dificil usar “Shared States” e “Locks”
  11. 11. The Functional Paradigm • Immutable Data • Ability to compose functions • Functions can be thread as data • Lazy Evalution • Pattern Matching
  12. 12. Immutability “Values are immutable by default”
  13. 13. Side-Effects – Also knowed as “The Butterfly Effect” • 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
  14. 14. Composing Functions f(x) = 3x+2 g(y) = 4y-1 g(f(2)) = ? f(x) g(x)
  15. 15. Motivação
  16. 16. #Inception
  17. 17. Language Evolution 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#F#
  18. 18. F# Evolution
  19. 19. What 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)
  20. 20. F# 1.0 Functional + Objects + .NET
  21. 21. F# 2.0 Functional + Objects + .NET + Async + Parallel + Interactive + Scripting
  22. 22. F# 2.0 Functional + Objects + .NET + Async + Parallel + Interactive + Scripting
  23. 23. F# 2.0 • Succinct, Expressive, Functional – Productive, simple, powerful, and fun language • Parallel, Explorative, Data-rich, Algorithmic – Extends the .NET platform to important new audiences • Innovative, Industry/Platform-Leading – Async, parallel, easy-objects, immutability, tuples, units- of-measure • Note: F# is not a replacement for C#/VB/C++ – Complementary, interoperable and augments and builds on .NET as multi-lang platform
  24. 24. let demo = “Code!”
  25. 25. Let’s Go Parallel
  26. 26. The Free Lunch is Over
  27. 27. Why not 10GHz?
  28. 28. Software Matrix Revolution
  29. 29. Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Parallel LINQ Threads Native Concurrency Runtime Managed Libraries ThreadPool DataStructures DataStructures Tools Async Agents Library UMS Threads Microsoft Research Visual Studio 2010 Parallel Debugger Windows Profiler Concurrency Analysis Race Detection Fuzzing AxumVisual F# Managed Languages Rx Native Libraries Managed Concurrency Runtime DryadLINQ Research / Incubation Research / Incubation Visual Studio 2010 / .NET 4 Windows 7 / Server 2008 R2 HPC Server Operating System Parallel Computing and PDC09
  30. 30. Imperative Parallelism Declarative Data Parallelism CODE!
  31. 31. Amdahl’s Law (1 / percent of time spent in sequential processing) Limits of Parallelism
  32. 32. GPU – Beyond CPU CODE!
  33. 33. The F#ture
  34. 34. Latest Books about F#

×