Dank je. Ja. Inderdaad, woon je code op de generatoren genomen? Dus ja, na deze presentatie heb je behoorlijk behoorlijk bezoek als kandidaten voor regevering. Je weet hoe de regevering in meer beheerbare en elegant pyfonic code is. En je hebt eerst de kwaaimtens met de standardlibraries Itertools module en de wondervol, meer Itertools package. Maar eerst laten we mezelf introduceren. Mijn naam is Jan-Hijn Buurmo. Ik ben de aandacht van de basic Python voor Java developers tutorial op real Python. En ik wist de eerste baby steps van Python heel dicht, meer dan 30 jaar geleden, wanneer ik een programma voor de Dutch National Research Institute voor Mathematics en Computer Science werkte. En in m'n karier werkte ik meestal in C++-developer. Maar ik heb altijd een eind op de ontwikkelingen van Python. En ik was zelfs nog steeds kunnen gebruiken in m'n werk. Mijn volgende employer voor meer dan 10 jaar nu is Ordina. Het is een benelux-based IT service provider. En toen ik er als Java unit manager was, kwam ik met de idee van starten een speciale Python-practice. En deze praktijk foberst op Python en software-artistiek. Ik denk dat het heel speciaal is om een dede Python-practice te hebben, waarin in een board-spectrum IT service provider-company je dat niet veel ziet. En de Ordina-Pythoners zijn ook een participatie-sponsor van de PSF. In de laatste paar jaar doe ik wat ik meestal, en dat is Python-programma. In deze presentatie ga ik jullie in een familie van bepaalde functies. Ze invoeren loeps. Ze containeren fragmenten van een bepaalde code. En ik zal je laten zien hoe je de verschillende verantwoordelijkheden binnen deze simulant en tangoord code kan ontdekken. Ik zal op het topic van generatoren functies en hoe deze generatoren functies kunnen aanbieden om je deze en tangoord code in verschillende functies te ontdekken. En finally, ik zal je uitleggen met de utility-generatoren en functies van de Ittotos module en de More Ittotos package. Dus ik zal je een fictieel verantwoordelijkheden vertellen. Niet een echte verantwoordelijkheden over het Python-team die de functies van een product-owner ontdekken zal ontdekken. En deze product-owner is verantwoordelijk de Fibonacci-sequence fanclub. En de product-owner wil je een functie maken om een list van alle Fibonacci-numbers minder dan een bepaalde threshold, zoals N. En dus eerst, wie weet wat de Fibonacci-numbers zijn. Nogmaals. Dus ik moet het niet uitleggen. Ik zal het wel doen. De definitie van Wikipedia staat, in Mathematica, de Fibonacci-numbers van een sequence. De Fibonacci-sequence, in die elk nummer is de zon van de twee precedende mannen. Dus dat is de essent. Je begint met twee nummers. Normaal, de meeste keer, 0 en 1. Er is een debat over de begrijpenvalu's. Maar laten we deze eens gebruiken. En de volgende valu is simpel de addition van de vorige twee. Dus in dit examen, 0 is de eerste, 1 is de tweede Fibonacci-numbers. En de volgende, de derde, is de zon van de vorige twee nummers. 0 en 1. Als je ze aanbiedt, dan krijg je de volgende valu, die is 1 weer. En de volgende valu is de zon van 1 en 1.  En 1 plus 2 maakt 3. 3 plus 2, 2 plus 3 maakt 5. 3 plus 5 maakt 8, et cetera, et cetera. En dat is hoe je deze Fibonacci-sequence opbouwt. Dus de volgende stap is om dit in Python te implementeren.  Deze implementatie, wat je hier ziet, heeft een andere naam. Het heeft type annotaties en een docstring, maar het is functioneerlijk equivalent naar dat examenfunctie. Dus wat doet het? Hoe werkt het? Eerst kreeg je een eindelijk makkelijke resultaties, een container. En subsequently, twee variables zijn initialiseerd naar de eerste twee Fibonacci-nummer, de 0 en de 1 die ik aanbiedt. En je kunt zien deze variables A en B als Fibonacci-register. Register A holdt de current Fibonacci-nummer en register B contains the next Fibonacci-nummer. En dan enter je een loop, in dit geval met een exit criteria, dat de current Fibonacci-nummer moet minder zijn dan de threshold-value, de gevolgde threshold-value. En je hebt gewoon de current Fibonacci-nummer op de list. En dan begint je te calculeren de volgende set van Fibonacci-register. En dan gebruik je dat hele mooie feature namelijk sequence-unpacking van Python om deze calculaties in een go. Dus je maakt de nieuwe current Fibonacci-nummer tegelijkertijd de value van de oud-next Fibonacci-nummer. Dus je maakt de value van de oud-b naar de nieuwe A en de nieuwe B krijgt de aarde van de vorige twee values. En finally, when the loop exits, then you return the result list. So you present that to the product owner and the product owner is happy. He says, oh, that's nice. Can you make another function for this Fibonacci fan club? And now he wants us to make a function that simply returns the end Fibonacci-nummer. So it's an indexed number. And it's zero-based counting from zero. So Fibonacci-nummer zero is the first Fibonacci-nummer, Fibonacci-nummer index one, en one is the second Fibonacci-nummer, enzo on. We just make it zero-based. He's facilitating us programmers to make the stuff zero-based. So let's go to this new feature. You see the implementation right here. Again, you see the initialization of these two Fibonacci registers, but you don't see the initialization of the container that holds a list of values. En you enter, in this case, another kind of loop, not a while loop, but a counting loop. You're using the range function to simply count the number of iterations that you want to go through. And the underscore is just a dummy variable that holds the countervalue that you don't need, that you don't use. And within the loop, you repeat this calculation of the next set of Fibonacci registers, A and B. En once you're ready, you have gone through the number of times of loop of the loop, then you simply return the current Fibonacci-nummer. So we could, in our faults, we could try to mimic how the processor works in this case. So if you would pass n equals zero as the threshold or as the index, then you initialize A and B to zero and one. The range function does not cause any iteration of the loop, so A and B remains the same. You return A, so you return the value zero, which is Fibonacci-nummer zero. And one more example, if you pass one, then you assign, then the loop is executed one time. So then the A gets the value what was before that, the B value, which is one, and then you would return one, which is indeed Fibonacci-nummer on index one. So, you demonstrate this to the polytoner again. The polytoner is still very happy, gets even more enthusiastic and says, okay, well, can you make two more functions for me? One function that returns the first n Fibonacci-numbers and another function that returns the smallest Fibonacci-nummer greater than or equal to a certain threshold again n. So, more features. I'll quickly present you the two implementations of those functions. Here again, you're returning a list. You have the A and B registers again, a counting loop. You append the result as long as the loop count holds. And after that, you return the list. And finally, a bit of a different function, smallest Fibonacci-nummer greater than or equal to the threshold. You initialize the registers again. You enter the loop while the current Fibonacci-nummer is less than the threshold. You calculate the next Fibonacci-nummer. And once the condition of the while loop does not hold any longer, then you have a value which is equal to n or greater than n, and you return that number. So, you have now a set of four functions. And I could go on, of course, because the polytoner is never satisfied, but nonetheless, you see a collection of these four functions right here in a sort of matrix setting. And I guess you, I see, I think you all see a pattern here, right? You see repeated codes. The code looks very similar, but there are also statements that are different. And if you normally see that kind of codes, you automatically, at least I, start automatically, start acting in a kind of refactoring mode. I want to refactor this because I see duplication of code and I want to get rid of this code. And what is this pattern that you see? The pattern that you see is that you have some function declaration definition. It accepts some sort of parameter. Sometimes you need to initialize the container. In our example, it was always a list that you sometimes need to initialize. You initialize those two famous, now famous Fibonacci registers, as I coined them. And you have some sort of loop, a for loop or a while loop. And in this loop, sometimes you need to fill the container with the current Fibonacci number. Sometimes you simply calculate and then next you, sometimes you don't do that and you only need to calculate the next set of Fibonacci registers. En at the end, you either return the current Fibonacci number or you return the built up container. That's how it, that's the sort of the pattern that you see. Okay, time to start refactoring code because you want to keep it dry. You don't want to repeat yourself. So you start looking for ways how to refactor the code. Extracting the common part into a function or a method. So a simple check, who knows what refactoring is. We see many hands, not all hands, so I can give you a short definition recap of what refactoring is. You restructure your code without changing its external behavior. And you usually do this to improve the design, structure and implementation. But again, you make sure that original functionality of the code remains the same on the outside. And you do that for a reason because if you do that, then you aim for making your code more readable, less complex and better maintainable. So if you attempt to do that in this particular case, it seems very hard. The code that you want to extract is mixed up with control flow constructs and the values are collected in a list and stuff like that. So it seems hardly doable. Of course you could try to extract that one single statement that calculates a new set of registers, for example, or the initialization of the two registers. But that's a bit of useless. You replace one line by another one liner. So that's not so useful. As a kind of apparently final resort, you could try to combine the functions in one golden super function. So you simply make one functions with multiple modes. So let's start with trying the first two requested features. En we will use in this case a mode flag to designate which of the two features is actually requested. But the warning up front, what you're going to see is very ugly code. So put on your peril sensitive sunglasses for a moment. Here it is. It starts already with the ugly type annotation, right?  And I think this example can only confirm that statement. I don't want to even explain what is happening here in this code. It's quite unmaintainable, not so readable. And you should also not take this contrived example too seriously. It merely demonstrates that the resulting code is not maintainable and this is not the way to go. We have to solve it in another way. So back to the drawing board again. And the solution lies in the fact that you have to take a step back and look at your code in a more conceptual way from a larger distance, from a higher flying altitude, so to say. And then you realize that there is a data producing part in your code, the code that is calculating and provided the Fibonacci numbers. And there is a data consuming part, the code that either collect these values in a container or is checking some condition that identifies the moment to return the current Fibonacci number. And the data producing part is the part that you can isolate. So, for that we need to make a short context switch, enter generator functions because that provides our way out. You just make a function. If you want to make a generator function, you just code it as a normal function, but instead of that it contains a return statement, it returns yield expressions that provides the return values, the values that you want to give back to the caller one by one instead of all at the same time. So, as a demonstration, I can show you a very basic generator function. You see it here, it's called gen2 and actually it mimics the range function when called with an argument of two. The range function with argument of two gives back first zero and then one. And this is just an alternative implementation of that, but also larded with some print statement so that you can see what's happening when. And so you yield the value zero and just before that you see a print that's indicating that that is happening. Likewise for the value one, that is yielding and finally you see a print statement when it's about to return. How do you use this function? You could use it through the iterator protocol. You create an iterator of this function generator like this. I assign it to the variable iter. And then if you want to get the first value, then you just call next on the iterator and you get the value zero back and you see the print. So it only starts doing something when it needs to provide something. And it immediately stops as soon as it has provided that value. And if you want to get the next value, you just call next again and then you get the value one and you see the print out again. And if you want to get the next value, uh-oh, there is no next value, then you get the stop iteration which is perfectly fine. It's fully according to the iterator protocol. It's signaling that your iterator is exhausted. There's no more value to give back. But you can also use it in a for loop, right? Like you're used to. And it looks like this. So you just get the values back and it stops neatly after it has provided the two values. How you're going to code the Fibonacci number using the generator? Well, that's what you see here. You see the registers again, A and B initialized. There is an endless loop. That's quite a difference from what you've seen before. And in the loop, you simply yield the current Fibonacci number, the A register. And in the loop, when it continues, you calculate the next set of Fibonacci registers. And this is all there is to code the Fibonacci number generator. And you could see this as perhaps the most canonical implementation of a Fibonacci function when you code it in an imperative programming style. And how can you use this generator? For example, if you want to get the first Fibonacci numbers using this generator, then you could zip the result of your generator together with the result of the range function. And you would throw away the value that you get back from the range function because you're not interested in that. But you use that because the zip function stops as soon as one of the generator stops. So once the range function stops, then also the Fibonacci generator stops. And that's the way you can print the first eight Fibonacci numbers. So we're set, problem solved. My talk could end here, but there's a little bit more that I can show you because we have these packages. Ittotools module from the standard library, the more ittotools package from PyPI. And you can read out the text later. I continue quickly to show you how you can implement that first requested function using the Fibonacci generator combined with these neat tools. So for that, I first need to point you to the take wow function, utility of the ittotools module. And the take wow function takes a predicate function. Predicate function gets one argument. That's the current value that it gets back from the generator. And it takes an iterable and that's the generator, the Fibonacci generator. And then the resulting function has become a one-liner because you build up a list and the list takes the values, the output of the ittotools take while, the argument of the predicate function is just a comparison of whether the current Fibonacci number is less than the provided threshold and the second argument is the Fibonacci generator. So that's all there is to create this first function. How would the second function look like? Well, therefore, I'm going to introduce you to the I-slice functionality. Very shortly, you can compare the I-slice functionality of the ittotools module to slicing a list in general, where you have this square bracket with columns and you can provide a start and a stop value and a step value. It's in two forms. The first argument is always the iterable and then either you provide only a stop value or you provide a start and a stop value and perhaps a step value. And the difference with standard slicing a list in party list is that you cannot provide negative numbers. That should be positive. And there is another function from the more ittotools package, which is called one, and one simply makes sure that your iterator or your iterable contains only one element. Not less, not more. If it's less or more, then it raises an exception. But if it's one, it extracts that value and returns that value from the iterable. And then you have a one-liner again because you simply return what the one function returns and that extracts the one number from the I-slice function or generator, which is called with your Fibonacci generator, indexed at index n and stopping just before n plus one. So you extract one value and that's the implementation of the n-Fibonacci number. The first n-Fibs, you need I-slice again. Yeah, that's here. So you just call the Fibonacci generator with I-slice that says, well, give me the first that number of Fibonacci numbers. And finally, the smallest Fibonacci number greater than or equal to n. We have a drop while function. It's comparable to the take while function, but it does exactly x the other way around. So it takes an iterable and it drops values as long as the condition holds. And it only starts returning values after the condition does not long hold. And the first function, you can guess it already, I think, gives you back the first value of a returned generator en if there isn't any, then it can return a default value. And combined to each other, it's again a one-liner, if the line was long enough and you see the result here. So you take the first value of a generator that drops all the values as long as the Fibonacci number is less than n. And if there is no value at all, then it returns none. So that's it, sort of almost. I encourage you to read through the documentation of the iter tools module and the more iter tools package. It might probably save you some work if you have a good idea about all the functionality that it has to offer. And it often makes your code more expressive as well, better maintainable, I guess. And there's a lot more to discover from these utilities. A final example is the chunked or eye-chunked function that partitions your generated data into chunks. This can be convenient for loading massive amounts of data into a database, for example, where you can partition that amounts to very short, to shorter, still large, but shorter chunks to keep it all maintainable and to keep it also doable for all your packages en modules that you're using for that. So, you've heard about the following. You are now able to recognize the pattern of certain loop constructs as candidate for refactoring. And I've introduced you to the generator functions to extract the data-producing part. And finally, the message is that the iter tools module and the more iter tools package might save you a lot of coding. So that's it, there are some resources and links that I've used to come up with the definitions. And I would like to thank you. Oh, by the way, all this code has been, all the, not the interactive sessions, but all the functions that you've seen, the old variations and the new variations, have been tested using PyTest BDD. It was a fun exercise by itself. You can find out how in my GitHub repository. So, thank you for the presentation. There is still some time for questions, I guess. Yes, thank you very much. We have some time for questions. So, if you have a question, please come to the microphone. Ooh, silence. Yeah, question. Yeah, a little less of a question and more like a direction for like additional reading if people are interested in this. Because first of all, thank you for presenting this. It's just like a little thing that I keep doing where I basically don't write loops anymore because of generators and things like that. And it gets rid of what I think is actually the biggest problem with Python that loops don't have their own scope. So if you don't write loops, you don't have that problem. And nice and simple. So, two hints for further reading. One is in the standard library, there's loads of other things to go with this which you obviously don't have time to go into now. Like the filter function, map function and plenty more, which you can combine with these generators. Yep. And another package that I would like to recommend is the tools package with a Z. It's like a super set of more eta tools which also goes into like lists of dictionaries and working through those super useful stuff if you're interested. Oké, thank you for reins. En of course there's a lot to debate about whether you should filter a map on and not list comprehensions, but that's a separate discussion. Yes. Thank you. I have a question as well. You were shown us lots of beautiful one-liners. Do you like writing along one-liners and do you think that's good for maintainability? I don't know. Well, you have to be careful actually. I think it's a good question. It looks like I love it. I was surprised by the end result that finally all these functions were one-liners. But that was not the ultimate goal. My goal was to make maintainable code. And indeed, I think I understand the question behind the question, you have to also be careful with one-liners because you compress a lot of information into one line. So I guess that the first time you see those one-liners you have to think a little bit, oké, what's happening here? So sometimes it's perhaps better to create an intermediate variable that contains the generator or an intermediate generator, right? But so the answer is perhaps silently I like writing one-liners but it was not the goal of my presentation. So if there are no more questions, I'd like to ask you to give one more final applause to Jan Heijn.


