WEBVTT
Kind: captions
Language: en

00:00:00.080 --> 00:00:05.680
The most powerful computer you own has zero&nbsp;
security. No, I'm not talking about this one.&nbsp;&nbsp;

00:00:05.680 --> 00:00:11.360
This one is a fortress by comparison. You have&nbsp;
dozens of applications spread across the device&nbsp;&nbsp;

00:00:11.360 --> 00:00:17.360
with no insight into what the others are doing.&nbsp;
No, I'm talking about the computer in your head.&nbsp;&nbsp;

00:00:17.360 --> 00:00:22.640
The thinking part of your brain has no permission&nbsp;
system. You can't just like pause your own heart&nbsp;&nbsp;

00:00:22.640 --> 00:00:26.560
just to see what happens. Although that's&nbsp;
somewhat debatable of a fact. But the layer&nbsp;&nbsp;

00:00:26.560 --> 00:00:32.400
above that where actual cognition happens has no&nbsp;
barriers. Thoughts can examine other thoughts,&nbsp;&nbsp;

00:00:32.400 --> 00:00:37.680
interrupt them, or even reason about them. Even&nbsp;
you watching right now can internally debate&nbsp;&nbsp;

00:00:37.680 --> 00:00:44.080
what I'm talking about. You're not just blindly&nbsp;
accepting input. You can take a concept and play&nbsp;&nbsp;

00:00:44.080 --> 00:00:49.120
around with it. You can even think about the&nbsp;
fact that you're thinking about this sentence.&nbsp;&nbsp;

00:00:49.120 --> 00:00:53.280
Try pause the video and think about it. That&nbsp;
little line of recursive thinking that you&nbsp;&nbsp;

00:00:53.280 --> 00:00:59.280
just did there, what cognitive scientists would&nbsp;
call introspection, almost no computer has the&nbsp;&nbsp;

00:00:59.280 --> 00:01:04.880
ability to do. In the 1980s, some of the smartest&nbsp;
researchers tried building a machine that could.&nbsp;&nbsp;

00:01:04.880 --> 00:01:10.880
And it worked. It was literally decades ahead of&nbsp;
its time. But it was also inadvertently the least&nbsp;&nbsp;

00:01:10.880 --> 00:01:16.640
private and most insecure operating system ever&nbsp;
created. It was so open that no one ever tried to&nbsp;&nbsp;

00:01:16.640 --> 00:01:23.120
build anything like it ever again. But fragments&nbsp;
of this superpower still remain inside many of the&nbsp;&nbsp;

00:01:23.120 --> 00:01:28.400
modern programming languages that we use today.&nbsp;
This is going to make the Rust people very angry,&nbsp;&nbsp;

00:01:28.400 --> 00:01:37.120
the Java people weirdly proud, and the C++&nbsp;
people more optimistic about the future.

00:01:37.120 --> 00:01:43.680
Pattie Maes, 1987. Computational reflection&nbsp;
is what a system does when it reasons about&nbsp;&nbsp;

00:01:43.680 --> 00:01:50.640
itself in a causally connected way. That was a&nbsp;
heck of a sentence, but just give me a second&nbsp;&nbsp;

00:01:50.640 --> 00:01:59.360
and I promise you'll understand something super&nbsp;
cool. Begin cloning process. This...is me. Or,&nbsp;&nbsp;

00:01:59.360 --> 00:02:03.760
was me like 10 seconds ago. And that's&nbsp;
kind of the problem. It's information,&nbsp;&nbsp;

00:02:03.760 --> 00:02:13.040
but it's not causally connected. If I do&nbsp;
something really silly like put on this crazy hat,&nbsp;&nbsp;

00:02:13.040 --> 00:02:19.840
the problem is the representation of me doesn't&nbsp;
also update. I can even take a pen and draw a&nbsp;&nbsp;

00:02:19.840 --> 00:02:26.880
mustache on the photo. And sadly, nothing appears&nbsp;
on my face. This isn't a reflection of the current&nbsp;&nbsp;

00:02:26.880 --> 00:02:33.600
reality. It's really just stale information.&nbsp;
But a mirror, well, a mirror is different.&nbsp;&nbsp;

00:02:33.600 --> 00:02:40.160
If I change, it changes. It is causally connected&nbsp;
information in one direction. Kind of without the&nbsp;&nbsp;

00:02:40.160 --> 00:02:44.480
boy [music] band reference. This still isn't&nbsp;
quite what Maes actually meant because a mirror&nbsp;&nbsp;

00:02:44.480 --> 00:02:50.240
is passive. It can show me what I'm doing, but it&nbsp;
can't actively participate in what I'm doing. But&nbsp;&nbsp;

00:02:50.240 --> 00:02:56.080
imagine we had a magic mirror that worked in&nbsp;
both directions. If something happens in the&nbsp;&nbsp;

00:02:56.080 --> 00:03:02.240
reflection, then it also happens to me as well,&nbsp;
the original representation. Wired back into the&nbsp;&nbsp;

00:03:02.240 --> 00:03:07.600
very thing that it reflects. And that is exactly&nbsp;
what Pattie Maes meant. Well, here's the annoying&nbsp;&nbsp;

00:03:07.600 --> 00:03:13.360
part. Almost every program on your computer is&nbsp;
a lot closer to the Polaroid. And I can tell you&nbsp;&nbsp;

00:03:13.360 --> 00:03:18.640
this from experience because otherwise my career&nbsp;
wouldn't exist. Conceptually, reverse engineering&nbsp;&nbsp;

00:03:18.640 --> 00:03:24.880
is kind of equivalent to performing introspective&nbsp;
surgery on a patient who can't do it himself. Most&nbsp;&nbsp;

00:03:24.880 --> 00:03:32.320
programs are like zombies. They run, they react,&nbsp;
they do things, but they have no understanding of&nbsp;&nbsp;

00:03:32.320 --> 00:03:39.040
what they are. It's kind of weird to think about,&nbsp;
but programs don't know I'm a class or this memory&nbsp;&nbsp;

00:03:39.040 --> 00:03:45.840
is this player's health bar. Zero self-awareness.&nbsp;
Much of my job is strapping programs to a table,&nbsp;&nbsp;

00:03:45.840 --> 00:03:51.680
hooking them up to debuggers, and reading through&nbsp;
their thoughts from outside the program space.&nbsp;&nbsp;

