Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So we need to get our source code converted into machine code somehow before it can run and there are two main ways of doing this: what's called compiling the source code and what's called interpreting the source code. Now luckily, this is not a big decision you have to worry about. Most languages you'll deal with will naturally fall into one or the other, but it is worth knowing the difference. So let's have a simple scenario. Let's say it's just you and me. You have your computer and I have my computer and you're going to write a program that you want me to run.
Now, with a compiled language, what happens is you write your source code and then you have a program called a compiler that will go through that source code and create a separate file that contains the machine code, and you just give me that file. This end result is sometimes referred to as an executable or an executable file because I can directly execute it. I can now just run your program. You keep your source code and I never see it. Now, with an interpreted language on the other hand, you don't compile your source code beforehand. You just give me a copy of it.
However, the downsides are if I compile it on a PC, that executable file won't work on a Mac. In fact, it often needs to be compiled separately for different kinds of CPU even on the same platform, and when you're writing code to compile is an extra step that you have to take every time you want to test your program. Now, with interpreted code, the big benefits are I don't really care what kind of machine is on the other end, because we don't provide machine code. We just send the source code and we let the other side take care of it.
So it can be more portable and more flexible across platforms. It's also a little easier when testing because you just write your source code and then run it, letting the interpreter take care of converting it. There is no in-between compile step. It can be easier to debug when things go wrong because you always have access to all the source code. However, it has its down sides too, because everyone who needs to run that program on their machine has to have an interpreter for that language on their machine. It also can be slower because you have to interpret it every time the program is run, and the source code is effectively public because you're sending it to everyone who needs to run that program.
Now, because there are good things about compiled languages and good things about interpreted languages, there is also a third way of doing this which is a bit of both. Instead of the compiled model where all the work is done upfront but can be a little bit inflexible or the interpreted model where all the work is done on the receiving end but can be a little bit slower, we kind of do half-and-half. Upfront, we compile it part of the way to what's called an intermediate language, which takes it as far along the way to machine code as it can get while still being portable often across platforms.
You then distribute this, sending it to the people who need to run it, and each person who runs it takes it the last step to take it to machine code on their computers. This is sometimes referred to as Just-In-Time or JIT compilation. Now, this intermediate language sometimes also goes by the name of bytecode. So this process has to happen somehow. It's just how much of it happens on your machine and how much of it happens on mine. Now, while theoretically all computer languages could use any of these methods, the normal usage of any one language tends to be one or the other.
Now, whether a language is compiled or interpreted or somewhere in-between is rarely a reason by itself to choose a language, but it can be something that you take into account. If one main priority of your program is absolute maximum speed running on one single platform, you'll probably look at a compiled language. If you're more interested in easily moving your code across multiple platforms, you're probably more interested in an interpreted one. But more usually, you're driven more by what you need to do.
You need to build iPhone apps or Windows desktop apps or dynamic website, or, in our case, just learn the fundamentals of programming, and you let that decision drive the language choice and the language choice will determine whether you are compiled, interpreted, or somewhere in the middle.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99329 Viewers
56 Video lessons · 112590 Viewers
71 Video lessons · 81411 Viewers
131 Video lessons · 39078 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.