it was finally christmas: perl 6 is here!

52
It was finally Christmas: Perl 6 is here! Wim Vanderbauwhede School of Compu6ng Science University of Glasgow

Upload: wim-vanderbauwhede

Post on 12-Feb-2017

496 views

Category:

Software


3 download

TRANSCRIPT

Page 1: It was finally Christmas: Perl 6 is here!

ItwasfinallyChristmas: Perl6ishere! WimVanderbauwhede SchoolofCompu6ngScience UniversityofGlasgow

Page 2: It was finally Christmas: Perl 6 is here!

“Languageisideology”

Kress,Gunther,etal."Languageasideology."(1982).

Page 3: It was finally Christmas: Perl 6 is here!

Atripdownmemorylane

Page 4: It was finally Christmas: Perl 6 is here!

2007

Page 5: It was finally Christmas: Perl 6 is here!

•  Perl6/PugsinvitedtalkatPOPL2007•  AudreyTanghadcreatedPugs,aPerl6

implementa6oninHaskell•  Perl6waspromisedfor"Christmas”•  Andtherewassomedelay…

Page 6: It was finally Christmas: Perl 6 is here!

Perl6meline

DowJonesindex,1985-2015

Page 7: It was finally Christmas: Perl 6 is here!

Context

hZp://www.codeeval.com/

Page 8: It was finally Christmas: Perl 6 is here!

Context

TIOBEIndexforFebruary2016,hZp://www.6obe.com/

Popularityofprogramminglanguages–TIOBE

Page 9: It was finally Christmas: Perl 6 is here!

Context

TIOBEIndexforFebruary2016,hZp://www.6obe.com/

Popularityofprogramminglanguages–TIOBE

Page 10: It was finally Christmas: Perl 6 is here!

Perl

NeilStephenson,“Cryptonomicon”,p480

Page 11: It was finally Christmas: Perl 6 is here!

Perl5

•  Interpreted•  Dynamicallytyped•  Garbagecollec6on•  InthatsenseverysimilartoJavaScript,Python,Ruby,…

Page 12: It was finally Christmas: Perl 6 is here!

Perl5

•  Usesfunnycharactersfortyping:$:scalar@:array(list)%:hash(dic6onary,map)&:subrou6ne

•  Incorporatesaseparatelanguage:regularexpressions(PCRE)

Page 13: It was finally Christmas: Perl 6 is here!

Perl5

•  Butalso:•  Lexicalscoping•  Higher-orderfunc6ons•  Anonymousfunc6ons•  Closures

Page 14: It was finally Christmas: Perl 6 is here!

Perl6

•  Isanewlanguage,notbackwardcompa6blewithPerl5.

•  S6llmostlyPerl•  Butamodernlanguage

Page 15: It was finally Christmas: Perl 6 is here!

CompilerandVM

Page 16: It was finally Christmas: Perl 6 is here!

Compiler(Rakudo)

hZps://github.com/rakudo/rakudo

Page 17: It was finally Christmas: Perl 6 is here!

VM(MoarVM)

•  Meta-objectprotocolbased•  Precise,genera6onal,andparallelGC•  First-classcodeobjects,closures,…•  Excep6ons•  Con6nua6ons•  Threads,mutexes,…•  JITcompila6onhZps://github.com/MoarVM/MoarVM

Page 18: It was finally Christmas: Perl 6 is here!

Grammars

Page 19: It was finally Christmas: Perl 6 is here!

Parsing

• Perl6hasGrammars,Rules,TokensandRegexesaspartofthelanguage• Similartoclassesbutusedtoorganizeparsers

• Rulesarelexemeparsers• Tokensaretokenparsers• RegexesarePCREs

• Perl6isparsedandexecutedusingaPerl6-stylegrammar.

Page 20: It was finally Christmas: Perl 6 is here!
Page 21: It was finally Christmas: Perl 6 is here!

Objects

Page 22: It was finally Christmas: Perl 6 is here!

JavaScript

Python

Objects

Page 23: It was finally Christmas: Perl 6 is here!

Perl6Objects

Page 24: It was finally Christmas: Perl 6 is here!

Perl6Objects

Roles