00:03:51.680 --> 00:03:58.240
Every single tool that exists in my field like&nbsp;
disassemblers, decompilers, even debuggers and&nbsp;&nbsp;

00:03:58.240 --> 00:04:04.320
stuff exist to try to take that information that&nbsp;
was lost during the journey down over to machine&nbsp;&nbsp;

00:04:04.320 --> 00:04:09.440
code and be able to reconstruct it. And also like&nbsp;
have you ever used a cheat engine before to like,&nbsp;&nbsp;

00:04:09.440 --> 00:04:15.120
you know, give yourself infinite gold or whatever?&nbsp;
I remember there was a cheat in the Sims and you&nbsp;&nbsp;

00:04:15.120 --> 00:04:19.120
could just give yourself like infinite money.&nbsp;
It was awesome. And like that's not the point&nbsp;&nbsp;

00:04:19.120 --> 00:04:26.160
of the Sims. The point of the Sims is to do like&nbsp;
crazy stuff and try to get the grim reaper to like&nbsp;&nbsp;

00:04:26.160 --> 00:04:33.120
[laughter]. We're basically simulating reflection&nbsp;
in a very hard way, like kind of after the fact. I&nbsp;&nbsp;

00:04:33.120 --> 00:04:38.160
mean, that's why it's called reverse engineering&nbsp;
is because we're effectively working backwards!&nbsp;&nbsp;

00:04:38.160 --> 00:04:43.440
What if programs were so smart that they could do&nbsp;
surgery on themselves? Would you trust me as your&nbsp;&nbsp;

00:04:43.440 --> 00:04:52.400
surgeon? Don't worry. I promise my hair won't fall&nbsp;
into your open liver. [laughter] I look absolutely&nbsp;&nbsp;

00:04:52.400 --> 00:04:58.240
insane right now. It's like Boop. All right, we've&nbsp;
got a great lineup for you guys [music] tonight.&nbsp;&nbsp;

00:04:58.240 --> 00:05:03.840
Let's go over to our returning champion. Where&nbsp;
would you like to start? Our categories are Before&nbsp;&nbsp;

00:05:03.840 --> 00:05:12.880
They Were Giants, Potent Protocols, Keyboard&nbsp;
Confessions, Winter is Coming, and Domain History.

00:05:15.520 --> 00:05:20.880
All right, your clue is on March 15th, 1985,&nbsp;&nbsp;

00:05:20.880 --> 00:05:27.840
this company registered the first&nbsp;
domain in internet history. [music]

00:05:27.840 --> 00:05:40.240
I'm waiting. Your possibilities are apple.com,&nbsp;
ibm.com, microsoft.com or symbolics.com.

00:05:40.240 --> 00:05:46.800
That is correct. The answer is Symbolics. I really&nbsp;
like having this microphone. It's like, yeah,&nbsp;&nbsp;

00:05:46.800 --> 00:05:52.240
listen to me. I am saying something important.&nbsp;
What if I just walked around with a microphone.&nbsp;&nbsp;

00:05:52.240 --> 00:05:56.480
Would people listen to me more? They'd probably&nbsp;
think I was nuts. There's a good chance that if&nbsp;&nbsp;

00:05:56.480 --> 00:06:00.480
you're around my age, you probably haven't&nbsp;
even heard of this company. But the entire&nbsp;&nbsp;

00:06:00.480 --> 00:06:05.600
hype behind it centered [music] around this&nbsp;
idea that quote unquote expert systems which&nbsp;&nbsp;

00:06:05.600 --> 00:06:10.720
was like a kind of early rule-based AI&nbsp;
system would replace doctors, lawyers,&nbsp;&nbsp;

00:06:10.720 --> 00:06:16.720
etc. All within the next decade. Symbolics and&nbsp;
the US as a whole was in this kind of mad fierce&nbsp;&nbsp;

00:06:16.720 --> 00:06:23.360
race with Japan's fifth generation computer system&nbsp;
to create the world's dominant AI machine. Sounds&nbsp;&nbsp;

00:06:23.360 --> 00:06:29.760
a bit familiar if you ask me. If you ignore the&nbsp;
eventual economic failure that Symbolics became,&nbsp;&nbsp;

00:06:29.760 --> 00:06:35.360
they did have some really early on kind of quirky&nbsp;
ideas. The whole idea around the company was&nbsp;&nbsp;

00:06:35.360 --> 00:06:41.440
selling these like super expensive lisp machines.&nbsp;
So this is custom silicon designed specifically&nbsp;&nbsp;

00:06:41.440 --> 00:06:46.640
for a single programming language. That would&nbsp;
be like today having a custom machine dedicated&nbsp;&nbsp;

00:06:46.640 --> 00:06:52.000
only to running Python. Anyway, Symbolics&nbsp;
realized that you can't just sell a box.&nbsp;&nbsp;

00:06:52.000 --> 00:06:56.800
You have to have an operating system that&nbsp;
goes along with it. Which brings us to&nbsp;&nbsp;

00:06:56.800 --> 00:07:02.400
Genera. The most powerful and least private&nbsp;
operating system ever created. Weirdly,&nbsp;&nbsp;

00:07:02.400 --> 00:07:07.840
one of the better ways to describe the complexity&nbsp;
of this operating system is just to take a look&nbsp;&nbsp;

00:07:07.840 --> 00:07:14.560
at the keyboard and see how many modifier keys&nbsp;
it has. You've got control, shift, super, hyper,&nbsp;&nbsp;

00:07:14.560 --> 00:07:19.840
meta, all of these additional ones. And you have&nbsp;
to like, contort your hands in crazy directions to&nbsp;&nbsp;

00:07:19.840 --> 00:07:26.800
try to hit all of the modifier keys. Like I'm&nbsp;
just doing gang symbols over here. [laughter]

00:07:26.800 --> 00:07:30.480
Watch this.

00:07:30.480 --> 00:07:39.280
Am I doing it? Magic. [laughter] Genera was, and&nbsp;
I really do mean this, just a fantastic operating&nbsp;&nbsp;

00:07:39.280 --> 00:07:45.040
system conceptually. Everything on your screen&nbsp;
was a live running object and you could just click&nbsp;&nbsp;

