SlideShare a Scribd company logo
1 of 37
Download to read offline
Haskell vs. F# vs. Scala
A High-level Language Features and Parallelism Support Comparison1


        Prabhat Totoo, Pantazis Deligiannis, Hans-Wolfgang Loidl

                              Denpendable Systems Group
                    School of Mathematical and Computer Sciences
                              Heriot-Watt University, UK
                                     FHPC’12
                               Copenhagen, Denmark


                              15 September 2012




1
    URL:http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/fhpc12.html
Goal

      comparison of parallel programming support in the 3 languages
      - performance
      - programmability




      we look at:
              language features and high-level abstractions for parallelism
              experimental results from n-body problem on multi-cores
              discussion about performance, programmability and pragmatic aspects



 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala         15-Sep-2012   1 / 29
Motivation




      promises of functional languages for parallel programming
              referential transparency due to the absence of side effects
              high-level abstractions through HOFs, function composition
              skeletons encapsulating common parallel patterns
      ”specify what instead of how to compute something ”
      SPJ: ”The future of parallel is declarative ”




 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala          15-Sep-2012   2 / 29
Recent trends in language design

      mainstream languages integrating functional features in their design
              e.g. Generics (Java), lambda expression (C#, C++), delegates (C#)
              improves expressiveness in the language by providing functional
              constructs
      Multi-paradigm languages - make functional programming more
      approachable
              F#
              - Microsoft .NET platform
              - functional-oriented; with imperative and OO constructs
              Scala
              - JVM
              - emphasize on OO but combined with powerful functional features
      library support for parallel patterns (skeletons)
              e.g. TPL


 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala         15-Sep-2012   3 / 29
THE LANGUAGES
Summary table


                               Table: Summary of language features

                         Key Features                                 Parallelism Support
               Haskell pure functional, lazy evaluation,              par and pseq
                       static/inferred typing                         Evaluation strategies
               F#        functional, imperative, object oriented,     Async Workflows
                         strict evaluation, static/inferred typing,   TPL
                         .NET interoperability                        PLINQ
               Scala     functional, imperative, object oriented, Parallel Collections
                         strict evaluation, strong/inferred typing, Actors
                         Java interoperability




 Totoo, Deligiannis, Loidl (HWU)           Haskell vs. F# vs. Scala                   15-Sep-2012   4 / 29
Haskell2


        pure functional language, generally functions have no side-effects
        lazy by default
        typing: static, strong, type inference
        advanced type system supporting ADTs, typeclasses, type
        polymorphism
        monads used to:
              chain computation (no default eval order)
              IO monad separates pure from side-effecting computations
        main implementation: GHC
        - highly-optimised compiler and RTS



   2
       http://haskell.org/
 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala        15-Sep-2012   5 / 29
Haskell - parallel support


      includes support for semi-explicit parallelism through the Glasgow
      parallel Haskell (GpH) extensions
      GpH
               provides a single primitive for parallelism: par
           1                  p a r : : a −> b −> b

               to annotate expression that can usefully be evaluated in parallel
               (potential NOT mandatory parallelism)
               and a second primitive to enforce sequential ordering which is needed
               to arrange parallel computations: pseq
           1                  p s e q : : a −> b −> b




 Totoo, Deligiannis, Loidl (HWU)        Haskell vs. F# vs. Scala       15-Sep-2012   6 / 29
Haskell - parallel support


        GpH e.g.
    1             f = s1 + s2                                       −− s e q u e n t i a l
    2             f = s 1 ‘ par ‘ s 2 ‘ pseq ‘ ( s 1 + s 2 )        −− p a r a l l e l

        Evaluation strategies
              abstractions built on top of the basic primitives
              separates coordination aspects from main computation
        parallel map using strategies
    1             parMap s t r a t f x s = map f x s ‘ u s i n g ‘ p a r L i s t s t r a t

              parList Spark each of the elements of a list using the given strategy
              strat e.g. rdeepseq Strategy that fully evaluates its argument




 Totoo, Deligiannis, Loidl (HWU)       Haskell vs. F# vs. Scala               15-Sep-2012    7 / 29
Haskell - parallel support


      Other abstractions for parallelism:
              Par monad
              - more explicit approach
              - uses IVars, put and get for communication
              - abstract some common functions e.g. parallel map
              DPH
              - exploits data parallelism, both regular and nested-data
              Eden
              - uses process abstraction, similar to λ-abstraction
              - for distributed-memory but also good performance on shared-memory
              machines3



   3
     Prabhat Totoo, Hans-Wolfgang Loidl. Parallel Haskell implementations of the
n-body problem.
 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala            15-Sep-2012   8 / 29
F#4


       functional-oriented language
       SML-like language with OO extensions
       implemented on top of .NET, interoperable with languages such as
       C#
       can make use of arbitrary .NET libraries from F#
       strict by default, but has lazy values as well
       advanced type system: discriminated union (=ADT), object types
       (for .NET interoperability)
       value vs. variable



  4
      http://research.microsoft.com/fsharp/
Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala   15-Sep-2012   9 / 29
F# - parallel support


      uses the .NET Parallel Extensions library
      - high-level constructs to write/execute parallel programs
      Tasks Parallel Library (TPL)
      - hide low-level thread creation, management, scheduling details
              Tasks
              - main construct for task parallelism
              Task: provides high-level abstraction compared to working directly
              with threads; does not return a value
              Task<TResult>: represents an operation that calculates a value of
              type TResult eventually i.e. a future




 Totoo, Deligiannis, Loidl (HWU)    Haskell vs. F# vs. Scala         15-Sep-2012   10 / 29
F# - parallel support


      Tasks Parallel Library (TPL)
              Parallel Class - for data parallelism
              - basic loop parallelisation using Parallel.For and
              Parallel.ForEach
              PLINQ - declarative model for data parallelism
              - uses tasks internally
      Async Workflows
      - use the async {...} keyword; doesn’t block calling thread -
      provide basic parallelisation
      - intended mainly for operations involving I/O e.g. run multiple
      downloads in parallel




 Totoo, Deligiannis, Loidl (HWU)    Haskell vs. F# vs. Scala        15-Sep-2012   11 / 29
Scala5



        designed to be a “better Java”...
        multiparadigm language; integrating OO and functional model
        evaluation: strict; typing: static, strong and inferred
        strong interoperability with Java (targeted for JVM)
        still very tied with the concept of objects
        language expressiveness is extended by functional features




   5
       http://www.scala-lang.org/
 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala       15-Sep-2012   12 / 29
Scala - parallel support


      Parallel Collections Framework
               implicit (data) parallelism
               use par on sequential collection to invoke parallel implementation
               subsequent operations are parallel
               use seq to turn collection back to sequential
           1                  x s . map ( x => f x )                   // s e q u e n t i a l
           2
           3                  x s . p a r . map ( x => f x ) . s e q   // p a r a l l e l

               built on top of Fork/Join framework
               thread pool implementation schedules tasks among available processors




 Totoo, Deligiannis, Loidl (HWU)            Haskell vs. F# vs. Scala                 15-Sep-2012   13 / 29
Scala - parallel support

      Actors
               message-passing model; no shared state
               similar concurrency model to Erlang
               lightweight processes communicates by exchanging asynchronous
               messages
               messages go into mailboxes; processed using pattern matching
           1                  a ! msg                        // s e n d message
           2
           3                 receive     {                   // p r o c e s s m a i l b o x
           4                   case     msg pattern          1 => a c t i o n 1
           5                   case     msg pattern          2 => a c t i o n 2
           6                   case     msg pattern          3 => a c t i o n 3
           7                 }




 Totoo, Deligiannis, Loidl (HWU)         Haskell vs. F# vs. Scala                      15-Sep-2012   14 / 29
IMPLEMENTATION
N-body problem

      problem of predicting and simulating the motion of a system of N
      bodies that interact with each other gravitationally
      simulation proceeds over a number of time steps
      in each step
              calculate acceleration of each body wrt the others,
              then update position and velocity
      solving methods:
              all-pairs: direct body-to-body comparison, not feasible for large N
              Barnes-Hut algorithm: efficient approximation method, more advanced



                                   consists of 2 phases:
                                     - tree construction
                                     - force calculation (most compute-intensive)


 Totoo, Deligiannis, Loidl (HWU)    Haskell vs. F# vs. Scala         15-Sep-2012   15 / 29
Sequential Implementation and optimisations



      Approach: start off with an efficient seq implementation, preserving
      opportunities for parallelism
      generic optimisations:
              deforestation
              - eliminating multiple traversal of data structures
              tail-call elimination
              compiler optimisations




 Totoo, Deligiannis, Loidl (HWU)     Haskell vs. F# vs. Scala       15-Sep-2012   16 / 29
Haskell
        Optimisations
              eliminates stack overflow by making functions tail recursive
              add strictness annotations where required
              use strict fields and UNPACK pragma in datatype definitions
              shortcut fusion e.g. foldr/build

        Introduce parallelism at the top-level map function
        Core parallel code for Haskell
    1            c h u n k s i z e = ( l e n g t h b s ) ‘ quot ‘ ( n u m C a p a b i l i t i e s ∗ 4 )
    2            n e w b s = map f b s ‘ u s i n g ‘ p a r L i s t C h u n k c h u n k s i z e
                        rdeepseq


        Parallel tuning
              chunking to control granularity, not too many small tasks; not too few
              large tasks


 Totoo, Deligiannis, Loidl (HWU)            Haskell vs. F# vs. Scala                      15-Sep-2012     17 / 29
F# (1)
          translate Haskell code into F#
          keeping the code functional, so mostly syntax changes
          some general optimisations apply
                 + inlining

                                                         1   ( ∗ TPL ∗ )
1   ( ∗ Async W o r k f l o w s ∗ )                      2
2   l e t pmap async f xs =                              3   (∗ E x p l i c i t t a s k s c r e a t i o n . ∗)
3       s e q { f o r x i n x s −> a s y n c {           4   l e t p m a p t p l t a s k s f ( x s : l i s t < >)
               return f x } }                                         =
4       |> Async . P a r a l l e l                       5       L i s t . map ( f u n x −>
5       |> Async . R u n S y n c h r o n o u s l y       6           Task< >. F a c t o r y . S t a r t N e w ( f u n
6       |> Seq . t o L i s t                                                ( ) −> f x ) . R e s u l t
                                                         7       ) xs

1   ( ∗ PLINQ − u s e s TPL i n t e r n a l l y ∗ )
2   l e t p m a p p l i n q f ( x s : l i s t < >) =
3       x s . A s P a r a l l e l ( ) . S e l e c t ( f u n x −> f x ) |> Seq . t o L i s t


     Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala                        15-Sep-2012     18 / 29
F# (2)

          imperative style
1   (∗ P a r a l l e l . For ∗)
2
3   l e t p m a p t p l p a r f o r f ( x s : a r r a y < >) =
4         l e t new xs = Array . z e r o C r e a t e xs . Length
5         P a r a l l e l . F o r ( 0 , x s . Length , ( f u n i −>
6                n e w x s . [ i ] <− f ( x s . [ i ] ) ) ) |> i g n o r e
7         new xs


          Parallel tuning
                  maximum degree of parallelism
                        - specifies max number of concurrently executing tasks
                  chunking/partitioning
                        - to control the granularity of tasks




     Totoo, Deligiannis, Loidl (HWU)          Haskell vs. F# vs. Scala          15-Sep-2012   19 / 29
Scala

          translate Haskell and F# implementations into Scala
          keeping the code as much functional as possible
          optimisations
                 - unnecessary object initialisations removal

1   // P a r a l l e l C o l l e c t i o n s .
2   b o d i e s . p a r . map ( ( b : Body ) => new Body ( b . mass , u p d a t e P o s ( b ) ,
            updateVel (b) ) ) . seq

1   // P a r a l l e l map u s i n g F u t u r e s .
2   d e f pmap [ T ] ( f : T => T) ( x s : L i s t [ T ] ) : L i s t [ T ] = {
3       v a l t a s k s = x s . map ( ( x : T) => F u t u r e s . f u t u r e { f ( x ) } )
4       t a s k s . map ( f u t u r e => f u t u r e . a p p l y ( ) )
5   }




     Totoo, Deligiannis, Loidl (HWU)          Haskell vs. F# vs. Scala                        15-Sep-2012   20 / 29
RESULTS
Experimental setup


      Platforms and language implementations:


                                   Linux (64-bit)               Windows (32-bit)
                                   2.33GHz (8 cores)            2.80GHz (4 cores with HT)
                   Haskell         GHC 7.4.1                    GHC 7.4.1
                   F#              F# 2.0 / Mono 2.11.1         F# 2.0 / .NET 4.0
                   Scala           Scala 2.10 / JVM 1.7         Scala 2.10 / JVM 1.7


      Input size: 80,000 bodies, 1 iteration




 Totoo, Deligiannis, Loidl (HWU)               Haskell vs. F# vs. Scala                15-Sep-2012   21 / 29
Sequential Runtimes



          Haskell (Linux)          479.94s
         F# (Win)                   28.43s
         Scala (Linux)             55.44s




 Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala   15-Sep-2012   22 / 29
Sequential Runtimes



          Haskell (Linux)          479.94s
         F# (Win)                   28.43s
         Scala (Linux)             55.44s
                                   before




 Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala   15-Sep-2012   22 / 29
Sequential Runtimes



          Haskell (Linux)          479.94s                              25.28
         F# (Win)                   28.43s                              21.12
         Scala (Linux)             55.44s                               39.04
                                   before                               after




 Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala           15-Sep-2012   22 / 29
Sequential Runtimes



          Haskell (Linux)          479.94s                                 25.28
         F# (Win)                   28.43s                                 21.12
         Scala (Linux)             55.44s                                  39.04
                                   before                                  after


                                                    Linux        Windows
                                      Haskell      25.28           17.64
                                     F#            118.12          21.12
                                     Scala         39.04           66.65




 Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala              15-Sep-2012   22 / 29
Parallel Runtimes
                             Haskell (EvalStrat)       F# (PLINQ)       Scala (Actors)
                     seq            25.28                  118.12           39.04
                      1             26.38                  196.14           40.01
                      2             14.48                  120.78           22.34
                      4             7.41                    80.91           14.88
                      8             4.50                    70.67           13.26

                                       Table: Linux (8 cores)



                               Haskell (EvalStrat)       F# (PLINQ)      Scala (Actors)
                    seq              17.64                    21.12          66.65
                     1               18.05                    21.39          67.24
                     2                9.41                    17.32          58.66
                     4                6.80                    10.56          33.84
                  8 (HT)             4.77                     8.64           25.28

                                     Table: Windows (4 cores)


 Totoo, Deligiannis, Loidl (HWU)             Haskell vs. F# vs. Scala                    15-Sep-2012   23 / 29
Speedups
Linux (8 cores)




 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala   15-Sep-2012   24 / 29
Speedups
Windows (4 cores)




 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala   15-Sep-2012   25 / 29
Observations

      Performance
              Haskell outperforms F# and Scala on both platforms
              - has been possible after many optimisations
              poor performance - F#/Mono (vs. F#/.NET runtime)
              poor performance - Scala on Windows
      Programmability
              Haskell - implication of laziness - hard to estimate how much work is
              involved
              Scala - verbose, unlike other functional languages
              in general, initial parallelism easy to specify
              chunking required to work for Haskell, but PLINQ and ParColl are
              more implicit
              F# and Scala retain much control in the implementation
              - not easy to tune parallel program



 Totoo, Deligiannis, Loidl (HWU)      Haskell vs. F# vs. Scala          15-Sep-2012   26 / 29
Observations



      Pragmatics
              Haskell
              - good tool support e.g. for space and time profiling
              - threadscope: visualisation tool to see work distribution
              F#
              - Profiling and Analysis tools available in VS2011 Beta Pro -
              Concurrency Visualizer
              Scala
              - benefits from free tools available for JVM




 Totoo, Deligiannis, Loidl (HWU)    Haskell vs. F# vs. Scala         15-Sep-2012   27 / 29
Conclusions


      employ skeleton-based, semi-explicit and explicit approaches to
      parallelism
      (near) best runtimes using highest-level of abstraction
      start with an optimised sequential program
      but use impure features only after parallelisation
      Haskell provides least intrusive mechanism for parallelisation
      F# provides the preferred mechanism for data-parallelism with the
      SQL-like PLINQ
      extra programming effort using actor-based code in Scala not justified




 Totoo, Deligiannis, Loidl (HWU)   Haskell vs. F# vs. Scala     15-Sep-2012   28 / 29
Future Work: Eden on Clusters6
                    Eden Iteration Skeletons: Naive NBody with 15000 bodies, 10 iteration
              512

              256

              128

              64
   Time (s)




              32

              16

               8
                              localLoop/allToAllIter
                            loopControl/allToAllRD
               4                    linear speedup
                    1        2         4          8       16           32     64       128
                                                  Processors

   6
     Mischa Dieterle, Thomas Horstmeyer, Jost Berthold and Rita Loogen: Iterating
Skeletons - Structured Parallelism by Composition, IFL’12
 Totoo, Deligiannis, Loidl (HWU)                   Haskell vs. F# vs. Scala                  15-Sep-2012   29 / 29
Thank you for listening!




    Full paper and sources:
    http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/
    fhpc12.html
    Email:
    {pt114, pd85, H.W.Loidl}@hw.ac.uk

More Related Content

What's hot

Functional Patterns in Domain Modeling
Functional Patterns in Domain ModelingFunctional Patterns in Domain Modeling
Functional Patterns in Domain ModelingDebasish Ghosh
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Scott Wlaschin
 
Gremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryGremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryMarko Rodriguez
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...Philip Schwarz
 
OSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaOSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaODPi
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemKostas Saidis
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsDebasish Ghosh
 
Functional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayFunctional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayDebasish Ghosh
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and PracticeBo-Yi Wu
 
Data structure in perl
Data structure in perlData structure in perl
Data structure in perlsana mateen
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdfBernardDeffarges
 
Dynamic Allocation in Spark
Dynamic Allocation in SparkDynamic Allocation in Spark
Dynamic Allocation in SparkDatabricks
 
DDD patterns that were not in the book
DDD patterns that were not in the bookDDD patterns that were not in the book
DDD patterns that were not in the bookCyrille Martraire
 

What's hot (20)

Functional Patterns in Domain Modeling
Functional Patterns in Domain ModelingFunctional Patterns in Domain Modeling
Functional Patterns in Domain Modeling
 
JSON-LD and SHACL for Knowledge Graphs
JSON-LD and SHACL for Knowledge GraphsJSON-LD and SHACL for Knowledge Graphs
JSON-LD and SHACL for Knowledge Graphs
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013
 
Catalyst optimizer
Catalyst optimizerCatalyst optimizer
Catalyst optimizer
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
Gremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryGremlin's Graph Traversal Machinery
Gremlin's Graph Traversal Machinery
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...
 
OSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaOSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of Egeria
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystem
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain Models
 
Functional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 WayFunctional Domain Modeling - The ZIO 2 Way
Functional Domain Modeling - The ZIO 2 Way
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and Practice
 
Data structure in perl
Data structure in perlData structure in perl
Data structure in perl
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdf
 
Dynamic Allocation in Spark
Dynamic Allocation in SparkDynamic Allocation in Spark
Dynamic Allocation in Spark
 
DDD patterns that were not in the book
DDD patterns that were not in the bookDDD patterns that were not in the book
DDD patterns that were not in the book
 

Viewers also liked

High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Haskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesHaskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesKatie Ots
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Scott Wlaschin
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakMarcus Denker
 
The Pharo Programming Language
The Pharo Programming LanguageThe Pharo Programming Language
The Pharo Programming Languagebergel
 
Pharo: Objects at your Fingertips
Pharo: Objects at your FingertipsPharo: Objects at your Fingertips
Pharo: Objects at your FingertipsMarcus Denker
 
Squeak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC SmalltalkSqueak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC SmalltalkSeanDeNigris
 
Pharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntaxPharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntaxPharo
 
2008 Sccc Smalltalk
2008 Sccc Smalltalk2008 Sccc Smalltalk
2008 Sccc Smalltalkbergel
 
Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013Pharo
 
Pharo Roadmap
Pharo RoadmapPharo Roadmap
Pharo RoadmapESUG
 
You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!ESUG
 
Pharo Hands-on: 05 object model
Pharo Hands-on: 05 object modelPharo Hands-on: 05 object model
Pharo Hands-on: 05 object modelPharo
 
O caml2014 leroy-slides
O caml2014 leroy-slidesO caml2014 leroy-slides
O caml2014 leroy-slidesOCaml
 
CQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java DevelopersCQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java DevelopersMarkus Eisele
 
Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Scott Wlaschin
 

Viewers also liked (20)

Why Haskell
Why HaskellWhy Haskell
Why Haskell
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Haskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesHaskell is Not For Production and Other Tales
Haskell is Not For Production and Other Tales
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
 
Pharo devnology20150401
Pharo devnology20150401Pharo devnology20150401
Pharo devnology20150401
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
The Pharo Programming Language
The Pharo Programming LanguageThe Pharo Programming Language
The Pharo Programming Language
 
Pharo: Objects at your Fingertips
Pharo: Objects at your FingertipsPharo: Objects at your Fingertips
Pharo: Objects at your Fingertips
 
Squeak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC SmalltalkSqueak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC Smalltalk
 
Pharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntaxPharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntax
 
2008 Sccc Smalltalk
2008 Sccc Smalltalk2008 Sccc Smalltalk
2008 Sccc Smalltalk
 
Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013
 
Pharo Roadmap
Pharo RoadmapPharo Roadmap
Pharo Roadmap
 
You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!
 
Pharo Hands-on: 05 object model
Pharo Hands-on: 05 object modelPharo Hands-on: 05 object model
Pharo Hands-on: 05 object model
 
C# 7
C# 7C# 7
C# 7
 
Stoop 432-singleton
Stoop 432-singletonStoop 432-singleton
Stoop 432-singleton
 
O caml2014 leroy-slides
O caml2014 leroy-slidesO caml2014 leroy-slides
O caml2014 leroy-slides
 
CQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java DevelopersCQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java Developers
 
Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)
 