Electrical impedance spectroscopy, EIS, is a powerful technique for investigating the electrical properties of various materials. It can be used to quickly characterize solids, liquids, semi-liquids, organic, and inorganic materials. The technique involves applying a sinusoidal voltage or current to the material under test and measuring its impedance over a specified frequency range. The resulting data can then be used to determine the material's electrical properties and behavior. EIS has been widely adopted in many applications such as quality control, process monitoring, and failure analysis. This article was authored by Mgrosi and Biriko.


Oh my lord All right, let's do it worse than we did last time My man's probably gonna get a tool or some corn like that Like look I can't even stop him. That guy is a pure slasher. Yeah, we got a little best of three It's like a playoff series with these guys. Don't wait dude gets all 21 and drops him off after a beautiful play call No way Hey, this group of individuals we have right here This has never happened before first of all for as long as I've known Duke for some reason We've just never played except that one time in 2k 21 next gen We played for like one time with Aiden and we never played again. That's it That's it and I haven't played with Phantom bro since he was the layup king in 2k 17 So yeah, yeah, right? Oh, yeah. Yeah, yeah, Phantom. I'm so excited to play with you. You have no idea Do not troll me bro, please. I see this is why I can't have fun on Videos because the second I even say I have a smile on my face. Apparently I begin trolling dog What do I do? I'm already a part of the program team. So you have to go to the program facility in the city center Hey, how do I find it? I don't know. It's on it's on the bottom left of the city center I think I have to leave the park. It's in the city. What game are you playing bro? It's okay On this channel I've talked a lot about how fortnight and epic games has been the gold standard when it came to creating content Which makes me happy to announce that fortnight is the sponsor of this video That's right ladies and gentlemen fortnight chapter 2 season 8 is here. Oh, and it's cubed Yeah, I know you guys probably looked under your bed in the closets and all over your bedroom Because kevin the cube has been a part of all our nightmares the past couple years But he's back and he's stronger than ever and the cubes all over the island are reaping and sowing Corruption and creating portals called the sideways and that's so crazy like the content is unbelievable You could enter these sideways and it brings you into this whole another world And once you get pulled in you could defeat plenty of sideways monsters to earn yourself some sideways weapons You ever think to yourself. Hey, man. I wonder what fortnight would be like if like there was no building Well in the sideways not only is there low gravity, but there's no building ladies gentlemen You can open up sideways chests to acquire weapons from the world and as you destroy the cube monsters They drop parts you can use to upgrade those weapons It's like a community effort the whole fortnight community is banding together to defeat these cube monsters and kevin Who of course has made its triumphant return with friends as a community? You create these turret stations and the turret stations as you could decide Which new weapons to bring in and which old weapons to unfold I'm telling you guys the gold standard when it comes to content I'm being for real and of course because it's fortnight is coming with its own brand new battle pass So if you haven't downloaded fortnight, well now is the time ladies and gentlemen It's free jump online take on the cubes with the rest of the fortnight community I'll leave a link at the top of my description and again a huge thank you to fortnight for helping sponsor this video You need to hire me bro at 2k. Just paint my dance, bro. A little mini-map wouldn't hurt Actually I was when I said yo get the logos. Look at that. I got the logos I should have unlimited logos every 2k till I die unlimited logos is crazy Toronto amp in a day everyone take regular amp dog. We had to get really They're not even amp. How they gonna take amp better amp for a n***a. I have false claiming Be false claiming No, there's no way. There's no way we lose to a team called press square. Come on dog Good shot, dude. All right. He bought crazy. Damn Mike 3v2 action. We got some 3v2 action. Oh, he back I'm over here. Yeah, I'm in the corner. I'm in the corner jump. Good job Damn, no, no, oh, I'm tweaking. I'm tweaking. No, no. It's a close. Don't be over close. Don't be over Yeah Oh, baby That's a shot boy I see Give me that, baby Let's talk about a game. I was good. I was good. Yeah, sir. No, no, my business agent go over there. Yeah Yeah, I'm I'm in the past. Oh, I jump. No, he not. He's not my boy. No way. We out. Yes, sir. We out. Yes, sir. We out Yes, sir. We out Well, baby And that's that back. I'm here.  Play threes. Play threes. Good spin. Good spin. Oh, no Bop boom. Bop. No. Oh, god Bop I like that. I like I'm right there. I'm right there. Damn. That's a big guy right there. That's a big guy No, I know. I know. Yeah Spin bop snatch bop momentum Damn, I'm trying to get the Pulse Good defense Damn, bro, it was perfect to low key. The shop boy. Come on. Yes. Let's get right Yep, I see There I was almost out ready though. Give me that. Oh my lord. Give me that. He ain't see you though. Wide open. Wow Boom You don't want it. You're not built that way. My lord. You're not built that way.  Hold on. Get the There's no game chat, man. There's no game chat. Oh Let's roll friends. Let's roll friends. Come on. Vamanos come through when we do it. You slide through when we shoot it Hood hood door All right, let's let's do it worse than what we did last time because I because Like I like that right there.  That was a bad move. All right. All right. All right. All right. Come back. Come back. There's no way Nope The box. Yeah No way Get on corner. You don't corner. You don't corner. Damn I'm talking about I'm talking about Yes, sir. My man's probably gonna get a tool or some corn like that Like look I can't even stop him. That guy is a pure slasher Okay, all right now. All right now. There's no way so let's tee up, man. No Damn, he can test it that stop stop. Oh my god.  He got it.  Hey, hey, hey, look though agent You don't leave your guy. Uh-huh and phantom on the switch. You run to the bit dude And I go to yours when you try to dog. You know what I'm saying? Oh, good shot. Good shot, dude. Yes, sir Give me that boy. That's food for me all the way.  You're not built that way That first step is Good shot, dude. Good shot. Good shot. I'm gonna stop one of these Damn me, bro Good shot. No hands. No hands up Yo, that's same spin, bro. That's same spin move. That's a two. That's a two. That's a two. That's a three Gang shot Boom, duke Come on, man. I'm not losing to these You know what I'm saying? We beat the first time. Yeah, I like that right there. Good shot. That's that back is fantastic, dude Whatever step back that is. Yeah, it's like, yeah, they look wrong. Keep it moving. Keep it moving. Keep it moving. Keep it moving Are you tweaking bro? Yeah, but not like right away doggie. No way. He shoots now. No, no, no, no, no, no, no, no I'm moving. I'm moving Hey, go to the corner right now Don't wait, duke. It's all 21 and drops him off after a beautiful play call. No way Because you're talking about Hey, y'all enjoyed the video drop a like subscribe to the channel if y'all missed the last gameplay.  Click that video. I'm gonna catch y'all in the next one. I'm out