00:07:45.040 --> 00:07:50.480
on it and inspect the live executing source code&nbsp;
corresponding to that object. So you didn't have&nbsp;&nbsp;

00:07:50.480 --> 00:07:56.000
to wait around for compilation. There's no concept&nbsp;
of user space, kernel space, everything you just&nbsp;&nbsp;

00:07:56.000 --> 00:08:00.880
click on it, and you can inspect it, and you can&nbsp;
even dynamically modify it. You want to change&nbsp;&nbsp;

00:08:00.880 --> 00:08:07.200
something, anything, just do it! In our modern&nbsp;
concept of programs, the compiler is king. The&nbsp;&nbsp;

00:08:07.200 --> 00:08:13.040
compiler knows absolutely everything. It knows the&nbsp;
types, the functions, the class names, all of the&nbsp;&nbsp;

00:08:13.040 --> 00:08:18.560
identifiers inside of the application. But once we&nbsp;
move on to the actual executable binary portion of&nbsp;&nbsp;

00:08:18.560 --> 00:08:23.120
this, the majority of that information is just&nbsp;
tossed away because we don't need it anymore.&nbsp;&nbsp;

00:08:23.120 --> 00:08:28.400
It's kind of like that Polaroid that we took&nbsp;
previously. We used to have this entire machine&nbsp;&nbsp;

00:08:28.400 --> 00:08:34.080
code representation of the program. But Genera&nbsp;
did things a little bit different. Genera didn't&nbsp;&nbsp;

00:08:34.080 --> 00:08:39.840
throw out any of that information. It's this&nbsp;
perfect example of a fully reflective operating&nbsp;&nbsp;

00:08:39.840 --> 00:08:46.080
system because all of that metadata stayed live&nbsp;
in memory attached to every different live object&nbsp;&nbsp;

00:08:46.080 --> 00:08:52.480
executing on the system. So, it's just like that&nbsp;
magical two-way mirror from previously because not&nbsp;&nbsp;

00:08:52.480 --> 00:08:58.480
only is it a live representation of an object,&nbsp;
but it's also an editable representation. So,&nbsp;&nbsp;

00:08:58.480 --> 00:09:04.080
that means that any process executing on the&nbsp;
system can modify any other running process.&nbsp;&nbsp;

00:09:04.080 --> 00:09:10.160
This kind of makes for some weird properties that&nbsp;
no other operating system really replicates today&nbsp;&nbsp;

00:09:10.160 --> 00:09:15.840
and for good reason too. For example, let's&nbsp;
say you have a program that crashes on the&nbsp;&nbsp;

00:09:15.840 --> 00:09:21.760
computer. Well, in Genera, it doesn't really&nbsp;
crash necessarily. It might be in a bad state,&nbsp;&nbsp;

00:09:21.760 --> 00:09:26.960
but it's kind of still there existing in memory.&nbsp;
So, what you could do is you could just walk over&nbsp;&nbsp;

00:09:26.960 --> 00:09:32.800
live patch the function that is causing the crash,&nbsp;
fix it, and then it runs and continues on its&nbsp;&nbsp;

00:09:32.800 --> 00:09:39.360
day. Fans of Genera often reported running their&nbsp;
system for months or even years without rebooting,&nbsp;&nbsp;

00:09:39.360 --> 00:09:45.360
which just sounds like absolutely nuts to me. But&nbsp;
it does sound really cool because they could just&nbsp;&nbsp;

00:09:45.360 --> 00:09:50.800
be live patching their underlying operating system&nbsp;
during execution. And in a lot of different ways,&nbsp;&nbsp;

00:09:50.800 --> 00:09:54.880
it kind of sounds like a programmer's dream.&nbsp;
But if you've been paying attention and like&nbsp;&nbsp;

00:09:54.880 --> 00:09:59.840
really paying attention, you've probably noticed&nbsp;
something. Keith's watching you. If you're paying&nbsp;&nbsp;

00:09:59.840 --> 00:10:08.240
attention, do not disappoint. [laughter] If any&nbsp;
code can touch any other code and there's no walls&nbsp;&nbsp;

00:10:08.240 --> 00:10:14.720
in between programs, then nothing is stopping,&nbsp;
for example, your mail application from silently&nbsp;&nbsp;

00:10:14.720 --> 00:10:20.720
reading, say, your banking application and getting&nbsp;
all of your credentials. Or even another program&nbsp;&nbsp;

00:10:20.720 --> 00:10:26.640
could just go [boop] recompile another program on&nbsp;
your system and you would have no idea. It would&nbsp;&nbsp;

00:10:26.640 --> 00:10:34.240
be incorrect to say that Genera had weak security.&nbsp;
Genera had no security. It truly is the least&nbsp;&nbsp;

00:10:34.240 --> 00:10:39.600
private operating system that was ever created.&nbsp;
And [music] the best part is it was completely&nbsp;&nbsp;

00:10:39.600 --> 00:10:44.080
intentional. Like this was all by design.&nbsp;
And you might be thinking to yourself like,&nbsp;&nbsp;

00:10:44.080 --> 00:10:49.040
what? How could a company like this possibly&nbsp;
have made it? But you have to think to yourself&nbsp;&nbsp;

00:10:49.040 --> 00:10:54.720
that the concept of malicious code wasn't&nbsp;
really as much of a thing at the time.&nbsp;&nbsp;

00:10:54.720 --> 00:10:59.440
Malware wasn't really that much of a thing yet&nbsp;
because the internet wasn't really much of a thing&nbsp;&nbsp;

00:10:59.440 --> 00:11:06.000
yet. So, nobody had this mental model of it. And&nbsp;
so, you have computers that are also like hundreds&nbsp;&nbsp;

00:11:06.000 --> 00:11:11.680
of thousands of today's dollars and researchers&nbsp;
just kind of trusted each other. And side note,&nbsp;&nbsp;

00:11:11.680 --> 00:11:16.640
if you're interested in learning about trusting&nbsp;
trust, go watch my previous video on the Original&nbsp;&nbsp;

00:11:16.640 --> 00:11:22.480
Sin of Computing. So, like, yeah, nothing was&nbsp;
technically preventing somebody at Stanford&nbsp;&nbsp;

00:11:22.480 --> 00:11:28.160
from just going through and modifying the computer&nbsp;
of somebody at MIT, but nobody really did because&nbsp;&nbsp;

