it was finally christmas: perl 6 is here!

Post on 12-Feb-2017

495 Views

Category:

Software

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

ItwasfinallyChristmas: Perl6ishere! WimVanderbauwhede SchoolofCompu6ngScience UniversityofGlasgow

“Languageisideology”

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

Atripdownmemorylane

2007

•  Perl6/PugsinvitedtalkatPOPL2007•  AudreyTanghadcreatedPugs,aPerl6

implementa6oninHaskell•  Perl6waspromisedfor"Christmas”•  Andtherewassomedelay…

Perl6meline

DowJonesindex,1985-2015

Context

hZp://www.codeeval.com/

Context

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

Popularityofprogramminglanguages–TIOBE

Context

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

Popularityofprogramminglanguages–TIOBE

Perl

NeilStephenson,“Cryptonomicon”,p480

Perl5

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

Perl5

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

•  Incorporatesaseparatelanguage:regularexpressions(PCRE)

Perl5

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

Perl6

•  Isanewlanguage,notbackwardcompa6blewithPerl5.

•  S6llmostlyPerl•  Butamodernlanguage

CompilerandVM

Compiler(Rakudo)

hZps://github.com/rakudo/rakudo

VM(MoarVM)

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

Grammars

Parsing

• Perl6hasGrammars,Rules,TokensandRegexesaspartofthelanguage• Similartoclassesbutusedtoorganizeparsers

• Rulesarelexemeparsers• Tokensaretokenparsers• RegexesarePCREs

• Perl6isparsedandexecutedusingaPerl6-stylegrammar.

Objects

JavaScript

Python

Objects

Perl6Objects

Perl6Objects

Roles

Perl6Objects

• Accessorsforfree

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

Butwait…

Perl6Objects

Perl6Objects

Gradualtyping!

Gradualtyping

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

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

Gradualtyping:subsets

• Typeconstraintcheckedatrun6me

Gradualtyping:typecapture

• Deferthespecifica6onofatypeconstrainttothe6methefunc6oniscalled.• Allowstorefertoatypebothinthesignatureandthefunc6onbody.

Gradualtyping:typecapture • Deferthespecifica6onofatypeconstrainttothe6methefunc6oniscalled.• Allowstorefertoatypebothinthesignatureandthefunc6onbody.

Roles

Roles

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

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

•  So…

Nomorefunnycharacters!

• Actually,the“funnycharacters”arenowop6onal:

Polymorphicfunc6ons

• Alsoknownasmul6pledispatch

Polymorphicfunc6ons

• Alsoknownasmul6pledispatch

Polymorphicfunc6ons

• Looksfamiliar?

Parametricroles

• Rolesthattakeoneormoretypevariables

PossiblyMaybe

FuncHonalprogramming

Func6onalfeatures

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

Typecapturerevisited

• Typecapturealsoworkswithclosuresandlambdas

Lazylists

• Perl6dis6nguishesbetweensequences,listsandarrays.

• Sequencesareimmutable,butareconsumedwheniterated.• Listsareimmutable• Arraysaremutable

• BydefaultsSeq,ListandArrayarelazy,butcanbemadeeager.

SeqandList

Array

Promises

Concurrency

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

• Low-level• Threads• Schedulers• Locks

Promises

Conclusion

• 

Thank you!

top related