WEBVTT

00:00:00.000 --> 00:00:00.920 align:middle line:90%


00:00:00.920 --> 00:00:04.520 align:middle line:84%
My name is Gary, and I am the
founder of Execute Program.

00:00:04.520 --> 00:00:06.770 align:middle line:84%
And I want to give you
a quick five minute

00:00:06.770 --> 00:00:10.310 align:middle line:84%
view into what it actually looks
like to learn a programming

00:00:10.310 --> 00:00:13.430 align:middle line:84%
language or other tool
through Execute Program.

00:00:13.430 --> 00:00:16.880 align:middle line:84%
And I've pulled up the very
first TypeScript lesson

00:00:16.880 --> 00:00:18.050 align:middle line:90%
that we have here.

00:00:18.050 --> 00:00:20.390 align:middle line:84%
It's going to be very
basic in terms of content

00:00:20.390 --> 00:00:24.108 align:middle line:84%
but it'll show us what it looks
like to use Execute Program.

00:00:24.108 --> 00:00:26.150 align:middle line:84%
We're going to begin with
some introductory text.

00:00:26.150 --> 00:00:28.010 align:middle line:84%
We're going to skip
past all of that

00:00:28.010 --> 00:00:30.560 align:middle line:84%
to get to the very
first code example.

00:00:30.560 --> 00:00:32.720 align:middle line:84%
Now like I said,
this is very simple,

00:00:32.720 --> 00:00:35.970 align:middle line:84%
but we'll see a more
advanced example in a moment.

00:00:35.970 --> 00:00:38.160 align:middle line:84%
So here we're adding 1
plus 1 to get a number.

00:00:38.160 --> 00:00:40.230 align:middle line:84%
The type here is
number, that's good.

00:00:40.230 --> 00:00:43.137 align:middle line:84%
And then the thing that we
need to actually type in here

00:00:43.137 --> 00:00:44.720 align:middle line:84%
is going to be
whatever is represented

00:00:44.720 --> 00:00:46.340 align:middle line:90%
by this last line of code.

00:00:46.340 --> 00:00:48.560 align:middle line:84%
In this case, it's going
to be the number two,

00:00:48.560 --> 00:00:51.020 align:middle line:84%
and Execute Program
accepts that happily.

00:00:51.020 --> 00:00:54.710 align:middle line:84%
If we type something wrong,
then it'll tell us that as well.

00:00:54.710 --> 00:00:57.500 align:middle line:84%
In this case, we are looking at
a string assigned to a string

00:00:57.500 --> 00:00:58.700 align:middle line:90%
variable, so that's fine.

00:00:58.700 --> 00:01:00.680 align:middle line:90%
And we add those two strings.

00:01:00.680 --> 00:01:03.530 align:middle line:84%
Skipping past some
more explanations.

00:01:03.530 --> 00:01:07.653 align:middle line:84%
Now we're seeing our very first
type error and in this case,

00:01:07.653 --> 00:01:10.070 align:middle line:84%
it tells us exactly what to
do, put type error in the box.

00:01:10.070 --> 00:01:12.500 align:middle line:84%
In the future it will
not tell us that.

00:01:12.500 --> 00:01:15.320 align:middle line:90%
And there's the type error.

00:01:15.320 --> 00:01:18.270 align:middle line:84%
So that's a very,
very simple example.

00:01:18.270 --> 00:01:20.630 align:middle line:84%
Now let's see what's going
to happen one day later when

00:01:20.630 --> 00:01:21.780 align:middle line:90%
we come back.

00:01:21.780 --> 00:01:23.840 align:middle line:84%
We're going to get our
first review session.

00:01:23.840 --> 00:01:26.330 align:middle line:84%
A little bit of explanation
here, that again we'll skip.

00:01:26.330 --> 00:01:28.163 align:middle line:84%
But it's going to give
us code examples that

00:01:28.163 --> 00:01:30.650 align:middle line:84%
are very similar to the
ones we saw in the lesson,

00:01:30.650 --> 00:01:32.060 align:middle line:90%
but slightly different.

00:01:32.060 --> 00:01:34.112 align:middle line:84%
Just so you can't
outright memorize them.

00:01:34.112 --> 00:01:35.570 align:middle line:84%
And in this case,
we have a string,

00:01:35.570 --> 00:01:37.550 align:middle line:84%
we're assigning it to a
number variable, that's

00:01:37.550 --> 00:01:38.810 align:middle line:90%
going to be a type error.

00:01:38.810 --> 00:01:40.580 align:middle line:84%
And then, once we
get that right,

00:01:40.580 --> 00:01:43.640 align:middle line:90%
we'll move on to more examples.

00:01:43.640 --> 00:01:46.220 align:middle line:84%
Incidentally, these reviews
will come back more than once.

00:01:46.220 --> 00:01:48.320 align:middle line:84%
And every time you
get it right, it

00:01:48.320 --> 00:01:50.630 align:middle line:84%
waits longer before
repeating the review.

00:01:50.630 --> 00:01:53.030 align:middle line:84%
And the idea here is that you
don't spend that much time

00:01:53.030 --> 00:01:54.710 align:middle line:84%
on reviews in Execute
Program, but it's

00:01:54.710 --> 00:01:56.330 align:middle line:84%
going to prevent
you from forgetting

00:01:56.330 --> 00:01:58.682 align:middle line:84%
all the things that you've
learned in the course.

00:01:58.682 --> 00:02:00.140 align:middle line:84%
Now let's move on
to something that

00:02:00.140 --> 00:02:03.620 align:middle line:84%
is much more advanced in
terms of the actual topic.

00:02:03.620 --> 00:02:05.780 align:middle line:84%
This is part of our
lesson on type predicates