00:11:28.160 --> 00:11:33.600
even the concept of the word hacker didn't really&nbsp;
have the same connotations that it does today. It&nbsp;&nbsp;

00:11:33.600 --> 00:11:38.160
more just meant somebody who really loves&nbsp;
exploring. And even the company Symbolics,&nbsp;&nbsp;

00:11:38.160 --> 00:11:44.240
who created Genera, ended up failing mostly just&nbsp;
for economic reasons. Although it is interesting&nbsp;&nbsp;

00:11:44.240 --> 00:11:50.800
to speculate if we still had the concept of&nbsp;
Genera today, how that would fare in the modern&nbsp;&nbsp;

00:11:50.800 --> 00:11:56.800
era of the internet. Ironic that the first .com&nbsp;
in history built the operating system that was&nbsp;&nbsp;

00:11:56.800 --> 00:12:02.640
fundamentally incompatible with the internet.&nbsp;
Unbelievably powerful but never attempted again.&nbsp;&nbsp;

00:12:02.640 --> 00:12:07.840
Symbolics ended up collapsing and although you&nbsp;
can find emulators of Genera, it's really just&nbsp;&nbsp;

00:12:07.840 --> 00:12:14.560
semi-abandonwear at this point. But the whole&nbsp;
idea behind it ended up escaping containment.&nbsp;&nbsp;

00:12:14.560 --> 00:12:20.000
You inevitably had hundreds of engineers leaving&nbsp;
and going to different parts of the industry. And&nbsp;&nbsp;

00:12:20.000 --> 00:12:25.040
this obsession with reflection followed them&nbsp;
to their respective industries. [music] This&nbsp;&nbsp;

00:12:25.040 --> 00:12:30.320
made it into different languages, different run&nbsp;
times, different language committees. Some got a&nbsp;&nbsp;

00:12:30.320 --> 00:12:36.160
full dose of reflection, some got a partial dose,&nbsp;
and then some like purposefully stayed away from&nbsp;&nbsp;

00:12:36.160 --> 00:12:41.040
it and stayed immune to it. All right, I think&nbsp;
it's time for a tier list. Now, just to be clear,&nbsp;&nbsp;

00:12:41.040 --> 00:12:46.720
Symbolics didn't actually invent the concept&nbsp;
of reflection themselves. And it's kind of a&nbsp;&nbsp;

00:12:46.720 --> 00:12:51.920
hard question to answer of who actually takes the&nbsp;
crown for this because depending on who you ask,&nbsp;&nbsp;

00:12:51.920 --> 00:12:58.320
it could be Brian Canwell Smith, Xerox PARC,&nbsp;
Pattie Maes, John McCarthy, Turing, Neumann,&nbsp;&nbsp;

00:12:58.320 --> 00:13:04.880
or even Godel. But it is safe to say that Genera&nbsp;
was one of the purest forms taken to the logical&nbsp;&nbsp;

00:13:04.880 --> 00:13:10.560
extreme of the concept of it. And you can actually&nbsp;
kind of rank what I would call the reflective&nbsp;&nbsp;

00:13:10.560 --> 00:13:16.960
IQ of a programming language based off of Maes'&nbsp;
definition. This would include one, how much does&nbsp;&nbsp;

00:13:16.960 --> 00:13:23.200
a running program understand about itself? And&nbsp;
two, how much can it act on that information? Keep&nbsp;&nbsp;

00:13:23.200 --> 00:13:28.560
in mind, these are my personal opinions, which&nbsp;
is synonymous with objectively correct, right?

00:13:31.520 --> 00:13:38.160
Start with C, first language. Now, I'm sorry, C&nbsp;
has to be F tier. You just have no introspection&nbsp;&nbsp;

00:13:38.160 --> 00:13:43.760
capabilities. You have no insight into what the&nbsp;
compiler actually knows about your program. If&nbsp;&nbsp;

00:13:43.760 --> 00:13:48.240
you want to traverse all of the members of a&nbsp;
struct, for example, you're going to have to&nbsp;&nbsp;

00:13:48.240 --> 00:13:52.880
manually list out every single one because the&nbsp;
compiler is not going to help you. Next one,&nbsp;&nbsp;

00:13:52.880 --> 00:13:59.040
Java. And Java is actually pretty darn good in&nbsp;
this particular area. Keep in mind that Java&nbsp;&nbsp;

00:13:59.040 --> 00:14:05.040
is compiled over to byte code and then the byte&nbsp;
code runs inside of a virtual machine or the JVM&nbsp;&nbsp;

00:14:05.040 --> 00:14:11.520
the Java virtual machine to be exact. So Java is&nbsp;
kind of this amalgamation between interpretation&nbsp;&nbsp;

00:14:11.520 --> 00:14:17.600
as well as compilation down to underlying native&nbsp;
code. And I personally really like Java but in&nbsp;&nbsp;

00:14:17.600 --> 00:14:23.760
this particular case the good thing about it is it&nbsp;
has a very powerful reflection API. Using the Java&nbsp;&nbsp;

00:14:23.760 --> 00:14:29.520
reflection API you can just go through and say hey&nbsp;
what kind of methods does this particular object&nbsp;&nbsp;

00:14:29.520 --> 00:14:35.440
contain inside of it and also you can go through&nbsp;
and dynamically invoke them as well the one thing&nbsp;&nbsp;

00:14:35.440 --> 00:14:41.840
that Java is missing is you cannot dynamically add&nbsp;
or delete methods while the program is executing&nbsp;&nbsp;

00:14:41.840 --> 00:14:47.440
so because of that I don't think it's deserving&nbsp;
of the highest tier. And I know one of you crazy&nbsp;&nbsp;

00:14:47.440 --> 00:14:53.440
commenters out there is going to be like oh no&nbsp;
you can do this crazy outofpocket hot swapping&nbsp;&nbsp;

00:14:53.440 --> 00:14:58.960
technique and directly modify the byte code&nbsp;
inside of memory and actually do your class&nbsp;&nbsp;

00:14:58.960 --> 00:15:03.120
manipulation. But I mean like at that point you&nbsp;
just have to call it quits somewhere. Like what&nbsp;&nbsp;

