Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

It was finally Christmas: Perl 6 is here!

In this talk I introduce Perl 6 and some of its exciting new features, especially gradual typing, roles and some functional programming features like lazy lists.
This talk was given at the Scottish Programming Languages Seminar on 24th Feb 2016 at the School of Computing Science of Glasgow University.

  • Als Erste(r) kommentieren

It was finally Christmas: Perl 6 is here!

  1. 1. It was finally Christmas: Perl 6 is here! Wim Vanderbauwhede School of Compu6ng Science University of Glasgow
  2. 2. “Language is ideology” Kress, Gunther, et al. "Language as ideology." (1982).
  3. 3. A trip down memory lane
  4. 4. 2007
  5. 5. •  Perl6/Pugs invited talk at POPL 2007 •  Audrey Tang had created Pugs, a Perl 6 implementa6on in Haskell •  Perl 6 was promised for "Christmas” •  And there was some delay …
  6. 6. Perl 6meline Dow Jones index, 1985-2015
  7. 7. Context hZp://www.codeeval.com/
  8. 8. Context TIOBE Index for February 2016, hZp://www.6obe.com/ Popularity of programming languages – TIOBE
  9. 9. Context TIOBE Index for February 2016, hZp://www.6obe.com/ Popularity of programming languages – TIOBE
  10. 10. Perl Neil Stephenson, “Cryptonomicon”, p480
  11. 11. Perl 5 •  Interpreted •  Dynamically typed •  Garbage collec6on •  In that sense very similar to JavaScript, Python, Ruby, …
  12. 12. Perl 5 •  Uses funny characters for typing: $: scalar @: array (list) %: hash (dic6onary, map) &: subrou6ne •  Incorporates a separate language: regular expressions (PCRE)
  13. 13. Perl 5 •  But also: •  Lexical scoping •  Higher-order func6ons •  Anonymous func6ons •  Closures
  14. 14. Perl 6 •  Is a new language, not backward compa6ble with Perl 5. •  S6ll mostly Perl •  But a modern language
  15. 15. Compiler and VM
  16. 16. Compiler (Rakudo) hZps://github.com/rakudo/rakudo
  17. 17. VM (MoarVM) •  Meta-object protocol based •  Precise, genera6onal, and parallel GC •  First-class code objects, closures, … •  Excep6ons •  Con6nua6ons •  Threads, mutexes, … •  JIT compila6on hZps://github.com/MoarVM/MoarVM
  18. 18. Grammars
  19. 19. Parsing •  Perl 6 has Grammars, Rules, Tokens and Regexes as part of the language •  Similar to classes but used to organize parsers •  Rules are lexeme parsers •  Tokens are token parsers •  Regexes are PCREs •  Perl 6 is parsed and executed using a Perl 6-style grammar.
  20. 20. Objects
  21. 21. JavaScript Python Objects
  22. 22. Perl 6 Objects
  23. 23. Perl 6 Objects Roles
  24. 24. Perl 6 Objects •  Accessors for free •  Default constructor •  Inheritance •  Roles (mixins) •  Built on a Meta Object Protocol •  Full introspec6on •  So s6ll nothing special …
  25. 25. But wait …
  26. 26. Perl 6 Objects
  27. 27. Perl 6 Objects
  28. 28. Gradual typing!
  29. 29. Gradual typing •  By default variables are dynamically typed. •  Explicitly typed variables are sta6cally typed. •  But type checks can be deferred to run 6me. •  Underlying theory: hZps://github.com/samth/gradual-typing-bib
  30. 30. Gradual typing: subsets •  Type constraint checked at run 6me
  31. 31. Gradual typing: type capture •  Defer the specifica6on of a type constraint to the 6me the func6on is called. •  Allows to refer to a type both in the signature and the func6on body.
  32. 32. Gradual typing: type capture •  Defer the specifica6on of a type constraint to the 6me the func6on is called. •  Allows to refer to a type both in the signature and the func6on body.
  33. 33. Roles
  34. 34. Roles •  Basis for the Perl 6 type system •  Used for composi6on and mixins •  In Perl 6, the “funny characters” are syntax for a set of predefined roles: @: Posi6onal (array) %: Associa6ve (hash) &: Callable (subrou6ne) •  So …
  35. 35. No more funny characters! •  Actually, the “funny characters” are now op6onal:
  36. 36. Polymorphic func6ons •  Also known as mul6ple dispatch
  37. 37. Polymorphic func6ons •  Also known as mul6ple dispatch
  38. 38. Polymorphic func6ons •  Looks familiar?
  39. 39. Parametric roles •  Roles that take one or more type variables
  40. 40. Possibly Maybe
  41. 41. FuncHonal programming
  42. 42. Func6onal features •  Higher-order func6ons •  Anonymous func6ons (lambdas) •  Currying •  Immutable lists, lazy evalua6on •  Tail call op6miza6on •  Op6onal immutable variables
  43. 43. Type capture revisited •  Type capture also works with closures and lambdas
  44. 44. Lazy lists •  Perl 6 dis6nguishes between sequences, lists and arrays. •  Sequences are immutable, but are consumed when iterated. •  Lists are immutable •  Arrays are mutable •  By defaults Seq, List and Array are lazy, but can be made eager.
  45. 45. Seq and List
  46. 46. Array
  47. 47. Promises
  48. 48. Concurrency •  High-level •  Promises (futures) •  Channels •  Supplies •  Low-level •  Threads •  Schedulers •  Locks
  49. 49. Promises
  50. 50. Conclusion • 
  51. 51. Thank you!

×