00:02:05.780 --> 00:02:08.030 align:middle line:84%
which are a fairly advanced
TypeScript feature.

00:02:08.030 --> 00:02:10.699 align:middle line:84%
That we won't cover in detail,
because there's not time.

00:02:10.699 --> 00:02:12.870 align:middle line:90%
This is hours into the course.

00:02:12.870 --> 00:02:15.440 align:middle line:84%
But if we look at
the code problem

00:02:15.440 --> 00:02:17.810 align:middle line:84%
that we've been given here,
the way to think about this

00:02:17.810 --> 00:02:21.350 align:middle line:84%
is that all of this is like a
single source file the Execute

00:02:21.350 --> 00:02:22.790 align:middle line:90%
Program is going to run.

00:02:22.790 --> 00:02:24.890 align:middle line:84%
These parts, this top
part and this bottom part,

00:02:24.890 --> 00:02:26.390 align:middle line:90%
we can't actually change.

00:02:26.390 --> 00:02:28.230 align:middle line:84%
We can only change
what's in here.

00:02:28.230 --> 00:02:31.280 align:middle line:84%
And so this allows us to write
these interactive problems

00:02:31.280 --> 00:02:34.110 align:middle line:84%
where we can kind of control
what you can and cannot do.

00:02:34.110 --> 00:02:37.670 align:middle line:84%
But you do still have the
full freedom of a text editor.

00:02:37.670 --> 00:02:40.370 align:middle line:84%
So what's the actual problem
that we're looking at here?

00:02:40.370 --> 00:02:43.380 align:middle line:84%
We have an array with some
numbers and also an undefined,

00:02:43.380 --> 00:02:45.650 align:middle line:84%
and what we want is
to produce code that

00:02:45.650 --> 00:02:47.480 align:middle line:90%
gives us just the numbers out.

00:02:47.480 --> 00:02:50.720 align:middle line:84%
Now if this were JavaScript,
we could say n, take n

00:02:50.720 --> 00:02:53.360 align:middle line:84%
as a callback argument
and then decide

00:02:53.360 --> 00:02:55.280 align:middle line:90%
whether n is not undefined.

00:02:55.280 --> 00:02:58.070 align:middle line:84%
If I run that with
command enter or control

00:02:58.070 --> 00:03:02.700 align:middle line:84%
enter on Windows and Linux,
then we will get a type error.

00:03:02.700 --> 00:03:04.315 align:middle line:84%
To fix that type
error, again, I can't

00:03:04.315 --> 00:03:06.440 align:middle line:84%
go through the full details
of this advanced topic,

00:03:06.440 --> 00:03:11.060 align:middle line:84%
but what we need to do is write
a function called anything

00:03:11.060 --> 00:03:13.490 align:middle line:84%
I suppose, but in
my case, I'm going

00:03:13.490 --> 00:03:15.080 align:middle line:90%
to call it is not undefined.

00:03:15.080 --> 00:03:17.750 align:middle line:90%
Here is the type predicate.

00:03:17.750 --> 00:03:21.020 align:middle line:84%
It's that little n, is number
part that I put on the end

00:03:21.020 --> 00:03:23.000 align:middle line:84%
there, and we'll
write a function body

00:03:23.000 --> 00:03:25.370 align:middle line:84%
to check for whether the
thing is not undefined.

00:03:25.370 --> 00:03:28.310 align:middle line:84%
And now if we pass this function
in, because of that type

00:03:28.310 --> 00:03:30.662 align:middle line:90%
predicate, it type checks.

00:03:30.662 --> 00:03:32.120 align:middle line:84%
So we've not
succeeded, we're going

00:03:32.120 --> 00:03:35.390 align:middle line:84%
to move on to see whatever
is next in this lesson.

00:03:35.390 --> 00:03:36.807 align:middle line:84%
But one more thing
to note here is

00:03:36.807 --> 00:03:38.182 align:middle line:84%
that when you
succeed at this, we

00:03:38.182 --> 00:03:39.440 align:middle line:90%
give you this little checkbox.

00:03:39.440 --> 00:03:40.857 align:middle line:84%
So you can actually
see the answer

00:03:40.857 --> 00:03:42.178 align:middle line:90%
that we put in as the author.

00:03:42.178 --> 00:03:44.720 align:middle line:84%
And this is also the answer that
our automated testing system

00:03:44.720 --> 00:03:47.660 align:middle line:84%
uses to make sure that
these problems are actually

00:03:47.660 --> 00:03:49.400 align:middle line:90%
solvable and correct.

00:03:49.400 --> 00:03:50.960 align:middle line:84%
Now in this case,
the two look almost

00:03:50.960 --> 00:03:52.845 align:middle line:84%
identical because
I wrote this code

00:03:52.845 --> 00:03:53.970 align:middle line:90%
problem in the first place.

00:03:53.970 --> 00:03:56.780 align:middle line:84%
So I solved it in
a similar way here,

00:03:56.780 --> 00:03:59.060 align:middle line:84%
but sometimes you
can use this if you

00:03:59.060 --> 00:04:02.450 align:middle line:84%
feel like your answer
might not be the quote

00:04:02.450 --> 00:04:03.680 align:middle line:90%
unquote "right answer".

00:04:03.680 --> 00:04:05.810 align:middle line:90%
You can use it to verify that.

00:04:05.810 --> 00:04:08.180 align:middle line:84%
That is a quick introduction
to some of the things

00:04:08.180 --> 00:04:09.980 align:middle line:84%
that you'll see inside
of Execute Program

00:04:09.980 --> 00:04:12.330 align:middle line:84%
and what it actually
looks like to use it.

00:04:12.330 --> 00:04:16.030 align:middle line:84%
So give it a try and
I hope you enjoy it.

00:04:16.030 --> 00:04:17.000 align:middle line:90%