GraalVM | The Polyglot VM | Spring Boot in Graal | Tech Primers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how many times have we had issues with interoperability between different programming languages basically creating applications with different programming languages the compliation time the run time the way you compile the way you deploy the way you run stuff it's always an overhead when you have different programming languages because the way you compile and run is completely different from different languages let's look at how the open-source community along with Oracle is trying to solve this particular problem of interoperability between different programming languages let's get started [Music] there's the bell icon on the YouTube app and never miss any updates from tech famous growl BM is a completely polyglot virtual machine if you have worked on the jvm languages you know what is a virtual machine the java virtual machine is nothing but the JVM however with growl VM Oracle and the open-source community is trying to create a universal VM or a polyglot VM using which you can run applications which could be designed in different programming languages like Java JavaScript Python Ruby R and also with languages such as C and C++ additional to that it supports the jvm languages like Scala Java Kotlin and closure because these are going to anyway create these jars so growl Miam is a project which is aimed at polyglot so there will be zero overhead in interoperability between programming languages and it allows you to write polyglot applications so what do I mean by polyglot applications you can write an application with different languages and they will be running the same VM for example calling JavaScript from Java or calling C++ from JavaScript etc so how does growl BM achieve it growl VM compiles the code into a native image and it runs code in that particular VM with that particular native image if you had seen what Java used to provide as Java used to provide this concept of compile once and then run anywhere right and that concept is going away because most of the time we are all running applications in Linux based in Romans and Linux based containers for example docker right in order to make things faster in order to make applications load faster and use interoperability between different programming languages we will have to sacrifice something or the other and the sacrifices which we are getting here is the concept of build once and then run in any platform right so just in compiler used to convert our bytecode into the machine understandable code based on the particular machine right however now we have to create a native image specifically for a particular machine and we are going to run these images faster than before by leveraging this native image concept so let's try experimenting the Guardium by running a Java project and a C++ project in the same VM right in order to do that you will have to download graal VM and install it in your machine I don't have docker right now so you can also use docker to have a container created and then run it from there unfortunately the docker the latest docker version doesn't support my version of Mac because it's pretty old so I'm going to use the Google cloud platform in order to use the docker image so I'm going to use the cloud shell if you had seen my kubernetes videos you would have seen what is cloud shell I'll just brief at what is cloud shell cloud shell is a shell prompt created for a specific user if you are using the Google cloud platform so you can have docker you can have G cloud you can have Java installed in this particular space so I'm going to use it for my purpose so this is a compute which is created for the login which you have under Google cloud platform so I'm going to use this particular cloud shell for this particular demo so I'm going to try and use the docker image of the growl VM and login to the docker image and then see what are the different versions and we will create a spring boot application and run it in graal VM so we already created a spring good application as a part of previous videos I'm going to use this same spring good application so which is called spring boot lazy in it example I also have created a folder called corral VM right now there is nothing in it because I don't need anything there so let's do a clear if you don't have a Google floor account and still want to try it out you can go to the github account of the grail VM team so it's github.com slash growl VM and you can use the growl VM from there so if you go to the documentation and say get started or in fact if you say try a try growl VM there is a there are some steps on how you can download for example navigate to the Downloads option if I click on it you can download this from github I am going to use the community edition but if you want to use the end price addition you can go ahead and use it I'm going to click here the Enterprise Edition is free for evaluation you cannot use software which you can sell via the Enterprise Edition however you can use the Community Edition for that particular purpose I am going to use the same Community Edition see this this particular version got released twelve days ago and it's pretty much a new concept so it's not production ready for supporting full-fledged enterprise applications but it is in the testing phase right now so you can download the package here so I have downloaded the zip from here for my local Mac but I'm not going to show that particular example I'm going to show from the cloud shell so you know to use this in the cloud shell I'm not going to download the project from github instead I'm going to use the docker image provided by the girl VM team so that I have a docker container running with a growl VM and I can try out stuff there right so I'm going to do that so let me get the command for doing it so if you want to pull the image you can do a docker pull and give this particular image URL the oracle growl vm c 1.0 so whenever we run the docker run come on it's going to check if the image is present locally if not it's going to pull the image dynamically so that's what is happening here I don't have the image locally present in my cloud shell so it's downloading it on the fly right now so the docker run ID and the image and I'm saying that login to the docker container once it has downloaded run the container and login to me using the bash shell so this is what will happen so let's wait for the download to complete and let's login to the rock container the download is complete now and the image is going to be processed and you can see that now we are in the Bosch mode so this is basically the docker container which we have see that there is no host name because we don't have the packages installed nothing is installed there right it's just a basic lightweight image here I am going to see if there is a Java version and let's do Java - version notice that it uses open JDK and also it says open JDK growl VM seee the Community Edition and RC 16 release candidate 16 so that is what we did so we use the docker image of the growl VM see the community edition and that's what we are under right same way as I said when you install growl vm you will get all the different polygon languages so we have the Java version we also will be having the C version so in order to use the C version we use the ll I so ll I is another VM where you can run C and C++ code so you can use Li to compile and run C and C++ applications and see that that is also supporting the growl B M sodium brought all these and it has its own native installation same with the node version so I'll do a node - V node sorry node - V this should give the node version so obviously node also got installed so we can run JavaScript we can join in C++ we can run Java as well now in order to test this particular girl VM to check the interoperability let's create a growl VM image of the spring booth application so right now this particular image only provides calcium but I want to create a docker image with care album as the base image and I want to provide a spring boot application in that a particular image let's try doing that so let's go to the home I already have the spring boot lazy init example I am going to use the same if you want to see the source code of this particular spring boot lazy net example head to github.com / Trek primers so you will find the spring boot lazy in an example there so this is the example it has a spring boot application with just one rest endpoint called lazy that's it nothing big right I'm going to use the same previously we used this particular example for deploying that spring good application into kubernetes cluster I'm going to use the same checked out version which we had before and I'm going to create a docker image with the grail VM image so when we deploy into kubernetes we created a basic Linux container with the Java Runtime with a spring good application however here in our case we are going to use the grail vm runtime and no Java version because gravia means everything together so let's create a docker file for that so I'll create a docker file I have the content already ready and I'll just explain what it does the base image is the growl VM image that's what the from statement signifies ad is nothing but what are the scripts artifacts which we need to add into the docker image we are going to add our string boot application which is present under the target so when we build this particular image so it's going to go to target folder locally and get the spring boot jar and then rename it as spring boot jar and also the container is gonna expose the port 8080 so that spring boot application which runs on the 8080 port can map it to the 8080 port directly also the entry point is nothing with the script which you want to run when the container comes up which is nothing but jaar zama - jar and then the spring boot jar that's a we typically start a java application which has a spring boot embedded in it so that's all we wanted let's save this so in order to build the docker image we will do docker build and we need to provide the name of this particular docker image which we are going to build right let's call it a spring boot growl VM and let's pass the path of the docker file so which is present in the car inside the current directory so looks like I missed the T option - T is the image tag basically I will say - T and I'll do an enter so this should build a image with the definition of the docker file see that the steps are getting a step one is nothing but creating a base image adding the artifacts and then exposing the port 8080 and also creating an endpoint when the container rose up so we have the image created successfully see that this is the image named spring boot growl VM : the latest right because that's what we built we did not provide attack so it builds the latest tag now in order to bring this particular image up we will say docker run - P we need to expose the port 8080 so that's what I'm doing exposing the port 8080 of the current machine map that - the 8080 of the container the docker container and I will provide the name of our image so this is going to bring the growl vm up and the docker and the spring boot application will be running inside and this is using the plain vanilla growl vm so we did not do any customization over it and it is bringing our application just like that right so let's see what's happening so the application came up with the port 8080 let's try accessing it I can access it directly let's try that from here so this will directly take us and access the Springwood application on the port 8080 see that we got the error message off the springboard X application and there is a URL called lazy and see that we are getting hello Brian take promise that's what we did and we can see the log getting printed constructor loaded right it's a lazy in it so the constructor loaded which will come when we hit the first rest endpoint so it looks like the gravity M is working with our java application so basically a spring good application which we built long back it's able to reuse the same jar file and it's running on the same girl VM without any change so I just killed the dock container now let's try running LC program inside this particular girl VM image so in order to do that I'm going to use the same image which we logged in right initially the docker run so I'm logged in to a clear so I'm inside the container where we had ll I - - version had the Illinois with the erosion of gravia now let's try creating a hello world program obviously that's what we do we'll do a hello world dot see if you remember we used to hash include stdio.h and we have an int main I want to do a print we'll do a printf hello YouTube we need to do a return we'll just do a return of zero just to be intact that's it now we need to compile this particular C language code in order to do that we can leverage the si Lang so si Lang is presently inside the same image so we can do a C Lang - C - oh one and emit LLVM so we are saying that use the LLVM and create a object file based on what we can run on the LLVM so it's basically converting the C code into a object file which can run on the LLVM that's what we are doing here and let's provide the hello world dot C so this is going to create a file here that you want it created so it created a hello world dot BC right so we are inside the growl VM docker container and it created a hello world dot BC now in order to run the LLVM d dot b c file we can just say l li and hello world dot BC that's it so see that it printed hello YouTube that's what we did right so if I want to change again I'll just try doing VI I'll just rename it as tech primers I'll also add a backslash n so that we can see it I'll compile it using the si Lang again and I'll run it using L Li again see that hello Tech remark or printed and we are using the same drawl VM so what we did here we created bit code from the hello world dot C by creating a hello world on PC so dot BC is a bit code and which can be run in a ll IBM that's what we did here so L Li is a lightweight high-performance interpreter which is integrated with the Grail VM which runs on lll IBM right so Allah is nothing but the command-line interface which is an interpreter which converts and runs the native growl vm runtime if you want to try out the JavaScript there is a JavaScript console as well see this there is a console or long if I do know you this will just print the hello youtube this is again as a growl VM console for the JavaScript so if you create a JavaScript again it runs on the same girl VM so you don't have to have a specific node or any installation separately so this is how you can use growl VM and run different interoperable languages with the same VM and we are running inside the same docker container using the growl BM native image I hope you found this particular concept interesting it's a completely polyglot VM which you can try for different languages including Ruby n R as always if you liked the video go ahead and like it if you haven't subscribed to the channel go ahead and subscribe to it meet you again in the next video thank you very much [Music]
Info
Channel: Tech Primers
Views: 7,912
Rating: undefined out of 5
Keywords: techprimers, tech primers, graalvm, graalvm spring boot, graalvm examples, graal vm with springboot, graalvm experiment, graalvm for beginners, polyglot vm, polyglot vms, graalvm initial experiment, graal vm tutorial, graal vm primer, how to run applications in graal vm, how to use graalvm, how to run graalvm
Id: VRb8JSfI9eg
Channel Id: undefined
Length: 17min 13sec (1033 seconds)
Published: Sun May 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.