Perl 6: Beyond dynamic vs. static

Video in TIB AV-Portal: Perl 6: Beyond dynamic vs. static

Formal Metadata

Perl 6: Beyond dynamic vs. static
Alternative Title
Perl - Perl 6: Beyond Dynamic vs. Static
Title of Series
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date
Production Year

Content Metadata

Subject Area
Observational study Symbolic dynamics Symbolic dynamics Static random-access memory Execution unit Mathematical optimization
Programming language Goodness of fit Run time (program lifecycle phase) Profil (magazine) Term (mathematics) Static random-access memory Electronic mailing list Archaeological field survey Planning Bit Formal language Compiler
Multiplication sign Static random-access memory Boilerplate (text) Fitness function Bit Discrete element method Formal language Compiler Internetworking Different (Kate Ryan album) Symbolic dynamics Static random-access memory Video game console Position operator
Module (mathematics) System call Parity (mathematics) Code Multiplication sign Static random-access memory Computer file Letterpress printing Bit Letterpress printing Computer programming Variable (mathematics) Symbolic dynamics Quicksort
Slide rule Pulse (signal processing) Code Static random-access memory Hecke operator Open set Line (geometry) Mereology Variable (mathematics) Computer programming Crash (computing) Energy level Compilation album
Pulse (signal processing) Default (computer science) Implementation Structural load Multiplication sign Static random-access memory Computer-generated imagery MIDI 1 (number) Variable (mathematics) 2 (number) Word Process (computing) Average Quicksort Escape character Resolvent formalism
Point (geometry) Run time (program lifecycle phase) State of matter Code Image resolution Multiplication sign Parameter (computer programming) Computer programming Declarative programming Automatic differentiation Impulse response Inference Mathematics Array data structure Radio-frequency identification Term (mathematics) String (computer science) Reduction of order Normal (geometry) Error message Compilation album Mathematical optimization Default (computer science) Parsing Software configuration management Chemical equation Structural load Static random-access memory Moment (mathematics) Sound effect Line (geometry) Variable (mathematics) System call Compiler Electronic signature Category of being Proof theory Type theory Message passing Personal digital assistant String (computer science) Summierbarkeit Figurate number Quicksort Object (grammar) Reading (process) Spacetime
Point (geometry) Pulse (signal processing) Run time (program lifecycle phase) Code Multiplication sign Compiler Student's t-test Computer programming Declarative programming Impulse response Term (mathematics) Core dump Boundary value problem Implementation Compilation album Social class Graph (mathematics) Static random-access memory Moment (mathematics) Projective plane Maxima and minima Line (geometry) Symbol table Compiler Data management Interpreter (computing) Computer science Quicksort Software architecture Object (grammar) Boundary value problem
Point (geometry) Pulse (signal processing) Game controller Run time (program lifecycle phase) Multiplication sign 1 (number) Set (mathematics) Parameter (computer programming) Open set Disk read-and-write head Rule of inference Lattice (order) Formal language Attribute grammar Power (physics) Impulse response Programmer (hardware) Mechanism design CAN bus Causality String (computer science) Operator (mathematics) Codierung <Programmierung> Compilation album Social class Module (mathematics) Link (knot theory) Inheritance (object-oriented programming) Closed set Static random-access memory Expression Content (media) Attribute grammar Menu (computing) Bit Hyperlink Instance (computer science) System call Compiler Word Inversion (music) Message passing Personal digital assistant Website Object (grammar) Quicksort Block (periodic table)
Point (geometry) Revision control Mathematics Matching (graph theory) Causality Code Closed set Static random-access memory Range (statistics) Error message Declarative programming Social class
Revision control Slide rule Building System call Inheritance (object-oriented programming) Multiplication sign Static random-access memory Moment (mathematics) Discrete element method Error message Physical system Condition number
Module (mathematics) System call Multiplication sign Static random-access memory Attribute grammar Right angle Bit Quicksort Disk read-and-write head Sturm's theorem Physical system Product (business)
Module (mathematics) Point (geometry) Parsing Context awareness Module (mathematics) Computer file Structural load Code Static random-access memory 1 (number) Bit 2 (number) Root Statement (computer science) Gastropod shell Software testing Software testing Quicksort Compilation album
Module (mathematics) Slide rule Code Static random-access memory Electronic mailing list Archaeological field survey Control flow Parameter (computer programming) Tracing (software) Symbol table Orbit Compiler Loop (music) Hash function Network topology Operating system output Gastropod shell Quicksort Routing Window
Module (mathematics) Meta element Service (economics) Computer file Multiplication sign Static random-access memory Numbering scheme Compiler Event horizon Declarative programming Computer programming Field (computer science) Compiler Type theory Event horizon Object (grammar) Social class
Bytecode Point (geometry) Service (economics) Computer file Code Patch (Unix) Multiplication sign Set (mathematics) Online help Parameter (computer programming) Solid geometry Event horizon Computer programming Attribute grammar Revision control Impulse response Arrow of time Endliche Modelltheorie Data structure Social class Module (mathematics) Default (computer science) Wrapper (data mining) Structural load Gender Static random-access memory Moment (mathematics) Electronic mailing list System call Compiler Electronic signature Type theory Membrane keyboard Event horizon Hash function Formal grammar Speech synthesis MiniDisc Object (grammar)
Game controller Game controller Group action Inheritance (object-oriented programming) Static random-access memory Price index Bit System call Template (C++) Template (C++) Web 2.0 Goodness of fit Software framework Quicksort Object (grammar) Multiplication Social class
Axiom of choice Game controller Default (computer science) Implementation Information Multiplication sign Static random-access memory Price index Bit Parameter (computer programming) Template (C++) Declarative programming Smith chart Template (C++) Uniform resource locator Medical imaging Uniform resource locator Personal digital assistant Quicksort Object (grammar) Intercept theorem Multiplication Social class
Logical constant Module (mathematics) Game controller Static random-access memory Web page Price index Variable (mathematics) Shift operator Declarative programming Template (C++) Wechselseitiger Ausschluss Queue (abstract data type) Object (grammar) Task (computing) Social class Condition number
Game controller Game controller Concurrency (computer science) Static random-access memory Web page Price index Variable (mathematics) System call Uniform resource locator Single-precision floating-point format Game theory Macro (computer science) Online chat Social class Condition number
Pulse (signal processing) Run time (program lifecycle phase) Code Similarity (geometry) Average Mereology Computer programming Formal language Impulse response Symbolic dynamics Static random-access memory Authorization Software framework Macro (computer science) Compilation album Condition number Software developer Structural load Static random-access memory Bit Line (geometry) Variable (mathematics) Compiler Category of being Integrated development environment Personal digital assistant Quicksort Object (grammar)
Point (geometry) Code State of matter Multiplication sign Control flow Computer programming Revision control Goodness of fit Googol Operator (mathematics) Error message Tunis Social class Module (mathematics) Noise (electronics) Computer font Meta element Multiplication Static random-access memory Mathematical analysis Basis <Mathematik> Bit Maxima and minima Line (geometry) Type theory Personal digital assistant Normal (geometry) Right angle Object (grammar) Quicksort
it not experience unit that want to talk about the prospects studies the dynamic of the company moved from the about what I I admire optimism I you other tend to have something interesting to say it's great to be a follows them again and that this is such a powerful room was who's here last year of my session is out of here OK does get everyone off the came last year of the summits even the least OK so by and an I like cold places this is my
vacation home ecclesia it was it was cool and that the so I am 1 of the folks who works on the the pulsar compiler stuff which means that in many ways I'm other folks to probably is going to get lynched if we don't actually could 6 0 this year and so I'm and developing plans but where I can go into hiding and all of these things but actually yeah plant plant put out of that that's that's a good advice yeah know but plant shaped yeah I was this shit saving would probably also work the primary plan is actually to the local 6 but anyway as so and I'm I work a lot on the of course opposes compiler and and the more the runtime so to some some of the uh bits of work and in many ways that I guess is a bit of a language polyglot in the programming language sense and that actually was preparing this talk I saw the fall back over the last year what languages that actually deliver codon that people use and they realize it was a little bit of a list and people actually even paid me to do some of these I actually want to harvesters are getting paid for it that's that's kind of something and now no it was because I was writing the UI for the pulsar 6 profile and that is really really slow because it it will in JavaScript's I used Angular JS um so it looks beautiful and it what really slow so there anyway and if I take these languages and I was to do a little survey OK of whether people would call and static or dynamic I think I would say probably get answers like this OK any lower hackled disagree no OK so and even though these terms are to me very well you know very well defined and we tend to sort of be pretty good at putting languages into what no 1 can or the other and
they're having get worked with or you know these languages over the last year and I can say that they have benefits and drawbacks in the being debated plenty and they don't really plan to to add fuel to that fire and but I can't say that I felt the pleasure and pain that comes from both sides and the I'm not really here to talk
about what's best and you know that there's plenty of places on the internet you can go and do that OK and just just search for is static Bezman dynamic and is dynamic better than static and you will have you know weeks and weeks of stuff to read and however and what they do like is the times when I can
sort of have my cake and eat it OK and 1 of the things that excite me about health fixes feels to me like 1 of those languages where a lot of the design calls them be made and a lot of the things we have kind of growing as a fit into this kind of position so the let's start out writing go a little bit of colonial do a few uh small examples in different languages OK so this is hopefully can easy code and we declare variable we assign something into it we do some bit of I O we have a lot of the boilerplate around it and what is this going to do is and wet 1 went what's going to fail but it's gonna fail to compile OK with the shot compiler is going to say the name morning the doesn't exist in the current context OK and well find so so it's another day and I'm
writing a Python Ruby is about the same actually when you start looking at parity bits of code sometimes you realize it really easy to be approving polyglot OK and but what are these gives you know and the money no and the here we're thinking about innovative they might fail yeah any other suggestions I printing what print and defines in my it will fail someone says yeah so actually them and when will it fail the run bingo again would
like that so that this is this is almost sort of you know articles of reckless dynamism and it's it's kind of that the sort of thing where we you know we we really put stuff off of solar and over time and it also we we take the miller 5 and we the the similar program and then we gonna get kind of the same and and that of course we don't do that we put you strict on the top again it tells a compile time so that his way and
other Dong without use strict pulse 6 program what is this 1 going to do you on the part of the is good for the opening of the 9 crash OK that's 1 idea anyone else exhales during compilation learning on we know that all what itself at all this this will I had a little slide hand it is it yet so what happens if the just above the x it fails
during compile OK and I mean seriously what the heck look at this thing it said sorry for my moronic typo I mean it's almost canadian level the plight here and I and then not only did it say it was sorry that I screwed up it went and looked at what variables they did declare said all maybe you meant morning instead of morally you probably this and that justice will help me out of because maybe this happened inside a nice long line of code it has a little full of green red thing OK and so so I was happily passing it was good I was happy and then I ejected here OK is ejects willful cassette player and and the everything beyond that was sad red OK so it points out exactly where on that line the problem was well that's kind of nice and this is just 1 of
many many examples the show you today when pulsates with 4 very carefully about what sort of things it's possible to know and complain about at compile time what sorts of things we really should make very dynamic and meet unresolved until for runtime and for all of those ones that we by default will tell you about a compile time we sort of also provide you a little escape valve but if you really really need it again so 1 of things
that has been really on both coming back to it again and again probable success design implementation process is just how valuable lexical scoping it's what do we mean by lexical scoping well it's just a fancy word for saying I I think he's between curly braces or a scope and anything that you declare inside of them with my lasts until the closing curly OK so in here instead of a little green scope on the outside about this is perfectly 1 OK and at the end of this purple 1 then we you know we got rid of some now we got rid of average we can't talk about them anymore thank so it's not just variables that 1 of the it's is not only know by default declared lexically remind resolve lexically but it's a it's also
subroutines so in 12 6 when you write club abbreviate that what do I actually kind of saying really if you wanted to put and 5 terms of my sub abbreviated and we haven't just made serve declaration lexical we made some resolution rest lexical so what happens is when you call a subroutine we go on we look for it in the current lexical scope and if we don't find it at the end we come back to said by the way and used this abbreviate spelled in a kind of abbreviated way at line 6 that and did you mean abbreviates for profit so this is just another place where writing will sober teens are you know the lexical by default will look them up and lexical we get a whole lot abilities of points devout compiled fine now you might at this point have some objections like how the way to x became welcome to those in just a moment now staying on this example the few more things that could go wrong the I mean if I'm having a bad day all type of things but it's a really bad day I'll forget 1 of the arguments and and because we can actually resolved as we compile this program what you calling we can take a look at this call we can say wait a minute you're passing a single argument there that appear in the that the signature says it wants to we'll tell you about a compiled fine in this case because we can No . letting him you know I the what back when the the they really get that was that me that entire and they'll say it is you know and then you you actually get all of them back they collects so we we classify it could pass errors in compilers into 2 categories we have panics and we have sorry no we say we sorry about all of them because just shouting Iike would be really really bad OK so what we do inside the compiler dough is we actually distinguish them and panic means we were passing the program but we can't possibly go any further because we to confuse and we'll just start spewing meaningless errors trying to guess but in other cases we spot the problem then we like this is definitely a problem we will compile the program but we still in the good state in we can keep passing and we actually distinguish them OK and we don't actually stopped collecting errors until we had something of the past so it's kind of a nice trade off between the 2 their effects in cases where I live this was C compilers again it 1 little mistake I get 100 hours for it and it's like come on show me the first one so I can actually even take that 1 step further the because but put in some types OK so a strength that's gonna be an enhanced antagonist happen now well I can actually even look at this and it can tell me you know that's definitely in and I can see is a literal OK it's really obvious to me as a compiler and it's really obvious to me is a string as well so your program is never possibly ever going to walk OK there is no way you can ever make this subroutine call and have it work at runtime no matter what you do this this is just never ever going to happen and we can put that out now there's only so many cases we can point is out so far and we don't have a lot of crazy inference and we actually we've been very careful about this because this in this case we can explain to what's going on OK we can say you call that women into the string and it wants a string and and and you can go and look at it and you can say 0 yeah I did and what we do not want to do is get to the point where we spit out this huge sort of massive mathematical proof we did of y your program of work and then you sort of look at it and you like a better get a phd before I do profits OK so that's that's not the goals we're trying to sort of balance out and telling you start without sort of going overboard and being able to understand you know what where we actually uh saying and for this 1 we catch little curiosity for you by the way you might be kids 1 guess what the the the compiler actually figure this out you know you you know you work on the compiler how that's cheating it essentially the optimizer and effect any that and really we're the optimizer is trying to prove properties about your program and help it optimizes and occasionally as it does so it proves your program could never actually work as a side effect again so we can get to 1 that I like that now I said that this is all a product of
lexical scoping but that I can only tell half the story that this what's really going on here is that those subroutines that you ads and those so those variables you declare the course they they exist at run time but they also sort of come into being at compile time as we compile your program and that is why by the time we get to the end of the the load of code we can start reasoning about so whenever I see a line of code like that OK that is taken an array of readings and the plus there is the reduction matterof OK it's like putting + between all the array elements and you get the sum of the and what we actually do is we can break that into the 2 things is say well you've done a declaration OK that is you have said that in this scope there exists a variable son and that it is something that we need a space for runtime as well and the run time of course we make every time you enter the scope some space to store that variable and we run the assignment of the play she wrote it but all the time when we do these things so picking the 2 apart and say well what does the compiler need to know and was going to go on at runtime OK so declarations impulse that's a very much a compile-time thing
just as the historical side and this idea of you know compile-time and run-time and objects that so there exist a compile-time so going over to run time was not 1 of those things that really took me a lot quite a while to get to terms with because when you compilers school OK well computer science classes and you got your compiler class and they sort of teach you know there's a compiler which does all the work at compile time and spits out a program and there's an interpreter which sort of terms its way through the code and and you know what you can understand a lot less out of that is sort of all the what possible shades of gray between an when I teach Software Architecture after show my my students a graph like this this is the ignorance crack OK is the idea that when you start working on something you're the point of maximum ignorance about it and over time hopefully it decreases and a lot of the time in the project can have an so hot moment where you understand something about the very core of the problem you sewing and for me with the pulse it's compiler actually this uh this sort of compile-time runtime boundary stuff of 1 of those things where can realized ha that's the reason that so much of code in the compilers really convoluted Back then if you actually wanted to you know just take a symbol that was can exist at compile time and try and said look at run time we saw that ad-hoc every way I wasn't too I realized that a really common thing that happens all the time and and of course that nowadays that's that's a line In the combined and as well as those places where you know as a manager of a lesson learned now OK let's talk about classes so
classes also declarations and that means that when we the class keyword and so we start writing methods in there and adding go back tributes in there step starts to exist at compile time and that provide us with a whole quite interesting opportunities so that this talk is about never called before we do that because that's that's kind 1 the reasons you write a class of data and the calling the methods on and the point so this is 1 of the things the impulse 6 and laid back prepare these of things that are resolved at runtime is completely up to the object that receives a method called to the side how it's going to handle it and that's very much in the spirit of the way that you know 0 0 works so you know if I'd write
something like this OK this this is a runtime you can tell cause we're not story about OK you laugh but if the reader visual and OK you get you get very useless when you're writing pulse if it's a sorry of their you know the compiler is telling you OK if it's not that you know you made it'll run for those things laughter while you you just take for granted and help you understand you know what do we need to do now you know in this case they're very class we have 3 fields OK and we we go we make an instance of it we call love a method that doesn't exist but that's that's clearly a runtime error now that that object there of course you know it it has a fairly fixed set of methods it could handle but so we very very dynamic about the whole method that is a lot of things you can do and you know what the easiest mechanisms we provide for this is the magical fullback method and the general design rule impulse 6 if something is uppercase it's something that global call for you in some kind of circumstance and fall back is 1 of these so we can write a horrible little he HTML producing here OK and what I do is I say hey HTML bald p and goes off it tries to call p method on this class and the class like I don't know how to p so what then happens but came about that at this time OK so well Mr. remember the example so what happens then the and fullback and the 1st thing that we get this past the name of the method we tried to call and then we get past the arguments that we tried to call it with 1 using a slower all of the positional warms up into an array and slow all of the the named ones up into a hatch and the other languages some horrible string munging and produce a bit of HTML and you can see that a k in the 1st case that the p taggers getting free children OK and therefore the a tag reviews the names argument there to get the attribution again of course don't actually do this without going and hooking it up to something that knows has HTML encode content of ways you gonna wonderful cross-site scripting but but but like the can shows the idea that you know an object is very much in control of the destiny of method calls the head of way and that it is 1 way of being able to sort of decide what to do with your method calls that you know you can't actually have so we make method calling a very the dynamic thing while the ways we actually thought about that impulse 6 linguistically we tend to consider a lexical scope as being your language it's the language you as a programmer writing as and when you to collect things in there you're adding words into your language that you can use and speak with when we make you may on the all over the so called the you the when using you know because there is a new method because you inherited it all use the site you you yes the doesn't know it actually assigns the attributes directly yeah so so no but not in that case yeah and so the method has the nonexistent any of your base classes and we get away new works is actually assigns to the attributes not calling a centers so yeah OK but that you have that the general principle is you not lexical scoping is always your language OK and you choose what you import into it and you choose what you declare there and you know it's it's something you all very much in control of and this is again a very general pulse 6 expressible we always know what language were so you know if you declare a new operator all you importer module that does add new operators and the language works just fine but at the end that that lexical scope the passes in recognize many more OK we keep all of these things very lexically constrained for any talking about the object the idea of objects is there a point of D. coupling their point of inversion of control where you say you know I want you to do this thing and you know I don't how you going to do it another define how you're going to do it but you know that's end of it is something I like you to do and it's up to the object and purpose for the words you tell it in the method called actually mean and and that's you know that the will of the power of the of objects and the very autonomous in that way so method calls all other things about classes that you know inherently we we really want to leave the very dynamic thing with a few other things in class is that you know maybe are a little bit more lexical that we can figure out by looking at what between the opening Kelly in the closing 1 so what is this 1 do and yeah that's a compile-time fail OK it's going to say the active you start here in declared and class war OK the and does however this what tha on the yeah compile-time fail again OK because this time it
actually also goes under this is quite a uh it's it's sort of a call mistake I don't make it that often but you know I get made now and then and that is forgetting the twiddle OK that that that exclamation mark then said this is actually an attribute of the class I'm interested in and what you've actually got there is just a mobile lexical worker and we actually catches them actually go and the when we catch these inwards inside the class we go unchecked when attributes the class has and saves the woman matches and suggested that so because it's it's it's 1 of those ones that people tripped up enough on that it's it's just kind of nice to point it out so and this is 1 the advantages of the year because it's compilers being written in you of pulse X and this feature this actual Mehra message edition was contributed about 1 month ago by someone who tripped up over this too many times some of like that nanopatches compiler so and we do
pretty much the same for private methods to OK so a private method is so a method that you can call anywhere in the the scope of this class and if you wanna call from out elsewhere you can tell the middle class trusts in the class but don't do that OK so so what I've got here is the I decided to refactor my code so I wrote a little uh uh little private methods use the exclamation mark that tells you it's private OK called a date range and it just makes a range from the start here to the engineer and that I want to call a private method compare the exclamation mark and I you know go and the smart match it against a year and it checks if that fall in the range and of course you know you can see what I've done here have gone and calls a math and then they and have them again we can come back to me at compile-time OK cause these non-virtual in it can say all you miss name that that private method when you call it so all of these things but where we made them you know lexical we have a very good all chooses how you about a compile-time and that includes roles
their so if you get the 2 roles and the going to provide something so the class that is in conflict when do we actually compose the roles for we we composed and when we hit the closing curly brace of your class declaration that's the actual composition point so as soon as we had that point we say OK let's composed roles in the class and then you know if anything is wrong it's an error so just to look at
an example OK we're building a little system for our friends who collects all books and rents them out so here I have an old book for rent OK it Borel ball so you can see that we can lend it out for a certain duration is going to cost the so the amount of borrow and then if the collectible so we know of to 1st edition whether it's in fine condition again so and that's fine until 1 day and you know we we get asked to change the system and we're told that so yeah actually these jerk people who borrow a bookstore ever returned in time so we want to start finding alright so we added a fine here good so they want spot but the problem the OK and then and now if you do that both X is
going to actually complete you I can think of top the 2nd half of that error message off uh which will do it came from so because there are my slide OK but the the thing you've been told there is that actually they are the 2 actually it should declare that they are in conflict and will tell you what methods that are in conflict of the moment thing and the 3rd if we done this was a multiple inheritance what would happen well no error and because it just turned out that completely arbitrarily you know
I I just full of horrible before collectible OK I would just have got the new behavior right within their overriding the the original 1 I had no warning OK no no heads you know system is often to production we have things happen OK so this is another place where you know at
compile time we can give you that extra bit of C good so what we're trying to do here
is you know balance out that in a very flexible method dispatch way even different whatever you like and with this this sort of the very you know of a large bunch of checking whether we can point out things that you almost certainly didn't mean on the Net actually going to work modules give you some interesting
opportunities because so when we know the Use statement we actually go off and load the module right away what that means is that at this point the module actually gets a chance to do some stuff and against the ducal do that's done in the context all the compilation of the bit of code that is going to do the use the other thing that we've done in keeping with all of the lexical the fold impulse that we've made imports lexical by the what that means is that if I have some curly braces Varanasi use test what can I do plan 42 again I close it I try and signal OK is going to come back and say 0 that's an undeclared retained a cake as we imported the stuff we needed just into 1 scope and after that schools gone OK the similar got and then you can just actually import that's why you need to know and I don't have to sort of you know do them all at the top of the file you can you can scoop these imports much more to the place is actually want the now you you might wonder you know
How can we and sort of you know do some slightly more dynamic things where we'd like to generate liberty and the various ways but modules are 1 of the really good ones so let's just write ourselves a little module and called it shell as OK when it's just a little module where am I name a couple of shell commands thing and trees root and that what I actually get as a couple of subroutines where I can just call the commands just by calling the OK now at the
module that's a lot of code so what we do is we write the survey explores and the at the input actually calls this when we use the module and it says that here are the things considering commands that we actually would like to uh this sort of have and the we get to interpret that however we want so we need to do is return the hash of the symbols that we want to have installed into the lexical scope of the thing that's doing the in so I need to do is loop over the commands for this little enormous orbiting and the takes some arguments OK runs the command flattens that argument list in there and then we'll just install it in this hash ampersand on the stock because that's the way so they're installed and return it with them now about that so the really nice thing about this is that I've just very dynamically gone and generated and produced subroutines on demand but what
happens if I you know I take the 1 that they've created there and then I you I spell it all the way out is trace route like you know as the operating system is Windows would do what happened I get all at compile-time OK it actually tells me here Trace were used OK this mean trees RT class OK and you might say why is it 1 more than the answer they do the minus B and then when I put it on the slide no I'm break with that so I beat you to ask me that it's not a compiler would OK so that that's and these and you can actually do that sort of thing with
classes to so I told you that you know when we encounter a class we make a declaration what they really mean by that what I mean is we go and we actually construct an object that represents that class so when we the method we construct an object representing that method we didn't have tribute we construct objects representing that attribute a character and for all of these things but really what the compiler is doing is it's just producing objects for you that describe the Declaration due making now occasionally some of us like the full of sound fancy and clever and that we call these objects mentor objects OK but actually off they just all objects that describes something in your program that's a lament object is and now How can we write a module that dynamically produces classes well the answer is no we just create the objects as the compiler would we export of turns and I have a little J. some file here maybe this is a very simple
scheme you know we're building some micro service chips events all over the place OK and and we have some schema and we just want the generate classes for all of these methods type that I've got this is oversimplified but you fly example licensable now OK it's got the name of the event I care when our class with that name and I want my class to have these different fields that now what I'd really like is to get to the use some module prepare the module is gonna read that Jason violet and reduce the classes can export them and I can then just use them and just to show you why it's really important that they exist at compile time if I to go to my radical here and I
say class food OK and then I say food on new it's actually going to complain and say all use them declared name through their so we actually want to know these names exist OK so we can't just really tedious and so it's let's
have a look at how we do it what we'll do is 1st of all is right a little help a subroutine to create our classes so that going at a name and it's going to get the set of values that we want to have attributes for and we're going to got trimester model I would take a class cooler class how and that is how the class what OK and that for all of the various things like grammar OK a grammar how rolled there's a role how OK I and what we do this is to say what I make a new type of and we tell it but the name should the dollar named by called bowler name actually is like passing a name parameter OK as named arrow stolen name that my speech or now we get sort out the at tributes and when you actually have finished creating a type membrane mention of the closing curly of a class that's when we finalize a lot of stuff OK what the compiler actually does the called composed on the objects representing the class and service thought have thing is actually recall ematical it's a call mold on the object itself OK but on the metal objects so it's only all gender described by class and so we saw the simulating that by closing curly and then will do it all the work over the things we want to have as as attributes will make a new at tributes objects OK will say it's a doorway mark attribute name I will say that so we don't care what type of value is stored and there I will say that that belongs on the the package bullet type OK that is the class we creating and we'd like it to have an excessive method generated and that's all we have to do it again composable were actually generate all the excessive so that's that's how we get across and now next up with very little in there and don't normally the way you export things is you put avec sport on OK and that that's it but because we're a little more than anarchy willing to do is just I explicitly put myself in the export the full package which is the default things we get export and then I'm going to use the GA some tiny module I give us look in adjacent file OK I know from J. solids which gives me back something and it had to be flat get into the flattening list that's the after the stop there and assigned it into this the events array and then I will group overdose OK and this this thing in the presence here is actually a signature unpack it means that what we're doing is we're saying well I'm looping over an array of patches but they don't actually will the hatch I want to pull out the name the combined at the Abdullah name and the values T invited the array values of k so it saves me having to unpack all of the hash so this is 1 the of nice things reducing is impulse X in the use of the data structure that or and then I generate the class for this name and values I stick it into the current packet OK and the name and we done and you only question that might remain is what is that begins thing OK when Paul sex you can precompile modules you can actually compile and say JVM bytecodes Morgan code and persisted on disk that persistence isn't just the code it's also all of these objects that we create a compile-time what this means is that the point that you compile this module 2 byte code for the 1st time that we can see that is the catch it will go off it will read the Jason file it will pass it it will generate all these classes OK in the future when you use that module it would have to do all of that anymore saved all the classes that we wrote just as if someone a program them by hand in a 4th file OK so we don't even have to pay the load cost every single time which is kind of nice what in the you have the things what you the then you you treated just as you know uh and a new version of the model and and the I would like to avoid the complications of so that yeah at the moment it happened that module installed I'm presuming here is Jason file is something you should put this little wrapper module and when you have data to a new version of it again you Jason some file we pre we recompiled because it's a new version and yet that's the way it currently the OK I think we have time for 1 last thing
so it classes roles that described using objects the what if we could actually sort of you know replace those objects or tweak those objects on maybe that could be an interesting well let's imagine rebuilding ourselves a little MVC framework and K and so where we decided we up without rooting call for me the control methods OK so here I have a a controller OK it inherits from some control of base class and I just said in the URL template for this action is this OK and I'm all the web framework designer so please don't cry too much Mel the what I want to do if I would like to sort of statically checked no when this framework is used when you write methods in the controller the you actually use the URL templates all the methods OK and if there aren't any would like to tell you a compile-time by the way you forgot the URL template can we do that well is it a little bit of infrastructure but it is my control a class that is the base class of things here good role Richard just holds uh URL template a notable excited I call a trait located at is key keyword what if that is there OK you can
choose what's going after that and the way you do it is by by writing will illustrate
most so retained and all I have to do is say what sort of declaration I want to my trait to apply to so this case methods and then I actually have a choice how I arrange for it to be called but the easy way is just the names parameter their matching the treatment and what actually gets passed that parameter is whatever the value is in the
province that OK well then do is I'll
just take this role you can actually use them as mixins into individual objects as well so this makes in the the method OK this URL templates we is very convenient syntax where a few or your makes it has only 1 public at tribute and you put something in France there we just initialized with that OK it's quite a convenient thing you do pretty often so what what is done is they've taken my method object images text of little bit of extra information onto it saying 0 in this is that you are the that's how we associate them how do we check that all the methods have them what I could do this time is turned away a special package called export house OK which is by exporting a mess objects that is falling objects that describe how things like classes well what I can do is I confess I want to supersede what class means having to do that by inheriting from the default implementation of classes and whenever you as a method preparing intercept might call and do some checking and provide the as well the recall same which is we delegate my base class OK that is do whatever adding a method normally would do and then there if but there they can actually just go and say well if this is a control and if the method isn't doesn't have a URL templates that is if we didn't URL template role into it than just die and say all this method likes the URL templates rest and then what else well actually that's it again I take this and I run it on this coat comes back to
me and said this about method lacks URL template for the so end and that you can push it even further you can actually do stuff where you where you get to declare your own kind of declarators I wrote a module for monitors withdrew concurrency constant and where
uh only 1 friend is allowed to be inside the object method that once and look at the start of this OK and so the writing class on you right monitor OK and then enforces the mutual exclusion for you but it gets better because you have this thing is called condition variables which basically air-conditioned you can wait on so I'm putting something into the queue I can wait on the condition multiple OK and when someone take something from the queue you can say 0 no we need the condition not fall what's really cute about this is if I was to register it
run this 1 out OK and OK and yeah it starts working runs OK a plot of land but here's the thing I wanted to actually show you if I
go and so those you know not fool instead of of k I a compile-time
narrative game what I've actually been able to do in here is so is actually do a whole bunch of stuff this this was actually more
evil because it's not only
exporting because the metaclass and until you can see that down here is the package supersede the sale of that declare a new kind of package again the monitor and you can imagine doing this the I'm deceivingly have a controlled class instead you know control something instead of a class something if you really wanted a carefully concurrency stuff it's really nice to have axle 1 as well but so actually wrote macros which of things that never really compile-time so what happens is this this meets condition OK it checks the main exists and then it goes and and actually this is the beginning of the active call single signal on it OK which is the low-level condition variables so tha not
much of land the it the yeah an actor runs a compile-time so by runtime yes and so yeah but no it's about when it runs so a macro gets a chance to say well you called me but actually I want you to compile this bit of code and the programs that yeah it's just like in line just like in line you yeah the so 1 the things that you might be looking at is is saying is all that's cool but can a crazy and and the answer is well I don't expect that the everyday user of pulse 6 is going to be you know going into another programming stuff why things really nice there was no we're putting into the hands of people who will why reason frameworks the tools to live a really nice developer experienced it doesn't matter that impulse thinks you framework is a part of the language because you can still find ways to get the compiler to do bits of checking on correct usage but in similar condition variable thing I think we have a lot of exciting things that explore here the summertimes about a case of citrus
together and I think for 1 impulse 6 we've made a lot of uh at a quite tasteful the full trade offs between static and dynamic where is that all these things that really make sense to try and decide as we compiled and tell you about these thinking of these things really want to be dynamic we really want to put them all 1 of things that author curious is by actually taking compilation which is the very static thing and saying we will allow the runtime in there we actually may all powerful and candles ironically is that very sort of great dynamism where we say even the language itself is mutable yeah but ironically opens the door to a whole load of really interesting opportunities to do not just the boring static checking like 0 yeah you call this method on this object and that object and declared had that method of their but a whole lot of much much more interesting program properties but you really would not like to make it out there into production environment so thanks for amateur listening um I probably use most of
my time but if I do have any left I I don't I don't to 2 minutes for full for OK then I will have more minutes for questions and if you're at the back then please make noise instead of just where you hand unified and stock and you have anything the OK 1 on the frontier certainly not the kind of problem the time your life but for the maximal uh yeah actually voc-caltech over now as pretty good API documentation on maximal stuff and so that that's discovered at least and I think there's a document now this whole ascribes to the big picture stuff over the wall so so yeah on some of the export stuff I'm not quite sure what the state of the the docks or that if then all what you want please say and them up so if I know a lot of documentation of the reason and I and you really was or was and you will the now Indonesian right that is this and this and this means they what do you mean in the world or yeah the only thing that I the the time and it also not wrong the mockery of uh it's done with levenstein and it has a a fresh hold on it so it has to be pretty close and we we actually think we even went and tweets to start and waiting things like you know Siegel's and decide how they so is it has had some tuning and you may write that yes and 0 8 only does it if your program is actually not compiler anyway so we have we've we've tried to make it non-obtrusive but useful and I think mostly we have 5 people seem to like it yeah OK that's good good basis the 2nd it spatial laughter the the the and you know was some of it yes yes you have no no no the the type analysis bits I was meaning specifically so that you know you call this summer team with these types of the actual reason that we doing that analysis is not for the particularly those cases the reason we doing it all the time as to the real of multi this fact candidates and and you adding say to native ends together we actually want in line the sort of low-level plus operator even though it's defined in a multi and so we actually looking for inlining opportunities all you know those sorts of things based on the types and yeah sometimes it just turns out the code you have the right to do that also produces all the errors for that sort of thing most of the rest of it is actually much earlier in the pipeline so we have yeah from what when you miss that you will have to look like a that won't have you all I would like to if you think about the the model and you will find lot yeah but there's a there an export how uh and uh so package composed and the idea of composed uh is that you will be able to have 2 modules that both provide instead for uh co at classes they provide roles and what will happen is that the 1st point you actually try and use the but the thing will will so create a subclass of the currently in walls meta object we'll compose those roles in the different modules of provided them then we'll do the normal role composition out for a moment and and then we'll be out of the tank you know metaclass conflicts and so that that's the goal that is specs and I didn't get that 1 yet but it's like 2 hours of programming when I can catch a break but a gay and that's my time thank you