Se on huomattu, että autot tuntuvat varioita, joilla on tuntuvat tuntuvat. Tämä videon olen tuntuvat, että se on oikein tarpeeksi. Ja mitä pitäisi tehdä tai ei. In HECNA's paper, autot tuntuvat, että tuntuvat varioita, joilla on tuntuvat multikollinarit. Se idea tuntuvat ja multikollinarit, on, että jos on X ja M, ja sitten tuntuvat formaprodukta X ja M, niin tuntuvat tuntuvat varioita on koko X ja M, koska tuntuvat varioita formaprodukta. Ja sen tuntuvat voimme tuntuvat tuntuvat varioita. Joten tuntuvat tuntuvat dataa. Tuntuvat 2 random numbers, X1 ja X2. Tuntuvat X1 ja X2 on tuntuvat 2, ja tuntuvat varioita X1 ja X2 on tuntuvat 0. Se idea tuntuvat on, että tehtäisit tuntuvat varioita, ja sitten tuntuvat tuntuvat tuntuvat varioita, ja se on tuntuvat varioita, jota on 0, ja me sanoit, että tuntuvat varioita on tuntuvat. Tuntuvat bar-symboli over the X tuntuvat tuntuvat varioita, tuntuvat tuntuvat varioita. Ja standardization on tuntuvat ja tuntuvat tuntuvat standardization. Me voisimme, että X1 ja X2 eivät ole hyvin koko kovin, joten se on tuntuvat tuntuvat tuntuvat tuntuvat, mutta kun me multiplaamme X1 ja X2 niin se on tuntuvat koko kovin X1 ja X2. Joten se on todella tyhjelmää. Kun me tuntuvat varioita, tuntuvat varioita on tuntuvat tuntuvat tuntuvat tuntuvat mutta me voisimme nähdä, että koko kovin X1 ja X2 ja tehtäisiin se on aika eri. On vielä todella tyhjelmää, joten X1 tai X2 on 0, joten ne on vain varioita ja dataa ja se on voittu suomalaisia, kun X1 ja X2 on todella tyhjelmää. Joten se on todella tyhjelmää, mutta se ei ole aslında kuciaa edellisestä. Joten mitä on se, yhdessä hallintain analytiottani tässä koko krikan, jossa on varioita rikroson analytiossa touched data, ja yhdessä hallintain analytiot kuten sen takaisin. Kun nähdään, että kuka on erityisessä, y- ja x1 ja x2, se on vain yleensä yleensä yleensä. Tämä yleensä yleensä on yksi, ja yleensä yleensä yleensä yleensä yleensä yleensä yleensä yleensä yleensä yleensä yleensä. Se on ihan yksi, koska kun senttiin, olemme yleensä yleensä yleensä yleensä yleensä x2, X2 ja se on yksi, koska sinä telekiin kertaa samaa numeroa every observation, se vain alkaa intersepti, koska se ei ole keskustelua X1, X2 ja co-variationsi between those two variables and why. Those are unaffected by centering. So centering will only affect means and in normal regression analysis it only affects the interest. What's the downside of centering is that once we calculate predictions, here the predictions for this model are on the original metric. So we will get predictions on whatever the y is. And if we calculate predictions using this model, then the predictions will be off by the amount that we centered. So for example if we're predicting a salary and let's say this model would give us 10,000 euros per year, then this model could give us minus 2,000 euros, which doesn't make sense unless we back convert or back translate that effect to the non-centered variables. So centering makes predictions and makes doing plots that apply predictions more difficult, and that's important for interactions for reasons that I'll explain in the last slide. When we take an interaction term, we can see now that there are some more differences. Importantly, the differences are only in the first three coefficients. So intercept again is different, which is expected, but now x1 and x2 coefficients are different, but the interaction of x1 and x2 is the exact same number. So the centering actually doesn't influence the interaction term at all. It influences only the first order coefficients. So is that something that you want to do or not? We have to consider, to answer that question, we have to consider what exactly the centering means and what exactly it means that we have this interaction term here. Let's take a look at a graph. So here the x1 and x2 effects are when x1 and x2 is zero and here the x1 and x2 effects are the mean effects. So when x1 and x2 are their means, then that's what the x1 and x2 effects are. What that means can be understood by looking at this graphically. So we have here a space and there is a plane in the space. Here we have x1 on this axis. We have x2 on this axis and then we have y here. So when we have two coefficients or two variables in the regression analysis as two independent variables, then the regression is a plane in three dimensional space. And we can see the plane here and because of the interaction the effect of x1 on y is the strength of that effect is contingent on the value of x2. So here when x2 is at zero, then x1 simply increases a little. So the effect is not that great. When x2 is at five, the effect is a lot greater. So we see a lot steeper slope here. So the idea is that the regression slope of x1 changes as a function of x2. Also the intercept changes so this line goes down here. So what centering does is that normally when we do an interaction term we take the effect of x1. So the regression with interaction gives you the effects of x1, effects of x2 and their product. When we don't center our data, the effect of x1 is this blue line here. So it's the effect of x1 when x2 is zero. Similarly, the effect of x2 is the effect of x2 when x1 is zero. When we center instead of taking the effect of x2 is at zero for x1, we take an effect of x1 when x2 is at its mean. So we take this green line in the middle. So the centering just influences which of these possible lines do we take it from here, from here, or perhaps all the way from the other end of the data. So it just changes at which part of the regression plane we are looking at. But the problem is that you have to look at multiple places. So you can't summarize this plane by saying that the effect of x1 is this line. You have to show multiple lines. So it doesn't really matter which of these lines you show in your regression table. And that's the problem. So you have to do these interaction plots. So you have to show multiple plots. So you show that the slope of x1 depends on the value of x2. And which of these lines we show in the regression table is arbitrary. So it doesn't really matter because we have to present these kind of plots anyway. So what we show here, whether we have the effect of x1 here to be the blue, green or red line, doesn't really make a difference. We have to show all the lines anyway. The problem with centering is that once we center our variables, then the interaction plot, the values of the predictive values of y will be incorrect by the amount that we center the data. So we can no longer do predictions usefully. We have to convert the predictions back to the non-centered metric for them to make sense. So centering is not useful because it doesn't do anything for the interpretation. You will have to interpret the results with this kind of plot anyway. And centering will be harmful for this plot because it makes forming these plots more difficult because you have to back convert your variables to the original metric to get the predictions correct. So because of these considerations, my recommendation is never center your data. It's not useful and it is harmful.


