Compiler and Interpreter: Compiled Language vs Interpreted Programming Languages — Transcript
Full transcript
- 0:00So, we need to get our source code
- 0:02converted into machine code somehow
- 0:05before it can run. And there are two
- 0:07main ways of doing this. What's called
- 0:09compiling the source code, and what's
- 0:11called interpreting the source code.
- 0:14Now, luckily, this is not a big decision
- 0:16you have to worry about. Most languages
- 0:18you'll deal with will naturally fall
- 0:20into one or the other, but it is worth
- 0:22knowing the difference. So, let's have a
- 0:24simple scenario. Let's say it's just you
- 0:27and me. You have your computer, and I
- 0:30have my computer, and you're going to
- 0:32write a program that you want me to run.
- 0:35Now, with a compiled language, what
- 0:37happens is you write your source code,
- 0:39and then you have a program called a
- 0:41compiler that will go through that
- 0:43source code and create a separate file
- 0:45that contains the machine code, and you
- 0:47just give me that file. This end result
- 0:50is sometimes referred to as an
- 0:52executable or an executable file,
- 0:54because I can directly execute it. I can
- 0:56now just run your program. You keep your
- 0:59source code, and I never see it. Now,
- 1:02with an interpreted language on the
- 1:04other hand, you don't compile your
- 1:06source code beforehand. You just give me
- 1:08a copy of it. So, I'll need my machine
- 1:11to interpret it whenever I want to run
- 1:14your program. Now, an interpreter is
- 1:16different to a compiler. It does this on
- 1:18the fly. We can think of it as going
- 1:20through your source code line by line
- 1:23and processing it on the spot. It does
- 1:25not save it as a separate machine code
- 1:27file.
- 1:29Now, you've used interpreted languages
- 1:30even if you don't know it. Whenever
- 1:32you've looked at a web page with
- 1:33JavaScript, which, if you've surfed the
- 1:35web for more than 2 minutes in your
- 1:37lifetime, you have, this is what's been
- 1:40happening. The JavaScript has been sent
- 1:42to you over the web, along with a bunch
- 1:44of other files like web pages and
- 1:46images, and it's been sent as source
- 1:48code onto your machine, and your web
- 1:50browser has just interpreted that
- 1:52JavaScript so it can run that code. So,
- 1:55which one's best? Well, they both have
- 1:57their good and their bad points.
- 1:59Benefits of compiled code. Once it's
- 2:02compiled, it's immediately ready to run
- 2:04and you could send it to 100 or 1,000 or
- 2:06100,000 different people. It's ready to
- 2:08go. It can be optimized for a CPU, so it
- 2:12can actually be faster. And you don't
- 2:14have to send your source code to
- 2:16everybody, which might be a good thing.
- 2:18However, the downsides are if I compile
- 2:21it on a PC, that executable file won't
- 2:24work on a Mac. In fact, it often needs
- 2:26to be compiled separately for different
- 2:28kinds of CPU even on the same platform.
- 2:31And when you're writing code, to compile
- 2:34is an extra step that you have to take
- 2:36every time you want to test your
- 2:37program. Now, with interpreted code, the
- 2:40big benefits are I don't really care
- 2:42what kind of machine is on the other end
- 2:44because we don't provide machine code.
- 2:46We just send the source code and we let
- 2:48the other side take care of it. So, it
- 2:50can be more portable and more flexible
- 2:52across platforms.
- 2:54It's also a little easier when testing
- 2:56because you just write your source code
- 2:58and then run it, letting the interpreter
- 3:00take care of converting it. There is no
- 3:02in-between compile step. And it can be
- 3:05easier to debug when things go wrong
- 3:07because you always have access to all
- 3:09the source code. However, it has its
- 3:11downsides, too. Because everyone who
- 3:13needs to run that program on their
- 3:15machine has to have an interpreter for
- 3:17that language on their machine.
- 3:19It also can be slower because you have
- 3:21to interpret it every time the program
- 3:23is run. And the source code is
- 3:25effectively public because you're
- 3:27sending it to everyone who needs to run
- 3:28that program. Now, because there are
- 3:31good things about compiled languages and
- 3:33good things about interpreted languages,
- 3:35there's also a third way of doing this,
- 3:37which is a bit of both. Instead of the
- 3:40compile model where all the work is done
- 3:42up front, but can be a little bit
- 3:44inflexible,
- 3:46or the interpreted model where all the
- 3:49work is done on the receiving end, but
- 3:51can be a little bit slower.
- 3:53We kind of do half and half. Up front,
- 3:56we compile it part of the way to what's
- 3:58called an intermediate language, which
- 4:01takes it as far along the way to machine
- 4:03code as it can get while still being
- 4:05portable often across platforms.
- 4:07You then distribute this, sending it to
- 4:10the people who need to run it, and each
- 4:12person who runs it takes it the last
- 4:15step to take it to machine code on their
- 4:17computers. This is sometimes referred to
- 4:19as just-in-time or JIT compilation. Now,
- 4:22this intermediate language sometimes
- 4:24also goes by the name of bytecode. So,
- 4:26this process has to happen somehow. It's
- 4:29just how much of it happens on your
- 4:31machine and how much of it happens on
- 4:33mine.
- 4:34Now, while theoretically all computer
- 4:36languages could use any of these
- 4:39methods, the normal usage of any one
- 4:41language tends to be one or the other.
- 4:44So, for example,
- 4:46C, C++, and Objective-C, these are
- 4:48typically found as compiled languages.
- 4:50So, you need a compiler. Now, the
- 4:52compiler can be downloaded for free, but
- 4:54are often built into integrated
- 4:57development environment applications.
- 5:00Now, languages like PHP and JavaScript,
- 5:03indeed most languages with the word
- 5:04script at the end are usually
- 5:06interpreted. And languages like Java,
- 5:09C#, VB.NET, and Python use this
- 5:12intermediate hybrid approach. Now,
- 5:15whether a language is compiled or
- 5:17interpreted or somewhere in between
- 5:20is rarely a reason by itself to choose a
- 5:22language, but it can be something that
- 5:24you take into account. If one main
- 5:26priority of your program is absolute
- 5:28maximum speed running on one single
- 5:31platform,
- 5:32you'll probably look at a compiled
- 5:34language. If you're more interested in
- 5:36easily moving your code across multiple
- 5:38platforms, you're probably more
- 5:40interested in an interpreted one. But
- 5:42more usually, you're driven more by what
- 5:45you need to do. Do you need to build
- 5:47iPhone apps or Windows desktop apps or
- 5:49dynamic websites or in our case just
- 5:52learn the fundamentals of programming
- 5:54and you let that decision drive the
- 5:56language choice and the language choice
- 5:59will determine whether you're compiled,
- 6:01interpreted, or somewhere in the middle.
About this transcript
This page contains the full transcript of Compiler and Interpreter: Compiled Language vs Interpreted Programming Languages by Coding Mentors, generated from the public captions YouTube serves with the video. The transcript has 1,092 words across 163 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.