00:15:03.120 --> 00:15:08.560
if you take a computer and just shake it at that&nbsp;
point and change the bits physically. How about&nbsp;&nbsp;

00:15:08.560 --> 00:15:14.880
them apples? I'm trying to rank based off of the&nbsp;
core intent of the language, not in kind of hacky&nbsp;&nbsp;

00:15:14.880 --> 00:15:21.600
techniques. B tier. Okay, next language common&nbsp;
lisp. Once they added the object system CLOS.&nbsp;&nbsp;

00:15:21.600 --> 00:15:26.640
And this is going to be the highest ranked kind&nbsp;
of realistic language, there is another language&nbsp;&nbsp;

00:15:26.640 --> 00:15:32.000
that is technically ranked higher, but I'm saving&nbsp;
this one. And it's more of an academicish type&nbsp;&nbsp;

00:15:32.000 --> 00:15:37.920
language. This is what Genera was written in, and&nbsp;
it has everything. You have meta objects. You're&nbsp;&nbsp;

00:15:37.920 --> 00:15:44.800
able to dynamically redefine functions on the fly.&nbsp;
It's actually just kind of crazy. And it has what&nbsp;&nbsp;

00:15:44.800 --> 00:15:51.040
computer scientists call homoiconicity [music]&nbsp;
which means that any program that you write in&nbsp;&nbsp;

00:15:51.040 --> 00:15:57.280
lisp is itself actually a lisp data structure as&nbsp;
well. That means that you can infer the entire&nbsp;&nbsp;

00:15:57.280 --> 00:16:02.400
anatomy of a program if you're just reading in&nbsp;
the lisp data structure. Now let's move on to&nbsp;&nbsp;

00:16:02.400 --> 00:16:08.240
the dreaded C++. [snorts] And it's a little bit&nbsp;
complicated in terms of reflection but I'm going&nbsp;&nbsp;

00:16:08.240 --> 00:16:15.680
to come from this from a C++ 26 perspective. Now&nbsp;
C++ 26 has brought a lot of new features and one&nbsp;&nbsp;

00:16:15.680 --> 00:16:21.520
of those new features is static compile time&nbsp;
reflection and that is very exciting and very&nbsp;&nbsp;

00:16:21.520 --> 00:16:26.480
cool but there's a couple distinctions that we&nbsp;
have to make. So we have meta objects and we're&nbsp;&nbsp;

00:16:26.480 --> 00:16:33.120
able to perform introspection on the structure of&nbsp;
a program but all of this metadata and information&nbsp;&nbsp;

00:16:33.120 --> 00:16:38.240
disappears at runtime. So it's only available&nbsp;
to us during compilation. In other words,&nbsp;&nbsp;

00:16:38.240 --> 00:16:45.520
you can write C++ code that executes inside of the&nbsp;
compiler. You can use the meta functions to query&nbsp;&nbsp;

00:16:45.520 --> 00:16:51.280
things like how many non-static data members are&nbsp;
present inside of this particular class and that&nbsp;&nbsp;

00:16:51.280 --> 00:16:57.840
metadata is available to you. But the thing is all&nbsp;
of that metadata disappears after the compilation&nbsp;&nbsp;

00:16:57.840 --> 00:17:02.880
process is complete. That's a little hint, some&nbsp;
foreshadowing about a project that I very recently&nbsp;&nbsp;

00:17:02.880 --> 00:17:07.680
presented at a conference and I'll get into that&nbsp;
in just a second. So, going back to our tier list,&nbsp;&nbsp;

00:17:07.680 --> 00:17:14.080
I'm going to give C++ 26 reflection a D tier&nbsp;
ranking. We are a lot better than C. We actually&nbsp;&nbsp;

00:17:14.080 --> 00:17:20.080
have introspection and meta objects and stuff, but&nbsp;
we're just not as high as other languages. Python.&nbsp;&nbsp;

00:17:20.080 --> 00:17:25.840
And this one was a little bit surprising to me.&nbsp;
So, I'm more of a C++ developer at heart. I can&nbsp;&nbsp;

00:17:25.840 --> 00:17:31.040
write Python, but I'm not like super deep into&nbsp;
their ecosystem. But if you're clever and you're&nbsp;&nbsp;

00:17:31.040 --> 00:17:36.240
a super deep Python developer, you might realize&nbsp;
that Python is an interpreted language. And since&nbsp;&nbsp;

00:17:36.240 --> 00:17:41.840
it's an interpreted language, we can probably&nbsp;
do some interesting things at runtime. But the&nbsp;&nbsp;

00:17:41.840 --> 00:17:47.040
real question is, is it better than Java? Is it&nbsp;
worse than Java? Or is it about the same level of&nbsp;&nbsp;

00:17:47.040 --> 00:17:53.840
reflectiveness as Java? You can pause and see how&nbsp;
smart you are. It is more reflective than Java.&nbsp;&nbsp;

00:17:53.840 --> 00:17:59.040
It is A tier. As much as I hate to admit it, there&nbsp;
is this concept known as monkey patching where you&nbsp;&nbsp;

00:17:59.040 --> 00:18:05.440
can alter the actual class during dynamic program&nbsp;
execution. And there is a stipulation that is&nbsp;&nbsp;

00:18:05.440 --> 00:18:10.400
this is generally not recommended for standard&nbsp;
application logic. But you can see how it might&nbsp;&nbsp;

00:18:10.400 --> 00:18:16.880
be something useful for unit testing for example.&nbsp;
So in general Java is structurally immutable and&nbsp;&nbsp;

00:18:16.880 --> 00:18:22.800
Python is structurally mutable even if it's not&nbsp;
really encouraged. I stand by A tier. It's time&nbsp;&nbsp;

00:18:22.800 --> 00:18:30.480
to address the elephant in the room. Or rather&nbsp;
the crab. You know I don't actually have a crab&nbsp;&nbsp;

00:18:30.480 --> 00:18:39.200
plushy. I've got Keith. I've got Duke over here.&nbsp;
I've got a Flareon, too. Uh, an Android, Upas,&nbsp;&nbsp;

00:18:39.200 --> 00:18:44.160
whatever this cat is called. I don't know what&nbsp;
it's got a particular name. I don't actually know&nbsp;&nbsp;

00:18:44.160 --> 00:18:48.880
what it is. I also have more on the ground, too. I&nbsp;
have a lot of stuff around me, but I do not have a&nbsp;&nbsp;