Similar to Haskell vs. F# vs. Scala

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperShreya Chakrabarti
 
An introduction on language processing
An introduction on language processingAn introduction on language processing
An introduction on language processingRalf Laemmel
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Лев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноЛев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноDaria Oreshkina
 
Diving into Functional Programming
Diving into Functional ProgrammingDiving into Functional Programming
Diving into Functional ProgrammingLev Walkin
 
Quadrupling your elephants - RDF and the Hadoop ecosystem
Quadrupling your elephants - RDF and the Hadoop ecosystemQuadrupling your elephants - RDF and the Hadoop ecosystem
Quadrupling your elephants - RDF and the Hadoop ecosystemRob Vesse
 
Functional Programming and Big Data
Functional Programming and Big DataFunctional Programming and Big Data
Functional Programming and Big DataDataWorks Summit
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSynesso
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Ralf Laemmel
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
 

Similar to Haskell vs. F# vs. Scala (20)

Stay fresh
Stay freshStay fresh
Stay fresh
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Programming Languages - Functional Programming Paper
Programming Languages - Functional Programming PaperProgramming Languages - Functional Programming Paper
Programming Languages - Functional Programming Paper
 
An introduction on language processing
An introduction on language processingAn introduction on language processing
An introduction on language processing
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Лев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноЛев Валкин — Программируем функционально
Лев Валкин — Программируем функционально
 
