Upgrade to Pro — share decks privately, control downloads, hide ads and more …

They're functional! They're efficient!! They're persistent data structures!!!

They're functional! They're efficient!! They're persistent data structures!!!

Functional programming is a cool paradigm to work in, because avoiding mutable objects can save you a lot of headaches! But when you’re using only immutable objects, you have to create a new object each time something changes, which means copying even the parts that didn’t change! This can slow things down, and you might even run out of memory!

Fear not: persistent data structures to the rescue! They save you time and space when modifying objects, by reusing parts of the old object that you don’t need to change! Let’s find out what that means and why it is SO AWESOME! And let’s learn how to easily use these structures in JavaScript!

(Given at !!Con 2016 - http://bangbangcon.com/)

Anjana Sofia Vakil

May 08, 2016
Tweet

More Decks by Anjana Sofia Vakil

Other Decks in Programming

Transcript

  1. 7KH\¶UH«
    )XQFWLRQDO
    (IILFLHQW
    3HUVLVWHQWGDWDVWUXFWXUHV
    #$QMDQD9DNLO
    &RQ

    View full-size slide

  2. )XQFWLRQDO3URJUDPPLQJ
    URFNV

    View full-size slide

  3. ,PPXWDELOLW\
    URFNV

    View full-size slide

  4. 1RERG\VLWVOLNHWKLVURFNVLWV
    7KHURFNMXVWVLWVDQGLV
    VZKDWZHQHHG
    ,䙧+XFNDEHHV
    ,OOXVWUDWLRQE\0DUFR3LD]]D

    View full-size slide

  5. » ¼ ½ ¾ ¿ À Á Â
    ,QWKHODQGRIPXWDELOLW\
    AJJ

    View full-size slide

  6. » ‹ ½ ¾ ¿ À Á Â
    ,QWKHODQGRIPXWDELOLW\
    AJJ

    View full-size slide

  7. 2YHUKHDG EXJV

    View full-size slide

  8. ,QWKHODQGRILPPXWDELOLW\
    » ¼ ½ ¾ ¿ À Á Â
    AJJ

    View full-size slide

  9. ,QWKHODQGRILPPXWDELOLW\
    » ¼ ½ ¾ ¿ À Á Â
    AJJ
    » ‹ ½ ¾ ¿ À Á Â
    RJJ

    View full-size slide

  10. &RS\LQJZDVWHVWLPHVSDFH

    View full-size slide

  11. 7KHUHPXVWEHDEHWWHUZD\

    View full-size slide

  12. 3HUVLVWHQW'DWD6WUXFWXUHV

    View full-size slide

  13. 2OGYHUVLRQVQHYHUFKDQJH
    WKH\MXVWVLWDQGDUH

    View full-size slide

  14. 1HZYHUVLRQVFUHDWHGHIILFLHQWO\
    '

    View full-size slide

  15. 5HXVHXQFKDQJHGSDUWV

    View full-size slide

  16. /LQNHGOLVWV
    » ¼ ½ ¾
    AJJ

    View full-size slide

  17. /LQNHGOLVWV
    » ¼ ½ ¾
    AJJ
    » ‹
    RJJ

    View full-size slide

  18. /LQNHGOLVWV
    » ¼ ½ ¾
    AJJ
    » ‹
    RJJ

    View full-size slide

  19. 7UHHV
    ,OOXVWUDWLRQE\0DUFR3LD]]D

    View full-size slide

  20. 7UHHV
    :HOODFWXDOO\
    WULHV
    ,OOXVWUDWLRQE\0DUFR3LD]]D

    View full-size slide

  21. 7UHHV
    :HOODFWXDOO\
    WULHV
    1RZHOODFWXDOO\¶V
    ,OOXVWUDWLRQE\0DUFR3LD]]D

    View full-size slide

  22. 7UHHV
    2RSVVRUU\
    :HOODFWXDOO\
    WULHV
    1RZHOODFWXDOO\¶V
    ,OOXVWUDWLRQE\0DUFR3LD]]D

    View full-size slide

  23. 7UHHV
    » ¼ ½ ¾ ¿ À Á Â

    View full-size slide

  24. 7UHHV
    » ¼ ½ ¾ ¿ À Á Â

    View full-size slide

  25. 7UHHV
    » ¼ ½ ¾ ¿ À Á Â

    View full-size slide

  26. 7UHHV
    » ¼ ½ ¾ ¿ À Á Â

    View full-size slide

  27. 7UHHV
    » ¼ ½ ¾ ¿ À Á Â
    AJJ

    View full-size slide

  28. 7UHHV3DWKFRS\LQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â

    View full-size slide

  29. 7UHHV3DWKFRS\LQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »

    View full-size slide

  30. 7UHHV3DWKFRS\LQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »

    View full-size slide

  31. 7UHHV3DWKFRS\LQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »

    View full-size slide

  32. 7UHHV3DWKFRS\LQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »
    RJJ

    View full-size slide

  33. 7UHHV3DWKFRS\LQJ6WUXFWXUDOVKDULQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »
    RJJ

    View full-size slide

  34. 7UHHV3DWKFRS\LQJ6WUXFWXUDOVKDULQJ
    » ¼ ½ ¾
    AJJ
    ¿ À Á Â
    ‹
    »
    RJJ

    View full-size slide

  35. ,PPXWDELOLW\
    &RS\LQJ
    6KDULQJ '

    View full-size slide

  36. 0RUL
    KWWSVVZDQQRGHWWHJLWKXELRPRUL
    QOJMŸ¼†½ ‡
    QJIEŸA†¾ ‡
    Ɣ &ORMXUH6FULSWSRUW
    Ɣ )XQFWLRQDO$3,
    Ɣ )DVW
    ,PPXWDEOHMV
    KWWSVIDFHERRNJLWKXELRLPPXWDEOHMV
    QQƔ -6WKURXJK WKURXJK
    Ɣ 3XEOLFPHWKRGV
    Ɣ $ELWVPDOOHUWKDQ0RUL
    -DYD6FULSW

    View full-size slide

  37. /LEUDULHVIRURWKHUODQJXDJHVWRR

    View full-size slide

  38. RUMXVWXVHDIXQFWLRQDOODQJXDJH
    VD\&ORMXUH

    View full-size slide

  39. )XUWKHU5HDGLQJ
    ³8QGHUVWDQGLQJ&ORMXUH¶V3HUVLVWHQW9HFWRUV´
    -HDQ1LNODV/
    RUDQJH
    KWWSK\SLULRQFRPPXVLQJVXQGHUVWDQGLQJSHUVLVWHQWYHFWRUSW
    ³,GHDO+DVK7UHHV´
    3KLO%DJZHOO
    KWWSODPSZZZHSIOFKSDSHUVLGHDOKDVKWUHHVSGI

    View full-size slide

  40. 7KDQNVIRUOLVWHQLQJ
    ,¶P#$QMDQD9DNLO
    +XJHWKDQNVWR
    5HFXUVH&HQWHUDOXPV
    6DO%HFNHU)¶
    &RQRUJDQL]HUV

    View full-size slide