00:18:48.880 --> 00:18:55.760
Rust crab. This one may surprise you as well. So,&nbsp;
both Rust and C++ are zero abstraction compiled&nbsp;&nbsp;

00:18:55.760 --> 00:19:02.800
languages, but only C++ has native built-in&nbsp;
static reflection capabilities. If we bring up&nbsp;&nbsp;

00:19:02.800 --> 00:19:09.360
the phases of a compiler, for example, C++ static&nbsp;
reflection happens after semantic analysis. Now,&nbsp;&nbsp;

00:19:09.360 --> 00:19:14.960
in Rust, you can have macros and stuff, but this&nbsp;
is happening before semantic analysis. You do not&nbsp;&nbsp;

00:19:14.960 --> 00:19:21.040
know anything at the parsing step. It's kind of&nbsp;
akin to you're trying to edit an essay, but you&nbsp;&nbsp;

00:19:21.040 --> 00:19:26.080
don't actually know what any of the words mean.&nbsp;
So, you can do like simple find and replace for&nbsp;&nbsp;

00:19:26.080 --> 00:19:31.040
letters, but you're basically just like throwing&nbsp;
spaghetti at the wall and seeing what sticks.

00:19:31.040 --> 00:19:32.960
Je n'ai pas compris.

00:19:32.960 --> 00:19:36.640
That was a terrible French accent. My&nbsp;
French teacher would kill me for that. So,&nbsp;&nbsp;

00:19:36.640 --> 00:19:41.280
these limitations combined with the fact that if&nbsp;
there's no static reflection, there's no runtime&nbsp;&nbsp;

00:19:41.280 --> 00:19:47.120
reflection as well means that we're going to&nbsp;
give this F tier. It is actually a little tiny&nbsp;&nbsp;

00:19:47.120 --> 00:19:52.080
bit better than C, but not enough to really bump&nbsp;
it up to another category. Interestingly enough,&nbsp;&nbsp;

00:19:52.080 --> 00:19:58.240
this puts our most memory unsafe language and&nbsp;
our most memory safe language on the same tier&nbsp;&nbsp;

00:19:58.240 --> 00:20:04.000
level for reflection. Very interesting. Go is&nbsp;
C tier. There is runtime type introspection,&nbsp;&nbsp;

00:20:04.000 --> 00:20:08.080
but it's like kind of annoying to use. And if&nbsp;
you don't believe me, then you can Go check&nbsp;&nbsp;

00:20:08.080 --> 00:20:12.800
it out yourself. Lastly, but clearly the&nbsp;
strongest, we have Brian C. Smith's Three&nbsp;&nbsp;

00:20:12.800 --> 00:20:20.960
Lisp. And this is SS plus tier. Easy. And 3-Lisp&nbsp;
kind of teaches us an important lesson here. So,&nbsp;&nbsp;

00:20:20.960 --> 00:20:28.080
3-Lisp is not truly its own programming language.&nbsp;
It's a derivation of lisp, but kind of a hint here&nbsp;&nbsp;

00:20:28.080 --> 00:20:33.040
that you can basically take any language and if&nbsp;
you're smart enough about how you write the code,&nbsp;&nbsp;

00:20:33.040 --> 00:20:38.960
you can manually raise it up like at least one&nbsp;
level on the reflection tier list. 3-lisp was&nbsp;&nbsp;

00:20:38.960 --> 00:20:45.840
part of Smith's PhD thesis where he described&nbsp;
an infinite tower of metacircular interpreters,&nbsp;&nbsp;

00:20:45.840 --> 00:20:51.120
infinitely high invocation by God himself. And&nbsp;
I'm not actually making that up because you could&nbsp;&nbsp;

00:20:51.120 --> 00:20:57.200
go check his code comments and see all of that.&nbsp;
[laughter] Man, programmers make me laugh. The&nbsp;&nbsp;

00:20:57.200 --> 00:21:03.040
correct definition is that the infinite reflective&nbsp;
tower means that a program can reify its own&nbsp;&nbsp;

00:21:03.040 --> 00:21:08.960
interpreter mid-execution and change the semantics&nbsp;
that it's running under, which is basically just a&nbsp;&nbsp;

00:21:08.960 --> 00:21:14.800
crazy way of saying that a program can change what&nbsp;
the definition of running is while it's actively&nbsp;&nbsp;

00:21:14.800 --> 00:21:20.880
running. The main difference is that with Genera&nbsp;
and common lisp, you can modify what is actively&nbsp;&nbsp;

00:21:20.880 --> 00:21:26.640
running, but you can't change what the concept of&nbsp;
running is itself. So, I'd kind of compare this&nbsp;&nbsp;

00:21:26.640 --> 00:21:31.920
to lucid dreaming. Like, this is the moment where&nbsp;
you realize you're in a dream and now you suddenly&nbsp;&nbsp;

00:21:31.920 --> 00:21:37.280
have the ability to change how gravity works.&nbsp;
You're changing the definition of reality. Anyway,&nbsp;&nbsp;

00:21:37.280 --> 00:21:42.480
you should really go check out his thesis because&nbsp;
it's very interesting to read because it like only&nbsp;&nbsp;

00:21:42.480 --> 00:21:48.000
partially works. So theoretically, you're working&nbsp;
with infinite towers, but you don't really have&nbsp;&nbsp;

00:21:48.000 --> 00:21:53.680
infinite towers of server racks of hardware to&nbsp;
work with. It's all going to be finite hardware.&nbsp;&nbsp;

00:21:53.680 --> 00:21:58.800
So there's actually a lot of cheating that is&nbsp;
involved inside of this concept. It's kind of&nbsp;&nbsp;

00:21:58.800 --> 00:22:04.800
like if you're working in your dream and your&nbsp;
dream is extending as you're looking around&nbsp;&nbsp;

00:22:04.800 --> 00:22:09.280
and only doing that when you actually look at&nbsp;
something. Now, it's time for the moment of truth,&nbsp;&nbsp;

00:22:09.280 --> 00:22:15.200
where I reveal the secret of how to raise any&nbsp;
language up about one tier. And this is exactly&nbsp;&nbsp;

