[00:00.000 --> 00:06.600] The next, and there are more Lisp, and what's up with Lisp, and how come I can't get enough Lisp, and so forth. [00:07.380 --> 00:10.280] And we're going to hear all about the answers to those questions right now. [00:17.090 --> 00:19.730] It's a little bit better dressed than I am, but... [00:19.730 --> 00:20.650] Not a contest. [00:20.970 --> 00:21.350] I know. [00:24.290 --> 00:25.930] Some people will recognize this. [00:37.520 --> 00:38.700] This is my third hope. [00:38.960 --> 00:41.060] This is my first presentation in... [00:42.860 --> 00:44.020] Maybe 16 years? [00:44.720 --> 00:45.920] I'm not that old, either. [00:52.210 --> 00:54.130] Alright, should I just flip the laptop around? [01:08.330 --> 01:09.710] Only one, if he's good enough. [01:10.630 --> 01:11.530] Alright, excellent. [01:11.730 --> 01:13.010] Now it's squished that way, too. [01:13.810 --> 01:14.230] Perfect. [01:19.340 --> 01:19.760] Nope. [01:23.650 --> 01:24.670] Good enough, right? [01:24.850 --> 01:25.510] You can read that? [01:25.690 --> 01:26.570] No, it looks like crap. [01:26.570 --> 01:26.650] Yep. [01:31.870 --> 01:32.230] Whatever. [01:34.030 --> 01:35.190] Thank you for coming to this talk. [01:37.510 --> 01:41.930] I had expected maybe a quarter of the room, but it is six o'clock, so... [01:41.930 --> 01:42.170] It's alright. [01:50.770 --> 02:00.510] Alright, this talk is Lisp, the oldest language of the future, which could be a grumpy old Lisp person and say, oh, you know, you're excited about an aspect-oriented program. [02:00.690 --> 02:06.490] Lisp solved that 20 years ago, but no one bothered to ask them, so they didn't volunteer the information. [02:09.430 --> 02:22.260] You know, the title sounds like a pretty tall order, but I think the history of the language will speak for itself, and I hope I can give you enough history of the language for this to be a worthwhile talk. [02:24.940 --> 02:30.180] Might be a little dense in content, at least I wrote that before I found out how long it takes to make each slide. [02:32.280 --> 02:33.860] Hopefully there's enough content in here. [02:34.740 --> 02:37.200] If you're not careful, you just might learn something before it's through. [02:39.720 --> 02:40.720] Speak up a bit. [02:40.880 --> 02:41.760] I am sorry. [02:42.040 --> 02:42.880] Is this better? [02:43.180 --> 02:43.460] Much. [02:43.740 --> 02:43.920] Yes. [02:44.740 --> 02:45.100] Thank you. [02:45.200 --> 02:45.880] Heckle louder. [02:49.260 --> 02:51.320] You know, maybe you know something about Lisp. [02:51.740 --> 02:52.900] Probably going to say parentheses. [02:54.640 --> 02:56.140] Maybe you saw it in a magazine article. [02:56.920 --> 03:00.100] Might have come across it in a program book or programming language surveys course. [03:00.820 --> 03:02.520] Maybe you experiment a little bit in college. [03:04.960 --> 03:08.540] Either you thought it was too complicated, too simple, to weird. [03:10.800 --> 03:13.380] You know, the functional style isn't for everyone. [03:13.800 --> 03:18.440] And most of the languages descend them from algol. [03:18.700 --> 03:23.240] And they look like C and EFC and Perl and PHP. [03:23.900 --> 03:26.060] And it's all basically the same. [03:28.120 --> 03:29.240] Because it's so old. [03:29.760 --> 03:31.800] Fortran came out in 1957. [03:32.200 --> 03:32.900] Lisp was 58. [03:33.260 --> 03:35.360] And COBOL was 59. [03:38.180 --> 03:39.820] You know, it's considered one of the classics. [03:40.280 --> 03:41.520] But because it's so weird. [03:42.040 --> 03:46.740] And you know, it was slow for a while because the hardware wasn't there. [03:46.740 --> 03:50.080] It didn't compile very easily into machine code. [03:50.320 --> 03:52.420] It just didn't really catch on. [03:54.180 --> 03:57.660] It's been stigmatized as being only for AI. [03:57.940 --> 03:59.620] Because AI is a bad thing. [03:59.920 --> 04:02.280] You would think if it's for AI, you'd want to use it in everything. [04:06.140 --> 04:07.560] But here we go. [04:07.640 --> 04:09.220] Here's some nice quotes about Lisp. [04:09.960 --> 04:16.320] These all come from a number of years ago when people were writing books about it. [04:16.420 --> 04:17.960] It has a new resurgence now. [04:18.380 --> 04:22.160] But you know, the first one is if you give someone Fortran, he has Fortran. [04:22.740 --> 04:23.500] Which is true. [04:23.680 --> 04:25.920] But if you give someone Lisp, he has any language he pleases. [04:26.660 --> 04:35.580] And while this is in the afterword to a book about scheme, hopefully I'll be able to show you at least a little bit how this might be possible. [04:36.200 --> 04:38.580] Typically when you're writing a program in Lisp, you... [04:39.200 --> 04:43.900] will write small functions that do what you want and then you build on top of it. [04:44.240 --> 04:47.420] Until eventually you've built the language towards your problem. [04:47.720 --> 04:55.580] Instead of in a lot of other languages where you go back to the boss and say, well, we can't deliver this on time, so let's cut this feature. [04:55.820 --> 04:59.640] Or, well, the spec isn't really clear on this, so we're not going to do it that way. [05:01.080 --> 05:02.020] Second quote here. [05:02.140 --> 05:04.800] All problems in computer science can be solved by another level of indirection. [05:05.000 --> 05:07.540] The addendum is except for too many layers of indirection. [05:09.720 --> 05:15.640] Because Lisp is a functional programming language, functions are a first class citizen. [05:16.200 --> 05:20.780] It's a phrase that bothered me because every time I tried to look it up, I would just get more confused. [05:21.420 --> 05:27.380] First class citizen just means that in the language, a function is on the same par as a variable. [05:27.380 --> 05:33.800] You can pass functions to other functions, functions can return functions, you can store a function in a variable name. [05:35.420 --> 05:37.240] Although in Lisp they're actually called symbols. [05:37.820 --> 05:39.140] They're not really variables. [05:41.220 --> 05:54.960] The last quote also speaks to the ability of you to write the language how you want, build your little utility classes, and eventually you end up with something that is ideally suited to solving whatever problem you have. [05:58.180 --> 05:59.800] It is indeed rather hot in here. [06:00.680 --> 06:01.980] This jacket isn't helping. [06:05.020 --> 06:06.520] But it's part of the shtick. [06:18.060 --> 06:25.780] So these are three of the books that I used for this talk, and in case I do a terrible job, you can read them too. [06:29.520 --> 06:32.420] The one all the way on the left is probably the gentlest. [06:32.720 --> 06:35.640] It's a gentle introduction to symbolic computation. [06:36.180 --> 06:39.040] If you've never programmed at all, this book is good. [06:39.760 --> 06:41.600] They don't even start with the WISP syntax. [06:44.120 --> 06:45.500] But they gradually introduce it. [06:45.600 --> 06:49.020] It has a very good explanation about recursion. [06:50.140 --> 06:52.780] They have a nice picture of the cat in the hat, but that's only in the print version. [06:52.780 --> 06:54.040] They didn't make it into the PDF. [06:54.740 --> 07:03.660] Practical Common Lisp by Peter Seibel may be one of the reasons why there's a recent upsurge in interest in the language. [07:03.860 --> 07:05.260] It was published in 2005. [07:06.080 --> 07:09.720] He gave a Google talk, but I didn't like it that much. [07:09.880 --> 07:10.420] Don't tell him. [07:11.940 --> 07:15.780] And then ANSI Common Lisp by Paul Graham is a little bit harder core. [07:15.780 --> 07:17.300] They have code in there for array tracer. [07:17.960 --> 07:21.140] And there's a good reference in there for the Common Lisp standard. [07:23.860 --> 07:24.900] Here's the titles again. [07:25.180 --> 07:28.400] And then this last book at the bottom, I wish I had found earlier. [07:29.800 --> 07:33.280] But they have 12 lessons in there that basically go over everything. [07:35.180 --> 07:41.720] Starting from the syntax all the way up to macros and different functions and all that other good stuff. [07:43.540 --> 07:45.500] These are a little bit harder core. [07:50.740 --> 07:58.000] The one all the way on the left is the book that was used to teach the MIT 6001 class. [07:58.640 --> 08:08.720] Also known as the wizard book or the purple book or sick P. In the middle is Paul Graham's on list, which is really good if you want to really understand macros, which I'll get to later. [08:08.940 --> 08:10.340] They're not like C macros. [08:11.380 --> 08:19.500] And the one all the way on the right, the paradigms of artificial intelligence programming is probably the toughest of all of them. [08:21.300 --> 08:25.600] The examples are in Common Lisp until the point where he develops a prologue interpreter. [08:28.440 --> 08:30.280] Then all the examples are in prologue. [08:31.760 --> 08:32.380] So... [08:32.380 --> 08:33.800] This is... [08:33.800 --> 08:34.280] This is... [08:34.280 --> 08:34.340] This is... [08:35.660 --> 08:37.560] Just to go back to the... [08:40.140 --> 08:41.980] It's available for free online. [08:46.300 --> 08:47.920] So, Common Lisp. [08:48.180 --> 08:49.200] General introduction. [08:49.460 --> 08:50.440] Available online in PDF. [08:50.720 --> 08:52.140] You can buy it if you want. [08:53.020 --> 08:53.940] Practical Common Lisp. [08:54.100 --> 08:56.740] Available at gigamonkeys.com slash book. [08:57.600 --> 08:58.460] ANSI Common Lisp. [08:58.460 --> 08:59.060] You'll have to buy. [09:00.840 --> 09:01.900] On Lisp is free. [09:02.200 --> 09:02.440] On Lisp is free. [09:03.260 --> 09:04.160] Successful Lisp. [09:04.420 --> 09:04.920] The... [09:04.920 --> 09:06.560] Bit of a publishing dispute. [09:06.720 --> 09:08.220] So, that's available free on his website. [09:11.800 --> 09:13.460] SICP is available free at MIT. [09:14.080 --> 09:15.500] And they have a whole bunch of... [09:16.800 --> 09:17.440] Ta-da. [09:17.700 --> 09:20.540] They have the lectures from 1986 at HP. [09:22.300 --> 09:24.740] I hope this classifies as fair use. [09:26.960 --> 09:27.400] Um... [09:27.400 --> 09:28.060] Yeah. [09:30.600 --> 09:31.040] So... [09:31.040 --> 09:31.860] Well, let me... [09:31.860 --> 09:32.300] Let me... [09:32.300 --> 09:34.960] I have a good few pages on this, but... [09:35.700 --> 09:36.140] Um... [09:36.140 --> 09:38.000] You know, this isn't the first time I've tried to learn Lisp. [09:38.560 --> 09:38.920] Uh... [09:38.920 --> 09:39.620] It's... [09:39.620 --> 09:41.820] You know, like I mentioned before with the first class functions. [09:42.260 --> 09:43.560] First class citizens language. [09:44.140 --> 09:44.500] Uh... [09:44.500 --> 09:47.440] If someone doesn't explain it just right, you're stuck. [09:47.800 --> 09:51.280] You know, you're never gonna progress past a certain point without the understanding. [09:52.400 --> 09:52.940] Um... [09:52.940 --> 09:54.340] Are there any physics teachers in here? [09:55.520 --> 09:56.060] No? [09:56.340 --> 09:56.780] Okay. [09:57.560 --> 09:57.980] Maybe... [09:57.980 --> 10:05.940] Maybe you've come across the phrase in a science textbook where they're talking about neutron stars and how a teaspoon of material would weigh ten tons! [10:06.960 --> 10:07.500] Amazing! [10:08.200 --> 10:09.640] But then they never explain it. [10:12.260 --> 10:14.320] You know, and it took me, uh... [10:14.320 --> 10:17.640] A number of years until I read a book by Robert Jastrow, uh... [10:18.320 --> 10:20.240] Red Giants and White Dwarfs, which... [10:20.240 --> 10:24.740] I guess was popular science in about 1956, but it never made it into the science textbooks. [10:25.660 --> 10:28.680] So they could've explained it when they went over the periodic table. [10:28.860 --> 10:31.740] We don't have any elements that are dense enough to weigh ten tons. [10:32.500 --> 10:32.900] Uh... [10:32.900 --> 10:34.400] They could've explained it when they went to nuclear fission. [10:34.660 --> 10:35.060] No. [10:35.060 --> 10:35.120] No. [10:35.720 --> 10:42.660] What happens in a collapsed star is the gravity and the pressure compress everything so much that the electrons get stripped off. [10:43.020 --> 10:51.500] You know, your familiar image of an orange in the middle of a football stadium with the electron pair going round the outside, round the outside. [10:54.900 --> 10:56.680] That gets all smooshed together. [10:56.720 --> 10:58.520] So you got all these, uh... [10:58.520 --> 11:01.000] All the neutrons and protons come together. [11:01.200 --> 11:02.200] The electrons get stripped off. [11:02.320 --> 11:02.960] They become a plasma. [11:03.420 --> 11:05.700] Eventually the star gets dense enough that it explodes. [11:05.980 --> 11:07.600] And that's where we get all our heavier elements from. [11:08.760 --> 11:10.220] Like I said, they never explained that. [11:10.400 --> 11:12.160] They could've done it in five seconds. [11:12.440 --> 11:14.320] There's always this hole in my understanding. [11:15.600 --> 11:17.020] Anyway, back to Lisp. [11:20.620 --> 11:21.980] Sorry I got my catchphrase in. [11:25.700 --> 11:26.140] Um... [11:28.690 --> 11:32.510] I went over the, just in case something terrible happens and you don't learn anything from my speech line. [11:33.830 --> 11:34.270] Uh... [11:34.270 --> 11:35.250] So here are some misconceptions. [11:37.470 --> 11:37.910] Uh... [11:40.190 --> 11:42.750] Hopefully I will allay your worries about Lisp. [11:43.110 --> 11:46.910] I guess it's good that the text on the bottom got cut off. [11:46.990 --> 11:48.390] Because it's not just good for AI. [11:49.370 --> 11:49.810] Uh... [11:49.810 --> 11:51.090] You can use it for just about anything. [11:52.310 --> 11:52.750] Um... [11:52.750 --> 11:56.930] The other funny thing is, whenever a problem is solved in AI, it's no longer AI. [11:57.470 --> 11:59.250] It's just some useful computer program. [12:00.250 --> 12:02.090] We thought that chess was intractable. [12:02.250 --> 12:03.990] And then we built machines to be very good at it. [12:04.190 --> 12:07.890] Suddenly it's, you know, a whole bunch of heuristics and depth-first searches. [12:08.490 --> 12:08.890] And... [12:09.930 --> 12:10.330] Uh... [12:10.330 --> 12:11.830] You know, lots of trial and error. [12:15.890 --> 12:16.290] Um... [12:16.290 --> 12:16.850] Yeah, I don't know. [12:17.010 --> 12:18.390] These kind of speak for themselves. [12:21.250 --> 12:21.710] Um... [12:21.710 --> 12:23.170] So, in the beginning was the Lambda. [12:24.830 --> 12:25.290] Dateline. [12:25.450 --> 12:26.870] Princeton, New Jersey, 1936. [12:27.650 --> 12:29.490] Mr. and Mrs. America and all the ships at sea. [12:30.590 --> 12:30.690] Uh... [12:30.690 --> 12:34.690] Alonzo Church was studying at Princeton, along with lots of other interesting people like, uh... [12:34.690 --> 12:36.390] Kurt Godel and, uh... [12:37.670 --> 12:38.450] Other interesting people. [12:39.070 --> 12:40.530] Alan Turing studied under him. [12:40.850 --> 12:41.210] And, uh... [12:41.210 --> 12:42.630] He developed the Lambda Calculus. [12:42.850 --> 12:46.030] Or, if you're studying formal systems, you would say he discovered it. [12:46.030 --> 12:47.450] Since, uh... [12:47.450 --> 12:50.710] Formal systems exist beyond anyone needing to perceive them. [12:51.810 --> 12:52.330] Uh... [12:52.330 --> 12:56.290] So, a little bit later, I think a year or two later, Alan Turing, uh... [12:57.450 --> 13:01.810] Worked out that the Lambda Calculus was equivalent to his Turing machines. [13:02.110 --> 13:04.510] They defined the same class of functions and were therefore equivalent. [13:05.650 --> 13:06.170] Uh... [13:06.170 --> 13:12.070] This, along with recursion, makes up the Church-Turing thesis, which covers things which a computer can solve. [13:12.070 --> 13:12.570] Uh... [13:12.570 --> 13:13.330] Even though it's... [13:13.330 --> 13:16.690] It's still a thesis slash hypothesis, we can't prove it. [13:17.890 --> 13:18.450] Eh... [13:18.450 --> 13:19.450] We're accepting it. [13:20.430 --> 13:22.870] You know, we've built all our computing systems on it. [13:23.930 --> 13:24.490] Uh... [13:24.490 --> 13:26.410] A few years later, 1958, uh... [13:26.410 --> 13:27.390] John McCarthy invents Lisp. [13:28.730 --> 13:29.290] Um... [13:29.290 --> 13:30.650] It was part of... [13:30.650 --> 13:32.890] A project to do Lisp processing. [13:33.170 --> 13:34.770] I'm not sure for what, but... [13:34.770 --> 13:37.950] Lots of log tables or military applications or whatever. [13:39.810 --> 13:40.250] Um... [13:40.250 --> 13:43.010] And they tried to do it with Fortran, and it didn't work out too well. [13:43.570 --> 13:43.790] Uh... [13:43.790 --> 13:45.030] One of the problems was the... [13:45.030 --> 13:48.670] The conditional in Fortran required you to evaluate the art... [13:48.670 --> 13:52.510] You know, both trees of the argument, regardless of whether you're gonna take them or not. [13:54.230 --> 13:54.670] Uh... [13:54.670 --> 13:56.750] Not generally a good idea, uh... [13:56.750 --> 13:58.550] If you only want one of the things to happen. [14:00.070 --> 14:00.510] Um... [14:00.510 --> 14:02.670] So, one of the weird things about the, uh... [14:02.670 --> 14:07.010] The syntax is the prefix notation, where you put the operator in the front of your arguments. [14:07.010 --> 14:08.070] And, uh... [14:08.070 --> 14:08.850] This appeared here. [14:10.470 --> 14:10.910] Um... [14:10.910 --> 14:15.070] You know, we've been doing math since kindergarten with the operators in the middle. [14:16.610 --> 14:17.490] And, uh... [14:17.490 --> 14:22.850] Which is fine if you're summing a few numbers, but if you have a whole list of a hundred, you don't have to put the plus in the middle. [14:23.130 --> 14:24.450] You know, what if you screw up once? [14:24.670 --> 14:25.330] Where's your bug? [14:26.190 --> 14:26.910] No idea. [14:29.210 --> 14:29.650] Um... [14:29.650 --> 14:33.330] We can thank Lisp and Mr. John McCarthy for the conditional operator. [14:34.150 --> 14:35.490] Fortran only had if and go to. [14:35.890 --> 14:38.550] Which worked out pretty well for the, uh... [14:38.550 --> 14:40.330] The machines of the time, but... [14:42.050 --> 14:42.490] Um... [14:42.490 --> 14:47.970] The funny thing is that it was not designed right away as a programming language. [14:48.210 --> 14:51.190] It was supposed to be a way to axiomatize mathematics. [14:51.510 --> 14:53.170] So that they could write expressions in it. [14:53.530 --> 14:55.670] Prove them mathematically through some other system. [14:56.870 --> 14:57.270] Um... [14:57.770 --> 14:58.170] Um... [14:58.170 --> 15:00.550] And, you know, do cool mathy things with them. [15:02.050 --> 15:02.450] Um... [15:02.450 --> 15:05.310] Eventually, the S expressions were supposed to be a lower form... [15:06.290 --> 15:06.690] Um... [15:06.690 --> 15:07.790] Of expression that... [15:07.790 --> 15:08.570] Uh... [15:08.570 --> 15:09.830] You would write in meta expressions. [15:10.070 --> 15:11.190] Which look a little bit like Haskell. [15:12.650 --> 15:13.050] Um... [15:13.050 --> 15:15.010] And the compiler would change them into S expressions. [15:15.170 --> 15:17.190] And then the S expressions would get turned into machine code. [15:19.110 --> 15:19.750] There we go. [15:19.850 --> 15:20.210] Like that. [15:20.210 --> 15:20.790] The... [15:20.790 --> 15:25.110] The project time frame was about two years to actually get a working compiler. [15:25.710 --> 15:26.310] Uh... [15:26.310 --> 15:26.870] Until... [15:26.870 --> 15:27.490] Steve Russell. [15:27.910 --> 15:29.570] Who I think was also at MIT. [15:30.070 --> 15:31.550] Realized that the eval function. [15:32.130 --> 15:32.730] Um... [15:32.730 --> 15:34.030] He could just code it up. [15:34.290 --> 15:35.630] In IBM 704. [15:36.290 --> 15:36.890] And... [15:36.890 --> 15:38.390] Once he coded that. [15:38.610 --> 15:40.070] It was, uh... [15:40.070 --> 15:43.210] Able to actually evaluate these S expressions into... [15:43.730 --> 15:44.330] Uh... [15:44.330 --> 15:44.570] Values. [15:44.870 --> 15:46.190] And suddenly we have a programming language. [15:47.210 --> 15:47.810] Uh... [15:47.810 --> 15:48.510] Little note at the bottom. [15:48.510 --> 15:49.890] Steve Russell also wrote Space War. [15:51.050 --> 15:53.350] I don't know what really popular means. [15:53.730 --> 15:55.710] In the context of, uh... [15:55.710 --> 15:56.950] 1958, 1960. [15:58.090 --> 15:58.690] Computers. [15:59.430 --> 15:59.730] But... [16:00.310 --> 16:00.910] Um... [16:00.910 --> 16:02.570] Over the years there were a whole bunch of... [16:02.570 --> 16:04.310] Different dialects that developed. [16:05.970 --> 16:06.570] Uh... [16:06.570 --> 16:08.410] Numerous incompatibilities between them. [16:10.270 --> 16:11.210] And, uh... [16:11.210 --> 16:12.110] Round about 1984. [16:12.530 --> 16:12.990] Uh... [16:12.990 --> 16:15.470] Guile Steele published the Common Lisp Language Book. [16:15.630 --> 16:16.110] And that... [16:16.110 --> 16:18.570] Became a major part of the... [16:19.130 --> 16:19.630] Uh... [16:19.630 --> 16:21.150] Standard that was actually adopted by ANSI. [16:22.470 --> 16:22.970] Um... [16:24.670 --> 16:25.170] Um... [16:25.170 --> 16:25.610] And... [16:25.610 --> 16:27.310] Scheme which came along in between. [16:27.650 --> 16:29.350] Also helped, uh... [16:29.350 --> 16:29.930] Influence. [16:32.290 --> 16:32.870] All right. [16:33.050 --> 16:34.710] So, this, you know... [16:34.710 --> 16:36.790] I made such a big deal about it in the, uh... [16:36.790 --> 16:37.970] Description of the talk. [16:39.230 --> 16:39.730] Um... [16:39.730 --> 16:39.790] Uh... [16:39.790 --> 16:41.590] These are some of the features that... [16:41.590 --> 16:42.390] You know... [16:42.390 --> 16:45.070] May not be that impressive, but... [16:45.070 --> 16:45.450] Come on. [16:46.030 --> 16:46.830] Conditional expression? [16:47.430 --> 16:49.010] I guess it had to come along sometime. [16:49.510 --> 16:50.430] But, uh... [16:50.430 --> 16:52.990] Anonymous functions are showing up in a lot of different places. [16:54.010 --> 16:54.410] Uh... [16:54.410 --> 16:56.570] JavaScript being one of them that sort of surprised me. [16:56.710 --> 16:58.130] But JavaScript is... [16:58.130 --> 17:00.930] Not the JavaScript you might know from 10, 15 years ago. [17:02.190 --> 17:02.590] Uh... [17:02.590 --> 17:04.130] Logo was also based on Lisp. [17:04.770 --> 17:05.170] Which... [17:05.170 --> 17:07.750] Hopefully after the talk you can look at it and say, Yeah, that makes sense. [17:08.150 --> 17:08.670] Uh... [17:08.670 --> 17:09.990] Do we still teach Logo to kids? [17:10.790 --> 17:11.310] No. [17:12.490 --> 17:13.570] That kind of sucks. [17:13.830 --> 17:14.330] Oh well. [17:14.910 --> 17:16.730] They stopped teaching the MIT, uh... [17:16.730 --> 17:17.950] Programming class in... [17:17.950 --> 17:18.670] Scheme. [17:18.990 --> 17:19.770] But it's okay. [17:19.830 --> 17:20.690] They replaced it with Python. [17:21.130 --> 17:21.870] It's still MIT. [17:25.270 --> 17:25.790] Um... [17:25.790 --> 17:29.310] I hope Mr. Randall Munro got my email about using this comic. [17:30.770 --> 17:33.830] While he does have a blanket license for, uh... [17:33.830 --> 17:34.550] For presentations. [17:35.090 --> 17:36.810] I mentioned that it's gonna be filmed, so... [17:38.010 --> 17:39.090] Please don't sue me. [17:51.790 --> 17:52.270] Um... [17:52.270 --> 17:52.970] So, now... [17:52.970 --> 17:54.410] Now we finally get... [17:54.410 --> 17:55.830] To, uh... [17:55.830 --> 17:56.690] To the syntax. [17:57.050 --> 17:57.430] Eventually. [17:59.630 --> 18:00.110] Um... [18:00.110 --> 18:02.070] You know, you might think it's not really used anywhere. [18:02.610 --> 18:03.470] But, uh... [18:04.130 --> 18:04.970] Lisp runs... [18:04.970 --> 18:05.870] You know, it runs Emacs. [18:06.610 --> 18:09.390] Unfortunately, you can't take the code in Emacs... [18:09.390 --> 18:12.210] Outside of Emacs without dragging the rest of the editor along. [18:13.010 --> 18:15.030] Although, some people call it an operating system. [18:15.030 --> 18:15.770] Not just an editor. [18:20.680 --> 18:21.200] Um... [18:21.200 --> 18:21.980] This is bad. [18:22.840 --> 18:24.520] I've totally outstripped my notes. [18:26.980 --> 18:27.500] Um... [18:27.500 --> 18:28.540] Let's back up a little bit. [18:30.820 --> 18:31.340] Um... [18:31.340 --> 18:32.480] Lisp is used in AutoCAD. [18:33.100 --> 18:33.300] Uh... [18:33.300 --> 18:35.740] Possibly one of the most successful programs of the 80s. [18:36.240 --> 18:37.340] It's still going strong. [18:37.480 --> 18:38.760] Still uses Lisp in it. [18:39.360 --> 18:39.740] Uh... [18:39.740 --> 18:42.580] The scheduling system of the Hubble Space Telescope is written in Lisp. [18:43.220 --> 18:45.720] And I haven't been able to dig up the story, but... [19:05.340 --> 19:05.720] Uh... [19:06.260 --> 19:07.120] Replace the code. [19:07.420 --> 19:10.940] The only other place that I've seen that touted as a feature is Erlang. [19:12.620 --> 19:13.500] Which, uh... [19:13.500 --> 19:14.420] Erlang is kind of hardcore. [19:14.820 --> 19:15.700] But there was a... [19:15.700 --> 19:23.860] There was a dialect of Lisp called Termite that incorporated the Erlang message box sort of paradigm in it. [19:24.120 --> 19:24.900] And, uh... [19:24.900 --> 19:25.900] That was kind of impressive too. [19:26.200 --> 19:31.560] Still looks like Lisp, but you get the concurrency benefits and being able to hot swap code and things like that. [19:33.600 --> 19:34.000] Um... [19:34.000 --> 19:35.900] If you want to write filters in GIMP, you can use that. [19:37.400 --> 19:37.800] Uh... [19:37.800 --> 19:38.720] Long time ago, there was a... [19:38.720 --> 19:41.200] A groundbreaking AI demo called Shurdlu. [19:42.160 --> 19:43.180] Do I have this later? [19:43.400 --> 19:43.640] Nope. [19:44.100 --> 19:44.380] Alright. [19:46.100 --> 19:46.500] Um... [19:46.500 --> 19:47.260] Unfortunately, this... [19:47.260 --> 19:47.960] This might have been... [19:48.780 --> 19:50.220] One of the, uh... [19:50.220 --> 19:52.320] Reasons why there was an AI winter was... [19:52.320 --> 19:53.220] There's so many... [19:53.220 --> 19:53.580] You know, they... [19:53.580 --> 19:56.800] They did such a good job that everyone's, uh... [19:56.800 --> 19:59.540] Expectations for what we'll have in five or ten years... [20:00.180 --> 20:00.740] Uh... [20:00.740 --> 20:01.180] Were, uh... [20:01.180 --> 20:01.920] Sort of inflated. [20:04.140 --> 20:04.700] Um... [20:04.700 --> 20:05.220] The, uh... [20:05.220 --> 20:09.600] The software company Naughty Dog also used two Lisp-based systems for the Jack and Daxter games. [20:11.100 --> 20:11.660] Um... [20:11.660 --> 20:14.280] Wasn't quite the same kind of Lisp, but... [20:14.280 --> 20:14.800] Uh... [20:14.800 --> 20:18.520] One of the benefits was that you can swap out, um... [20:18.520 --> 20:20.160] Models while the system is running. [20:20.540 --> 20:21.040] And... [20:21.040 --> 20:22.620] It'll just garbage collect the old stuff. [20:24.300 --> 20:24.860] Uh... [20:24.860 --> 20:25.300] But... [20:25.300 --> 20:25.540] Anyway. [20:25.940 --> 20:26.720] To Lisp. [20:28.820 --> 20:30.180] The, uh... [20:30.180 --> 20:32.260] The weird syntax is actually an asset. [20:33.120 --> 20:33.800] Uh... [20:33.800 --> 20:35.000] It denotes a... [20:35.000 --> 20:35.880] A statement. [20:36.600 --> 20:36.940] The... [20:36.940 --> 20:39.500] The list begins and ends with a parenthesis. [20:41.120 --> 20:41.800] Um... [20:41.800 --> 20:43.600] Lists are composed of atoms and other lists. [20:45.280 --> 20:46.640] And, uh... [20:46.640 --> 20:48.960] By its definition, it uses symbols. [20:49.280 --> 20:50.580] It's for symbolic computation. [20:50.580 --> 20:54.000] You would normally describe C as a generalized assembler. [20:54.300 --> 20:55.140] That, uh... [20:55.140 --> 20:57.240] You could port to whatever machine you want, but... [20:57.240 --> 21:00.040] You're still, you know, just a few steps above the hardware. [21:01.120 --> 21:01.600] Uh... [21:01.600 --> 21:02.720] Lisp is much more abstract. [21:04.140 --> 21:04.620] Uh... [21:04.620 --> 21:05.140] And... [21:05.140 --> 21:09.040] You know, slowly languages are getting closer and closer to that. [21:09.040 --> 21:10.900] So, why not go to the source? [21:13.960 --> 21:14.400] Um... [21:14.400 --> 21:14.740] The, uh... [21:14.740 --> 21:17.180] The weird syntax, it's not that weird if you understand it. [21:17.600 --> 21:18.340] But, uh... [21:18.340 --> 21:19.040] The first... [21:20.620 --> 21:26.640] The first symbol after a parenthesis is typically evaluated as a function. [21:27.860 --> 21:28.300] Um... [21:28.300 --> 21:29.980] And then the rest of them are the arguments. [21:30.820 --> 21:31.260] Uh... [21:31.260 --> 21:33.620] In other languages, you have the function outside the parenthesis. [21:33.620 --> 21:35.340] It's not that different, really. [21:37.480 --> 21:38.000] Um... [21:38.000 --> 21:39.500] One of the benefits of... [21:39.500 --> 21:40.220] Well... [21:40.860 --> 21:42.200] This could have been done wrong. [21:42.660 --> 21:43.180] But... [21:43.180 --> 21:45.660] The way that things usually go is... [21:45.660 --> 21:46.280] Uh... [21:46.280 --> 21:47.900] Alright, well this slide is missing a few things. [21:49.660 --> 21:50.180] Um... [21:50.180 --> 21:51.940] The way things usually go is... [21:51.940 --> 21:53.100] You have a function. [21:53.440 --> 21:54.420] It's a functional language. [21:55.100 --> 21:55.600] Um... [21:55.600 --> 21:57.480] You have a function and you pass in the arguments. [22:00.920 --> 22:02.540] And the arguments are not changed. [22:03.460 --> 22:07.640] The arguments should be the same when the function returns the value. [22:07.920 --> 22:09.040] As when they came in. [22:11.100 --> 22:11.620] Um... [22:11.620 --> 22:13.340] This gives you some benefits that, uh... [22:13.340 --> 22:14.380] You won't have side effects. [22:14.760 --> 22:15.780] Which is... [22:15.780 --> 22:17.540] Typically what you program for in other languages. [22:18.600 --> 22:19.240] And, uh... [22:19.240 --> 22:20.600] Anyone who says that... [22:20.600 --> 22:21.280] The, uh... [22:21.280 --> 22:22.340] The syntax is insane. [22:24.180 --> 22:24.700] Well... [22:24.700 --> 22:25.900] Syntax is very regular. [22:26.120 --> 22:27.060] In a grammatical sense. [22:27.740 --> 22:28.240] Uh... [22:28.240 --> 22:29.160] You have a statement. [22:29.520 --> 22:30.480] After a parenthesis. [22:30.720 --> 22:32.060] And you have all the arguments afterwards. [22:32.060 --> 22:33.320] Uh... [22:33.320 --> 22:34.860] Here you have infix syntax. [22:35.220 --> 22:36.160] You have, uh... [22:36.660 --> 22:38.260] You know, assignment to the left hand side. [22:38.500 --> 22:40.160] You have prefix, postfix. [22:40.680 --> 22:42.600] Object oriented stuff tacked on. [22:44.000 --> 22:44.320] Uh... [22:44.640 --> 22:45.500] Array access. [22:45.800 --> 22:47.040] Or pointer access. [22:48.800 --> 22:49.440] Um... [22:49.440 --> 22:51.040] It all looks about the same in Lisp. [22:52.480 --> 22:53.120] Um... [22:53.120 --> 22:53.680] Kinda cheated. [22:53.960 --> 22:55.680] These two aren't actual functions. [22:55.860 --> 22:56.880] They're special forms. [22:57.980 --> 22:58.780] But, uh... [22:58.780 --> 22:59.480] I'll get to that later. [23:04.200 --> 23:04.600] Um... [23:04.600 --> 23:06.040] Should probably be keeping track of the time. [23:07.460 --> 23:10.500] I don't think anyone wants to stay in this room any longer than they have to. [23:10.940 --> 23:11.700] Me especially. [23:14.140 --> 23:14.540] Um... [23:14.540 --> 23:17.400] So, here's this big, ugly, terrible... [23:18.800 --> 23:19.200] Uh... [23:19.200 --> 23:19.780] Equation. [23:20.080 --> 23:21.060] It's actually not an equation. [23:21.200 --> 23:21.660] It's a form. [23:22.240 --> 23:22.640] Uh... [23:22.640 --> 23:23.780] The form is gonna be evaluated. [23:24.240 --> 23:24.640] Although... [23:24.640 --> 23:28.080] I evaluated it artistically for, uh... [23:28.080 --> 23:28.920] Display purposes. [23:32.060 --> 23:32.540] Um... [23:33.020 --> 23:34.260] So, what the... [23:34.900 --> 23:37.600] What the Lisp machine will do is, it will... [23:37.600 --> 23:37.920] Uh... [23:37.920 --> 23:38.500] See the form. [23:38.620 --> 23:40.200] It'll find the left-most parenthesis. [23:40.400 --> 23:42.060] And then find the matching right-most parenthesis. [23:42.360 --> 23:43.100] It's building its... [23:43.100 --> 23:43.880] Building up a tree. [23:44.360 --> 23:44.840] Uh... [23:44.840 --> 23:45.520] In the parser. [23:46.560 --> 23:47.600] With all the arguments. [23:48.240 --> 23:49.540] And it just... [23:49.540 --> 23:52.100] Applies the function to the arguments as it goes through. [23:52.100 --> 23:54.160] It's actually a prime factorization. [23:55.060 --> 23:56.100] Of 2600. [23:57.240 --> 23:58.740] Is anyone still paying attention? [23:59.000 --> 23:59.260] No? [23:59.800 --> 24:00.500] I tried. [24:02.640 --> 24:03.160] Um... [24:03.160 --> 24:04.560] Like I said, this is a little bit creative. [24:04.840 --> 24:06.100] Because the, uh... [24:06.620 --> 24:08.560] The 7 multiplied by 191. [24:08.760 --> 24:10.300] Would have been evaluated first. [24:10.420 --> 24:12.480] Since it's the deepest, uh... [24:12.480 --> 24:13.500] It's the deepest expression. [24:13.900 --> 24:14.400] Uh... [24:14.400 --> 24:15.860] The other cool thing to note here. [24:16.040 --> 24:17.100] Is that... [24:18.260 --> 24:18.780] Um... [24:18.780 --> 24:20.900] Lisp has a lot of embedded data types. [24:20.900 --> 24:21.920] That you get free. [24:22.760 --> 24:22.920] Uh... [24:22.920 --> 24:23.440] You have integers. [24:23.700 --> 24:24.040] Which... [24:24.040 --> 24:24.800] I hope you would expect. [24:24.980 --> 24:25.760] But you also have... [24:25.760 --> 24:26.200] Uh... [24:26.200 --> 24:26.940] Perfect fractions. [24:27.220 --> 24:27.420] Or... [24:27.420 --> 24:27.540] Well... [24:27.540 --> 24:28.400] You have rational numbers. [24:29.120 --> 24:29.520] Uh... [24:29.520 --> 24:31.060] These will not reduce... [24:31.580 --> 24:32.860] To some ugly decimal. [24:33.500 --> 24:33.900] Uh... [24:33.900 --> 24:34.720] I tried it in Python. [24:34.960 --> 24:35.920] And the first one gave me zero. [24:36.020 --> 24:36.900] And the second one gave me one. [24:38.500 --> 24:38.900] Not... [24:38.900 --> 24:40.040] What you would expect. [24:40.340 --> 24:41.400] Or not what you would want. [24:43.220 --> 24:43.620] Um... [24:43.620 --> 24:44.500] It'll reduce it for you. [24:44.580 --> 24:45.860] But it will still maintain the precision. [24:45.860 --> 24:47.140] There's also... [24:47.140 --> 24:49.360] Native support for complex numbers. [24:49.660 --> 24:50.020] Uh... [24:50.020 --> 24:50.920] You don't have to write that. [24:52.820 --> 24:53.150] Um... [24:53.480 --> 24:54.880] Really outstrip my notes here. [24:57.660 --> 24:58.320] Um... [24:58.320 --> 24:59.400] So, the... [25:00.060 --> 25:01.260] Lisp, uh... [25:01.260 --> 25:01.760] Data structure. [25:02.140 --> 25:03.540] The native data structure is a list. [25:04.300 --> 25:07.100] Lisp programs themselves are... [25:07.100 --> 25:07.980] Um... [25:07.980 --> 25:08.680] Lists. [25:09.280 --> 25:09.840] Uh... [25:09.840 --> 25:12.240] This feature of the language is called homoiconicity. [25:12.240 --> 25:13.800] Which just means that... [25:13.800 --> 25:16.440] The representation of the data and the program are the same. [25:17.000 --> 25:19.400] This will come in handy later when I discuss macros. [25:19.640 --> 25:21.420] Which are not the same as C macros. [25:23.180 --> 25:23.620] Um... [25:23.620 --> 25:25.300] So, here are some list manipulation forms. [25:26.700 --> 25:27.060] Uh... [25:27.060 --> 25:29.540] The quote operator delays evaluation. [25:30.080 --> 25:30.520] So... [25:30.520 --> 25:32.600] Ordinarily you would have gotten an error saying... [25:32.600 --> 25:32.880] You know... [25:32.880 --> 25:34.420] One is not a function. [25:34.620 --> 25:35.900] And it will crap out on you. [25:37.500 --> 25:37.940] Um... [25:37.940 --> 25:38.700] Car and Kidder. [25:38.920 --> 25:39.920] I hope I'm pronouncing that right. [25:41.220 --> 25:42.020] Car is... [25:42.020 --> 25:42.940] Stands for the... [25:42.940 --> 25:43.160] Uh... [25:43.160 --> 25:45.040] The contents of the address portion of the register. [25:45.460 --> 25:47.640] Which on the IBM 704 made a lot more sense. [25:48.180 --> 25:48.500] But... [25:49.200 --> 25:49.600] Um... [25:49.600 --> 25:51.560] I think it was a 36-bit architecture. [25:52.920 --> 25:53.320] And... [25:53.320 --> 25:53.720] Whatever. [25:54.280 --> 25:54.680] But... [25:54.680 --> 25:55.320] Uh... [25:55.320 --> 25:55.600] So... [25:55.600 --> 25:56.980] Car gives you the first... [25:56.980 --> 25:57.780] Uh... [25:57.780 --> 25:58.380] Part of a list. [25:58.600 --> 26:00.040] And Kidder gives you the rest of it. [26:01.560 --> 26:01.960] Um... [26:01.960 --> 26:02.900] There are a bunch of... [26:03.940 --> 26:04.340] Shorthand. [26:04.760 --> 26:05.060] For... [26:05.060 --> 26:05.340] You know... [26:05.340 --> 26:06.440] Second, third, fourth, fifth. [26:06.440 --> 26:06.580] If... [26:06.580 --> 26:08.500] If you really wanted to say... [26:08.500 --> 26:10.600] C-A-A-D-D-I-A-R. [26:10.920 --> 26:12.540] To extract something terrible. [26:14.520 --> 26:14.960] Um... [26:14.960 --> 26:15.440] You could. [26:15.940 --> 26:16.580] But, uh... [26:16.580 --> 26:16.820] That's... [26:16.820 --> 26:17.840] That's standardized usually. [26:18.380 --> 26:18.660] Uh... [26:18.660 --> 26:21.080] They have first and rest as synonyms for car and kidder. [26:25.840 --> 26:26.280] Um... [26:26.280 --> 26:26.600] So... [26:26.600 --> 26:27.680] Cons, which means construct. [26:28.740 --> 26:29.180] Uh... [26:29.180 --> 26:30.500] You can actually use to make lists. [26:31.060 --> 26:32.200] But that's a pain in the ass. [26:32.360 --> 26:33.420] So you can just use list. [26:33.420 --> 26:34.420] Or... [26:34.420 --> 26:36.560] Use the quote operator and specify it yourself. [26:40.120 --> 26:40.640] Um... [26:40.640 --> 26:41.500] The, uh... [26:41.500 --> 26:42.540] This is how you define a function. [26:42.900 --> 26:44.020] You have the... [26:44.020 --> 26:45.200] The defund keyword. [26:45.540 --> 26:46.240] It's not a keyword. [26:46.380 --> 26:47.320] It's a function name. [26:48.040 --> 26:48.900] Technically it's a macro. [26:50.380 --> 26:50.900] Um... [26:50.900 --> 26:52.820] And add three gets added to the symbol table. [26:53.300 --> 26:54.160] As a function. [26:54.300 --> 26:55.100] You have one argument. [26:55.900 --> 26:56.940] And the... [26:56.940 --> 26:59.220] Last value that gets evaluated in the list. [27:00.260 --> 27:00.780] Um... [27:00.780 --> 27:01.840] Gets returned as the value. [27:02.320 --> 27:02.840] Uh... [27:02.840 --> 27:05.520] The cool thing is that the documentation comes inside the function. [27:06.280 --> 27:07.480] And the common lisp environment. [27:07.840 --> 27:10.500] Has ways of extracting the documentation for you. [27:11.240 --> 27:11.740] So... [27:11.740 --> 27:12.840] If you're lucky and... [27:13.400 --> 27:14.800] There is documentation for the function. [27:14.880 --> 27:15.480] You can find it. [27:15.720 --> 27:16.160] Uh... [27:16.160 --> 27:18.400] You can also use a command called apropos. [27:18.540 --> 27:19.280] And it will... [27:19.280 --> 27:19.840] Search through... [27:21.080 --> 27:21.520] Um... [27:21.520 --> 27:22.500] All the available documentation. [27:23.040 --> 27:23.500] Uh... [27:23.500 --> 27:25.520] Give you names of functions that you might want. [27:26.060 --> 27:27.800] It's kind of annoying after you've... [27:27.800 --> 27:30.160] Programmed something and find out that... [27:30.160 --> 27:31.320] Came with the distribution. [27:32.660 --> 27:33.100] Um... [27:33.100 --> 27:33.460] But anyway. [27:41.620 --> 27:42.420] Is there water? [27:42.520 --> 27:43.280] Yes, there is water. [27:43.500 --> 27:43.820] Alright. [27:45.820 --> 27:46.260] Um... [27:46.260 --> 27:47.720] This isn't going quite as well as I thought. [27:47.940 --> 27:48.300] But... [27:48.300 --> 27:49.940] At least it's all true so far. [28:09.090 --> 28:09.530] Alright. [28:09.710 --> 28:11.370] So, as I sort of touched on earlier. [28:12.010 --> 28:12.450] Um... [28:12.450 --> 28:13.810] One of the goals of functional programming. [28:15.250 --> 28:15.690] Um... [28:16.490 --> 28:18.490] Is not to modify your arguments. [28:19.830 --> 28:20.270] And... [28:20.270 --> 28:21.310] The, uh... [28:21.310 --> 28:22.950] The primary way you interact with the method. [28:23.270 --> 28:23.790] Or the function. [28:24.050 --> 28:25.230] Is through its return values. [28:25.870 --> 28:27.490] So, it's sort of like a black box. [28:27.790 --> 28:28.590] That, uh... [28:28.590 --> 28:29.650] You don't know what's going on. [28:29.810 --> 28:30.750] But you call it. [28:31.210 --> 28:32.330] You don't care what it does. [28:32.430 --> 28:33.510] As long as there's no side effects. [28:33.910 --> 28:35.690] And you use the return values. [28:37.030 --> 28:37.470] Um... [28:37.470 --> 28:39.510] This is good because you won't have... [28:40.010 --> 28:42.090] You won't have mysterious bugs showing up. [28:42.930 --> 28:44.470] Somebody characterized the... [28:44.970 --> 28:45.450] Uh... [28:45.450 --> 28:46.870] The average imperative program. [28:47.370 --> 28:48.170] As, uh... [28:48.170 --> 28:49.410] Someone boasting that, Oh! [28:49.510 --> 28:51.630] My function takes 316 arguments. [28:52.870 --> 28:53.350] Like... [28:53.350 --> 28:55.390] Well, if you consider all the global variables. [28:55.650 --> 28:56.830] That you might be exposed to. [28:56.950 --> 28:57.910] That's technically correct. [28:58.130 --> 29:00.850] And if you have the opportunity to change some of them in there. [29:01.210 --> 29:02.850] You're not going to get the same results. [29:03.110 --> 29:04.250] Every single time you call the function. [29:05.830 --> 29:06.310] Um... [29:06.310 --> 29:07.630] Well, that's nice in an ideal way. [29:09.670 --> 29:10.150] Uh... [29:10.150 --> 29:11.590] You're not going to, uh... [29:11.590 --> 29:13.350] Be doing terribly much programming. [29:13.350 --> 29:14.290] If you rely... [29:14.290 --> 29:15.770] Only on return values. [29:15.950 --> 29:16.790] So you need some... [29:16.790 --> 29:18.730] Side effects in order to get things done. [29:21.470 --> 29:21.990] Um... [29:24.370 --> 29:24.890] So... [29:24.890 --> 29:25.550] This is a console. [29:26.270 --> 29:27.110] One box. [29:27.370 --> 29:27.890] One block. [29:28.470 --> 29:28.550] One block. [29:28.550 --> 29:29.190] The, uh... [29:29.190 --> 29:30.190] The car and kidder... [29:32.630 --> 29:33.150] Um... [29:33.150 --> 29:34.850] Conventions make a little bit more sense now. [29:36.190 --> 29:36.710] Uh... [29:36.710 --> 29:38.610] Basically, these two hold... [29:38.610 --> 29:39.690] Register values. [29:40.370 --> 29:40.850] And... [29:41.530 --> 29:42.010] Uh... [29:42.010 --> 29:42.590] The... [29:42.590 --> 29:44.230] First part of the list. [29:44.490 --> 29:45.670] Points to... [29:45.670 --> 29:46.250] Whatever it is. [29:47.170 --> 29:47.650] Uh... [29:47.650 --> 29:48.750] Could be a hash table. [29:48.930 --> 29:49.910] Could be a single value. [29:50.030 --> 29:50.550] Could be a string. [29:52.330 --> 29:52.810] Um... [29:52.810 --> 29:53.910] And then the second... [29:53.910 --> 29:55.070] Points to... [29:55.070 --> 29:56.450] The next element of the list. [29:56.730 --> 29:57.210] And... [29:57.210 --> 29:58.270] Yes, they are... [29:58.270 --> 29:59.350] Linked lists. [29:59.610 --> 30:00.450] This is where maybe... [30:00.450 --> 30:01.390] People think it's slow. [30:02.030 --> 30:02.690] And, uh... [30:02.690 --> 30:04.550] You do have to go through each one of them. [30:04.610 --> 30:06.190] If you're doing something like that. [30:06.890 --> 30:07.330] Uh... [30:07.330 --> 30:08.010] The good thing... [30:08.010 --> 30:09.450] The side effect is that... [30:09.450 --> 30:12.350] You end up with being able to... [30:12.350 --> 30:13.830] Compute arbitrarily long. [30:14.050 --> 30:14.890] Sometimes infinite. [30:15.270 --> 30:15.550] Uh... [30:15.550 --> 30:15.990] Sequences. [30:16.450 --> 30:17.810] And either you don't consume them. [30:18.070 --> 30:19.410] You consume them as you need to. [30:20.210 --> 30:20.550] Uh... [30:20.550 --> 30:21.330] Or you just... [30:21.330 --> 30:21.790] You don't care. [30:21.870 --> 30:22.630] You recurse through it. [30:22.730 --> 30:23.630] Or you iterate through it. [30:25.410 --> 30:25.850] Um... [30:26.470 --> 30:27.310] But, uh... [30:27.310 --> 30:29.370] The good thing about using pointers is that... [30:29.370 --> 30:30.510] When you change a pointer. [30:30.870 --> 30:33.570] The common list system will garbage collect it for you. [30:33.710 --> 30:34.850] So you don't have to worry about that either. [30:36.570 --> 30:37.030] Um... [30:37.030 --> 30:39.070] On a proper list, the last element is gonna be nil. [30:43.330 --> 30:43.790] Um... [30:43.790 --> 30:44.110] Damn it. [30:44.730 --> 30:45.990] This slide was supposed to be complete. [30:47.150 --> 30:47.610] Alright. [30:48.250 --> 30:48.690] No. [30:48.950 --> 30:49.270] No. [30:49.490 --> 30:49.630] No. [30:50.090 --> 30:50.450] Alright. [30:50.590 --> 30:51.050] Just a moment. [30:54.410 --> 30:55.330] Let's, uh... [30:58.430 --> 31:00.050] Now would be a good time to leave. [31:00.710 --> 31:01.810] If you so desire. [31:04.370 --> 31:04.830] Um... [31:04.830 --> 31:05.150] Anyway. [31:05.330 --> 31:06.910] Here's a nice little program that, uh... [31:06.910 --> 31:08.610] Is hosted on Peter Seibel's website. [31:12.050 --> 31:12.610] Um... [31:12.610 --> 31:13.450] It's, uh... [31:13.450 --> 31:14.430] Called Lisp in a Box. [31:15.510 --> 31:17.530] Saturday Night Live references notwithstanding. [31:21.840 --> 31:22.400] Um... [31:22.400 --> 31:23.520] It is really hot in here. [31:36.830 --> 31:37.390] Alright. [31:39.110 --> 31:41.990] This is how you define a global variable. [31:42.210 --> 31:42.610] Um... [31:42.610 --> 31:45.130] They put the asterisks around it so that you know that you're using it. [31:54.570 --> 31:55.010] Um... [31:55.010 --> 31:55.350] Whatever. [32:00.520 --> 32:03.260] You know, I was feeling much better about this talk before I started speaking. [32:05.880 --> 32:08.780] Maybe doing one thing that scares you isn't always the best idea. [32:10.780 --> 32:11.180] Um... [32:12.060 --> 32:12.800] So, whatever. [32:13.700 --> 32:14.100] Alright. [32:14.280 --> 32:14.520] Thanks. [32:16.900 --> 32:17.300] Um... [32:17.300 --> 32:18.140] So, I've defined it. [32:18.300 --> 32:19.340] It returns the name of the variable. [32:21.320 --> 32:21.720] Um... [32:21.720 --> 32:26.800] If you evaluate it at the prompt, it'll return the values for you. [32:28.900 --> 32:29.300] Um... [32:29.300 --> 32:32.900] So, if you're not supposed to change state, what are you gonna do? [32:33.000 --> 32:33.980] How do you get all your variables? [32:35.220 --> 32:35.620] Um... [32:35.620 --> 32:38.640] So, there are a few looping constructs, iteration constructs. [32:43.230 --> 32:43.650] Um... [32:43.650 --> 32:45.070] Now everyone just saw I checked the time. [32:47.410 --> 32:47.830] Um... [32:47.830 --> 32:48.690] DoList is a macro. [32:50.230 --> 32:50.650] Um... [32:50.650 --> 32:52.010] Which I'm getting a little bit ahead of myself. [32:52.990 --> 32:53.410] But... [32:53.410 --> 32:55.570] It lets you chop up the, uh... [32:56.770 --> 32:59.470] It lets you chop up the arguments that you pass into the function. [33:01.450 --> 33:01.870] Um... [33:01.870 --> 33:04.050] This way you can, uh... [33:04.050 --> 33:08.350] You can do things like apply a function across all the arguments, conditionally. [33:09.050 --> 33:09.450] Or... [33:09.450 --> 33:11.590] Supply the test that you want to use, uh... [33:11.590 --> 33:12.650] For a sorting algorithm. [33:14.610 --> 33:15.010] Um... [33:15.010 --> 33:16.390] Say you had a whole bunch of... [33:16.390 --> 33:17.950] Entries you got, uh... [33:17.950 --> 33:20.270] You got a whole bunch of files off of your video camera. [33:20.610 --> 33:24.350] But, if you sort it alphabetically, all the pictures are gonna end up before the movies. [33:24.350 --> 33:26.810] So, you could write a little function... [33:29.390 --> 33:32.250] That'll strip off the first four characters and sort only by the numbers. [33:32.970 --> 33:33.310] And... [33:33.310 --> 33:35.270] It'll return the list... [33:35.270 --> 33:36.070] For you. [34:09.370 --> 34:09.770] Um... [34:10.390 --> 34:10.930] Um... [34:10.930 --> 34:12.610] But it basically defines its own language. [34:14.190 --> 34:14.730] Uh... [34:14.730 --> 34:16.130] Which is totally... [34:16.720 --> 34:17.570] Bizarre, arbitrary. [34:17.930 --> 34:18.750] But still cool. [34:20.390 --> 34:20.930] Um... [34:20.930 --> 34:22.150] It's not what I wanted it to do. [34:25.670 --> 34:26.210] Alright. [34:28.790 --> 34:29.330] Yes. [34:30.290 --> 34:30.830] Excellent. [34:31.110 --> 34:32.650] Exactly what I wanted it to do, right? [34:33.450 --> 34:33.990] Alright. [34:34.310 --> 34:34.930] That sucked. [34:36.350 --> 34:37.490] Let's try this again. [34:40.870 --> 34:41.410] Um... [34:41.410 --> 34:41.970] Just... [34:42.570 --> 34:44.130] Using x as a temporary variable. [34:45.810 --> 34:49.190] You can have any number of variables here in the front part of the form. [34:49.930 --> 34:50.410] Um... [34:50.410 --> 34:52.090] You can also... [34:52.090 --> 34:53.470] Have a... [34:54.130 --> 34:58.870] There are starred forms that allow you to reference other variables in your declaration. [35:00.130 --> 35:00.610] Um... [35:00.610 --> 35:01.090] The... [35:01.090 --> 35:06.730] The do and let forms usually don't let you do that. [35:06.930 --> 35:10.430] If you use an asterisk at the end of it, you can reference... [35:11.070 --> 35:11.530] Um... [35:11.530 --> 35:12.570] Values you've just defined. [35:15.050 --> 35:15.510] So... [35:16.490 --> 35:18.130] I'm glad I'm not doing this on the radio. [35:18.330 --> 35:20.270] Although I guess technically I am with Radio Statler. [35:21.290 --> 35:21.750] Uh... [35:21.750 --> 35:22.510] Lots of dead air. [35:24.610 --> 35:25.070] So... [35:25.070 --> 35:26.410] If you'll notice that the, uh... [35:26.410 --> 35:27.190] Parentheses... [35:27.750 --> 35:28.210] Flash... [35:28.210 --> 35:28.970] When I close them. [35:29.390 --> 35:30.550] That's really the only... [35:31.050 --> 35:31.510] Yeah. [35:31.730 --> 35:32.090] Fail. [35:34.410 --> 35:36.530] It's really the only feature you need in a Lisp editor. [35:36.870 --> 35:37.390] Although... [35:37.950 --> 35:38.910] This, uh... [35:38.910 --> 35:43.330] Version of Emacs has a slime installed, which is the superior Lisp interaction mode for Emacs. [35:43.550 --> 35:45.150] It's not helping me too much right now. [35:45.490 --> 35:46.930] But, um... [35:46.930 --> 35:49.670] You can do cool things like compile from a buffer. [35:50.170 --> 35:53.150] And it'll automatically put it into the Lisp interpreter for you. [35:59.220 --> 36:01.080] Is it compiled or interpreted? [36:01.340 --> 36:01.920] Yes. [36:02.360 --> 36:02.680] Awesome. [36:03.200 --> 36:03.460] Thank you. [36:05.600 --> 36:06.240] Um... [36:06.240 --> 36:07.440] This particular... [36:07.440 --> 36:07.760] Uh... [36:07.760 --> 36:08.740] Let me do something simple. [36:10.140 --> 36:12.220] This particular, um... [36:13.600 --> 36:15.480] Lisp environment is, uh, CLisp. [36:15.920 --> 36:17.220] It's, uh... [36:17.880 --> 36:21.060] There's a little Easter egg that you might have seen in the beginning. [36:21.360 --> 36:21.820] Uh... [36:21.820 --> 36:24.700] It's only activated during certain calendar year, calendar days. [36:25.240 --> 36:25.640] But... [36:25.640 --> 36:29.340] I couldn't find any reference on it online, so... [36:29.340 --> 36:30.640] I did find it in the source code, though. [36:35.360 --> 36:35.760] Um... [36:35.760 --> 36:36.060] Alright. [36:36.440 --> 36:37.480] Good thing I took notes. [36:39.840 --> 36:40.240] Um... [36:40.740 --> 36:41.140] So... [36:41.140 --> 36:42.880] This is not going as well as I thought. [36:43.180 --> 36:43.860] But, uh... [36:43.860 --> 36:44.420] CLisp is... [36:44.420 --> 36:47.020] CLisp is designed to compile into a bytecode. [36:47.580 --> 36:47.980] Uh... [36:47.980 --> 36:49.500] There's another... [36:50.060 --> 36:51.300] Interpreter that I have on a... [36:51.300 --> 36:53.220] On a shell somewhere that I was gonna show you. [36:53.760 --> 36:54.140] Um... [36:54.140 --> 36:55.500] Although it'll probably be equally disastrous. [36:56.000 --> 36:56.480] Uh... [36:56.480 --> 36:57.280] Called SBCL. [36:57.420 --> 36:58.560] Which is Steel Bank Common Lisp. [36:58.860 --> 36:59.500] And that... [36:59.500 --> 36:59.800] Com... [36:59.800 --> 37:01.400] It's designed to be very fast. [37:01.600 --> 37:03.260] And it compiles into... [37:04.180 --> 37:04.660] Um... [37:04.660 --> 37:05.960] Into machine code. [37:06.180 --> 37:07.320] Or assembly language. [37:07.520 --> 37:08.460] And you can actually... [37:08.960 --> 37:10.540] See it as, uh... [37:11.100 --> 37:11.940] As it's compiled. [37:13.080 --> 37:13.560] Um... [37:22.080 --> 37:22.560] Yes. [37:22.800 --> 37:23.820] I'm going to give up now. [37:24.000 --> 37:24.560] Because, uh... [37:24.560 --> 37:25.400] This is terrible. [37:25.740 --> 37:26.960] What it's supposed to do... [37:26.960 --> 37:28.200] Is, uh... [37:28.200 --> 37:28.780] Print out the list. [37:28.980 --> 37:29.540] One on each line. [37:29.780 --> 37:30.520] I was gonna sort it. [37:30.660 --> 37:31.960] But it turns out that sort is destructive. [37:33.280 --> 37:33.760] So... [37:35.060 --> 37:35.540] The... [37:35.540 --> 37:37.460] The list would've ended up... [37:37.460 --> 37:38.960] With, uh... [37:39.660 --> 37:40.980] The list would've ended up... [37:40.980 --> 37:43.200] Chopping itself off at, uh... [37:43.200 --> 37:43.800] I guess desktop. [37:44.280 --> 37:44.640] Nope. [37:45.140 --> 37:45.440] Alright. [37:45.580 --> 37:46.860] Well, lucky me I put console first. [37:48.060 --> 37:48.540] Um... [37:50.300 --> 37:50.780] So... [37:50.780 --> 37:51.340] Yeah. [37:51.400 --> 37:52.440] There's something very wrong here. [37:54.740 --> 37:55.140] Oh. [37:55.400 --> 37:55.740] I remember. [37:56.300 --> 37:56.400] Oh. [37:56.720 --> 37:57.020] Good. [37:57.140 --> 37:58.840] I get to show you functional programming. [38:01.040 --> 38:02.680] I'm passing in the name of a function. [38:03.540 --> 38:04.800] Actually, I should be doing this. [38:06.720 --> 38:09.920] I'm passing in the name of a function as the sort criteria. [38:11.620 --> 38:12.020] Um... [38:12.020 --> 38:13.720] So, it sorts it as it should. [38:15.260 --> 38:15.660] Um... [38:15.660 --> 38:18.840] If you really wanted to, you could change this to something else. [38:19.720 --> 38:20.680] Starts it reverse. [38:21.480 --> 38:22.240] Starts it reverse. [38:22.680 --> 38:23.080] Um... [38:23.080 --> 38:24.040] Or what you could do. [38:24.500 --> 38:28.520] Although I don't have the mental capacity right now to actually do this. [38:29.160 --> 38:29.560] Um... [38:29.560 --> 38:30.500] And I wanted to get to it. [38:33.280 --> 38:34.080] Otherwise, um... [38:34.080 --> 38:35.960] You know, you'll write something called a lambda expression. [38:36.240 --> 38:40.400] And if you come across lambda, this is another one of those stumbling blocks that nobody could explain properly. [38:40.620 --> 38:41.480] Lambda just means function. [38:41.760 --> 38:42.880] It's a function without a name. [38:43.660 --> 38:46.720] It's the same thing as the defund in the previous... [38:47.880 --> 38:48.580] Previous one. [38:49.620 --> 38:49.740] Here. [38:50.280 --> 38:51.200] All it does is add three. [38:52.100 --> 38:52.960] Let's try that. [38:53.100 --> 38:53.940] Maybe that won't fail. [38:58.920 --> 38:59.320] Um... [38:59.320 --> 38:59.420] Yep. [39:00.860 --> 39:01.320] All right. [39:01.400 --> 39:02.520] Well, I'm showing you a lot of the debugger. [39:02.640 --> 39:03.700] Did not expect that to happen. [39:04.940 --> 39:05.340] Um... [39:05.340 --> 39:06.640] Let me just give you... [39:07.920 --> 39:09.080] This takes one argument. [39:11.060 --> 39:13.540] Prefix notation plus three x. [39:13.920 --> 39:15.060] The x is... [39:15.760 --> 39:18.080] A binding inside this function definition. [39:18.280 --> 39:19.980] It does not exist outside of the function definition. [39:20.180 --> 39:20.680] But that's okay. [39:21.540 --> 39:22.080] So... [39:22.080 --> 39:22.760] We have add three. [39:23.160 --> 39:23.440] All right. [39:23.580 --> 39:25.080] Well, I'm gonna apply add three to... [39:25.700 --> 39:26.100] I don't know. [39:26.280 --> 39:26.780] Six. [39:27.040 --> 39:27.320] Seven. [39:28.820 --> 39:29.360] And... [39:30.080 --> 39:31.640] I hate this laptop sometimes. [39:32.100 --> 39:33.100] We get ten. [39:33.280 --> 39:33.580] Great. [39:35.820 --> 39:36.360] Um... [39:36.360 --> 39:44.480] If you think that Lisp is slow, maybe you should take a look at what it's actually doing. [39:45.140 --> 39:45.940] And, uh... [39:45.940 --> 39:46.440] Like I said... [39:47.520 --> 39:48.560] The, uh... [39:48.560 --> 39:49.480] CLisp, uh... [39:50.040 --> 39:52.400] Is designed to compile into a bytecode. [39:52.660 --> 39:53.180] Uh... [39:53.180 --> 39:55.100] I guess, which helps with being cross-platform. [39:55.900 --> 39:56.100] Um... [39:56.100 --> 40:00.120] SBCL will compile into actual assembly code, which looks really cool. [40:00.420 --> 40:01.140] Can you read this? [40:01.520 --> 40:04.600] You know, it's really annoying when, you know, everyone can, uh... [40:05.120 --> 40:06.040] Can squint at the screen. [40:06.040 --> 40:08.080] The person giving the presentation can read it just fine. [40:08.300 --> 40:09.280] But, uh... [40:09.280 --> 40:11.040] When it's an eight point console font... [40:12.100 --> 40:12.460] Um... [40:12.460 --> 40:14.360] I hope you can read it because I can't make a font any bigger. [40:14.920 --> 40:15.360] In, uh... [40:15.360 --> 40:16.060] Lisp in a box. [40:17.180 --> 40:17.500] All right. [40:17.660 --> 40:17.980] Thank you. [40:19.260 --> 40:19.620] Um... [40:19.620 --> 40:20.880] Let's go back to the presentation now. [40:21.660 --> 40:23.480] At least the presentation won't change on me. [40:24.380 --> 40:24.660] Um... [40:24.660 --> 40:26.200] This was supposed to have a little more code in it. [40:27.880 --> 40:28.240] Um... [40:28.240 --> 40:30.940] Here's the joke that started the entire presentation. [40:33.220 --> 40:33.580] Um... [40:34.220 --> 40:34.740] Um... [40:34.740 --> 40:39.000] One unfortunate fact that I discovered yesterday is that you can't spell sick P without ICP. [40:42.460 --> 40:42.980] So... [40:43.900 --> 40:46.940] What I should have gotten to earlier is, uh... [40:46.940 --> 40:50.320] That the regular syntax of Lisp, where it's... [40:50.320 --> 40:55.120] Built entirely out of symbols and parentheses, which may drive you insane, is actually an asset. [40:55.120 --> 40:56.420] Because, uh... [40:56.420 --> 40:57.360] It's very easy to parse. [40:57.680 --> 40:59.200] You can validate it very easily. [40:59.500 --> 41:05.560] The editor has had the matching parentheses to help the programmer for quite a while. [41:05.700 --> 41:08.340] It shows up in the 1986, uh... [41:08.340 --> 41:10.120] Sussman and Abelson, um... [41:10.720 --> 41:11.380] Talk at HP. [41:14.760 --> 41:15.240] Um... [41:15.240 --> 41:18.640] I'm glad that I wrote these down because I didn't quite get to them earlier. [41:20.660 --> 41:27.360] Some people say that the only requirement for functional language is for it to have functions that are first-class citizens. [41:30.620 --> 41:31.080] Um... [41:31.080 --> 41:35.120] With a macro, you can, uh... [41:35.700 --> 41:37.460] With a macro, you can, uh... [41:37.460 --> 41:38.140] Change the syntax. [41:38.380 --> 41:39.980] You can basically write whatever you want it to. [41:54.160 --> 41:54.620] Um... [41:54.620 --> 41:55.760] The entire... [41:56.920 --> 41:57.360] Uh... [41:57.360 --> 41:59.620] The language itself has access to the symbol table. [42:00.060 --> 42:00.500] Uh... [42:00.500 --> 42:03.660] While you're running it, you can redefine functions. [42:04.780 --> 42:05.220] Um... [42:05.220 --> 42:06.560] Just run that piece of code again. [42:06.740 --> 42:11.260] It will dereference the pointer pointing now to the new code instead of the old code. [42:13.060 --> 42:13.500] Um... [42:13.500 --> 42:14.780] And hopefully you've solved the bug. [42:15.160 --> 42:16.780] You won't have to shut the system down. [42:17.060 --> 42:18.600] You don't have to, uh... [42:18.600 --> 42:19.220] Compile it. [42:20.060 --> 42:21.860] Although you probably should compile it for speed. [42:23.260 --> 42:23.680] Um... [42:24.560 --> 42:25.200] I don't know. [42:25.580 --> 42:25.720] This... [42:25.720 --> 42:27.520] This slide speaks for itself. [42:28.560 --> 42:28.980] Uh... [42:28.980 --> 42:31.200] Which is good because I'm having trouble speaking. [42:41.980 --> 42:43.660] I lean away from the mic to breathe. [42:48.850 --> 42:49.270] So... [42:49.270 --> 42:51.250] You know, I got to this slide much quicker than I thought. [42:51.550 --> 42:53.610] Hopefully these make a little bit more sense to you. [42:55.990 --> 42:56.470] Um... [42:56.470 --> 42:58.770] Probably not considering the way that I rushed through it. [42:59.070 --> 42:59.550] But... [43:00.290 --> 43:00.770] Um... [43:00.770 --> 43:05.370] The cool thing about a macro is that you have access to the entire language. [43:05.670 --> 43:06.050] Uh... [43:06.050 --> 43:07.290] In C or... [43:07.290 --> 43:08.970] I guess VB or XL or whatever. [43:09.650 --> 43:09.870] Uh... [43:09.870 --> 43:10.930] Macro is kinda... [43:10.930 --> 43:12.050] It's kinda boring. [43:12.170 --> 43:12.570] Kinda simple. [43:14.030 --> 43:14.510] Um... [43:14.510 --> 43:15.810] Nice typo there with a double quote. [43:16.430 --> 43:16.850] No? [43:16.930 --> 43:17.510] Now you see it. [43:18.890 --> 43:19.370] Um... [43:19.370 --> 43:19.810] The, uh... [43:19.810 --> 43:21.890] The macro has access to the entirety of the language. [43:22.850 --> 43:23.650] And, uh... [43:23.650 --> 43:24.970] You can string together macros. [43:25.190 --> 43:28.330] When it comes across another function, it will interpret that function as well. [43:28.610 --> 43:30.970] If it comes across another macro, it's gonna expand that macro. [43:31.490 --> 43:35.990] In C, you often run into problems where you forgot a parenthesis in the, uh... [43:35.990 --> 43:36.430] Macro definition. [43:36.810 --> 43:40.290] And it just does a direct text substitution and suddenly you have a bug that you have no idea where it comes from. [43:40.570 --> 43:41.790] Because it's not in the source code. [43:41.910 --> 43:42.410] It's in the, uh... [43:42.410 --> 43:43.590] It's in the, uh... [43:43.590 --> 43:44.330] The macro definition. [43:46.470 --> 43:46.870] Um... [43:48.030 --> 43:48.430] Um... [43:48.430 --> 43:50.670] This is, I guess, the unofficial Lisp logo. [43:51.390 --> 43:51.870] Uh... [43:51.870 --> 43:53.450] Good thing I didn't have to ask permission for it. [43:55.570 --> 43:56.050] Um... [43:56.050 --> 43:56.230] Um... [43:56.230 --> 43:57.090] This, uh... [43:57.090 --> 43:57.570] This MD. [43:57.810 --> 43:58.290] This doctor. [43:58.710 --> 43:59.350] Conrad Barsky. [43:59.470 --> 44:04.130] Suggests that we use spell instead of macro because other languages have sort of polluted it. [44:07.130 --> 44:07.610] Um... [44:07.610 --> 44:08.850] Let's see if I can get this to run. [44:11.630 --> 44:12.110] Um... [44:12.110 --> 44:13.570] There's a very good... [44:15.170 --> 44:16.810] It's a very good, uh... [44:16.810 --> 44:19.390] Demo that he has, um... [44:19.390 --> 44:20.690] On his website, Lispirati. [44:22.270 --> 44:22.750] That... [44:22.750 --> 44:23.950] Don't need that anymore. [44:24.230 --> 44:25.110] Don't need that anymore. [44:25.950 --> 44:26.430] Um... [44:26.430 --> 44:27.450] It's basically an adventure game. [44:27.750 --> 44:29.370] And, uh... [44:29.370 --> 44:33.770] One of the cool things is that you can structure your data how you want it to. [44:33.970 --> 44:34.890] How you want it to be. [44:35.150 --> 44:36.510] And, uh... [44:36.510 --> 44:39.430] Use different access methods to only get what you want. [44:39.430 --> 44:40.070] Uh... [44:40.070 --> 44:42.310] So here we have a nice global variable called map. [44:42.710 --> 44:43.050] And, uh... [44:43.050 --> 44:46.910] Just looking at it, you can sort of understand what the, uh... [44:46.910 --> 44:47.850] What the structure is. [44:50.610 --> 44:51.050] Um... [44:51.050 --> 44:51.490] The... [44:51.490 --> 44:57.250] The plot of this story is that you wake up in a wizard's house and he's passed out drunk. [44:58.790 --> 44:59.230] And... [44:59.950 --> 45:02.670] You have to revive him in order to get the magical low carb donut. [45:04.210 --> 45:04.650] Um... [45:04.650 --> 45:07.270] I would recommend you read this because it's a very good tutorial. [45:08.450 --> 45:08.890] Uh... [45:09.530 --> 45:09.930] Um... [45:09.930 --> 45:13.590] This way I can at least have benefited you a little bit. [45:14.790 --> 45:15.190] Um... [45:15.190 --> 45:16.890] But it goes through, um... [45:17.850 --> 45:18.050] Um... [45:18.050 --> 45:18.890] All the, uh... [45:19.590 --> 45:22.630] All the steps to build this program up from the ground. [45:23.170 --> 45:23.570] Uh... [45:23.570 --> 45:24.670] This is what a list looks like. [45:25.350 --> 45:27.410] This is the command that goes in the front of the list. [45:29.170 --> 45:29.570] Um... [45:29.570 --> 45:30.490] You know, you can read it yourself. [45:30.910 --> 45:32.750] I'm not, I'm not here to read to you. [45:34.670 --> 45:35.070] Um... [45:39.070 --> 45:39.610] So... [45:39.610 --> 45:40.930] This is, this is what a macro looks like. [45:41.050 --> 45:43.050] You have this weird syntax where you... [45:44.490 --> 45:45.030] Are... [45:45.030 --> 45:49.790] Slipping in and out of whether you want to evaluate the argument as a symbol. [45:50.050 --> 45:51.130] Or get the name. [45:52.550 --> 45:53.090] Um... [45:53.090 --> 45:54.050] Or just pass it through. [45:54.770 --> 45:55.090] The, uh... [45:56.270 --> 45:56.590] The, uh... [45:56.590 --> 45:57.090] The macro doesn't... [45:59.370 --> 45:59.850] Um... [45:59.850 --> 46:00.550] All right. [46:01.130 --> 46:02.110] Where'd my macro slide go? [46:03.550 --> 46:04.210] Oh, well. [46:04.870 --> 46:05.110] Um... [46:05.110 --> 46:06.770] Macros return forms to the compiler. [46:06.930 --> 46:07.810] They don't return values. [46:07.810 --> 46:08.770] And so... [46:08.770 --> 46:09.730] The, uh... [46:09.730 --> 46:12.490] The interpretation of the macro happens before it's compiled. [46:12.770 --> 46:15.390] You're basically using code to generate more code for you. [46:18.790 --> 46:19.270] Um... [46:19.270 --> 46:23.890] And you end up being able to abstract your code, um... [46:23.890 --> 46:26.910] Much more if you have a lot of functions that are doing basically the same things. [46:27.430 --> 46:28.590] You can just write it once. [46:28.810 --> 46:29.610] You have less code. [46:29.770 --> 46:30.350] Less bugs. [46:30.690 --> 46:31.290] And, uh... [46:31.290 --> 46:34.370] If you need to change it, you can change it very easily. [46:36.210 --> 46:36.690] Um... [46:36.690 --> 46:40.390] It's not self-modifying code, as cool as that would be. [46:40.730 --> 46:41.010] Uh... [46:41.010 --> 46:42.870] This is not a virus programming workshop. [46:44.970 --> 46:45.410] Um... [46:45.410 --> 46:47.570] Macros basically spit out forms to the compiler. [46:50.510 --> 46:50.950] Um... [46:50.950 --> 46:53.590] If I could have gotten the AMD project to work, which they have a... [46:53.590 --> 46:55.470] They have a talk going on at the same time right now. [46:55.690 --> 46:56.570] So I'm gonna blame them. [46:56.910 --> 47:00.650] And not the fact that I hadn't programmed in this language until yesterday. [47:05.310 --> 47:05.750] Um... [47:05.750 --> 47:09.010] One of the languages that's gaining a lot of attention is closure. [47:10.450 --> 47:10.890] Um... [47:10.890 --> 47:11.530] See, I didn't... [47:11.530 --> 47:11.990] I didn't... [47:11.990 --> 47:14.990] The name isn't funny to you because I didn't explain what a closure is. [47:16.050 --> 47:16.490] Um... [47:16.490 --> 47:18.750] But it's basically a value trapped inside a function. [47:18.970 --> 47:21.910] And it doesn't get garbage collected because the function is globally defined. [47:22.030 --> 47:22.530] And so it... [47:23.030 --> 47:25.250] It captures that value. [47:25.470 --> 47:27.510] You can use it for, you know, stupid things like counters. [47:27.510 --> 47:28.790] Or you can use it to... [47:28.790 --> 47:30.650] Keep track of the state in the state machine. [47:32.390 --> 47:32.790] Um... [47:32.790 --> 47:34.290] You can use it for an infinite list. [47:34.570 --> 47:36.350] Where you don't have to care about... [47:36.350 --> 47:36.990] Uh... [47:36.990 --> 47:37.910] Creating the entire list. [47:39.510 --> 47:39.910] Um... [47:39.910 --> 47:40.150] Anyway. [47:40.570 --> 47:41.510] Cool thing about closure. [47:41.730 --> 47:42.690] Aside from the, uh... [47:43.330 --> 47:44.710] If you notice the lambda in there. [47:45.530 --> 47:46.710] It does have a clever logo. [47:47.030 --> 47:47.170] Um... [47:47.170 --> 47:47.910] It's a Lisp dialect. [47:48.910 --> 47:49.310] Uh... [47:49.310 --> 47:51.650] With a powerful macro system running on the Java virtual machine. [47:51.650 --> 47:53.050] So you could write... [47:53.730 --> 47:56.050] You could write code in closure. [47:56.610 --> 47:57.690] And deploy it, uh... [47:57.690 --> 47:58.450] On a JVM. [47:58.810 --> 48:00.530] And the boss won't know. [48:00.830 --> 48:01.970] Because it just works. [48:08.130 --> 48:08.650] Um... [48:08.650 --> 48:11.950] If I had had time to, uh... [48:11.950 --> 48:14.690] Write something, I was gonna do a live readout of all the badges in the room. [48:15.130 --> 48:15.650] Uh... [48:15.650 --> 48:18.370] But the AMD site is still returning test data. [48:20.570 --> 48:21.090] Um... [48:21.090 --> 48:21.590] But... [48:23.870 --> 48:28.090] One of the improvements that this has over Common Lisp is that, um... [48:28.090 --> 48:29.150] They're using the... [48:29.150 --> 48:32.370] The Java thread model, um... [48:32.370 --> 48:34.690] Along with it's own built in software transactional memory. [48:35.190 --> 48:36.590] To avoid deadlocks. [48:36.970 --> 48:37.050] Uh... [48:37.050 --> 48:38.430] You may end up with a lot of contention. [48:39.110 --> 48:39.550] But... [48:40.090 --> 48:41.290] Nothing's gonna step over each other. [48:41.610 --> 48:42.410] And this is... [48:42.410 --> 48:43.030] Uh... [48:43.030 --> 48:43.510] A side effect. [48:43.690 --> 48:44.270] If you'll... [48:44.270 --> 48:45.190] Pardon the language. [48:45.390 --> 48:46.350] You want to avoid side effects. [48:46.550 --> 48:47.030] But this is... [48:47.030 --> 48:48.270] This is a benefit of... [48:50.630 --> 48:51.070] Uh... [48:51.630 --> 48:53.350] The arguments are typically immutable. [48:54.170 --> 48:55.010] And, uh... [48:55.010 --> 48:56.830] When you do change them, uh... [48:56.830 --> 49:01.550] Any code that goes back to reference it is gonna get the new value, um... [49:01.550 --> 49:01.830] Immediately. [49:02.470 --> 49:06.310] So, you won't have to worry about the data changing in the middle. [49:20.550 --> 49:21.050] Um... [49:21.050 --> 49:22.290] The music makers and we are the dreamers of dreams. [49:22.910 --> 49:24.670] Immediately you're gonna think Willy Wonka. [49:25.070 --> 49:27.050] But, in fact, it is part of... [49:27.050 --> 49:28.610] A nine stanza piece. [49:29.170 --> 49:29.670] Uh... [49:29.670 --> 49:30.970] Which thankfully is in the public domain. [49:31.890 --> 49:34.010] We are the music makers and we are the dreamers of dreams. [49:34.350 --> 49:37.310] Wandering by lone sea breakers and sitting by desolate streams. [49:37.930 --> 49:41.770] World losers and world forsakers on whom the pale moon gleams. [49:42.270 --> 49:45.270] Yet we are the movers and shakers of the world forever, it seems. [49:45.970 --> 49:47.290] There are eight more stanzas. [49:47.790 --> 49:49.670] So, this is not the end. [49:49.830 --> 49:50.730] This is just the beginning. [49:52.770 --> 49:53.330] Thank you. [49:53.490 --> 49:53.950] That is all. [49:54.330 --> 49:54.970] Thank you!