100:00:05,750 --> 00:00:10,395They come back! Before we canstart with any serious work,200:00:10,395 --> 00:00:12,255let's do some housekeeping.300:00:12,255 --> 00:00:17,380As you know, this year is a tad special.While the broad direction is clear,400:00:17,380 --> 00:00:19,730there are some organizationaldetails that500:00:19,730 --> 00:00:22,370still need to be workedout as we go along.600:00:22,370 --> 00:00:23,930The main hub for700:00:23,930 --> 00:00:27,215all the information is theKEATS page of this module.800:00:27,215 --> 00:00:29,300Let me say a few words on how900:00:29,300 --> 00:00:35,269it is organized. The module isorganized into weekly topics.1000:00:35,269 --> 00:00:39,785So there are entries for weeksone up till week ten.1100:00:39,785 --> 00:00:44,390Let's also proceed inapproximately weekly steps.1200:00:44,390 --> 00:00:46,790Because if youalready asked me in1300:00:46,790 --> 00:00:49,130week two somethingabout week ten,1400:00:49,130 --> 00:00:51,275then you might confuse me1500:00:51,275 --> 00:00:53,720and also your fellow students.1600:00:53,720 --> 00:00:55,970All the communication in1700:00:55,970 --> 00:00:59,945this module can be done inthe course discussion area.1800:00:59,945 --> 00:01:02,300You can ask any questions.1900:01:02,300 --> 00:01:05,465For example, I haven'tunderstood this point,2000:01:05,465 --> 00:01:07,910this video isn't clear,2100:01:07,910 --> 00:01:10,160I cannot run this code,2200:01:10,160 --> 00:01:13,910I have problems withaccessing the coursework.2300:01:13,910 --> 00:01:16,295This can be all discussed here.2400:01:16,295 --> 00:01:18,590If you have any private matter,2500:01:18,590 --> 00:01:20,900like, I can't understand why2600:01:20,900 --> 00:01:23,465did I get such a goodmark, for example?2700:01:23,465 --> 00:01:27,245Or there are some privatereasons why you can't keep up.2800:01:27,245 --> 00:01:31,430Please feel free to usemy private email address.2900:01:31,430 --> 00:01:35,630But for any other matterrelated to the module,3000:01:35,630 --> 00:01:38,480try to use the coursediscussion area.3100:01:38,480 --> 00:01:41,510And I will try to stay on top3200:01:41,510 --> 00:01:45,450of all the discussionsas much as I can.3300:01:45,580 --> 00:01:48,500Each week is organized into3400:01:48,500 --> 00:01:52,550a mandatory section andan optional section.3500:01:52,550 --> 00:01:55,835The mandatory sectioncontains videos,3600:01:55,835 --> 00:01:58,190a handout, and the slides,3700:01:58,190 --> 00:02:00,725which I used toproduce the videos.3800:02:00,725 --> 00:02:04,324I recommend that yourfirst read the handouts,3900:02:04,324 --> 00:02:07,430then watch the videos and then4000:02:07,430 --> 00:02:11,030read the handoutagain for each week.4100:02:11,030 --> 00:02:14,795Apologies, some of thesehandouts are quite lengthy.4200:02:14,795 --> 00:02:17,615I think the longestone is 20 pages.4300:02:17,615 --> 00:02:19,235On the good side,4400:02:19,235 --> 00:02:21,650these handouts arewritten in such a way4500:02:21,650 --> 00:02:24,935that you can read them justbefore you fall asleep4600:02:24,935 --> 00:02:26,720and you should still be able4700:02:26,720 --> 00:02:28,835to understand what is going on.4800:02:28,835 --> 00:02:32,105Also, they contain lotsof pictures and code.4900:02:32,105 --> 00:02:35,330So 20 pages isa bit misleading.5000:02:35,330 --> 00:02:38,870You can see the second weekis organized similarly.5100:02:38,870 --> 00:02:41,030You will have some videos.5200:02:41,030 --> 00:02:42,260You will have a handout,5300:02:42,260 --> 00:02:43,624you have the slides,5400:02:43,624 --> 00:02:45,770and some optional resources.5500:02:45,770 --> 00:02:51,410I have also put up a generalsection, with general5600:02:51,410 --> 00:02:57,965material, where I puta PDF about my notation.5700:02:57,965 --> 00:03:01,385This might be veryuseful because5800:03:01,385 --> 00:03:04,610remember this topicis already many,5900:03:04,610 --> 00:03:07,445many decades old,at least 50 years,6000:03:07,445 --> 00:03:09,185and over the time,6100:03:09,185 --> 00:03:11,510many authors and many lecturers6200:03:11,510 --> 00:03:13,745have introducedtheir own notation.6300:03:13,745 --> 00:03:16,565So if you read anythingon the web or in books,6400:03:16,565 --> 00:03:19,640you might be confused about that6500:03:19,640 --> 00:03:24,035they call something, whichI call X, they call Y.6600:03:24,035 --> 00:03:26,150So in this PDF,6700:03:26,150 --> 00:03:30,320I have collected all theinformation on what kind of6800:03:30,320 --> 00:03:34,940notation I am using and whereI introduce some shortcuts.6900:03:34,940 --> 00:03:38,240The problem is, you alwayswant to be precise,7000:03:38,240 --> 00:03:40,070but we also lazy.7100:03:40,070 --> 00:03:43,745We don't want to writeeverything into the last detail.7200:03:43,745 --> 00:03:47,375So here I say somethingabout my notation.7300:03:47,375 --> 00:03:50,180I have also put upa document about7400:03:50,180 --> 00:03:53,510the Scala I'm going touse in this module.7500:03:53,510 --> 00:03:56,090This is importantfor the coursework.7600:03:56,090 --> 00:03:58,175In the coursework whichwill come in a moment,7700:03:58,175 --> 00:04:00,440you can use anyprogramming language you like7800:04:00,440 --> 00:04:03,665to solve the questions andimplement your code.7900:04:03,665 --> 00:04:05,615But, I'm sorry,8000:04:05,615 --> 00:04:09,830all the code I'm going toshow you will be in Scala.8100:04:09,830 --> 00:04:12,155And the main difference is that8200:04:12,155 --> 00:04:15,095between PEP course from last year8300:04:15,095 --> 00:04:17,675is that I'm going touse the Ammonite8400:04:17,675 --> 00:04:21,170REPL instead ofthe Scala REPL.8500:04:21,170 --> 00:04:23,615They work very similarly.8600:04:23,615 --> 00:04:26,070For example,8700:04:28,120 --> 00:04:33,710I can now evaluate codeand get a feedback of what8800:04:33,710 --> 00:04:37,100it calculates, just like the original one.8900:04:37,100 --> 00:04:40,220The difference is thatAmmonite is9000:04:40,220 --> 00:04:42,440an extension andprovides some features9100:04:42,440 --> 00:04:44,975which will be very useful for us.9200:04:44,975 --> 00:04:47,600And I recorded someof the features9300:04:47,600 --> 00:04:50,970we are going to usein this document.9400:04:52,330 --> 00:04:55,970The last point to noteon the KEATS webpage9500:04:55,970 --> 00:04:59,405is that in the optional section,9600:04:59,405 --> 00:05:02,270I will always givethe source code of9700:05:02,270 --> 00:05:05,845the programs I discussedin the videos and in the handouts.9800:05:05,845 --> 00:05:08,420And I really, reallyencourage you9900:05:08,420 --> 00:05:11,060that you play around with this code10000:05:11,060 --> 00:05:14,420to make sure you understandwhat was discussed.10100:05:14,420 --> 00:05:17,540At the also have sometimessome additional pointers10200:05:17,540 --> 00:05:19,490to interesting topics, which10300:05:19,490 --> 00:05:22,680you can read up in your own time.10400:05:22,690 --> 00:05:26,240Exams, I'm sorry,there will be exams.10500:05:26,240 --> 00:05:31,760There will be a final exam inJanuary, counting for 30%.10600:05:31,760 --> 00:05:34,190There will be amidterm shortly after10700:05:34,190 --> 00:05:37,565Reading Week, accounting for 10%.10800:05:37,565 --> 00:05:40,625This will be a normal exams,10900:05:40,625 --> 00:05:44,780just that they will be onlinein some form or shape.11000:05:44,780 --> 00:05:49,939There will be also a weeklyengagement component.11100:05:49,939 --> 00:05:52,370So 1% in each week,11200:05:52,370 --> 00:05:56,360where I make sure thatyou are engaged with11300:05:56,360 --> 00:06:01,625the material and you willget 1% each week for that.11400:06:01,625 --> 00:06:06,020How that is going to beworking out in practice,11500:06:06,020 --> 00:06:08,000unfortunately, I do not know11600:06:08,000 --> 00:06:11,285yet what tools we useor what it means,11700:06:11,285 --> 00:06:13,685but I will let you know about it.11800:06:13,685 --> 00:06:19,295There's also an optionalweekly homework.11900:06:19,295 --> 00:06:22,999The homework isuploaded on KEATS.12000:06:22,999 --> 00:06:27,230You should send your answersvia email to me.12100:06:27,230 --> 00:06:31,955I will respond individuallyand give some feedback.12200:06:31,955 --> 00:06:33,920Normally, if everything is okay12300:06:33,920 --> 00:06:36,605with a question, I willjust respond "OK"?12400:06:36,605 --> 00:06:38,630If there issomething wrong,12500:06:38,630 --> 00:06:41,060I will sometimes answer with a longer12600:06:41,060 --> 00:06:44,480email. All the questions in12700:06:44,480 --> 00:06:49,415the exam and in the midtermwill be from this homework.12800:06:49,415 --> 00:06:53,330So I do not give out thesolutions to the homework.12900:06:53,330 --> 00:06:55,415You have to email me first13000:06:55,415 --> 00:06:57,290what do you thinkthe solution is...13100:06:57,290 --> 00:07:01,280and I will give answersindividually back.13200:07:01,280 --> 00:07:05,270And I will then ensurethat all the questions in13300:07:05,270 --> 00:07:09,560the exam and the midterm comingonly from this homework.13400:07:09,560 --> 00:07:11,825The simple reason for that is13500:07:11,825 --> 00:07:14,645that I hate if students ask me13600:07:14,645 --> 00:07:17,705if something is relevantfor the exam or not.13700:07:17,705 --> 00:07:21,620I really like this materialand whatever I tell you,13800:07:21,620 --> 00:07:23,840I feel like youshould know about it.13900:07:23,840 --> 00:07:26,645So, to prevent that question,14000:07:26,645 --> 00:07:28,415if it's relevant to the exams,14100:07:28,415 --> 00:07:32,165you can just look atwhat's in the homework.14200:07:32,165 --> 00:07:34,370And if this questionis in the homework,14300:07:34,370 --> 00:07:36,335then yes, it will be relevant.14400:07:36,335 --> 00:07:40,410And if not, it willnot. Thank you.14500:07:42,280 --> 00:07:46,610Can you please make one morepoint about the homework?14600:07:46,610 --> 00:07:50,959Please submit youranswers only as PDF.14700:07:50,959 --> 00:07:53,780That just makes it easyfor me to look at.14800:07:53,780 --> 00:07:55,160Remember, I might get14900:07:55,160 --> 00:07:58,82060 or more emails about15000:07:58,820 --> 00:08:03,110that and it's just mucheasier for me to read PDFs.15100:08:03,110 --> 00:08:07,880Also, please in your answercopy the question.15200:08:07,880 --> 00:08:11,480I have an extremely limited memory15300:08:11,480 --> 00:08:15,290and have no idea what I actuallyasked in this homework until15400:08:15,290 --> 00:08:16,910I actually look it up.15500:08:16,910 --> 00:08:18,530Just to prevent that,15600:08:18,530 --> 00:08:20,255that I have to look it up myself,15700:08:20,255 --> 00:08:23,765please send inalways the question15800:08:23,765 --> 00:08:26,330and then give your answer.15900:08:26,330 --> 00:08:29,915And finally, there are some16000:08:29,915 --> 00:08:32,540optional homework. They are just to16100:08:32,540 --> 00:08:34,130reminders actually that16200:08:34,130 --> 00:08:36,140you really shouldhave a look at that.16300:08:36,140 --> 00:08:39,830But they're optional. The ones16400:08:39,830 --> 00:08:43,520that you are supposed tosolve, they look like this.16500:08:43,520 --> 00:08:45,890And as I said,16600:08:45,890 --> 00:08:50,645please copy the questionand then give your answer.16700:08:50,645 --> 00:08:53,780And at the end,package it into a PDF.16800:08:53,780 --> 00:08:58,505Thank you. A veryimportant component16900:08:58,505 --> 00:09:02,240for assessment in thismodule is the coursework.17000:09:02,240 --> 00:09:04,160There will be five of them.17100:09:04,160 --> 00:09:06,590We will first implement a matcher.17200:09:06,590 --> 00:09:09,770Then a lexer buildingon top of the matcher.17300:09:09,770 --> 00:09:13,655Then build a parserand an interpreter.17400:09:13,655 --> 00:09:16,730And then acompiler for the JVM17500:09:16,730 --> 00:09:20,420and a compilertargetting the LLVM.17600:09:20,420 --> 00:09:24,155So you can see thisaccounts for 45%.17700:09:24,155 --> 00:09:27,200You will submit yourcode and you also have17800:09:27,200 --> 00:09:30,260to give some explanationabout your code.17900:09:30,260 --> 00:09:31,520This will be always18000:09:31,520 --> 00:09:34,655explained in thecoursework description.18100:09:34,655 --> 00:09:36,785For the coursework, you can use18200:09:36,785 --> 00:09:38,945any programminglanguage you like.18300:09:38,945 --> 00:09:42,860In the past, people haveused Haskell and Rust.18400:09:42,860 --> 00:09:45,905Obviously many go for Scala.18500:09:45,905 --> 00:09:49,730You can use any codeI showed you in18600:09:49,730 --> 00:09:54,230the videos or in handoutsor uploaded on KEATS.18700:09:54,230 --> 00:09:56,390But nothing else.18800:09:56,390 --> 00:09:59,450Remember, unlikein the PEP course,18900:09:59,450 --> 00:10:02,030here, in the Compiler course,19000:10:02,030 --> 00:10:04,130I actually will look with19100:10:04,130 --> 00:10:07,910my own eyes at the submissionsand make judgments.19200:10:07,910 --> 00:10:13,775And I'll see if people havecopied from each other.19300:10:13,775 --> 00:10:15,545Please don't do that!19400:10:15,545 --> 00:10:20,160That's very annoyingfor everybody involved.19500:10:20,440 --> 00:10:23,570To conclude thishousekeeping video,19600:10:23,570 --> 00:10:25,580let me tell you abit more about how19700:10:25,580 --> 00:10:28,025this module is organized.19800:10:28,025 --> 00:10:32,600The first five weeks we willspend on lexing and parsing.19900:10:32,600 --> 00:10:37,370This is essentially thefrontend to our compiler.20000:10:37,370 --> 00:10:39,500The first part willbe about lexing.20100:10:39,500 --> 00:10:42,995Actually, we will emphasize quite abit on the lexing part,20200:10:42,995 --> 00:10:45,005because that's about my research.20300:10:45,005 --> 00:10:47,855And sorry, I can talkabout this for hours.20400:10:47,855 --> 00:10:49,400But I also like to show you that20500:10:49,400 --> 00:10:50,750there's actually something really20600:10:50,750 --> 00:10:52,340interesting going on andI want to20700:10:52,340 --> 00:10:54,529show you a number of techniques.20800:10:54,529 --> 00:10:57,435Then obviously we haveto do parsing because20900:10:57,435 --> 00:11:01,669lexing essentially onlyfinds the words in our programs.21000:11:01,669 --> 00:11:03,860We then have to putthem into sentences to21100:11:03,860 --> 00:11:07,350understand what ourprograms actually do.21200:11:09,820 --> 00:11:12,200The next five weeks,21300:11:12,200 --> 00:11:15,330actually that overlapswith the parsing part,21400:11:15,330 --> 00:11:18,850we will first start withwriting an interpreter.21500:11:18,850 --> 00:11:20,470This is essentially to get21600:11:20,470 --> 00:11:22,285the baseline for our compiler.21700:11:22,285 --> 00:11:24,325Also, you will see compilers are21800:11:24,325 --> 00:11:27,370sometimes fiendishlydifficult to get correct.21900:11:27,370 --> 00:11:30,880And to actually know whatthe results should be, 22000:11:30,880 --> 00:11:32,320by having it calculated with22100:11:32,320 --> 00:11:35,515an interpreter, isreally important.22200:11:35,515 --> 00:11:40,030And then we reallyspent time on a compiler.22300:11:40,030 --> 00:11:45,310We will first write JVM codefor a little While language.22400:11:45,310 --> 00:11:46,780That is an extremely,22500:11:46,780 --> 00:11:50,335extremely simple C-likelanguage, if you want.22600:11:50,335 --> 00:11:53,770And also JVM Code fora functional language.22700:11:53,770 --> 00:11:55,615Again, something very small.22800:11:55,615 --> 00:11:57,815And then for thatfunctional language22900:11:57,815 --> 00:12:03,080also generate LLVM-IR codethat can be23000:12:03,080 --> 00:12:09,270then used to generate directlyCPU code for X86 or ARM.23100:12:09,460 --> 00:12:12,095Just to whet your appetite,23200:12:12,095 --> 00:12:14,780here's the first compiler for23300:12:14,780 --> 00:12:20,240the While-language calculatingthe Mandelbrot program.23400:12:20,240 --> 00:12:22,160It generates code for23500:12:22,160 --> 00:12:25,460the JVM, for the Javavirtual machine.23600:12:25,460 --> 00:12:27,350So what it first does, like in23700:12:27,350 --> 00:12:29,855the example I showed you earlier,23800:12:29,855 --> 00:12:33,215it takes the Mandelbrotprogram from the BF language,23900:12:33,215 --> 00:12:35,480generates a While program24000:12:35,480 --> 00:12:38,520in our language we aregoing to implement...24100:12:38,530 --> 00:12:40,940this has produced a program which is24200:12:40,940 --> 00:12:44,795approximately 70k of source code.24300:12:44,795 --> 00:12:47,585Then our compiler produced24400:12:47,585 --> 00:12:53,015a Java Virtual Machinebyte code file.24500:12:53,015 --> 00:12:54,890This is the readable version of24600:12:54,890 --> 00:12:57,500the Java Virtual Machine bytecode.24700:12:57,500 --> 00:12:59,480And we use then an assembler24800:12:59,480 --> 00:13:01,535to actually producethe class file.24900:13:01,535 --> 00:13:04,460And then this compilerjust runs this class file.25000:13:04,460 --> 00:13:06,830It takes a little while andunfortunately this compiler25100:13:06,830 --> 00:13:09,365doesn't show it incrementally.Only at the end25200:13:09,365 --> 00:13:13,205it shows us it neededapproximately 40 seconds.25300:13:13,205 --> 00:13:16,745And you have toremember the GCC with -O025400:13:16,745 --> 00:13:21,485took a littlebit more than 20 seconds.25500:13:21,485 --> 00:13:24,440And so this is quiteremarkable result25600:13:24,440 --> 00:13:27,575considering we arerunning it on the JVM.25700:13:27,575 --> 00:13:29,345Just to assure you,25800:13:29,345 --> 00:13:33,245the Mandelbrot program will not be theonly program we can compile.25900:13:33,245 --> 00:13:36,380But we will focus on integers26000:13:36,380 --> 00:13:39,605and strings in ourprogramming language.26100:13:39,605 --> 00:13:43,280Because for more complicateddata structures 26200:13:43,280 --> 00:13:46,250we don't have enough timeto fit into this module.26300:13:46,250 --> 00:13:49,040So let's start nowwith the serious work.26400:13:49,040 --> 00:13:52,020I hope I see you in a bit.