00:22:15.200 --> 00:22:21.920
what I've been doing to C++ with my new library,&nbsp;
Call Me Maybe. We can bring C++ up to C tier.&nbsp;&nbsp;

00:22:21.920 --> 00:22:28.320
This is my brand new open-source tool that I&nbsp;
just recently released built on top of C++ 26&nbsp;&nbsp;

00:22:28.320 --> 00:22:34.080
called Call Me Maybe. So, what it's doing is it&nbsp;
is implementing runtime reflection on top of the&nbsp;&nbsp;

00:22:34.080 --> 00:22:41.040
static C++ 26 reflection. And I just recently&nbsp;
presented this research over at ACCU on C,&nbsp;&nbsp;

00:22:41.040 --> 00:22:46.480
which is a really cool C++ conference over in the&nbsp;
UK. And if you have a chance to check it out, you&nbsp;&nbsp;

00:22:46.480 --> 00:22:52.080
should definitely attend that conference. When I&nbsp;
was there, I was presenting all of this research.&nbsp;&nbsp;

00:22:52.080 --> 00:22:58.560
And it was so scary because I'm building on top of&nbsp;
other people's research that's released inside of&nbsp;&nbsp;

00:22:58.560 --> 00:23:04.480
the actual like C++ standard now. And a lot of&nbsp;
these people are sitting there in the audience&nbsp;&nbsp;

00:23:04.480 --> 00:23:11.920
watching me. and I'm like I'm explaining how their&nbsp;
features work kind of to them. But yeah, it was an&nbsp;&nbsp;

00:23:11.920 --> 00:23:17.200
interesting experience. I had a lot of fun. Those&nbsp;
people are really nice. If you'd like to use or&nbsp;&nbsp;

00:23:17.200 --> 00:23:21.360
try any of the code in this, I'm going to put a&nbsp;
link to it in the description below. The coolest&nbsp;&nbsp;

00:23:21.360 --> 00:23:28.080
thing is that if you actually want to go see the&nbsp;
paper for reflection, you can go over to the P2996&nbsp;&nbsp;

00:23:28.080 --> 00:23:34.480
reflection for C++ 26 proposal. And if we go down&nbsp;
here, we can take a look at the introduction.&nbsp;&nbsp;

00:23:35.200 --> 00:23:39.760
The interesting thing that I want to talk&nbsp;
about here [music] is this is proposing static&nbsp;&nbsp;

00:23:39.760 --> 00:23:45.600
reflection. So remember this is a feature that&nbsp;
is happening during just the compilation process&nbsp;&nbsp;

00:23:45.600 --> 00:23:51.520
and all of this information is only available at&nbsp;
compile time. So what I wanted to do with this&nbsp;&nbsp;

00:23:51.520 --> 00:23:57.600
research and with this project is have this kind&nbsp;
of bridge that allows us to get this information&nbsp;&nbsp;

00:23:57.600 --> 00:24:03.760
also at runtime. A few of the main interesting&nbsp;
features of C++ 26 static reflection is first&nbsp;&nbsp;

00:24:03.760 --> 00:24:11.200
of all this std::meta::info and this is kind of&nbsp;
an opaque handle. So it's this ID system into&nbsp;&nbsp;

00:24:11.200 --> 00:24:18.400
the compiler itself. So each ID points to a node&nbsp;
inside of the compiler and each of these nodes&nbsp;&nbsp;

00:24:18.400 --> 00:24:25.040
represents something inside of the syntax.&nbsp;
So next we also have the reflection operator&nbsp;&nbsp;

00:24:25.040 --> 00:24:30.640
and [music] it's this double carrot here. Okay,&nbsp;
so funny story. When I was giving my talk for this&nbsp;&nbsp;

00:24:30.640 --> 00:24:34.960
afterwards, somebody raised their hand and and&nbsp;
corrected me and said this is actually called the&nbsp;&nbsp;

00:24:34.960 --> 00:24:42.480
cat ears operator. [laughter] So I think somebody&nbsp;
somebody actually wanted to name it the cat ears&nbsp;&nbsp;

00:24:42.480 --> 00:24:48.400
operator cuz you know carrot carrot, [gasps]&nbsp;
but it is officially not the cat ears operator&nbsp;&nbsp;

00:24:48.400 --> 00:24:54.800
sadly. What the reflection operator does is it&nbsp;
takes in regular syntax and it raises this into&nbsp;&nbsp;

00:24:54.800 --> 00:25:00.640
the reflection domain. So now we're working with&nbsp;
that kind of mirror that represents our self and&nbsp;&nbsp;

00:25:00.640 --> 00:25:05.680
represents the original syntax, but you have&nbsp;
to have the kind of inverse of that. So what&nbsp;&nbsp;

00:25:05.680 --> 00:25:11.600
we have [music] is the splice operator and brings&nbsp;
us back down into regular syntax. So they're kind&nbsp;&nbsp;

00:25:11.600 --> 00:25:17.200
of like this endless circular loop back and forth&nbsp;
from each other. So you might be asking yourself,&nbsp;&nbsp;

00:25:17.200 --> 00:25:23.600
okay, what is the thing that forces us to stay&nbsp;
working inside of the compiler? Like how can you&nbsp;&nbsp;

00:25:23.600 --> 00:25:29.760
tell the programmer what to do that you're not&nbsp;
allowed to use this particular function or thing&nbsp;&nbsp;

00:25:29.760 --> 00:25:35.360
during runtime? How do you enforce this? Well,&nbsp;
there's a special keyword here called consteval.&nbsp;&nbsp;

00:25:35.360 --> 00:25:42.160
And this is associated with all of those meta&nbsp;
functions that belong to C++ 26 reflection. So&nbsp;&nbsp;

00:25:42.160 --> 00:25:48.160
if you mark a function as consteval, it is&nbsp;
forced to execute at compile time. This is&nbsp;&nbsp;

00:25:48.160 --> 00:25:54.960
the clang implementation of C++ 26 reflection&nbsp;
inside of the actual clang compiler itself.&nbsp;&nbsp;

00:25:54.960 --> 00:25:59.920
You can see we have all those keywords that we&nbsp;
talked about previously like consteval to force&nbsp;&nbsp;

00:25:59.920 --> 00:26:07.680
this to execute at compile time and we also have&nbsp;
our info which is our ID into the compiler that&nbsp;&nbsp;

