Interpreted vs Compiled Programming Languages

So, the interpreter, and this is going tobe a short video I think, but we're basically going to talk about thedifference between an interpreted programming language and compiledprogramming language, and this might be a little adept for the no viceprogrammer but just stick with us.

again if you have any questions or not sure ifyou completely understand it, there's a discussion section to theright of this video, yes should be right to the right of thisvideo, so use that and I will try and clear up any confusion.

So, first, with acompiled programming language you write your code and you save it into this file,and you can't run that file yet. Let's say you're writing C++ code, so youwrite a function, you write a script that will do something.

If you try and openthat file with the .cpp extension, which is for C++ files, it is just going toopen that in a text editor or code editor because that's not an executablefile. What you need to do with a compiled programming language is once you save your file you need to compile it into a language that the computer can read, sobinary ones and zeros, and by compiling this file into an executable file, then you can double click it and it will run. So, if you're on Windowsbuilding executable files for windows they will have a .exe extension.

Ifyou're on Linux I don't believe they have an extension. So, the difference hereis with Python when you write a script you can instantaneously run that scriptwithout having to compile it into binary and because we can do thatwhat's actually happening is when you run the Python command you're notrunning the file standalone.

So, when you compile a programming file into abinary file you can just type the name of that file in the terminal or command prompt and hit enter and itwill run that program as a standalone program because the computer alreadyknows how to run it, but when you run Python scripts you're going to run itwith the Python command and then the name of the file, and what basicallyhappens is you're running the program Python which is interpreting your codeand running that.

So, what happens is it does compile into binary but it does what's called just-in-time compilation, and what that does is everytime you run its going to parse all the code and it's going to convert it into atemporary file and then run that temporary file.

So, let me break out ofthis, there. So, how you would run a scriptand we're going to talk about that later but basically how to enter theinterpreter on its own you just type python3 to use the three version ofPython you can see the version we are using Python 3.5.1. So, basicallyin the interpreter you can run real time code, so if I were to type "print helloworld" it's going to instantaneously run thatline of code.

If I run "4 + 6" it's going to return 10 because that'sthe sum of four and six, and so the interpreter is great to use if you wantto test something really quick, if you want to debug a few lines of code, or ifyou just want to see if something would actually work.

So, we're going to bestarting out using the interpreter but as things get a little more complexwe're going to get into writing scripts and executing those scripts. So, now weneed to learn how to run a Python script

Post a comment