SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Who Needs C++ When
                             You Have D and Go?

                                    Russel Winder
                                  email: russel@winder.org.uk
                                 xmpp: russel@winder.org.uk
                                    twitter: @russel_winder
                                 Web: http://www.russel.org.uk




Copyright © 2013 Russel Winder                                   1
controversy
           noun
              dispute, argument, or debate, especially one
              concerning a matter about which there is
              strong disagreement




Copyright © 2013 Russel Winder                               2
Calculate the sum of the squares of the
           numbers between 0 and 100 that are
                       divisible by 7.




Copyright © 2013 Russel Winder                      3
int sequential_iterative() {
                                   auto sum = 0;
                                   foreach (i; 0 .. 100) {
                                     if (i % 7 == 0) {
                                       sum += i * i;
                                     }
                                   }
                                   return sum;
                                 }




Copyright © 2013 Russel Winder                                  4
func sequential_iterative() (sum int) {
                                    for i := 0; i < 100; i++ {
                                       if (i % 7 == 0) {
                                           sum += i * i
                                       }
                                    }
                                    return
                                 }




Copyright © 2013 Russel Winder                                             5
int sequential_iterative() {
                                   auto sum = 0;
                                   for (auto i = 0; i < 100; ++i) {
                                     if (i % 7 == 0) {
                                       sum += i * i;
                                     }
                                   }
                                   return sum;
                                 }




Copyright © 2013 Russel Winder                                        6
So all native code programming
                            languages are the same?




Copyright © 2013 Russel Winder                           7
We are, of course, expected
                   to be more declarative these days…




Copyright © 2013 Russel Winder                          8
Possibly even functional…




Copyright © 2013 Russel Winder                               9
reduce!"a + b"(map!"a * a"(filter!"a % 7 == 0"(iota(100))))




Copyright © 2013 Russel Winder                                      10
functools.Inject(func (a, b int) int { return a + b },
           functools.Collect(func (i int) int { return i * i },
              functools.Filter(func (i int) bool { return i % 7 == 0 },
                  make([]int, 100))))




Copyright © 2013 Russel Winder                                            11
int sequential_declarative() {
   std::vector<int> numbers (100);
   std::iota(numbers.begin(), numbers.end(), 1);
   std::list<int> filtered;
   std::copy_if(numbers.begin(), numbers.end(),
     std::back_insert_iterator<std::list<int>>(filtered), [=] (int i) { return i % 7 == 0; });
   std::vector<int> squares (filtered.size());
   std::transform(filtered.begin(), filtered.end(),
     std::back_insert_iterator<std::vector<int>>(squares), [=] (int i) { return i * i;});
   return std::accumulate(squares.begin(), squares.end(), 0, [=] (int i, int j) { return i + j;});
 }




Copyright © 2013 Russel Winder                                                                   12
What about being fluent…




Copyright © 2013 Russel Winder                              13
iota(100).filter!"a % 7 == 0"().map!"a * a"().reduce!"a + b"()




Copyright © 2013 Russel Winder                                      14
functools.IntSlice(make([]int, 100)).
                 Filter(func (i int) bool { return i % 7 == 0 }).
                     Collect(func (i int) int { return i * i }).
                        Inject(func (a, b int) int { return a + b })




Copyright © 2013 Russel Winder                                         15
?


Copyright © 2013 Russel Winder       16
Execute it!




Copyright © 2013 Russel Winder                 17
Use D
                                     Use Go

                                   Use Python

                                 Anything but C++

Copyright © 2013 Russel Winder                      18
http://www.dlang.org


                                 http://www.go-lang.org




Copyright © 2013 Russel Winder                            19
Who Needs C++ When
                             You Have D and Go?

                                    Russel Winder
                                  email: russel@winder.org.uk
                                 xmpp: russel@winder.org.uk
                                    twitter: @russel_winder
                                 Web: http://www.russel.org.uk




Copyright © 2013 Russel Winder                                   20

Mais conteúdo relacionado

Mais de Russel Winder

Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etcRussel Winder
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Russel Winder
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testingRussel Winder
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular TestingRussel Winder
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamicRussel Winder
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Russel Winder
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needRussel Winder
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to PythonRussel Winder
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as JavaRussel Winder
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New BeginningRussel Winder
 
GPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaGPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaRussel Winder
 
GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily Russel Winder
 
Switch to Python 3…now…immediately
Switch to Python 3…now…immediatelySwitch to Python 3…now…immediately
Switch to Python 3…now…immediatelyRussel Winder
 
Given Groovy Who Needs Java
Given Groovy Who Needs JavaGiven Groovy Who Needs Java
Given Groovy Who Needs JavaRussel Winder
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Russel Winder
 
Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Russel Winder
 