Mae'n meddwl am y desbydd yw sy'n ddigom yn gallu bodie'n brifysgol filed ydw i'r sgolers. Mae'n meddwl am ei ddweud yn meddwl iddyn ni'n cerddau. Mae'n meddwl am y ddotru— fel ychydig mor hwnnw— C Roeddo â ddu, fyddwn i'r meddwl hynny. Be'n ddweud yw'r meddwl hynny sydd ymraged oedd o'r meddwl ar gyfer y oddagol. This, this, this, they have like that there, they're important, but no, I'm saying that people that actually were buried there, that they're my mentors, I don't get it they're dead. How are they your mentors? And I know all of us have these kinds of moments where we tried to explain to people what is it about the law of Ziarra, that makes us want to go year after year, even month I find so many times that I am a friend with those who are friends with and I am the enemy of those who you are enemies with. I'm thinking, you know, this whole time, yes, fine. You're friends with Jabr, I will look up to Jabr as well. You're friends with Habib, yes, I'll do Ziar of Habib when I come to do Ziar of Ymah Hasein. Or you're friends with Abadhar, okay, I will make sure I remember Abadhar. Okay fine, maybe that's the friend's part. But I was thinking, okay, who are their enemies? Okay, the ones who killed them, the ones who tortured them. What is it about those individuals that made them the enemies? Fine, they killed them, fine, they tortured them.  And ultimately, in most cases, it boils down to what? Ego, hunger for power, jealousy of those who had power. Seeing a man like Arritha alai hissalam emerge from a house on Eide in such humble clothing would tear that heart of the Abbasids. There was something about this ego, this pride and arrogance of these enemies of them that created them to be enemies of Ahle-Mohammed. And I thought we'll hold on. Are the enemies of Ahle-l-Bait those who hold those traits too? Is it just the ones who actually killed each of those infallibles that that's what makes you become an enemy of Ahle-Mohammed? Is it the act, just the act, is that the only thing? Is it maybe saying, well, it's all the billah that you have detest for Ahle-Mohammed that makes them an enemy? I don't know. I'm not sure that's what it is. I'm sure that contributes. But maybe there's something more underlying within it. Maybe these very individuals who we go and stand and we do our iddne dduchol at their zeara, and we say that I know, O imam, that even though I can't see you with my eyes, I know that you can hear my every voice. I know that you can hear my every word. I know that you'll reply to my salam and I know that as for Quran, that you are living and not dead because you are a martyr in the way of Allah. Maybe these very individuals, when I'm yearning for their salam, they'll return because it's Wajib. But do they see me as a friend or an enemy? Do they really want to associate with me the one who has the same traits of the one that killed them? And that's why I find it so rich that I'm so quick to say, yes, yes, they're my mentors. Yes, you know, come into my grave, I've come to visit you, you'll come to visit me, right? That was the deal. When I read Carmeliziano, that's the deal.  That's how it works. I remember you, I weep a tear for you. You'll come to me. You'll use that tear to extinguish that fire. You'll come to me, right? But at the very same time, I'm enemies with those who you are enemies with as well. And you'd be enemies with those who have these cancers of those souls. And I'm one of those who maybe holds one of those tumors on my soul. Yes, come and cry. Yes, come and lament. Yes, give your money in the way of this cause. For if you are part of a moment that revives one person's life, it is as if you have given life to all of mankind. This is true in a spiritual sense as well, that if someone finds Ali Mohamed through a megylis, through a lecture, through a book that you have contributed to, you are part of it, of course. But if you're also their very enemy due to the tumor on your soul, then maybe they have a decision to make. Maybe that very person knocking on their varee, maybe that very person beating that chest is the one who Ahlulbayt sees as an enemy because I've not corrected that same vice that their killers had. Use these tears tonight to extinguish that tumor from your soul. Use that feeling tonight, that mournful state of this evening, to ask through Fatima Dazahra and Hazrat Muhsin aleyhim wassalam to remove any shackles from our souls so we can reach of our Subhanahu wa Ta'ala. Don't just let it be another Saturday night. Don't just let it be another way of mourning. Don't just let it be another megylis I attended. Start to write your own chapter.