Page 25: It was finally Christmas: Perl 6 is here!

Perl6Objects

• Accessorsforfree

• Defaultconstructor • Inheritance• Roles(mixins) • BuiltonaMetaObjectProtocol• Fullintrospec6on• Sos6llnothingspecial…

Page 26: It was finally Christmas: Perl 6 is here!

Butwait…

Page 27: It was finally Christmas: Perl 6 is here!

Perl6Objects

Page 28: It was finally Christmas: Perl 6 is here!

Perl6Objects

Page 29: It was finally Christmas: Perl 6 is here!

Gradualtyping!

Page 30: It was finally Christmas: Perl 6 is here!

Gradualtyping

• Bydefaultvariablesaredynamicallytyped.• Explicitlytypedvariablesaresta6callytyped.• Buttypecheckscanbedeferredtorun6me.• Underlyingtheory:

hZps://github.com/samth/gradual-typing-bib

Page 31: It was finally Christmas: Perl 6 is here!

Gradualtyping:subsets

• Typeconstraintcheckedatrun6me

Page 32: It was finally Christmas: Perl 6 is here!

Gradualtyping:typecapture

• Deferthespecifica6onofatypeconstrainttothe6methefunc6oniscalled.• Allowstorefertoatypebothinthesignatureandthefunc6onbody.

Page 33: It was finally Christmas: Perl 6 is here!

Gradualtyping:typecapture • Deferthespecifica6onofatypeconstrainttothe6methefunc6oniscalled.• Allowstorefertoatypebothinthesignatureandthefunc6onbody.

Page 34: It was finally Christmas: Perl 6 is here!

Roles

Page 35: It was finally Christmas: Perl 6 is here!

Roles

• BasisforthePerl6typesystem• Usedforcomposi6onandmixins• InPerl6,the“funnycharacters”aresyntaxforasetofpredefinedroles:

@:Posi6onal(array)%:Associa6ve(hash)&:Callable(subrou6ne)

•  So…

Page 36: It was finally Christmas: Perl 6 is here!

Nomorefunnycharacters!

• Actually,the“funnycharacters”arenowop6onal:

Page 37: It was finally Christmas: Perl 6 is here!

Polymorphicfunc6ons

• Alsoknownasmul6pledispatch

Page 38: It was finally Christmas: Perl 6 is here!

Polymorphicfunc6ons

• Alsoknownasmul6pledispatch

Page 39: It was finally Christmas: Perl 6 is here!

Polymorphicfunc6ons

• Looksfamiliar?

Page 40: It was finally Christmas: Perl 6 is here!

Parametricroles

• Rolesthattakeoneormoretypevariables

Page 41: It was finally Christmas: Perl 6 is here!

PossiblyMaybe

Page 42: It was finally Christmas: Perl 6 is here!

FuncHonalprogramming

Page 43: It was finally Christmas: Perl 6 is here!

Func6onalfeatures

• Higher-orderfunc6ons• Anonymousfunc6ons(lambdas)• Currying• Immutablelists,lazyevalua6on• Tailcallop6miza6on• Op6onalimmutablevariables

Page 44: It was finally Christmas: Perl 6 is here!

Typecapturerevisited

• Typecapturealsoworkswithclosuresandlambdas

Page 45: It was finally Christmas: Perl 6 is here!

Lazylists

• Perl6dis6nguishesbetweensequences,listsandarrays.

• Sequencesareimmutable,butareconsumedwheniterated.• Listsareimmutable• Arraysaremutable

• BydefaultsSeq,ListandArrayarelazy,butcanbemadeeager.

Page 46: It was finally Christmas: Perl 6 is here!

SeqandList

Page 47: It was finally Christmas: Perl 6 is here!

Array

Page 48: It was finally Christmas: Perl 6 is here!

Promises

Page 49: It was finally Christmas: Perl 6 is here!

Concurrency

• High-level• Promises(futures)• Channels• Supplies

• Low-level• Threads• Schedulers• Locks

Page 50: It was finally Christmas: Perl 6 is here!

Promises

Page 51: It was finally Christmas: Perl 6 is here!

Conclusion

• 

Page 52: It was finally Christmas: Perl 6 is here!

Thank you!