SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022Alexander Ioffe
 
Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Julien Truffaut
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Philip Schwarz
 
Context free languages
Context free languagesContext free languages
Context free languagesJahurul Islam
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...Philip Schwarz
 
Hackolade Tutorial - part 1 - What is a data model
Hackolade Tutorial - part 1 - What is a data modelHackolade Tutorial - part 1 - What is a data model
Hackolade Tutorial - part 1 - What is a data modelPascalDesmarets1
 
Impossibility of Consensus with One Faulty Process - Papers We Love SF
Impossibility of Consensus with One Faulty Process - Papers We Love SFImpossibility of Consensus with One Faulty Process - Papers We Love SF
Impossibility of Consensus with One Faulty Process - Papers We Love SFHenryRobinson
 
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraApache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraFlink Forward
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of CompositionScott Wlaschin
 
Capabilities for Resources and Effects
Capabilities for Resources and EffectsCapabilities for Resources and Effects
Capabilities for Resources and EffectsMartin Odersky
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Scott Wlaschin
 
1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリNVIDIA Japan
 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsPhilip Schwarz
 
Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type ClassesJohn De Goes
 
Confluent Partner Tech Talk with SVA
Confluent Partner Tech Talk with SVAConfluent Partner Tech Talk with SVA
Confluent Partner Tech Talk with SVAconfluent
 
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
 
Building Scalable Data Pipelines - 2016 DataPalooza Seattle
Building Scalable Data Pipelines - 2016 DataPalooza SeattleBuilding Scalable Data Pipelines - 2016 DataPalooza Seattle
Building Scalable Data Pipelines - 2016 DataPalooza SeattleEvan Chan
 

Mais procurados (20)

ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022
 
Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
 
ゼロから始めるQ#
ゼロから始めるQ#ゼロから始めるQ#
ゼロから始めるQ#
 
Context free languages
Context free languagesContext free languages
Context free languages
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
 
Hackolade Tutorial - part 1 - What is a data model
Hackolade Tutorial - part 1 - What is a data modelHackolade Tutorial - part 1 - What is a data model
Hackolade Tutorial - part 1 - What is a data model
 
Impossibility of Consensus with One Faulty Process - Papers We Love SF
Impossibility of Consensus with One Faulty Process - Papers We Love SFImpossibility of Consensus with One Faulty Process - Papers We Love SF
Impossibility of Consensus with One Faulty Process - Papers We Love SF
 
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraApache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of Composition
 
Capabilities for Resources and Effects
Capabilities for Resources and EffectsCapabilities for Resources and Effects
Capabilities for Resources and Effects
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)
 
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging modulePython Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
 
1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ
 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also Programs
 
Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type Classes
 
Confluent Partner Tech Talk with SVA
Confluent Partner Tech Talk with SVAConfluent Partner Tech Talk with SVA
Confluent Partner Tech Talk with SVA
 
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...
 
Building Scalable Data Pipelines - 2016 DataPalooza Seattle
Building Scalable Data Pipelines - 2016 DataPalooza SeattleBuilding Scalable Data Pipelines - 2016 DataPalooza Seattle
Building Scalable Data Pipelines - 2016 DataPalooza Seattle
 

Destaque

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
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 

Destaque (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
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 

Semelhante a 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
 

Semelhante a 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
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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.
 

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