welcome to python video series again in this video we are continuing with intro of computer and coding specifically we will talk about compiler versus interpreter in other words different languages and how they are processed so we mentioned about machine language already and we know that it's understood by machine so the machines could pretty much process and execute the instructions that's inside the machine language and then we have almost an one two one translation from the machine language of zeros and ones to a little bit more human friendly assembly language for an assembly language code to be executed it needs to be assembled by an assembler therefore it becomes something that the machine could understand and execute then we have high level language and these languages need to be compiled or interpreted by compiler or interpreter and afterwards they can be executed and then we come to 4gl mostly sql these are query languages so they go through query processing and these are getting much more sophisticated and very involved so is 5gl which is getting ever closer to natural language than ever and needs a lot of sophisticated processing with more applications taking advantage of the innovation and development of higher level language evolution coding as well as software development are getting very interesting and exciting now let's go back and focus on compiler so for a compiled language such as c or c plus plus we code the source code and then we use for example gcc which is a very commonly used c compiler or g plus plus which is a c plus plus compiler or some other compilers to compile the source code into some sort of executable machine code and then the machine code is run on hardware mostly driven and controlled by cpu and we then get the outcome of the execution of the code as for interpreter it is a little bit simpler comparing to compiler since we are talking about python so let's use python as example here we have python source code which goes through the python interpreter and then we get the outcome from running the source code we will talk about more details but interpreter is usually executing one statement at a time following the process we just described so now to drill in a little bit more of compiled versus interpreted language we see that the advantages of compiled languages is that the entire block of code is compiled ahead of the time and thus it's optimized usually by the compiler therefore when we run the block of code or the app it will have faster performance whereas with interpretive languages we get to execute the statement immediately and we get the result right away and also an interpreter is easier to write than a compiler so if we compare them further we use some use cases for a compiled code which is for most general applications whether they are hosted or as installed local apps they are most likely compiled as for the interpreted code the use cases are usually the interactive apps so that the users enter some input and get some sort of output as response immediately or another common example is the code that's executed in the browser oftentimes without our knowledge but there are code errors sent by the server to our browser and it gets executed inside the browser and the result is responded displayed back to us so hopefully this gives a little bit clearer idea of compiled languages versus interpreted languages although the lines could get blurred as we move forward in our video we will touch on some of the newer development and intricacies now let's just quickly list some of the popular high-level languages for the compiled languages we have java c sharp c c plus plus as these two are very closely related languages and you see the percentage of market share as of this year for interpreted languages python is definitely the dominating one we also have javascript with substantial market share and php in ruby among others so as indicated or implied previously between the compiled and interpreted languages there are hybrids out there that try to take advantages of both world so first of all we want to introduce more about this concept of a virtual machine the most famous one is java virtual machine or jvm and then we have python virtual environment or a python virtual machine normally what happens is that these languages are compiled to bytecode instead of the targeted machine code and then the bytecode is actually interpreted for the targeted machine for execution so how does that work and why do we do that the idea is such that it could fulfill the following principle with the acronym w-o-r-a write once run anywhere or w-o-r-e write once run everywhere which essentially says the same thing again interpreted language could be slow the reason why you want to have virtual machine is so that on any platform or let's say operating system as long as the virtual machine is running on that particular architecture or platform or operating system the same bytecode could be interpreted on that particular virtual machine on that particular platform so that the app's coder only need to write the app once and then compile them into bytecode and the bytecode could just be copied from machine to machine and they don't need to go through recompilation like most of the classical compiled languages such as c for c language for instance if you write a c language app compile it let's say on linux and you want to take it to execute on a windows platform you will have to get the source code compiled on the windows platform so that the recompiled executable could be run on windows whereas with java virtual machine once we have java virtual machine running on linux and on windows java developers code the apps and compile them into bytecode the same bytecode could run on the linux java virtual machine or the windows java virtual machine there is no recombination effort needed but we know already that interpretive language could be slow now when we have a virtual machine which is interpreting the byte code for the targeted machine it could be slow therefore a jit jit or just in time compiler is developed so that those frequently used portion of bytecode are translated into native machine code therefore it doesn't need to be interpreted multiple times so after it's interpreted once jet will come into play and translate the frequently used portion into native machine code to improve the performance now let's recap in this video we mentioned the high level code that's compiled into machine code or interpreted into machine code we compared and contrasted compiled versus interpreted languages and then we talked about the kind of hybrid with virtual machine for bytecode which does improve the code portability although with the virtual machine for bytecode we do have a performance hit but we also have jit just in time compiler developed for alleviating performance problem