Instructor: V8, is it this mysterious black box
that we can't possibly hope to understand
or peek inside of?
Quite the opposite.
Google's V8 engine is open source.
It's available to look at, to use, and to even change
for your own purposes.
That's not the goal of this course, but because of that
we can take a quick look and demystify just a little bit
the mystique of something like a Javascript engine.
Let's take a quick look at V8.
To find it, I'll just do a simple Google search,
I'll search for Chrome V8.
And, you'll see that under code.google.com,
there's the project hosting for the V8 Javascript engine.
I searched for Chrome V8 because V8
was primarily written to be used inside the Google Chrome
browser, and it certainly is.
However, it's also built in a way that let's it be used
elsewhere, and in other ways.
So I'll go to the project hosting page, and we'll see that
right away, we have a few bullet points that are of interest
under the V8 Javacscript engine,
according to Google's documentation.
We can see that V8 is Google's open source
Javascript engine, we understand that.
V8 is written in C++ and used in Google Chrome,
we understand that.
V8 implements the ECMAScript standard,
and runs on Windows, Mac, Linux, and systems that use
particular machine code, particular micro-processors
that speak particular machine code,
like IA-32, x64,
ARM or MIPS processors.
So we understand that too.
So, here we have the V8 Javascript engine,
and there's even a link called source.
I could export the source to GitHub,
if I have a GitHub account,
or if I go to source and then click the link,
there's a Git repository, a source code repository,
that is to say, there's a spot where all the source code
of V8 lives, and I can go grab it free of charge.
That's open source software.
So I've already done that.
If you know C++, you know Git,
as far as how to use a Git repository to grab code.
Feel free to mess around with this if you'd like,
but it's certainly not necessary, however, I've done it
for you so that we can gain a little bit
better understanding of V8 itself.
I've gone ahead and downloaded all the source code
for the V8 engine, and I've opened it here
in a programme called Visual Studio Code,
which is for Microsoft.
Visual Studio Code works on Mac, Linux, and Windows,
and it's a great programme for editing code
and taking a look at it.
So that's what I'm using, but you can use whatever
code browser you want throughout the rest of this course.
I'll be using Visual Studio Code quite a bit.
However, for the moment, we're just looking at V8.
If I open this source folder, the src folder,
you already see some things that we might've seen before:
ARM,
IA32,
x64,
there's entire sets of code
for each of the machine languages that V8 supports.
So we can convert Javascript into any one of these languages
and it's more than that, inside there's a huge number
of .h and .cc files, .cc is a C++ file,
and .h is also a part of the C++ language.
All of this code, all of this C++
has to do with implementing the ECMAScript standard.
This is the engine, this is the engine's code
that will read Javascript, the text of Javascript,
and convert it into machine code,
and it's a lot of code.
There's things in here that we could, some would understand
even if you don't write C++,
like there's a date .cc file
that deals with dealing with dates.
Javascript has to deal with dates, and so there's code
written in C++, and notice this looks a little bit
like Javascript.
There's code written in C++ that handles dates,
because Javascript needs to handle dates
and this engine is gonna convert what you write
in Javascript to something that the computer processor
can actually run.
So, this is code within the engine.
V8 is huge.
It's been worked on for years, and it's highly performant,
it's really fast.
And it's extremely useful,
and it's free.
Open source, you can use it within your own programmes,
and that's what we're going to see next.
But here we can see that V8 isn't some mysterious black box.
It's just a lot of code.
Code designed to do exactly what
an engine is supposed to do, execute Javascript.
That is to say, convert Javascript code that you write,
into something far more based, far lower,
and in some ways, more complex.
Alright, let's move on.