Closures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaClosures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaRussel Winder
 

Mais de Russel Winder (20)

Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etc
 
GPars Remoting
GPars RemotingGPars Remoting
GPars Remoting
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.
 
GPars 2014
GPars 2014GPars 2014
GPars 2014
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testing
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamic
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you need
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to Python
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as Java
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New Beginning
 
GPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for JavaGPars: Groovy Parallelism for Java
GPars: Groovy Parallelism for Java
 
GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily GroovyFX: or how to program JavaFX easily
GroovyFX: or how to program JavaFX easily
 
Switch to Python 3…now…immediately
Switch to Python 3…now…immediatelySwitch to Python 3…now…immediately
Switch to Python 3…now…immediately
 
GPars Workshop
GPars WorkshopGPars Workshop
GPars Workshop
 
Given Groovy Who Needs Java
Given Groovy Who Needs JavaGiven Groovy Who Needs Java
Given Groovy Who Needs Java
 
Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.Testing: Python, Java, Groovy, etc.
Testing: Python, Java, Groovy, etc.
 
Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…Why Groovy When Java 8 or Scala, or…
Why Groovy When Java 8 or Scala, or…
 
Closures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In JavaClosures: The Next "Big Thing" In Java
Closures: The Next "Big Thing" In Java
 

Último

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Último (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Who needs C++ when you have D and Go

  • 1. Who Needs C++ When You Have D and Go? Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder Web: http://www.russel.org.uk Copyright © 2013 Russel Winder 1
  • 2. controversy noun dispute, argument, or debate, especially one concerning a matter about which there is strong disagreement Copyright © 2013 Russel Winder 2
  • 3. Calculate the sum of the squares of the numbers between 0 and 100 that are divisible by 7. Copyright © 2013 Russel Winder 3
  • 4. int sequential_iterative() { auto sum = 0; foreach (i; 0 .. 100) { if (i % 7 == 0) { sum += i * i; } } return sum; } Copyright © 2013 Russel Winder 4
  • 5. func sequential_iterative() (sum int) { for i := 0; i < 100; i++ { if (i % 7 == 0) { sum += i * i } } return } Copyright © 2013 Russel Winder 5
  • 6. int sequential_iterative() { auto sum = 0; for (auto i = 0; i < 100; ++i) { if (i % 7 == 0) { sum += i * i; } } return sum; } Copyright © 2013 Russel Winder 6
  • 7. So all native code programming languages are the same? Copyright © 2013 Russel Winder 7
  • 8. We are, of course, expected to be more declarative these days… Copyright © 2013 Russel Winder 8
  • 9. Possibly even functional… Copyright © 2013 Russel Winder 9
  • 10. reduce!"a + b"(map!"a * a"(filter!"a % 7 == 0"(iota(100)))) Copyright © 2013 Russel Winder 10
  • 11. functools.Inject(func (a, b int) int { return a + b }, functools.Collect(func (i int) int { return i * i }, functools.Filter(func (i int) bool { return i % 7 == 0 }, make([]int, 100)))) Copyright © 2013 Russel Winder 11
  • 12. int sequential_declarative() { std::vector<int> numbers (100); std::iota(numbers.begin(), numbers.end(), 1); std::list<int> filtered; std::copy_if(numbers.begin(), numbers.end(), std::back_insert_iterator<std::list<int>>(filtered), [=] (int i) { return i % 7 == 0; }); std::vector<int> squares (filtered.size()); std::transform(filtered.begin(), filtered.end(), std::back_insert_iterator<std::vector<int>>(squares), [=] (int i) { return i * i;}); return std::accumulate(squares.begin(), squares.end(), 0, [=] (int i, int j) { return i + j;}); } Copyright © 2013 Russel Winder 12
  • 13. What about being fluent… Copyright © 2013 Russel Winder 13
  • 14. iota(100).filter!"a % 7 == 0"().map!"a * a"().reduce!"a + b"() Copyright © 2013 Russel Winder 14
  • 15. functools.IntSlice(make([]int, 100)). Filter(func (i int) bool { return i % 7 == 0 }). Collect(func (i int) int { return i * i }). Inject(func (a, b int) int { return a + b }) Copyright © 2013 Russel Winder 15
  • 16. ? Copyright © 2013 Russel Winder 16
  • 17. Execute it! Copyright © 2013 Russel Winder 17
  • 18. Use D Use Go Use Python Anything but C++ Copyright © 2013 Russel Winder 18
  • 19. http://www.dlang.org http://www.go-lang.org Copyright © 2013 Russel Winder 19
  • 20. Who Needs C++ When You Have D and Go? Russel Winder email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winder Web: http://www.russel.org.uk Copyright © 2013 Russel Winder 20