00:26:07.680 --> 00:26:13.200
identifies what syntax we're working with. Now&nbsp;
the compiler has kind of provided us all of this&nbsp;&nbsp;

00:26:13.200 --> 00:26:20.720
free information and metadata. So we can kind of&nbsp;
ask it about itself. We can pass in an object and&nbsp;&nbsp;

00:26:20.720 --> 00:26:26.240
say "what is the type of this object"? We&nbsp;
can pass in a class and say "what are all&nbsp;&nbsp;

00:26:26.240 --> 00:26:31.920
of the non-static data members that comprise this&nbsp;
particular class"? And the compiler is also giving&nbsp;&nbsp;

00:26:31.920 --> 00:26:37.920
us rules. It's like I'm laying down the law.&nbsp;
I've got this consteval declaration over here.&nbsp;&nbsp;

00:26:37.920 --> 00:26:44.480
You are not allowed to take this information after&nbsp;
compile time. Personally though, I really do not&nbsp;&nbsp;

00:26:44.480 --> 00:26:51.040
like to be told what to do, which is why I built&nbsp;
an entire library just to break all of the rules!&nbsp;&nbsp;

00:26:51.040 --> 00:26:56.720
I created my own entire custom registration&nbsp;
system for runtime reflection. So, you can&nbsp;&nbsp;

00:26:56.720 --> 00:27:03.280
see this is registering a class and it's taking in&nbsp;
the compile time reflection and kind of converting&nbsp;&nbsp;

00:27:03.280 --> 00:27:09.760
it over to a runtime reflection object. And you&nbsp;
see every time we have this std::meta, that means&nbsp;&nbsp;

00:27:09.760 --> 00:27:17.920
we're using those C++ 26 features to build on&nbsp;
top of it. This is just my registration class,&nbsp;&nbsp;

00:27:17.920 --> 00:27:26.160
by the way. It goes on for freaking ever. This&nbsp;
took a lot a lot of work. Oh my gosh. The best&nbsp;&nbsp;

00:27:26.160 --> 00:27:32.880
part was is that as I was developing this, you&nbsp;
actually don't know if it's you making a mistake&nbsp;&nbsp;

00:27:32.880 --> 00:27:38.480
or the compiler making a mistake because all of&nbsp;
this was completely experimental as I was writing&nbsp;&nbsp;

00:27:38.480 --> 00:27:45.440
this library. Fortunately for you, however, I have&nbsp;
done all of the heavy lifting for you proactively.&nbsp;&nbsp;

00:27:45.440 --> 00:27:52.000
So, all you need to do in order to use runtime&nbsp;
reflection is annotate your functions inside of&nbsp;&nbsp;

00:27:52.000 --> 00:27:59.360
your classes with my custom CMM. call me maybe&nbsp;
[snorts and laughter] reflectible annotation&nbsp;&nbsp;

00:27:59.360 --> 00:28:05.440
and then you can automatically register all&nbsp;
of them for reflection. And not only that I&nbsp;&nbsp;

00:28:05.440 --> 00:28:12.160
am extremely picky when it comes to API design.&nbsp;
I think the APIs should be beautiful and kind of&nbsp;&nbsp;

00:28:12.160 --> 00:28:18.560
speak for themselves. So what I did is I decided&nbsp;
to mirror the meta functions. So it almost exactly&nbsp;&nbsp;

00:28:18.560 --> 00:28:25.680
copies C++ 26 already. You see I have the info&nbsp;
object as well which is my custom scaler type&nbsp;&nbsp;

00:28:25.680 --> 00:28:31.200
that returns the non-static data members which&nbsp;
should look just a little bit familiar. And with&nbsp;&nbsp;

00:28:31.200 --> 00:28:38.320
that simple...it's not really simple it's like&nbsp;
[laughter] that was kind of a lot to work on but&nbsp;&nbsp;

00:28:38.320 --> 00:28:46.560
with one single library we can effectively raise&nbsp;
C++ or any language from a lower tier level in the&nbsp;&nbsp;

00:28:46.560 --> 00:28:52.400
reflection tier list up to a higher level. Now, I&nbsp;
think the really kind of counterintuitive takeaway&nbsp;&nbsp;

00:28:52.400 --> 00:28:57.600
from all of this is that computers are usually&nbsp;
defined by what you can't do, like what you're&nbsp;&nbsp;

00:28:57.600 --> 00:29:03.120
not allowed to do. You can't touch this memory,&nbsp;
for example. You can't modify this object at&nbsp;&nbsp;

00:29:03.120 --> 00:29:09.520
runtime. But what I really wanted to show is that&nbsp;
with just a little bit of creativity and work,&nbsp;&nbsp;

00:29:09.520 --> 00:29:14.720
you can greatly exceed the original intent&nbsp;
and limitations of a language. You know,&nbsp;&nbsp;

00:29:14.720 --> 00:29:18.960
sure there's going to be some trade-offs, but&nbsp;
that's kind of what makes computer science so&nbsp;&nbsp;

00:29:18.960 --> 00:29:25.200
interesting and fun. And to me, reflection is one&nbsp;
of the most interesting and complex subjects that&nbsp;&nbsp;

00:29:25.200 --> 00:29:30.960
you can actually learn in computer science. So,&nbsp;
what are you waiting for? Go find your favorite&nbsp;&nbsp;

00:29:30.960 --> 00:29:35.840
programming language and raise it up one tier&nbsp;
on the reflection tier list. You might surprise&nbsp;&nbsp;

00:29:35.840 --> 00:29:41.040
yourself how far you can go. As always, thank&nbsp;
you so much for watching and until next time,&nbsp;&nbsp;

00:29:41.040 --> 00:29:48.160
LaurieWired out. We're going to do a C-section.&nbsp;
Hope my knife isn't Rusty. Going to need some&nbsp;&nbsp;

00:29:48.160 --> 00:29:59.280
Java to wake me up for this surgery. Oh no, a&nbsp;
Python. I think I can slip that one in naturally.

00:29:59.280 --> 00:30:08.560
Oh my gosh. I like to do my incisions in&nbsp;
a Zig zag. I can't think of a single other&nbsp;&nbsp;

00:30:08.560 --> 00:30:14.480
programming language right now. Lua. How&nbsp;
the heck can you get Lua into anything?