All right, can you guys hear me in the back? Yeah, okay. Thank you. Thank you for that amazingly upbeat introduction. I really appreciate that So just to make sure I'm in the right place that you're in the right place. This is the room for CSE 340 Yes, most of people nod some people leave. That's fine principles of programming language Okay, so first things first For those that don't know me, which is probably the majority of you. I'm Adam DuPay This is my first undergrad class. I'm teaching here at ASU. So I'm pretty stoked about that I hope you guys are excited about that because I think we'll have a good time a little bit about my background. I did Five years at UCSB where I did my undergrad and grad kind of like the five plus one Or what do you call it here or four plus one? Yeah, so that's similar program then I went to Microsoft or I worked full-time as a software developer there doing coding stuff And I decided that I really really really like doing research So I went back to Santa Barbara to do my PhD and there I work on I worked on Security research so automatically finding vulnerabilities in specifically web applications So through static analysis techniques or some dynamic analysis techniques And so that's really my research focused and that's why I'm actually really excited to be teaching this class because this Compilers and the principles of programming language really form the basis for a lot of the bug-finding stuff that I do so if you can Using the exact same techniques. We're gonna kind of learn about in this class. We can actually Try to find and identify vulnerabilities in a program without even executing it Okay, so before I continue questions about me my background Yeah What languages that I use in Microsoft? My team it was all I think all C sharp. I want to say So yeah, the app I was working in was written in C sharp Which is actually a really fun kind of cool language. It's like Java, but I feel like better It's like if they actually designed designed Java to be useful.  Any other questions? So I'd be happy to talk to you Later on whatever as interviews come up. You want some Feedback or some tips on how to do interviews. I'd be happy to help you there More questions. There's plenty of spots people in the back. There's lots of seats. We have a lot of people enrolled So I'd say the limit is 250 on the room. Yeah, I think it does. All right Maybe we can fit 10 more people in here Okay, so this course 340 This is the syllabus. There's a link to it on my ASU. You can also get to it from going to my website I'm dupe.com click teaching classes. It's pretty easy. I have to assume at this point everyone knows how to surf the web Use a web browser So We meet Monday Wednesday 2 30 my office hours are here. I have three hours of office hours a week You can also email me for appointments. I don't think you need to take a picture unless something's important. It's happening That is all on the web. It's all public just FY The course we have a course mailing list which I'll get to in a second the lead TA for the course Mohsen He's gonna be in charge of the homework the project submission system He couldn't be here today. So you'll get to meet him and see his face on Wednesday That our other TA sigh is here. He's the one who got me lost today. That's why we're late So sigh waves of the class. Yes. Okay, so sigh also has three hours of office hours a week Monday Wednesday Friday Your office we need to find you a place, but it will be in brickyard close-ish to my desk and Mohsen has four hours of office hours a week. So Together somebody who's really good at math. What is that? 16 33 and 4 is 10 10 10 guys, I know it's the first day, but you know, you can wake up a little bit Yeah, so we have 10 hours of office hours a week. So please come and talk to us So that's basically what this section is about. So we've tried to distribute it Throughout at all days of the week. There will be office hours some in the morning some in the afternoon If you can't make those times Talk to us email us. We'll also communicate with you if we have to change or move around office hours schedule What we expect from you we expect that you'll actually have Done some work or some prep when you come into our office hours.  Okay. What did you what actually don't you understand? What have you tried solving? What ways have you tried solving it? What didn't work? that shows us that you put the time in to think about it and That means we can help you more effectively. So it'll greatly help all of our times So yeah, that's basically this is about And if you have questions about the programming projects We also expect that you've made an effort if you come in and say I don't know what this error message is And I Google that error message and the first result tells me exactly how to fix your problem That you did not do sufficient research to understand that problem. Okay, then I'm gonna I don't know what I'll do But don't do that Because that's silly right if you can help yourself. That's awesome If you can't and you're stuck with and ran out of options.  It's Difficult to see all right So all the communication for this class is going to happen over This web page and a mailing list. So I'm not gonna have a blackboard site most likely Because I feel like this is a lot easier and a lot more maintainable so So part of your first assignment will be to sign up for the course mailing list So the ta's and I will make announcements to the mailing list you guys can ask questions to the mailing list Obviously, I love it if you guys help each other out because this is going to be a very difficult course. So I am Very happy if somebody has a question. Hey this you know, I'm getting this Whatever weird obscure compile error and I've looked at Google and I can't find any reference to it Does anybody know what's going on and somebody else says oh, yeah, I had that same problem The problem is you're compiling 64 bits instead of 32 bits or something weird, right? So tried to leading this file and recompiling that's totally fine But if you send somebody code and be like oh this code solves your problem, right? That's a violation of academic integrity and that's gonna be very bad. It's gonna make me be mean and I don't really want to be mean So there's a great link here advise everybody to read this article I'm gonna test the Wi-Fi to see if the Wi-Fi works. Yes, it does. Okay. How to ask questions the smart way It's a fantastic essay that will tell you exactly What we're looking for to help answer your questions effectively it basically boils down to what I've been talking about so Do your homework before you ask questions if you just ask thought thought list questions without doing any work or effort or looking at things yourself then I Mean we'll help you because that's what we're here to do But it's not gonna be a good good way to spend all of our time Da-da-da oh and sometimes so if you email us you're feel free to email us directly obviously if there's something sensitive But be advised that when we reply we will often times reply to the whole mailing list because this helps cut down on questions that everybody has questions Course communication Cool. Okay, pre-rex. That should be fine. Everyone here is past that. Okay the textbook So I have a link on here the bookstore should be either today or tomorrow having the textbooks I don't know if they do or not It's recommended. So this is actually the second edition. This is the one I have It's a lot a lot cheaper than the third edition so keep that in mind and the content from there is going to be Very much the same so what I'm going to do is I'm going to give pointers to the book of the stuff We cover in class, but I'm not going to sign any reading out of the book So you can use that as a supplemental to help you understand the material better That makes sense Cool. All right so This is the calendar of the course events Some things will notice on there that we'll talk about the first project is doing a week. Yeah. Yes, you can go to You go to my website teaching classes. It's right here. It's linked to the syllabus. It's also in my ASU There's that syllabus link that goes right to this page So yeah Cool. Okay, so things on here. There's midterms exam scheduled so look over this make sure you understand We're having a midterm on the 30th Then we're gonna have our next midterm on the 18th and the final exam is gonna be on the 7th So the exam dates are fixed If you have anything in accordance to any of the policies or whatever come talk to me Questions, okay, we get to the fun part. So this is gonna be a difficult class So I'm not going to lie to you and tell you that's gonna be easy You're gonna have to work really hard in this class Especially if you don't have strong programming skills So all of the projects in this class are gonna be in C and C plus plus and you're gonna be writing big projects that are complex and they're going to challenge you hopefully in good ways, but I Think it's you're gonna have to understand new abstract concepts that we talked about in class You're gonna have to understand new programming completely new ways of thinking about programming and you're gonna have to implement complex systems So if you don't think your skills are up to snuff, then I would say take this course another semester maybe Questions there's lots of people scratching their heads. Yeah, got it Okay, there's gonna be six written homework assignments They'll go over the course the concepts covered in class. They will also help you with the exams So the stuff on the exams will be in similar formats for the homeworks Two midterms, so I'm gonna say this now. I know I'm gonna have to say it later, but Everything it could potentially be on any mid-term midterm or the final okay, so Asking is this gonna be on the exam is a silly question because the answer is yes And the more questions I get about that maybe the more I put something on the exam that would be asked more so Just so we're we've we've gone over this we're clear. All right programming projects There's gonna be five programming projects the first two are gonna be very well the first one should be very very easy We'll talk about it in a second But they get More and more complex So all projects are gonna be done individually so there's gonna be no pair programming no teaming up This is something that you're gonna have to figure out and solve on your own All right, that's gonna be a final exam comprehensive cover all the materials cool It's the breakdown of grades can somebody who got the first answer to make sure that that lines up to a hundred It does I got at least one verification good Otherwise you guys just lose those points Okay preliminary grade thresholds, so This is right now what I'm gonna put them as So it means obviously if you get above that threshold you get that grade. I May I mean it all depends on how this course goes. I may Lower those thresholds, right? I may make an a b. I don't know 92 or 91 percent It all depends on how everything falls, but I won't go up Okay, that makes sense. I won't get it. I won't make it more difficult to get one of these grades, so Let's have an example. So if you get a 90% right that's guaranteed at least an a-minus it could be an a depending if I have to go down and Make everything match up. Does that make sense? Okay Do you have questions raise your hand? We're all friends here. It's okay. Yeah Are there gonna be any quizzes? No, maybe I don't know No, no, it'll be what's on the what's on here. I Won't try I won't try to throw any curveballs Okay Homework due dates homework or due online by midnight on the date that is due I'll have a link when I release the first homework assignment will release how to submit the homework No late homework is accepted. So don't try don't ask Projects projects will each have a date and Exact time that they're due for each day that it's late It's gonna be a 30% is gonna be taken off of whatever grade that you get So even if you complete the project 100% if you submit it a day late the motion get is 70 And it goes down 30% day after day I think it's pretty clear Yeah, depends on what reason they give if it's 11 59 59 It also depends on why like if you're these are gonna be big projects.  So you should not be doing that Though submit early The you'll have feedback right away that tells you that this was right or not, right? And so then you can use to know in advance Yes, absolutely. Yes, I believe I'll check with Mohsen because he's in charge of that system But I believe it's unlimited submissions So you can keep submitting but obviously Don't like go make a change Submit it and then be like oh it doesn't compile because I forgot to actually compile it on my own computer before submitting it Right, so don't use it as an oracle, but yes, there's a hand over here Yeah, yes, there will be well. I'll show you in a second. Actually about that assuming everything works more questions So maybe as you can tell by well actually probably only these people can see maybe you people I'm gonna try to record all the lectures in class because I know whatever your schedule You can't make it and you have to ask me what's gonna be covered So I'm gonna try to record the audio and the screen here So you get to know what we talked about in class and I'll try to post these but this is not guaranteed so You're all adults. You're responsible for the material covered in class If I forget this thing, I'm not gonna stress out about it and record another lecture for people who weren't here I'm just gonna lecture so, you know, it's And I'll post the slides all the notes as much material as I can and pointers to the book Questions any extra credit? Probably not I'd say no at this point unless like So, I mean this time the projects are gonna be already hard enough. I don't know that having extra credit It's gonna be good a good thing So I'd say no at this point. That's why I would the a plus is at 97, right? All right cell phones put your cell phones on vibrate or silent. I feel like that's should be pretty easy If you need any special accommodations, let me know we can talk about this Okay, this one is very important. So I'd like everybody To pay attention and listen I take plagiarism and cheating very seriously. So part of what you're getting out of this class is the ability to create a complex interesting System and so by plagiarizing somebody else's code or helping somebody plagiarize That's to me like one of the worst things you could do. Just take the zero I've already caught a Number of people cheating and I don't want to catch any more It's a lot of work for me It's a lot of work for the TAs, but I'm happy to do that because I think it's fair to everyone else Who's actually putting in the effort so if you're Sitting there and it's 10 minutes to the deadline.  So they keep a record of it. If it happens again, you get like Very serious things happen.  Ah, well, it was just so hard Yeah, okay. It was hard, but you never came to office hours to talk to us Or you never asked any questions on the mailing list So it's really up to you to monitor that some examples Sharing code with a fellow student even if it's a few lines Collaborating on code with a fellow student. So even if you both worked really really hard on it together That's not a good excuse. It's still plagiarism Submitting another student's code as your own I should be that should be pretty obvious Submitting a prior students code as your own also plagiarism Okay, and this is something I do have to cover so, you know, please do not post your projects online I know for a lot of you you want to build up an online resume for employers So they can see the stuff that you've done in class and they can hopefully give you a job and they can see What an awesome coder you are. I'm here to tell you I've like worked in industry Everybody takes classes and does class assignments Right, so the best way to get noticed is to do something outside of class something different So instead of thinking hey, maybe I should post this project on my github Think hey, I'm going to Create some new cool thing that's related to that some interesting type system that we didn't even talk about and I'm gonna put That on github because employers are gonna love they seriously eat that stuff up and feel oh, yeah That website on my github. Yeah, I created that in my free time. I'm like a hundred people use it They go wow people don't do that They just do the bare minimum in class and you went above and beyond So because it it really hurts the other students it resists it takes away that temptation for students to Google CSE 340 project to and find a bunch of stuff right so Protect your fellow students protect yourself Don't post your cook don't post your code from this class online any questions about the plagiarism and academic integrity policy Yes So using code from yeah, so if you use code from other sources like stack overflow or even If you find a library function or a library from somewhere else I'm totally fine you can include that but you have to include the attribution right so in your comments It should say hey, I got this code from this stack overflow thing, you know if it's something small I think that's fine right if you happen to find something that does exactly what we're talking about in here And you say this entire code came from stack overflow. Well, great. It's not like I mean It's not plagiarism, but then you did nothing right it'd be like in an English class Submitting an essay as a Wikipedia article and saying the Wikipedia article on ethics says this right? It's not plagiarism because you attributed the source, but you also didn't do anything So that's my policy there. Yeah it Is that's true and but I'm expressly forbidding that I'm saying no because then you're Yeah, it's one thing if you find one thing online right that somebody else wrote in another context. That's helpful for you It's something completely different if you're both working towards the same goal and you go Oh, hey, look at that awesome function. You wrote to do that. I'm gonna not write that Yeah, I mean from using from somebody else Yeah, yeah, I would say yeah, you know use your judgment if you look I mean If you're looking at it and going man, this is the entire project don't use that right or if it's but if it's But you should also understand how that code works too, right? If you just you don't want to be one of those copy-paste coders who just like goes to random websites literally when I was working in Microsoft I was One of the product that we were working on we're making an XML based tree So you could like click on the link in this tree and then it would point in the document where you were And so I was tasked to like we need to improve this it sucks So I started looking at the code and I was like, how do you do one of these like trees? So I looked it up and I'm reading this like I think it was one of those code Academy No, that's not the right word but one of those like C sharp Programmers things and I go huh these these variable names are very familiar and I go look in the code And it was the exact same thing That somebody had posted to the site and it's not like Stack Overflow where they give you license to use that thing Right, so the Stack Overflow has the I think it's the Creative Commons license on all this stuff there This was somebody's proprietary blog where there was no copyright on the code in our product So as soon as I told my manager that we had to like rip it out and completely re-implement it So yeah, that's like it is literally a liability to your company for you to do that So yeah, don't you know understand things And if you have any questions ask that's the other thing, right? So if you're thinking about using something and saying ooh, I don't know where this falls ask I'll be happy to to let everyone know Questions Yeah, I mean we can be honest We're not like it's not in the back in the days where we didn't have internet where all we had was like a both to look at right? So there's a lot of resources out there. Help yourself educate yourself But know what you're doing Okay, and I could change the syllabus if stuff has to happen Kind of standard claim disclaimer. Anybody have any questions on the syllabus? Anything there? Can you oh should you? No, no I don't know I was gonna say maybe if you're really short and you can't see over the person in front of you You could use it, but it's not that big so I would say no don't I wouldn't bring your book to class Do you have to bring books to a lot of classes? No, okay, just curious more questions All right, so let's look at the first project See if a week to do this project It's two parts first part sign up for the course mailing list So do that put your ASU ID. I don't care what email you use whatever Doesn't matter to me. Just sign up before next Monday to get 10 points Right pretty easy Good Okay, so the other part is right a So this is what I say. This is an easy programming assignment. It should be so write in C or C plus plus a Slightly advanced hella world application You're gonna write a program that reads from standard in a string an integer and Then your program is going to output that many times the string hella world with a new line So example if your program is given an input of one to standard in you output hella world and you're outputting Hella world with a slash n the new line character not so output of just hella world is Not correct because it lacks the trailing new line Hello, this one is not correct Because there's multiple spaces here, right? It's kind of hard to see in HTML, but that's also not correct This hella world is also not correct. There's no space in between the hella world and there's also not a new line This is also not correct hella world slash r slash n because the new line character is only slash n So you maybe think of yourself man, that sounds crazy. Why would we be so strict on this? And the reason is well, you got to start thinking like the computer, right? So what happens if you've got a semi colon in your program? Huh, yeah, the line ends your program crashes. It won't compile. It doesn't do anything, right? You made one mistake one little error, but the whole thing doesn't work so that's the same thing here so you have to get in the habit of Implementing exactly the specification that we give you and that's why we have this very small practice homework Okay, so yeah, if you're given the input of five you will let's make sure I do this one two three four five Yeah, okay, so five hella worlds All right, so hopefully this works Okay, so that link there will take you to the link to the submission the project submission site The URL is I don't know CSE 3 for CSE 340 dot Fulton dot esu ASU dot edu. I don't know why these things are so long But they are Let's see you will click here to register Mosin will be emailing everyone very shortly your verification code To your ASU account that's affiliated with the school So you just put in all your information here You can log in I go back I See the problem here All right, well This is when you break your rule about not using your own web browser Okay, so last pass knows my password. I don't even know my password. So I type log in and I sign into 340 And tells me these are the list of projects then in here I can look at the make file So this will actually help me compile my code and this is the exact make file that Mosin system uses to compile your code a test script to test your code a zip file with some test cases and this awesome Programming projects guide which I think well So Mosin lead TA wrote this awesome guide about how to program projects for 340 so this is 12 pages so It tells you about all the test cases it tells you how the test cases are run It shows you that there is no room for error on the outputs It shows talks to you about Input output redirection so you can run to develop your own test cases She's got an example here The test script that you have for grading Let's go to okay the development tool. So this is really important. So you know to make sure that we can compile your code and That you can compile your code. We're standardizing on sent OS 6.7. Yeah, there's a question from the front Do you know I see a hand on my eye? Okay So this is the same I believe this is the same version that general dot ASU uses So if you want to use that for development purposes you can it's also the same thing That's on the second floor in the brickyard those computers in there. The easiest thing to do is to Where is it Okay, it talks about make files installing sent OS on a virtual machine So there's all the instructions everything here is free. You can have sent OS running on a machine here Just like I do Hopefully if I click this it'll work and everything won't die So literally I installed this just by following those exact same instructions So now I have if this ever boots up a machine where I can compile on and that version of GCC that I'm using here Is the exact same thing on the submission system? So that when I go to submit my project I can make sure that it's correct. So yeah, there's all the instructions you need and So now I can submit Let's see teaching projects I Can submit my hello example Submit it and says hey past two tests out of two yay a hundred percent awesome And I can look at all my submissions and it gives me like some of the output All that stuff so the big part about project one should not be the programming so let me go back to the The thing here So the programming on this project is intentionally meant to be very easy The real goal here is to familiarize yourself with the submission process so that when we start having complex Programming projects, you'll know how to submit to the system. Yeah, what are what instructions? Oh? Right so So there's a link on Yeah, so on the projects page There's a link to these guidelines so you can even get to them without Worrying about the course submission thing and then most then we'll be sending emails with that verification code that you need to Create an account on the turn in system. Yeah maybe So I would say probably not so we will go off the test cases We may for various projects have the graders and TAs go through and look at them Just so that we can I don't know if you somehow hard-coded the test cases or something We could give you some feedback and reduce your score But yeah, you know that would be kind of mean so I probably wouldn't do that unless it turns out we need to Any other questions so okay, so back to the note so If this assignment takes you like Significantly longer than on the order of an hour you should seriously consider about not taking this class and taking it some other time The submission stuff, okay, maybe but This is a slightly more advanced hello world and if you can't do that you're gonna have serious problems doing the programming assignments So consider this kind of a self-check before we start Other questions on the assignment the submission system. Yeah So this is the requirement your code has to run on sent os 6.7 on our submission server If it doesn't then you might as well not do anything so If you're willing to develop it in visual studio and then Make sure and get that code working on sent os 6 7 with the exact version of GCC that we're using That is fine, but No, you're taking a risk by doing that So that's why we have this standardized system so that we can make sure that everybody's using the same thing That way because what happens is you submit it doesn't work then you say ah, but it works on my computer, right? That's like the classic Anybody doing an internship is like a tester or something like that Some people yes, that's like the classic dev thing like ah well it works on my machine So yeah, but it doesn't work in production. So your code is crappy and it doesn't work So Like go fix your code So we want to avoid those issues and get you in the habit of getting on a standard and doing Everything the same. Yeah, so yeah os x is a little bit tricky So I mean I developed this little application in os x with I think actually the newest versions don't even have actual GCC I think it's linked to clang. So you definitely could run into problems there. So that's why I installed I Installed sent os. I mean, it's not very big. It's kind of small and Honestly like a lot like you should be getting very familiar with Linux these days That's also a selling point to employers is saying like hey, I have a Linux system on my box I know how to configure it. I know how to use it. I know how to compile on it. Like that's good Yeah, there's other questions hands. Yeah, I send us a link. I mean You can use a VMWare. I think they have a free version on On all the platforms except for this one So yeah, either virtual box on The Mac or VMWare on Windows. That's what I'd say consent os compile C plus plus 14 I have no idea you'd have to look at the version of the compiler for that So if you want to use anything special like that, then you can change your make files so that you're using whatever compiler flag Do you need for that? But if it's not on that that system then don't count on it also related to that if it turns out it's somehow Technically physically impossible for you to get a VM running on your system Tell me and we can find a system for you to be on Because yeah, you should also have general I think general should work to or the lab machines a lot of choices more questions Yeah, you can resubmit it. It's got to work on the machine So the question comes down to is why doesn't it work? So if you if you have the code in your computer You say it works you submit it to the thing and then you wait till the deadline expires and you go Ah, but it worked on my machine, you know, and it turns out there's some you made actually a technical error And you I've I've had this happen where people submit the version on their Windows machine when they've been testing on their The Linux VM and of course that one doesn't work on On our Linux servers, so it was a problem on their part So that's kind of also a good point that's in that essay that I sent out So assume that the bug is in your code first come to us and show us that you've like That it actually is a bug in our code With the submission system and you can send that to us and we'll try and fix it more questions You didn't think that was all we were going to do today. Did you? Yeah Yeah, so that's that's the big thing especially with Windows and Linux That's why I say probably don't develop in Windows because the default line endings there are I think slash r slash n and The default line endings and Linux is slash n so oftentimes you can completely mess things up If you submit what it looks like identical versions So you can use a hex editor. There's a tool hex dump. I think HD is installed by default on Linux things You can look at the raw bytes and see like those aren't like an OA and OA like they should be at the end Well, that's why you have a lot I would say you should start you got to start early So you don't want to wait on these assignments submit and that way you can You can verify so the golden standard is right you you test it on a cent OS 6 7 machine It compiles there you submit exactly that version onto the submission site and then if it doesn't work Then we have problems, but if it that should work More questions Yeah, yes, so the slides we posted the lecture The lecture recordings will be posted Also some notes that I have from dr. Basi will also be posted so should be Ample material plus links to book stuff and the questions before we get started Is this the classic keep asking questions about the syllabus so we don't have to do any lecture stuff I know these tricks and if that's not these things. I'm saying are not the case then let me know because Mohsen has maintained this system. He's been using it for a long time. So He has a lot more experience with this submission system. So if there are things like that that we can improve I think we're happy to do that Anything else? Okay. Oh, yeah, so comment about the notes.  I have to assume right so It's up to you whether you take notes in class or you just listen or I don't care. Whatever. Whatever you want to do is fine I'm not gonna force anything on you So I wanted to kind of start This class off. Yeah Yes, the lecture slides will absolutely be online. Yes, and if they're not let me know, but I'll wait until I'm done with the whole topic before submitting it online, right? I'm not gonna do it like piecemeal So yeah, so after these slides are done. We'll post those after the next Lexical analysis slides are done. I'll post those. Yeah, it's a good question. Um, I'd say no Especially So I'll be using some slightly different terminology. I mean in general. Yes, the ideas and concepts are very similar I'm not following the book chapter for chapter though And there's things we're definitely going to talk about in class that are absolutely not in the book because they're kind of advanced and really cool So the slides are good for that there'll also be notes For those yeah, try maybe in the future, but we'll see You know you like to make improvements and changes and stuff even like right before so Okay, so what is a programming language? This is not a rhetorical question. I'm asking what so I think most people are like Junior-ish area right junior senior somewhere in there, right? You've been at this kind of a long time So you've been doing this right? What is a programming language? Yeah, it's pretty good a much more. Yeah Much more readable interface to tell the computer what to do besides giving it ones and zeros. Yeah, that's good anything else Yeah, so some well-defined syntax and semantics. We're gonna get all into that Yeah, I kind of like it's a way to communicate instructions to a machine, right? So that's very similar to that example So we want to tell the computer what to do But is that the only definition and here? I think definition may be a little tricky But what's the other purpose of a program or a programming language? Yeah, yeah, so other people can interpret and read your work. I'd say that that's almost Honestly, once you leave academia and you go into industry you're gonna spend a lot more time reading other people's code and Cursing them that they wrote this code in this way Until you finally realize oh they did it because they had all these other constraints that I couldn't think about and then Hopefully you'll start writing your code in a way that future you in a year or two years from now When you have to fix a bug there, you'll be able to actually do it. So yeah, that's definitely one of them I think it's it's not even it doesn't have anything to do with the computer at all, right? You're communicating to your teammates future developers People that may use your library. You're telling them What this system or process should work? any other kind of Uses sort of communicating an algorithm Right, so you may not care that I mean you guys have all taken Data structures and algorithms right so oftentimes you look at things there. That's you know pseudo code, right? It's not it's not even to describe Instructions to another person, but it's to describe how an algorithm works operates all that kind of things Describing some sort of process it may not necessarily be an algorithm But it may be okay do this take this thing put it over here wait 30 seconds Call Google get the response from Google put that that in here mix it around and throw it in here Right that could be some kind of process that the program the programming language describes We talked about this communicating a system to another person This is I I will say this is a very important point that you want to keep in mind as you go because It comes up a lot oftentimes you think you're not actually Writing talking to the computer you're talking to future people So kind of already alluded to how does the computer understand your C or Java or Python code? Is it magic? Yes, it's all magic you just like throw together Random things and you've learned through trial and error and probably lots of error like in my case What compiles what doesn't compile and at some point like magically executes, right? So answer that is no, it's not magic, right? There's nothing magic here, and that's honestly why I love Computer science and computer engineering all this stuff right because you're learning how the whole thing works And that's part of what this class is designed to do is we're gonna peel back that curtain and realize oh, it's just Programs and algorithms all the way down right from that your Python code gets interpreted by a Python interpreter Which was written in C and compiled by a compiler to assembly code And that's interpreting your Python program and executing it and doing what you want it to do But you feel like hey, I'm just programming a Python program So we talked about this you kind of gave away my awesome graphic so the CPU understands assembly instructions, right? So that little hardware chip Needs and I guess this should be like a square or something that ship understands assembly language like ones and zeros, right and so But I don't know about you But it would be incredibly tedious to program with a keyboard But just like a bunch of one one one zero zero one zero zero you can do it I've you know, I've done some stuff for you like patch binaries to try to fix vulnerabilities and so you have to like look at the Assembly code and be like oh if I change that eight to a nine It'll flip and be instead of an if greater than it'll be an if less than which means that it skips this condition But you don't want it you don't want to program in that right? So we want some Abstraction away from the machine and so then once we start building these abstractions we build and build and build So yeah, this is kind of I talked about earlier so programs right it's all programs programs translate Your intentions what you the programmer want to have happen Into assembly language that the CPU understands So there's a couple of these can we go over to find some terminology so compilers Maybe we want to take a stab at defining what a compiler is Everybody looks away from my gaze. Yeah Yeah, turns it into Stuff that's very general. It's probably so general. It's correct. Yeah, I'd probably say It's kind of got a strict definition generally I like the more general definition of a compiler where it just translates from one thing to another right so See program to an executable It's becoming more often now that people have a very narrow definition of what a compiler is like a compiler Translates a programming language to an executable binary What about an interpreter? Translates one language into another I would say no Been close line by line. What does that mean? I can't see okay. What doesn't take the whole program at once Maybe what was that? Wait, sorry. Sorry. Yeah, doesn't convert the program to bytecode Yeah, I'd say that's That's almost there. It's getting closer. Yeah Wait, just like just like now we're getting into crazy semantics. Is the virtual scene for Java an interpreter? Maybe I'll talk about that in a second kind of What so yeah? right, so So yeah, I'd say an interpreter translates and executes. I miss missing some s's but translates and executes a programming language So it Understands it right it does that part of the compiler, but then it actually does the computation itself. So Yeah, is the so yes the JVM is an interpreter So the Java compiler does what the Java C. What does it take in? Go on so the Java compiler with a take in Java and what does it spit out? bytecode Java bytecode right JVM bytecode so in the JVM. What does the JVM take in? Takes in bytecode and then it executes. I wouldn't say it outputs right because we don't know if it ever outputs But yeah, so it does some computation.  I hate this word But people actually do use it. So that's why I'm making a separate Category for it. And we want to get a stab at what this means. Yeah, perfect. Yeah So this translates a pro one program language to another programming language Anybody know of any good examples of transpilers? Wait, just like oh nice. So a matlab to python compiler. Yeah, that's cool. Yeah What is it? Oh jiphon. Yeah. Yeah. Yeah Yeah, I'm Trying to think about it. Yeah, you could say yeah, so it does compile Python. Well Maybe I'd say that's more of a compiler because it's compiling it does it compile it to the bytecode Okay. Yeah, we're kind of splitting weird hairs here That's why I don't like any of these definitions because to me those are all compilers but compilers translate. Yeah, I would absolutely think that counts. Yeah, yeah Exactly. So the Python 2 to 3 compiler right is an automatic program that converts from Python 2 to Python 3 Yeah, so Python 2 program isn't necessarily a Python 3 program. So they are different languages. Yeah Anything else? Anybody know of any of the crazy JavaScript stuff? I like what was it?  This is the Acoustics here are super weird. You sound like you're coming from everywhere at once. Yeah What does Babel do? Ah, okay. So oh so it down converts. So it basically adds in the Non-existing language features to support backwards compatibility. That's cool Absolutely. I think those things see that's why I think these are so important So I consider all those compilers you can split hairs of compilers transpilers But yeah, so those are things that people may not think about so being able to translate from like Sass was that the one sass to CSS so like the compiler there, right? So that's a better way of doing CSS because you're gonna sign variables you can have inheritance all this cool stuff that makes see a Cascading style sheets super difficult to program in and they said hey We can write this awesome cool language to actually help us do that and make it easier to write CSS What about is it closure script one of the JavaScript ones that has this like completely different syntax But it compiles the JavaScript Rhino for Java. What is that? Java oh Java to JavaScript. Yeah, and Google has something similar right with GWT the Google web toolkit that takes a Java program that describes a web page and compiles it to JavaScript yeah, so This is part of what I want to get across is that like the stuff that we're learning is how to do all these Build all these tools because oftentimes it is the best tool for the job to say hey, you know what man CSS is terrible. I wish there was something better. Hey, I can create something better using the things I learned in 340 to take in a new awesome language and spit out CSS So cool stuff So yeah, that's what so it leaves me in right here. So we're gonna study how These programs the compilers transpilers interpreters are able to translate a high-level program language into something that a computer can understand and so to do this you got to know we're We're gonna be talking about two different things here and so this is also why I really really like this class because We talk about some of the theory stuff, right? So why do we care about theory? I know this is kind of a leading question. So I'll take it. It's like We don't care said someone Yeah, well, we do kind of care, but why why do we care? So assuming we care? Why? You answer a lot. I'm gonna go somebody else no offense Yeah It makes this makes you better in what way better humans better programmers I'd say that's definitely true.  So yeah, that's really good. So yes, it'll make you a better Well, I don't know if directly it'll make you a better programmer. I don't know that you go man I know the formalism behind regular expressions. I'm amazing But I think it helps you Think about those things and specifically I think in this context It helps us to define what we can and can't do When defining or creating a programming language or something we want to interpret or compile, right? So without the theory we just say You'd say well before this took this class You'd probably never hope maybe never think of ever creating a compiler or translator or programming language But after this class you're like hey, that's not magic. I know how those things work I can do my own thing But man this theory helps me know what I can actually do and what I can't do And how I should actually design my language So I can't talk about this. So yeah, there's all kinds of things. So anybody Here of the company called fog Creek software Yeah, some people can raise your hand so people don't think that I'm just crazy. Okay, good So their company anybody actually worked for them. That'd be a long shot, but okay So their company New York they make I think their big thing now is bug tracking software. I want to say and so they For a long time had this big application Written in I think like visual basic which whose programming visual basic Yeah, like one of the worst languages known to man Or maybe you like it. I don't know but My opinion is I do not like visual basic, but they wrote this huge application But their clients kept demanding like we want a PHP You know we we want to host it ourselves and we want to run it on PHP So they have a lot of smart people there They said wow it would be really terrible for us to maintain two versions of this application, right the PHP version and the Visual basic version then when we have bugs in one we have to make sure we fix it in the other and we have To duplicate our test cases. It's gonna be a nightmare. So they actually wrote a Language to compile from I think visual basic to PHP And then they started like improving it and ended up creating their own language to write the web application in and that Allowed them actually to then go from like From their crazy language to now. I think they've completely moved to C sharp So all that was like compilers at each stage Translating and improving for business purposes because it made sense And so yeah, so these you know these are the skills that Are very important and they are powerful and I think they do make you a better programmer Maybe not in your day-to-day, but that time that you're like wow I can create a compiler here This is gonna be awesome And it's gonna save me and this company so much time then you go to your boss and say hey I just saved the company millions of dollars a week. How about a raise? And then it'll be good for everyone Okay, so now I want to talk about some programming languages. So what is this? We can use abbreviations or acronyms for this specific language So for those that haven't seen it before I mean does this look like any programming language that you've ever used or programmed in Yes, you've used this. What's the biggest BF program you've written? Okay, so about this size then Okay So I didn't even write this I stole it offline So yeah, so this is a programming language called I'll shorten it to BF. You can look it up afterwards running this program in a BF interpreter outputs hello world and Because we've taken because I've taken computing theory, right? So you know about turning completeness More or less. Okay, so if you haven't this means that anything you can do in one program language that's Trying to remember the words that is Turing complete you can you can write that program in another language That is also Turing complete. So you BF is Turing complete you could write Microsoft Windows in BF. You could write Firefox or Chrome It would be crazy. I would not you know suggest you do that But you can and so if you want to go there'll be a link here where you can actually run this online with a JavaScript BF interpreter and Kind of what this whole class is about is the mystery behind like how does it go from those? Symbols to actual computation. Yeah, there's a question in the back Okay, forgot it. Okay. What's this nothing? It's my name part of it. It's my name ASU is my name. No The class name is actually a program Yeah, so There's actually a programming language that somebody developed that is Turing complete and this side changed all the spaces to underscores the tabs to slash T and the new lines to slash N and Using these three characters. They created an entire programming language called white space and this program outputs Hello world of spaces That's it. So the other really cool thing is it ignores everything.  So yeah, you can do like double computation. It's kind of cool And yeah, here's a link you can go to check out all The white space interpreter written in a bunch of different languages What about this this language? Python Python 2 right. It's gonna be doesn't have the parentheses. Yeah, so python right So python takes in some input like this prints out. Hello world. What about this? Haskell yeah, good somebody got it Yeah, so this is Haskell code This is a crazy programming language that I really like that We're gonna actually talk about some of its features in the context of this class and What about this?  This is x86 assembly specific for a specific assembler and that outputs. Hello world And so the point of all this is to show you that what like In some ways what you think of as a programming language is kind of arbitrary, right? I mean, it's You could code anything in any language. So Yeah, I guess so are all of these programming languages Yeah, would you actually want to code in all of them? No are none of them programming languages. Maybe I just made one of those up Some people have heard of them. So I need to make up my own specific language and then do that Some of them. Maybe some you'd use they have different purposes But the the point of this class and the whole point is what we're gonna study is how does a Program either a compiler or an interpreter or something. How does it take in? Essentially bytes on one side right raw bytes and perform some output or do some kind of computation In a way that's useful so I like to think of this as kind of a pipeline and so We have source code coming on one Right and that's just made up of bytes and then we have some lexer that's going to interpret those bytes and Generate something useful or something that our computer can understand because we really don't want to be worried about individual bytes, right the whole time So then those tokens are going to get passed to a parser and that job is to create a parse tree So it's going to understand what the program looks like and then we're going to actually analyze this tree to say does it make sense, right? Have you ever compiled the program that? Compiled and then you ran it and it crashed. I Think everybody should be nodding their head if you haven't done that I don't know you'd like the perfect programmer and you should have no problems with this class Right and why is that well because maybe the program wasn't valid or maybe you did something wrong a lot of these errors We can check for it early so we can say it does the type do the types in this system match Does it make sense to add to multiply a I'm trying to find the example. It doesn't work in a like Does it make sense to multiply like a string by a fraction or something like I Think that doesn't work in Python. Python messes up that example, but a String multiplied by a decimal number, right doesn't really mean anything So we should reject that program and then hopefully that outputs some valid parse tree where then some other component can say Okay, now let's compile that let's or let's interpret that or output something else Okay, so we touched on this a little bit So these are kind of gonna kind of be two of the three main things. We're gonna talk about so syntax So what is syntax? So I'm gonna raise their hand. There's too many of you to talk at once. I should get like Yeah, so a strut syntax is how you write the program Rules for yeah, yeah, yeah, so I think of it like what does it mean to look like like what is a valid program look like? Right, so we just don't want any arbitrary like pounding on the keyboard We want to have some well-defined way of what it looks like and who's that for us? Yeah, exactly So us as programmers, so we know how to write a program that at least looks like a valid program What about semantics? Raise this yeah What is what is it actually what was that right? So what does the program actually do? Yeah, so this is I kind of think what does it mean for a program to be valid? So one is talking about what does a valid program look like? Right, and the other one is what does it mean for a program to be valid? So this is where things like type system or defining a variable before you use it and see right those are all under semantics and Before anybody asks the question these kind of do bleed together because you can enforce some semantic things in the syntax But we don't have to get into that too much Especially at this stage of the game What about correctness does not make a program valid does it I don't know I Mean so I think of it is the program the correct one for the job is this program Right for the task and that's kind of a high-level thing I Like to think of it from a security perspective So I always think like does this program have any security vulnerabilities, right? Because that a program with security vulnerabilities is obviously not correct so What I try and like to do is can we write a Static analysis or some kind of tool that analyzes the program and can try to analyze this aspect of correctness, but Doing complete correctness your code is 100% correct It's very very difficult Questions Yeah Yeah, so the question is does it depend on the job in essence?  I I implemented this program exactly to your spec It's amazing and they go ah, you know what that was like three months ago I like I don't really need that one feature anymore Can you like change that and make that font bigger and like put that box over here? And so you have like shifting requirements of what what even is correct? So yeah, it's very very nebulous topic and I always get to the point where it's like, okay If you have a spec that's good enough that you can mathematically verify that the code matches the spec Well, then you're just going to verify if your code has any of the bugs in that spec So I have to write things exactly right twice You have to have a spec that doesn't have any bugs and an implementation that doesn't have any bugs And I guess a checker that doesn't have any bugs Unless you use it you use it to check itself and then you get into whole your head explodes and Any other questions?  All right, I guess we'll stop here and We'll see each other on Wednesday