Diving into Functional Programming
Diving into Functional ProgrammingDiving into Functional Programming
Diving into Functional Programming
 
Quadrupling your elephants - RDF and the Hadoop ecosystem
Quadrupling your elephants - RDF and the Hadoop ecosystemQuadrupling your elephants - RDF and the Hadoop ecosystem
Quadrupling your elephants - RDF and the Hadoop ecosystem
 
Functional Programming and Big Data
Functional Programming and Big DataFunctional Programming and Big Data
Functional Programming and Big Data
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Perl Reference.ppt
Perl Reference.pptPerl Reference.ppt
Perl Reference.ppt
 
F# for Scala developers
F# for Scala developersF# for Scala developers
F# for Scala developers
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
master_thesis_greciano_v2
master_thesis_greciano_v2master_thesis_greciano_v2
master_thesis_greciano_v2
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Haskell vs. F# vs. Scala

  • 1. Haskell vs. F# vs. Scala A High-level Language Features and Parallelism Support Comparison1 Prabhat Totoo, Pantazis Deligiannis, Hans-Wolfgang Loidl Denpendable Systems Group School of Mathematical and Computer Sciences Heriot-Watt University, UK FHPC’12 Copenhagen, Denmark 15 September 2012 1 URL:http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/fhpc12.html
  • 2. Goal comparison of parallel programming support in the 3 languages - performance - programmability we look at: language features and high-level abstractions for parallelism experimental results from n-body problem on multi-cores discussion about performance, programmability and pragmatic aspects Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 1 / 29
  • 3. Motivation promises of functional languages for parallel programming referential transparency due to the absence of side effects high-level abstractions through HOFs, function composition skeletons encapsulating common parallel patterns ”specify what instead of how to compute something ” SPJ: ”The future of parallel is declarative ” Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 2 / 29
  • 4. Recent trends in language design mainstream languages integrating functional features in their design e.g. Generics (Java), lambda expression (C#, C++), delegates (C#) improves expressiveness in the language by providing functional constructs Multi-paradigm languages - make functional programming more approachable F# - Microsoft .NET platform - functional-oriented; with imperative and OO constructs Scala - JVM - emphasize on OO but combined with powerful functional features library support for parallel patterns (skeletons) e.g. TPL Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 3 / 29
  • 6. Summary table Table: Summary of language features Key Features Parallelism Support Haskell pure functional, lazy evaluation, par and pseq static/inferred typing Evaluation strategies F# functional, imperative, object oriented, Async Workflows strict evaluation, static/inferred typing, TPL .NET interoperability PLINQ Scala functional, imperative, object oriented, Parallel Collections strict evaluation, strong/inferred typing, Actors Java interoperability Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 4 / 29
  • 7. Haskell2 pure functional language, generally functions have no side-effects lazy by default typing: static, strong, type inference advanced type system supporting ADTs, typeclasses, type polymorphism monads used to: chain computation (no default eval order) IO monad separates pure from side-effecting computations main implementation: GHC - highly-optimised compiler and RTS 2 http://haskell.org/ Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 5 / 29
  • 8. Haskell - parallel support includes support for semi-explicit parallelism through the Glasgow parallel Haskell (GpH) extensions GpH provides a single primitive for parallelism: par 1 p a r : : a −> b −> b to annotate expression that can usefully be evaluated in parallel (potential NOT mandatory parallelism) and a second primitive to enforce sequential ordering which is needed to arrange parallel computations: pseq 1 p s e q : : a −> b −> b Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 6 / 29
  • 9. Haskell - parallel support GpH e.g. 1 f = s1 + s2 −− s e q u e n t i a l 2 f = s 1 ‘ par ‘ s 2 ‘ pseq ‘ ( s 1 + s 2 ) −− p a r a l l e l Evaluation strategies abstractions built on top of the basic primitives separates coordination aspects from main computation parallel map using strategies 1 parMap s t r a t f x s = map f x s ‘ u s i n g ‘ p a r L i s t s t r a t parList Spark each of the elements of a list using the given strategy strat e.g. rdeepseq Strategy that fully evaluates its argument Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 7 / 29
  • 10. Haskell - parallel support Other abstractions for parallelism: Par monad - more explicit approach - uses IVars, put and get for communication - abstract some common functions e.g. parallel map DPH - exploits data parallelism, both regular and nested-data Eden - uses process abstraction, similar to λ-abstraction - for distributed-memory but also good performance on shared-memory machines3 3 Prabhat Totoo, Hans-Wolfgang Loidl. Parallel Haskell implementations of the n-body problem. Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 8 / 29
  • 11. F#4 functional-oriented language SML-like language with OO extensions implemented on top of .NET, interoperable with languages such as C# can make use of arbitrary .NET libraries from F# strict by default, but has lazy values as well advanced type system: discriminated union (=ADT), object types (for .NET interoperability) value vs. variable 4 http://research.microsoft.com/fsharp/ Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 9 / 29
  • 12. F# - parallel support uses the .NET Parallel Extensions library - high-level constructs to write/execute parallel programs Tasks Parallel Library (TPL) - hide low-level thread creation, management, scheduling details Tasks - main construct for task parallelism Task: provides high-level abstraction compared to working directly with threads; does not return a value Task<TResult>: represents an operation that calculates a value of type TResult eventually i.e. a future Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 10 / 29
  • 13. F# - parallel support Tasks Parallel Library (TPL) Parallel Class - for data parallelism - basic loop parallelisation using Parallel.For and Parallel.ForEach PLINQ - declarative model for data parallelism - uses tasks internally Async Workflows - use the async {...} keyword; doesn’t block calling thread - provide basic parallelisation - intended mainly for operations involving I/O e.g. run multiple downloads in parallel Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 11 / 29
  • 14. Scala5 designed to be a “better Java”... multiparadigm language; integrating OO and functional model evaluation: strict; typing: static, strong and inferred strong interoperability with Java (targeted for JVM) still very tied with the concept of objects language expressiveness is extended by functional features 5 http://www.scala-lang.org/ Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 12 / 29
  • 15. Scala - parallel support Parallel Collections Framework implicit (data) parallelism use par on sequential collection to invoke parallel implementation subsequent operations are parallel use seq to turn collection back to sequential 1 x s . map ( x => f x ) // s e q u e n t i a l 2 3 x s . p a r . map ( x => f x ) . s e q // p a r a l l e l built on top of Fork/Join framework thread pool implementation schedules tasks among available processors Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 13 / 29
  • 16. Scala - parallel support Actors message-passing model; no shared state similar concurrency model to Erlang lightweight processes communicates by exchanging asynchronous messages messages go into mailboxes; processed using pattern matching 1 a ! msg // s e n d message 2 3 receive { // p r o c e s s m a i l b o x 4 case msg pattern 1 => a c t i o n 1 5 case msg pattern 2 => a c t i o n 2 6 case msg pattern 3 => a c t i o n 3 7 } Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 14 / 29
  • 18. N-body problem problem of predicting and simulating the motion of a system of N bodies that interact with each other gravitationally simulation proceeds over a number of time steps in each step calculate acceleration of each body wrt the others, then update position and velocity solving methods: all-pairs: direct body-to-body comparison, not feasible for large N Barnes-Hut algorithm: efficient approximation method, more advanced consists of 2 phases: - tree construction - force calculation (most compute-intensive) Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 15 / 29
  • 19. Sequential Implementation and optimisations Approach: start off with an efficient seq implementation, preserving opportunities for parallelism generic optimisations: deforestation - eliminating multiple traversal of data structures tail-call elimination compiler optimisations Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 16 / 29
  • 20. Haskell Optimisations eliminates stack overflow by making functions tail recursive add strictness annotations where required use strict fields and UNPACK pragma in datatype definitions shortcut fusion e.g. foldr/build Introduce parallelism at the top-level map function Core parallel code for Haskell 1 c h u n k s i z e = ( l e n g t h b s ) ‘ quot ‘ ( n u m C a p a b i l i t i e s ∗ 4 ) 2 n e w b s = map f b s ‘ u s i n g ‘ p a r L i s t C h u n k c h u n k s i z e rdeepseq Parallel tuning chunking to control granularity, not too many small tasks; not too few large tasks Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 17 / 29
  • 21. F# (1) translate Haskell code into F# keeping the code functional, so mostly syntax changes some general optimisations apply + inlining 1 ( ∗ TPL ∗ ) 1 ( ∗ Async W o r k f l o w s ∗ ) 2 2 l e t pmap async f xs = 3 (∗ E x p l i c i t t a s k s c r e a t i o n . ∗) 3 s e q { f o r x i n x s −> a s y n c { 4 l e t p m a p t p l t a s k s f ( x s : l i s t < >) return f x } } = 4 |> Async . P a r a l l e l 5 L i s t . map ( f u n x −> 5 |> Async . R u n S y n c h r o n o u s l y 6 Task< >. F a c t o r y . S t a r t N e w ( f u n 6 |> Seq . t o L i s t ( ) −> f x ) . R e s u l t 7 ) xs 1 ( ∗ PLINQ − u s e s TPL i n t e r n a l l y ∗ ) 2 l e t p m a p p l i n q f ( x s : l i s t < >) = 3 x s . A s P a r a l l e l ( ) . S e l e c t ( f u n x −> f x ) |> Seq . t o L i s t Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 18 / 29
  • 22. F# (2) imperative style 1 (∗ P a r a l l e l . For ∗) 2 3 l e t p m a p t p l p a r f o r f ( x s : a r r a y < >) = 4 l e t new xs = Array . z e r o C r e a t e xs . Length 5 P a r a l l e l . F o r ( 0 , x s . Length , ( f u n i −> 6 n e w x s . [ i ] <− f ( x s . [ i ] ) ) ) |> i g n o r e 7 new xs Parallel tuning maximum degree of parallelism - specifies max number of concurrently executing tasks chunking/partitioning - to control the granularity of tasks Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 19 / 29
  • 23. Scala translate Haskell and F# implementations into Scala keeping the code as much functional as possible optimisations - unnecessary object initialisations removal 1 // P a r a l l e l C o l l e c t i o n s . 2 b o d i e s . p a r . map ( ( b : Body ) => new Body ( b . mass , u p d a t e P o s ( b ) , updateVel (b) ) ) . seq 1 // P a r a l l e l map u s i n g F u t u r e s . 2 d e f pmap [ T ] ( f : T => T) ( x s : L i s t [ T ] ) : L i s t [ T ] = { 3 v a l t a s k s = x s . map ( ( x : T) => F u t u r e s . f u t u r e { f ( x ) } ) 4 t a s k s . map ( f u t u r e => f u t u r e . a p p l y ( ) ) 5 } Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 20 / 29
  • 25. Experimental setup Platforms and language implementations: Linux (64-bit) Windows (32-bit) 2.33GHz (8 cores) 2.80GHz (4 cores with HT) Haskell GHC 7.4.1 GHC 7.4.1 F# F# 2.0 / Mono 2.11.1 F# 2.0 / .NET 4.0 Scala Scala 2.10 / JVM 1.7 Scala 2.10 / JVM 1.7 Input size: 80,000 bodies, 1 iteration Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 21 / 29
  • 26. Sequential Runtimes Haskell (Linux) 479.94s F# (Win) 28.43s Scala (Linux) 55.44s Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 22 / 29
  • 27. Sequential Runtimes Haskell (Linux) 479.94s F# (Win) 28.43s Scala (Linux) 55.44s before Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 22 / 29
  • 28. Sequential Runtimes Haskell (Linux) 479.94s 25.28 F# (Win) 28.43s 21.12 Scala (Linux) 55.44s 39.04 before after Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 22 / 29
  • 29. Sequential Runtimes Haskell (Linux) 479.94s 25.28 F# (Win) 28.43s 21.12 Scala (Linux) 55.44s 39.04 before after Linux Windows Haskell 25.28 17.64 F# 118.12 21.12 Scala 39.04 66.65 Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 22 / 29
  • 30. Parallel Runtimes Haskell (EvalStrat) F# (PLINQ) Scala (Actors) seq 25.28 118.12 39.04 1 26.38 196.14 40.01 2 14.48 120.78 22.34 4 7.41 80.91 14.88 8 4.50 70.67 13.26 Table: Linux (8 cores) Haskell (EvalStrat) F# (PLINQ) Scala (Actors) seq 17.64 21.12 66.65 1 18.05 21.39 67.24 2 9.41 17.32 58.66 4 6.80 10.56 33.84 8 (HT) 4.77 8.64 25.28 Table: Windows (4 cores) Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 23 / 29
  • 31. Speedups Linux (8 cores) Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 24 / 29
  • 32. Speedups Windows (4 cores) Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 25 / 29
  • 33. Observations Performance Haskell outperforms F# and Scala on both platforms - has been possible after many optimisations poor performance - F#/Mono (vs. F#/.NET runtime) poor performance - Scala on Windows Programmability Haskell - implication of laziness - hard to estimate how much work is involved Scala - verbose, unlike other functional languages in general, initial parallelism easy to specify chunking required to work for Haskell, but PLINQ and ParColl are more implicit F# and Scala retain much control in the implementation - not easy to tune parallel program Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 26 / 29
  • 34. Observations Pragmatics Haskell - good tool support e.g. for space and time profiling - threadscope: visualisation tool to see work distribution F# - Profiling and Analysis tools available in VS2011 Beta Pro - Concurrency Visualizer Scala - benefits from free tools available for JVM Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 27 / 29
  • 35. Conclusions employ skeleton-based, semi-explicit and explicit approaches to parallelism (near) best runtimes using highest-level of abstraction start with an optimised sequential program but use impure features only after parallelisation Haskell provides least intrusive mechanism for parallelisation F# provides the preferred mechanism for data-parallelism with the SQL-like PLINQ extra programming effort using actor-based code in Scala not justified Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 28 / 29
  • 36. Future Work: Eden on Clusters6 Eden Iteration Skeletons: Naive NBody with 15000 bodies, 10 iteration 512 256 128 64 Time (s) 32 16 8 localLoop/allToAllIter loopControl/allToAllRD 4 linear speedup 1 2 4 8 16 32 64 128 Processors 6 Mischa Dieterle, Thomas Horstmeyer, Jost Berthold and Rita Loogen: Iterating Skeletons - Structured Parallelism by Composition, IFL’12 Totoo, Deligiannis, Loidl (HWU) Haskell vs. F# vs. Scala 15-Sep-2012 29 / 29
  • 37. Thank you for listening! Full paper and sources: http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/ fhpc12.html Email: {pt114, pd85, H.W.Loidl}@hw.ac.uk