Greach 2013

Desmitificando el AST de Groovy

Andrés Almiray  · 

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

so let's begin a groovy AST demystify and I think that because of that that same topic there are so many people here interested to know probably what our asds and probably most importantly how can you make your own is the transformations this this was

one question that was asked a year ago or so when I gave a similar topic similar talk on this topic so quickly Who am I why do I believe I'm qualified to give this talk to you guys well first because i love java I jumpy to the Java bandwagon since the

early days since 95 because of pallets yes I know applets bad but I like job then I discover open source because of Linux and thanks to java and linux i discovered lynn grooving in 2006 it completely blew my mind away and one year after i kept pestering jian

when this doesn't work this doesn't work please fix this please fix this he said you know what you can fix it here's commit access to it please so that's what happen and after that with together with two other friends I we create a project

called Griffin which there is a talk tomorrow in case you're interested and currently working for canoes company in Switzerland I come from Mexico that's why my accent is a little bit different and uh well there is a book and Griffin because you're

interested am I also one of the few Latin America and Java champions so let's get on with the topic this is our agenda first I will describe what was my personal experience trying to get into NC transformations why you may need HD transformations why they

are so powerful and why they are what is that what they are then we will survey the whole list of AC transformations at least the local ones that are available in every groovy distribution and then we will come to the piece de resistance please the French

guys tell me if I sit correctly how to make your own SED transformation so first step we know this guy this is a standard Java Bean this is a standard Java yes we love Java is very verbose in order to create a simple property we know by heart that we had to

generate a getter and setter and so much noise around it this is me after a while after i had to deal with this code yeah ok one more bean yes I know that the ide of choice Eclipse idea which is better I will say netbeans or whatever you want can generate

this source code for you but the problem with generator source code is that it gets out of date immediately because if you had today generate a new property there goes the generate the source code you have to do it again change the name whatnot it's such

a pain but then in groovy I discover that and do this the compilers magically is aware of the javabeans convention and it's only a matter of defining the property name and the property type and boom I get the property and what is what's else well I'm

see i'm showing here that even though there are no method name that name and get name i can still make use of those that is because a compiler injected those methods or pretty much generated the methods into the bytecode this is me when I discover groovy

I couldn't believe my eyes this is exactly what I was waiting for because I previous to this I spent some time in dynamic language land yes I did PHP who did PHP before yes I know you guys I did pearl I like / and I did some JavaScript yeah before the

hipsters came in and say oh JavaScript the best language ever and it's a true language and whatnot so yes I I long for some dynamism inside the Java language but it wasn't meant b-but then groovy came along and say hey this is it and after a while

I discovered these little project called Grails which was in version 02 or old tree at the time this is remember 2006 and I noticed something funny that if I follow some conventions like that this definition that property and the constraints thing here then

I could do some crazy stuff like calling a method that was not defined by me neither the compiler but it will still work and based on some does again those naming conventions it would be easier to infer the rules what those methods could be and this is me

afterwards now i'm really interested what's the new meme you got my curiosity now you have my attention where's the other way around anyway I said hmm how I thought for a moment how are these guys doing this stuff well turns out there is something

called runtime metaprogramming this is how the Grails at the time was able to figure out based on those conventions that this method was a valid one and it can only be called once the application is running or when your tests are running which is great but

I still have to eat I had to put bread on my table and at the time java was the one doing that stuff for me now is groovy now I'm fine so I'm not starving you can see ah so I wanted to have this kind of facility to call these methods from Java well

no such luck because again its runtime metaprogramming but then along came a SD transformations when grube 16 was released and this is the time when we can say we can do compile-time metaprogramming this is exactly what a sweet transformations allows you to

do update the code generator code change the code in such a way that it feels that you're doing runtime metaprogramming but everything is baked into right there in the bytecode the aftermath is that yes you have this dynamic behavior just running but those

new additions those things that you do and you apply to the x code are visible to Java code as well so now it doesn't matter which JVM language you use if you happen to make use of st transformations to generate all those all those kind of blocks of boilerplate

code or variable scope they are already gone now you can use them from anywhere now for that if you ever see this guy walking on the street dinah for him please stop him and say thank you very much he is the guy that eventually put the first or made the first

iteration what we call the asd transformation framework this guy lives in Colorado Springs because you have a go to Colorado search for him so thanks to him we can do crazy stuff today like this this is the first AST transformation implemented ever it happens

to be a lot of transformation and it happens to be related to desktop application development thank you very much desktop development application is still important see so there are two types of transformations local and global we will start with local transformations

because they are the easier to grasp what you need for our local a street transformation is first and annotation the annotation is like an anchor your entry point is where you instruct the compiler something magical will happen here so we're saying that

[ ... ]

Nota: se han omitido las otras 3.229 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.