I think we're going to get started in about a minute or so. And the mic's off. All right, I think we're about to get started. There's my microphone on. All right, I think we are ready to get started here. Before we actually dive in, a quick show of hands. Who here has no idea what this functional stuff is, and they're here to figure out what I'm talking about? OK, who here knows what functional programming is, and is here to figure out how in the world it applies to PHP? OK, so about evenly split. I think I saw some people raise their hand twice. Who raised their hand twice? Yeah, I knew someone had. OK, so let's dive right in. Thank you all for coming. The second session is functional PHP. A bit about me. My name is Larry Garfield. I'm a senior architect at Palantir.net, for a Drupal development shop based in Chicago. I'm an advisor to the Drupal Association, one of the initiative owners for Drupal 8, co-author of Drupal 7 Module Development. And I talk a lot about software architecture, and shoot my colleagues with Nerf guns. That's basically what I do during the day. At Palantir, we do mostly institutional not-for-profits with Drupal. So Journal of Foreign Affairs is one of our sites. The Field Museum of Natural History in Chicago. It's a very large museum, all Drupal now. OpenSource.com, which is run by Red Hat, a partnership between us and Acquia. How many Americans are there in the audience at this point? OK, so a few of you know what I'm talking about these places, Marketplace. That's the kind of work we do. That's kind of my background with Drupal. But here we're talking about functional programming, which is not a Drupal-specific topic. So there's going to be very little Drupal in this session. I'm going to warn you right now. This is going to be a kind of heavy session. Please bear with me.  So I'm going to try and annoy both groups equally. So let's set the way back machine for the early history of computer science, as we understand it today. And a man named John Van Neumann. John Van Neumann was an early mathematician, physicist, computer scientist, and all-around insanely smart person. Among other things, he was responsible for set theory, operational theory. He was involved in quantum theory that he actually considered that his greatest contribution. He worked on the Manhattan Project. He's just way too smart for us to not all know who he is. But one of the things that he is credited for is something called the Van Neumann architecture. The Van Neumann architecture is basically the way all computers work. So you've probably seen a diagram like this at some point. A computer consists of some kind of processing unit, some kind of memory system to store information, and input and output, all connected via this data bus. Every computer you have in this room works on this model. Basics of the Van Neumann architecture. A program is just data. This is the concept of stored program. This is one of the fundamental building blocks of computer science as something that you can use a keyboard for instead of a screwdriver. A program is simply a series of steps. That's all it is at a basic level. Those steps execute in linear sequence one after another. And the purpose of those steps is to alter registers in memory, places in memory that hold some value. The purpose of a step in a program is to change state. One of the things that you can change is what that next step is so you can have flow of control. So if the value in this register is something, then the register that says what the next instruction is to some other value, and you can jump around like that. That's assembly. Who's actually done assembly of some form? Wow. Who's done assembly not in school? Much smaller group, I thought so. This is the concept of imperative programming. By imperative, we mean like the imperative mood in a human language. Go here, do this, change that, say this. That's that type of programming. It's just a series of commands for the computer, a series of very precise instructions that are carried out in order. And you have state. State is those memory registers. They are values that change over time. And the reason you have the program is to change that state. Every single computer today works on this model. Everything we do, every programming language, is syntactic sugar on top of that. Imperative programming conceptually is following a recipe for a cake. You have this bowl that is your state, and you say, OK, add this ingredient to it. I've changed my state. Add this ingredient. I've changed my state. Mix it. I've changed my state. That is imperative programming. Procedural programming, which we should all be familiar with if we work in Drupal, is really just an evolved form of that. Introduces the concept of a procedure, which is a reusable series of commands, sometimes called a subroutine, depending on the language. And when you have this reusable set of commands, you can do more complex things with it. You also get structured programming, which are these very familiar control structures, so that you can logically say, if this do that, do this X number of times, rather than playing around with if this value set the jump register to this thing. Because really, who wants to do that? I thought so. So very simple procedural program here. We have some variable that's a list of numbers. We want to find the biggest one, so we have that variable. We define a procedure that just modifies and checks these values, and we call it, and then we can print the value. This is your fairly basic procedural program. Older programming languages work exactly like this. This is not a syntax from an existing language as far as I'm aware, but they all work essentially the same way. So if imperative programming is following a recipe for a cake, procedural programming is like singing a song, where you have a refrain. Do these things, and then call the refrain. Say these things, and call the refrain. This is all just the concept behind how most programming languages that we use work. When you're dealing in imperative programming, your job as a programmer is to define how a program works. How being the key word there. You say exactly what the program will do when, and the program does it. And it's up to you to not screw up, because the program will do exactly what you tell it to, which is the problem. Contrast this to a different approach to programming, declarative programming. Pretty much everyone in here, I'm going to bet, has done some declarative programming. Who here has written an SQL? Declareative programming. You are not saying how the database should go about joining tables or finding values or aggregating things. You say what it should do. You're telling it, find me this value out of this column when this is true from my data set. Just go do it. And then it's up to the program to figure out what that actually means in terms of moving memory registers around. You're not concerned with that. That's not your job. Your job is to think at a higher level. This brings us to our next super smart person, a man named John Bacchus. You may have heard of him, or may not, but he is most notable for, among other things, inventing Fortran, one of the first programming languages, first high-level programming languages. And as penance for inventing Fortran, he then spent the rest of his career coming up with good ways to write programs instead. So he is, for instance, one of the people behind Bacchus in our form. Does anyone remember that from school? OK, it's that guy. This is a standard way of defining the syntax of a programming language. He was one of the people involved in that. He was one of the co-developers of ALGOL, which is another tool for defining algorithms in a way that makes sense. And in 1977, when he was accepting a Turing Award, he presented a paper on functional-level programming called Can Programming Be Liberated from the Von Neumann Style? Functional Style and Algebra Programs. Now, he did not invent functional programming. The concepts behind functional programming had been around for a long time. They go back to advanced mathematics from the beginning of the 20th century, lambda calculus and such, which I will not mention again. That will not be on the test. But this is really when the concepts started to become popular. List people will argue that list-invented functional programming, but then list people consider lists of invented everything. Functional programming is a kind of declarative programming that is based on algorithm-first thinking, not steps, algorithms. In functional programming, you simply declare what the algorithm is you want to use. And then it's the job of the compiler to turn that into a series of steps. And when we say functions here, we mean functions in mathematical sense. PHP functions and what most languages we're used to call functions are actually subroutines. They're procedures. And you can use them as mathematical functions, but most people don't in practice. Functional programming is built on this different definition of the word function. Functional programming is built on a couple of concepts. Pure functions. Pure functions are functions that have all the properties of a function that you remember from math class in school. Higher order functions and first class functions. Technically, slightly different things, but for our purposes, we're going to say they're close enough that I'm going to refer to them as the same thing. These are functions that you can treat the same as any other variable. A variable can be a function. And you can then, therefore, pass it to other functions as you can any other variable. Immutable variables, that is, once you set the value of a variable, it does not change. Think about that. A variable you can only set the value of once. That's weird. But actually can be very useful at times. And of course, recursion. Let's talk about each of these. Pure functions. A function is pure if it has no side effects. That is, when you call it, the only thing that changes as a result of you calling it is you get back a return value. Nothing else changes. Nothing is printed to the screen. Nothing is written to the database. No global variables have changed. No values in the input objects have changed. Everything is a very explicit input and a very explicit output. Very clearly defined what your parameters are and what you get back. They are stateless. When you call a pure function, then call a pure function again, that the first call to it has zero impact on the second call. And you can guarantee that. You know this for a fact if it is a pure function. All it does is take input, give output, period. That's a pure function. As an example, you can do a theme function that is pure. This is not quite what theme list looks like in Drupal, but it's a viable implementation of it. You get in two variables, an array and a list. Neither of those changes as a result of this function. There's no globals, there's no state retained, there's no statics, and you return a string at the end. That's it. You can call this function 1,000 times, and it will have no impact on the 1,001th time you call it. You can call this function 1,000 times, nothing anywhere else in your program will change, guaranteed. That is a pure function. Now think about that, a function where you know that there's no side effects. You know it only depends on the things you know about. That actually makes testing really easy, doesn't it? Or it can. Testability is one of the main benefits of pure functions because you know you don't have weird side effects you need to keep track of. There's no global states to worry about. They're inherently thread safe. Now this doesn't matter in PHP so much, but in many languages that have pure functions explicitly, the language interpreter is able to make optimizations and say, this function, I know I can break off and run in a separate thread. I can break off and run on a separate CPU. I can run on a separate computer if it's a distributed program, and you know that's safe to do. Again, PHP doesn't use threads, but conceptually it still frees you from a lot of, wait, what's the side effect of this? What's this going to do over here? Is this going to break this thing? If it's a pure function, you know it's not going to. It's only going to break things that depend on its return value. They're fairly self-evident. If you look at a functional program, you know everything that goes into it. That function we saw a moment ago. Those six lines or so is all there is to know. You can wrap your head around that and not worry about what's this global state happening over here and does this matter what the input value was? No. You have this little black box, and that's the extent of what you need to know. They're also idempotent, which is the fancy academic way of saying if you put in one value and get a result, if you put in that value again, you'll get the same result. You're guaranteed that if you call this function with 5i, a string i, and you get back 17 through whatever that magic algorithm is, you know for a fact that the next time you call it with 5 and i, you'll get back that same value. You know this, and you can prove this. And that turns out to be really, really powerful. First-class functions. Functions as a variable. Therefore, functions can be a parameter to another function. So you can pass a function to a function, and it can then return a function. We here's worked in JavaScript as well. JavaScript does this all over the place. Oops, there we go. Example, yeah. In PHP, as a 5.3, you have the ability to have functions you can pass around. So this variable here, dollar function, is a function. And you can pass it wherever you want, like any other function. And you can call it at any point. We'll get back to these. They're really, really nice. Benefits, for the OO people in the room who I think are an increasing number, you know strategy pattern? OK, really, really easy because you pass a function to a function, pass function A to function B, function B calls function A. That's strategy pattern. That's the entirety of it, wrapped up there in two functions, each of which can be one line long if you want. You can do some really cool things with partial evaluation and curing, and we'll get back to this in a moment. And you can also do lazy evaluation because you can declare a function and then use it sometime later, but not actually use it if you don't need it. Immutable variables. These are simply variables that are not allowed to change. If you want, but if you have a new function, then they have a new value there. So for example, if you have a language that has immutable functions, which PHP is not, so don't get too worried, then the way you would change something, change a value, is you call another function with a parameter of that variable plus five, or whatever. And when you're doing, when you're thinking in algorithms, not in steps, that's actually really easy to do. That's a natural way of doing it. Benefits, you don't need to worry about the value changing off from under you. If once you know it has this value, you know it's not going to change. If you actually know that, then the engine, the compiler, can do some optimizations and not copy data around. It just moves your references. So you can actually, in a purely functional language, get some very good performance and memory optimizations by the fact that it can make assumptions about what you're going to do. And that can save a lot of memory. And it forces you to think in a stateless way. It forces you to think algorithmically rather than change a value and change it again and change it again and change it again and change it again and oh wait, what happened? Yeah. It forces you to not fall into that trap. Recursion. Now everyone here understands recursion, right? Okay, then you understand recursion. All recursion is, is a function that calls itself. It recurses on itself. And you can use that actually to replace loops. There are programming languages that do not have loops. All they have are recursive functions which actually can do everything a loop does. So kind of the canonical example here, computing a factorial of a number is, one factorial is one, factorial. People know who that is actually? Factorial. Is a mathematical operation. What's that? They don't know it's a number. Yeah, you may remember this from middle school. So fact of number factorial is a number times all of its smaller numbers. Five factorial is five times four times three times two times one. 10 factorial, 10 times nine times eight and so forth. So any number factorial is the number one less than it, factorial times the number. So we define it exactly that way. One factorial is one, anything else is that value times the next thing down from it. And so in six lines, and I'm being verbose here about it, we have that entire algorithm. And we have a termination, so it's not gonna go into an infinite loop. This turns out to be extremely common in any kind of programming that is not purely business logic. You end up with this kind of problem space. Benefits of recursion. Divide and conquer. Probably the most important rule that any programmer can follow. The way to approach a problem is to break it down to smaller problems that are dead simple to solve and then build it back up. With recursion, what you typically are doing is taking a problem and slicing it into a smaller piece and solving that piece. By slicing it into a smaller piece and solving it. By slicing that into a smaller piece and solving it. Very, very common approach. And many languages, PHP not being one of them, unfortunately, can recognize when you're doing that and translate, tail recursion, where the last statement in the function is a recursive call, into an iterative loop approach down in the compiler. Which means that it's really fast, but still really easy for you to debug because you can just look at the algorithm and see what it is. You don't have to deal with implementation. You're just like a definition of the algorithm. And it can be stateless. Why is stateless important? Stateless is important because state is the number one source of bugs. State is the number one source of bugs because keeping track of state is hard. State messes with your logic. Debugging logic, when you have lots of state messing with it, is hard. If you can eliminate all of these variables that are changing the way you're going to behave and just deal with the algorithm, it's a lot easier to wrap your head around what's going on. It means you're more likely to run into an error that is a syntax error than a logic error you need to step through a debugger for an hour to find it. So let's put all of these together. A canonical example for functional programming and recursion, I believe in tradition. The Fibonacci series, which is yet another one of those mathematical things you learned about in school and probably have since forgotten, which is just a series of numbers where each number is equal to the sum of the previous two numbers. And I never had any idea what that was useful for, but apparently it's actually very useful in fractal research and it shows up in nature a lot. So botanists use it, which is kind of bizarre. But okay, let's define it that way. So if A is zero, then that's the zero-width number. If it's one, then it's one. And for anything else, it's just A minus one and A minus two added together, which is exactly the definition of this series. And so you want to know the fifth Fibonacci number? Okay. We calculate that by getting the fourth and the third. And we calculate the third by getting the second and first and so forth. And you have a very simple, straightforward piece of code that you can look at and know exactly how it works. It's pure. There's no state change going on here. If you actually can guarantee that all of these things are true, which this has, there's a lot that you can then do in the compiler or just in your own head in terms of optimizing how you think about a problem. So if imperative programming is following a recipe for baking and procedural programming is singing, functional programming is plugging values and formulas into a spreadsheet. Think about it. We've all used spreadsheets, right? Excel or Google spreadsheet or whatever. You simply put in, you know, the value in this cell is equal to the sum of the value of these cells. You don't care how those get added up. You just care that it's equal to that sum. Same in this column. And then this cell over here is these two numbers divided by themselves. And when you change some input, it just updates. You don't need to concern yourself with what order things update in. You don't need to concern yourself with maintaining state of the addition process. You're just declaring this cell means some of these others. This cell means these two cells divided. It's a lot that you don't have to worry about that way. There are a lot of languages that are built on these concepts. So for instance, ML is one of the older languages. Haskell came out, I think, in the early-mid-'80s originally. It's still around. Very popular in purely functional circles. Erlang is one of the few programming, functional programming languages that people actually use in production. One of the most popular Java servers is actually written in Erlang, eJabberD. Erlang was developed originally by Ericsson to run network switches because it then can be massively parallel. The programmer as an author doesn't care how parallel the program is because every function can be its own thread. In fact, you can replace functions at runtime without shutting down a program in Erlang because of all of these restrictions. Because you know it's stateless, because you know that function is not going to affect anything else. So if you find a bug, you can fix it in production after testing it, of course, but you can upload, you know, your fixed-to-production and load that new component without shutting the program down and nothing breaks. That's really important when you're running a network switch that's carrying 5,000 voice calls a minute. There are a lot of others, too. And you're probably never going to run into any of them in practice because as you saw, most of these examples are mathematical. They're very academically oriented, and that is where most purely functional languages are. This has been changing a bit more recently because when you get right down to it, if everything you have is pure, then your program doesn't do anything. If your program cannot generate output, it's kind of a useless program, right? Most functional languages, therefore, have introduced little gaps in these rules where you can carve out and say, okay, this part of my program is not going to follow these rules so that I can actually have input and output here. And you also have a lot of traditional imperative languages that have been adding functional components to them, saying, okay, I want to get something done, but this actually is kind of useful. This approach is valid. I just need to still be able to break out of it. So you've been having in the past couple of years these two families of language kind of head towards each other. They're starting to converge. And PHP is one of them. You can do everything we just talked about in PHP. You don't get the full benefits of doing so necessarily because the PHP engine doesn't take advantage of it automatically, but you can still take the mental advantage of it. PHP doesn't enforce it, but you can. PHP is as functional as Lisp. I just pissed off all the Lisp people in the room, I'm sure, in that you can do things functionally if you want to. And you can do things procedurally if you want to. And you can do things object-oriented if you want to. And you can mix and match these techniques depending on which makes sense in your use case. This is one of the nice things about PHP as a language. I know it's fun to rag on PHP, but the fact that you can mix and match these different approaches effectively is really, really nice. So let's have a look at how this works. PHP 5.3 introduced anonymous functions. And they work like this. This value equals the function keyword with no actual name that takes these two parameters and does whatever it's going to do. So in this case, we're saying, you know, are these two card objects a pair? And then you can call it just like any other function.  Okay? Now, the way PHP does this is kind of interesting. And purists will tell you that PHP is not truly functional because of the way it does it. I say, meh, it works. Internally, what happens, PHP translates this into this. So as of PHP 5.3, all classes can have an invoke magic method, which gets called when you call the object with, you know, as if it were a function. These two are exactly equivalent as far as the PHP runtime is concerned or close enough to it that we don't need to worry about the differences. Actually, there was one subtle difference. You don't need to worry about name collisions because it's actually anonymous. It's whatever your variable is called. So you don't pull out your namespace with this extra class name. Closures. People argue about this all the time what qualifies as a closure. I'm going to go take this approach. A closure is when an anonymous function references stuff from outside it. So in this case, this is just straight PHP syntax. Use wild while being this card. Okay. That makes wild available in the scope of this function.  In JavaScript, it's implicit. If you use a variable name that is defined in the parent scope of where that function is defined, it just gets bound to it and used magically. In PHP, you have to specify it explicitly.  I actually think this helps avoid security issues, the kind that plague JavaScript all the time. But whatever your opinion, this is how PHP works. And then this is functionally identical to this. Wild. Use that as a growing the constructor. And then when you invoke, you just call this wild. Okay. This is eight lines of code. This is 17. This, you're going to need to create an extra class for it. This, you don't. It's effectively just an easier syntax around the system on the bottom here but lets you think about things in a cleaner fashion. If we have first class functions, functions that can be past the functions, you can nest this kind of thing. So, let's say, is this card a wild card? We're just comparing those two. So now we have this anonymous function that is bound as a closure over this variable. And then our find pair as a closure over is wild. So what happens when we call find pair? Well, find pair takes two arguments and compares those two values out of those and then it calls that function and checks that and then it calls that function again with a different input. But this knows nothing about what the wild card is. This function does, and that's all we need. Cool? Cool. Another advantage is, as I said, delayed execution. Let's say we have a class called container and we use PHP's magic get and set functions on it. And I can go into how those work, but if you don't specify, if you define these and then use a variable, a property on an object that is not set, these get called instead. Okay. And so we say con is equal to this anonymous function, which takes one parameter. Okay. This function, which just returns this array. So we've assigned these into this array here. So when we call container con, that says, okay, get that anonymous function out of that array and call it with this object, which means that C is that container and then we can reference con info, which calls back to that, and we can now instantiate our database connection only when we're about to use it. You've all heard me talk about dependency injection before, at least a lot of you. That's all it is. 11 lines of code with white space. Anonymous functions are very, very powerful when you use them properly. If you want to see this technique in more detail, have a look at pimple, which is a very small dependency injection library written by Fabien Pontoncier, who's our Thursday keynote speaker, which is built on exactly this principle. It's actually more advanced than this, but not by much. It's less than 100 lines of code, but it really exercises anonymous functions in PHP very, very well. Lexical scoping. We were talking about using use before. This is where it comes in handy. To take some array of values and call a function to all of them. Well, array map. It's a very easy way to do that in PHP, and you pass it the name of a function. Okay. And if I want to do something other than double, I now need to define yet another function. So I need to define statically every function I might possibly need. That's gross. Well, we could set a global, and then have multiply just grab that global value, and if you do that, I'll shoot you. This is terrible. I think we've gotten most of these out of Drupal, I hope. Or make it easier on yourself. You can use an anonymous function in almost every place you can use the name of a function. So we say, okay, array map that function. So take that array and apply this anonymous function to every single value in it, and get back the result. And use factor in there. So whatever that is, we now have a function that can multiply by anything on the fly, and we've not polluted our name space. And it's even fewer lines of code than the other things are, too. This is an example of where we are, in fact, using this in Drupal. I copied this out of Drupal 8th this morning. So one of the things we're doing in Drupal 8 is switching to a simply based router to replace the menu system. But we haven't converted all of our thousand or so menu items over to it. So we need some way for them to keep working in the new system. Okay. We've already got the system set up here. So if we've ignored this stuff for a moment, the symphony-based stuff, we can get the information about the menu item. And then if the controller, page callback, is a function, then replace it with an anonymous function. That will call that function. Why in the world would we add that extra wrapper? Precisely for this reason, so that we can get this information where we want it. As an example, the reason we did this is just trying to pass through normal functions as is when we were porting the system over. We got about 40% of page callbacks broke because of just quirks in the way they worked that didn't map to the way symphony worked. We can just grab all of the arguments and show them in here cleanly, and everything suddenly worked. This is a five-line backward compatibility layer that is very fast and keeps all of the people working while we build a new system. It brings us through currying, which has nothing to do with Indian food whatsoever. I apologize.  Actually, it's just named for Mr. Curry, who is also the person that the Haskell language is named after even though he apparently hated his first name, go figure. I'm not going to go into too much detail on him other than to say yet another one of these crazy smart mathematicians that very few people have heard of, which is very unfortunate. Currying is simply splitting a multi-parameter function into a series of single-parameter functions that get called in sequence.  There's various reasons for why you would want to do that. I'm not going to go into detail on those, but this is just a special case of partial application. Partial application meaning halfway call a function. Halfway call a function? Sure. So let's say we've got a function that adds two numbers. We could also say, I want to be able to add one number to this, to a lot of different things. So we have a function add whose sole purpose is to return another function that adds a single value to stuff. So when we call add one, we get back a function that will take whatever is past the it and add a to it, a being one, because we have a closure over that value. Another one add five, this will add five, because in this case this is a separate function, separate object, separate instance, separate anonymous function that's bound to a different value. And then we can call add five and it will add five to whatever we want. Eh, this gets interesting when you then are able to preconfigure functions. So instead we have an adder that we say, okay, I want to be able to add some user defined value to all of these and practice something, you're going to do something a bit more complicated than that, but let's keep it simple. And now you have this function without the overhead of a class, without the overhead of loading, without the overhead of any of this other stuff that people are resistant to. And you can now call this on whatever you want to get back that value and get dependent on that user-supplied data. Make sense? You can also then use that anonymous function in things like ArrayMap and say, okay, cool. I want to take everything and apply some operation to it, but that operation depends on some configured value. Memoization. It's another fun, fancy academic word. Memoization is really a fancy name for caching results. I'm sure there's some better academic term for it, but really that's what it is. And this works only on pure item-potent functions. You get the same input. You get the same output every time. You can take advantage of that fact and optimize your code. And in Drupal, in fact, does this all over the place. Who has seen this code in Drupal somewhere? We've got, you know, passing some value. We have a static cache of the values. Compute them and then return that. And the next time we call it with that value, we just say, oh, it's already in the array, so we don't do any of this expensive stuff and just return it. You've all seen that somewhere, right? That's memoization. Kind of a poor man's memoization, but that's memoization. It's really all it is. Unfortunately, we usually do that around stateful operations like database lookups, which means that we run into really bizarre caching problems when we use the system in ways we don't expect, like unit testing, but that's another issue. But you can memoize a function externally as well. Languages like Haskell will do this automatically. In PHP, you have to do a little work for yourself, but it works. What do you imagine happens with this code? This is an anonymous version of that factorial function we saw before. So we say, okay, this function would use it itself, and therefore it takes itself by reference, so that this is how you can recurs an anonymous function. And we print out what we're about to do, and then have that exact same logic as before. What do you think happens when you call this twice? Well, we get a lot of useless runs of this code, because we call it, you know, three factorial, which calls two factorial, which calls one factorial, and then four factorial, which calls three factorial and two factorial and one factorial.  I have tested this, this does work. If you have a memoize function, which takes whatever function you pass in, and you say you use it, so it's available in the scope, and we just wrap that same static logic around it, you can now take any function, including sometimes recursive functions, and cache its results externally. So now, we don't bother calling three and two and one multiple times, we just call four, and then three is already cached and we're done. That's cool! Does anyone else think that's cool? Okay, someone raised their hand. I thought this was cool when I realized this was actually possible. This works on any normally defined function, a names function. It works on anonymous functions. It works on anonymous recursive functions if the function is still in its declared scope when you do so. So it's a bit tricky there. This does in fact work if it's all in one file together, but I have tested it. You can in fact memoize any function this way, or any non-recursive function. It's biffy! And then you can pass this memoized version around and call its, as if it were the original function, always get the caching.  Cool! Pure functions are awesome. Really. They allow you to do a lot of really cool things, even if the engine isn't taking advantage of it. You can. The key, though, is separating your logic from your I.O., because I.O. makes things impure. So if you want to take advantage of this kind of technique, this kind of style programming, you have to separate your logic from your I.O., which really you should be doing anyway. Even if you're not doing any of this stuff, you should still be separating your I.O. from your business logic. There's a couple of other things that are functional style techniques that you can, again, do in PHP. MapReduce. Who's heard the term MapReduce before? Okay. I see you grinning at me. MapReduce is useful for embarrassingly parallel problems.  It contains two parts. Map, which is take a problem and divide it up into identical sub-problems that are independent of each other. And then distribute those to separate workers. Separate workers could be separate threads. It could be separate iterations. It could be separate computers on different continents. It doesn't actually matter conceptually. Because they are independent of each other, because those are pure, the code for you is the same either way. And then reduce, which is, okay, take all of those results, combine them back together in some logical fashion, whatever makes sense in your use case. This is really useful for epically huge data sets, say Google Search, or Parsing Twitter, or other problem sets along those lines. And could get very complicated, depending on your use case, or in PHP, that's what ArrayMap does. Who's used ArrayMap before seeing it in this presentation? Yeah, that's MapReduce. Not a very complicated MapReduce, but it's MapReduce. ArrayMap takes some kind of callback, which can be any callable, which includes anonymous functions, and then an array. So we call it ArrayMap, your logic here in the array. And whatever that array is, that function gets applied to every element, and you get back an array. PHP is not actually going to break it out into separate threads, but you can still conceptually think about it as separate problems. Inside this anonymous function, you deal with only a single value at once, and that lets you zone in on that one problem space. ArrayMap also lets you pass in multiple arrays and get back a single array. So it's a trivial example. Pass in two arrays, add the corresponding values and add the zero with value to the zero with value, first value to first value and so forth, and get back a single array. Conceptually, then, if the PHP developers ever actually managed to parallelize that within the PHP engine, your system would suddenly get faster. You don't have to think about iterating and combining and foreaching, and which array is which, and what's my I offset and so forth. You don't have to worry about any of that. You just deal with this function, and you can get back a single value or with these two values or whatever. Accomplish is the same kind of thing as foreach, but it lets you separate the looping logic from your business logic. And any time you can separate out two different things, it's good. It is slightly slower than doing a foreach, but unless you're running XDbug, it's close enough that it doesn't really matter. If you're running XDbug, function calls get very expensive. So if you're going to benchmark this turn off XDbug first. Fold. This is the academic definition of fold from Wikipedia. Analyze your recursive data structure and recombine through the use of a given combining operation the results of recursively processing its consistent parts building up a return value. I don't understand that either. Iterate over a list and turn it into a single value. That's fold. Take big list, crunch down to single value. And you do that stepwise. So let's say you want to have a sum. And simple mathematical examples. We could do it this way and say, all right, keep track of our results and iterate over this array and just add it up that way and keep changing the result. Or we could use array reduce, which takes an array and then a function, which is backwards from array map because PHP can't get that right to save its life. And so we say, okay, grab this initial value and then starting from that initial value, turn through each item in the array and return the new result that way. Make sense? This is an operation common in functional programming in functional languages that we can do in PHP today and have been able to do for, I think since PHP 4 or so, filter, reduce a data set to relevant elements. Well, that's kind of what the name means. Filter, take this long list and drop it down to the list I care about. It's very similar to the map operation in that you can do it in parallel. And the PHP is the array filter function, which, again, takes an array and then a filter, which is the order that array reduce does, not the array map. It's PHP. What do you want? What's that? Array map takes multiple arrays, filter, I don't believe does. The concept of, you can do it in parallel still applies. So we say, all right, we take this array of values and apply this function to it. That function returns true or false. If it returns true, whatever that value is should be in the result. If it returns false, it doesn't. Most common use to this, if you don't specify a filter function, then PHP just casts the value to a boolean. So if we have this string, if this array, 0, 4, negative 4, some string, false and null, let's see, in PHP, that's false, that's true, that's true, that's true, that's false, that's false. Array filter. We just get back the true ones. Easy. Where is this useful? Oh, I don't know. Multiple checkboxes where you get back an array that is ID equals ID or ID equals 0. But you don't want to save the whole thing. Call array filter on that, boom. You get down to just the values that actually were checked. One line of code. Cool. If you want to do something fancier, provide your own function inline like that so you don't need to pull out your namespace. The code is right there where you can see it. You know what your entire algorithm is. Neat. Key takeaways. I hope you get from this session. Pure functions are awesome. Mostly. There are plenty of places where it just makes your life more difficult. Mathematically, it's been shown. Imperative programming and functional programming are equally expressive. There is no algorithm. There is no program that you cannot write in either of them. It's just sometimes way easier to do it in one or the other. There are plenty of cases where doing something in a procedural fashion is way easier than functional. There are also plenty of cases of doing something functionally and it's way easier than doing it procedurally. In PHP, you get to pick and choose case by case, depending on what makes sense for you. To do that, separate your pure functions, your pure routines from your impure ones. That's just good practice in general even if you're not doing anything functionally. Even if you're doing all-o-o, the same concept applies. Separate out your data and your logic and your I-O. People will tell you that PHP's anonymous functions are not real anonymous functions. PHP is not really functional. Whatever. I ignore that. They're cool. They are powerful. They're even more powerful in PHP 5.4 where you can, in fact, bind them to an object. So you can use anonymous functions to add methods to an object at runtime, which is just slick. And try to think logically, not in terms of state. Think of your algorithm. Think of what you're trying to accomplish, not the nitty-gritty details you don't want to get trapped at that level. Think at a higher level. Think in terms of logic and algorithm, which can be difficult if you're not used to it. Try and force yourself to think at that higher level first and then dip down further if you actually need to. Functional programming is not a language. It's a methodology. It's an approach. It's a thought process. It's a state of mind. It's the way you go about solving problems. And you can use that methodology in PHP, effectively. I think we've got about seven minutes for questions, and then please rate the session online. I think there's a microphone around here someplace. Where's the microphone? There's a microphone here somewhere, I think. No, just yell out a question. Any questions? Yes. The question for the recording is when you use a variable in an anonymous function, can you write to it? There are other ways you can do that. If you just specify the variable name, then it passes by value the same way as a function parameter, which means that if it's an array or a primitive and you modify it, it's a new instance so it doesn't affect the parent scope. If it's an object, then they're both handled to the same object so it will. If you pass it with an ampersand, then it passes by reference, or you use it with an ampersand, it passes by reference, and then it's exactly the same as a function parameter again. If you modify it, then it is the same variable. You can go either way with it depending on what fits your use case. Other questions? Yes. The question is that if you call an anonymous function repeatedly, does PHP recompile it? Not as far as I know. My understanding, someone who has been inside the PHP engine, please correct me, is that the file step turns it into that class-like implementation, so it's only parsed the one time and then it has some garbage internal only name. So, yeah, it should not recompile that every time. That does happen if you're using the create function commands, which is how you use to define functions at runtime before 5.3. Dear God, never do that. And if you use eval, it will recompile it every time. Anonymous functions avoid that problem. That's one of the reasons why they're so nice. So, with anonymous functions, eval and the create function should both be purged from your memory. There's another question here, I think. Someone? Where are the plans to integrate these kinds of things into Drupal? My position at this point is anonymous functions are a tool. Use them where appropriate. If you find some place that they're appropriate, go ahead and use it. If you find some place that they're totally not appropriate, don't use them. Anonymous functions in particular, you know, we are using it a few places right now in court, not many. I have, in fact, seen client code that clients of mine have written where they use anonymous functions as a form callback, a submit callback. That does, in fact, work, which kind of surprised me, but it does. I haven't done that myself, but it does make sense for you. The concept of, you know, pure functions and pure routines and so forth, you should be doing, just as a matter of course, in your programming, Drupal or otherwise, trying to think in that mindset. As far as I know, there's no big anonymous function everything in Drupal like there is with object orientation, and I don't think there should be. But if they fit the problem space and they do what you need them to do, go ahead and use them. We're introduced in PHP 5.3, Drupal 7. You should be running on PHP 5.3 anyway at this point because it's much faster than 5.2, and Drupal 8 is going to require PHP 5.3. So, yeah. The official requirement for Drupal 7 is PHP 5.2, which does not have anonymous functions. If you use anonymous functions in a module, declare a minimum version, and then people have to have 5.3 in order to use your module, which is fine. Plenty of modules did that for requiring 5.2 back in Drupal 6. Yes. So the question is, given this, what's the future of procedural code in Drupal? My expectation is that through Drupal 8 and Drupal 9 will become predominantly OO and use anonymous functions where they make sense but not as an integral core part of the entire system because we're not JavaScript, and that doesn't really make sense to do just the way the language works. Even in JavaScripts, you can get carried away with anonymous functions too if you're not careful. So I don't see Drupal turning into this big all-anonymous function framework. I would again be against that myself. So for readability, is it better to declare a function and then make it a parameter to another call or to inline it? It depends on the use case. If that's the only place you're going to use it, I usually will go ahead and inline it. But to a large extent, that's kind of stylistic. If you have a large array, do you inline it into a function call or do you make it a separate variable and pass it in? Case by case, whatever looks most readable. I usually, like with an array map or something like that, I will usually default to inlining it. But I don't think either way is wrong. Uh-oh, checks. Yeah, so this point, just because we have anonymous functions doesn't mean we're going to turn all functions in Drupal into anonymous functions. That would be a very bad idea. Possibly so. If most things in Drupal are classes and some are anonymous functions, what do we do with the remaining named functions? We'll figure it out when we get there. We're not to that point yet. Any other questions? Back there? Okay, so I'm going to be focusing on different programming paradigms, functional or procedural or OO. Conceptually, I'm okay with it. A system should probably have kind of its primary paradigm and Drupal traditionally has been primarily procedural. Drupal 8, and definitely by Drupal 9, I think would be primarily OO. But, as I said, if anonymous functions are the best way to get something done, if functional programming is the easiest way to use it, if that means you have an anonymous function that you're defining inside an object somewhere and then passing off somewhere else, okay, it works. I'm not a purist and pedant about which one you're using. I just want you to use one that makes sense, has the best


Alrighty, I actually have a construction update on the new ride at Canada's Wonderland. So markings have appeared and they are definitely marking where the support columns are going to go for this attraction. And when you see where they're going to go, you actually can see exactly where it's going to swing. There's one support column that's going to tuck in between a support column of Yukon Striker and the track. It looks like a really tight fit. But when we mapped it out, it honestly will work. And it's going to have really close calls with Yukon Striker, that swing radius. So that ride's actually going to be pretty sick. But yeah, pretty surprised that we're seeing construction markings pop up for flat rides. Wonderland usually starts flat ride construction in late winter, early, early spring. And it just pops right up and they're good to go. So it's weird to see that. And not construction starting on the new coaster, just more markings. For those of you that don't know, Riptide always shuts down early in the season. So this is them just packing Riptide up. Nothing new going on there. They're just packing that ride up and putting her to sleep until spring next year. So yeah, I just thought that'd be cool to film for you guys. Trying to think if there was anything else. Oh yes, Haunt Prep. So there's actually a lot. You'll see the new restaurant. We got to somewhat experience the bar and all that. But this is where Vampire Disco is going to go. They're getting that ready and set up. It looks like it's going to be the new Vampire Disco and not the old one. Not Silent Disco. And the new Haunt Store is looking really good. These windows actually have like holographic like TV screens that look realistic, especially at night. At the end of the video, you'll see the night versions of those. But that was really cool. I really like their Haunt Store. I love the stuff that they sell. So I'm super excited about that. But let me rant about Wonderland and they're theming right now. I absolutely love the Haunt Decor. I shouldn't say Haunt Decor. It's more so Fall Decor and this new restaurant. The new restaurant is honestly so stunning. The amount of like the attention to detail that they put into this thing. The sign. I rave about Wonderland's sign team like all the time. But the sign department at Canada's Wonderland is insane. They knocked it out of the park again with that new entrance sign as you just saw. The stained furniture that was stained at Canada's Wonderland looks amazing. The restaurant looks amazing. The detail to just covering up the conduit. The wires inside the restaurant. Amazing. The little critters that are scattered all over the restaurant. Amazing. The theming. Amazing. The themed restrooms. Amazing.  It looks like this restaurant's going to introduce little kind of like tidbits. Nothing like significant but little tidbits to the rides in the park. So just honestly like as you can hear my voice I am so impressed. Now it is up to the food department to knock this restaurant out of the park. Okay because the menu looks good. Okay I have a few questions about some of the sides but that's just nitpicking and that's being a Karen. I will put my opinions on the sides aside. But look at this restaurant. Look at it. Look at it. It's amazing. Like oh my goodness. I was not expecting. I was expecting a nice restaurant. I wasn't expecting this much attention to detail. This is so Wonderland taking a step in the right direction.  Whoever is in charge of decor at Canada's Wonderland I'm assuming it's a sign department or carpentry. Something some department along those routes. It is just oh my god I could cry. I cry. I'm a huge fan of Dollywood. A huge fan of Dollywood. It's my favorite park and Wonderland is taking steps towards it. I'm kind of disappointed that I didn't film the fall decor. I was so focused. Like there's a couple things. I was gonna rant in this video about the food department but I'm gonna make a separate video. I wanted this to be just about my positives on the park and like honestly there's a lot to be really happy about if you're a Canada's Wonderland fan because the park is taking steps in the right direction. They're receiving the most investments and there's signs that there's a whole nother restaurant or building coming in 2023 as well. If you look at the insulation that's stored in the parking lot it's enough for a whole nother building. So fingers crossed that there is more restaurants or restaurant upgrades coming in 2023 and with the amount of money that we're hearing that Wonderland's gonna be getting over the next couple years I could see that happening. But I if for any of you that know me I spent a fortune at Canada's Wonderland last year at the Haunt Store and I expect to spend a fortune this year as well based off of what I've already seen in that window shopping. But Oktoberfest seemed to be a really big hit at Canada's Wonderland this year. It was really exciting to see just people like with those massive jugs of beer but here's those Haunt Store windows the Haunt boutique at night that you guys would like want to see them and check them out.  So stay tuned for that. I do want people to know that if you're not into like negative reviews on Wonderland then maybe don't watch my next video. But as someone who has been a business manager for one of the world's largest coffee shops for over 10 years I have a lot of experience and I've just witnessed a lot of things that I cannot turn a blind eye to anymore and I just have to speak on it. Anyways see you in the next video. Thanks so much for watching guys. Have a good one. Bye.


Blessing Okagbari and Grace Wankocha are through to the semifinals of the women's 100 meters event at the Olympics. Okagbari finished first in her heat in 11.05 seconds to advance. The Nigeria record holder in 100 and 200 meters ran from lane 7. Grace Wankocha on the other hand finished third with a personal best of 11.00 seconds at the Tokyo Olympic Stadium. Hello, hope you enjoyed the news. Please do subscribe to our YouTube channel and don't forget to hit the notification button so you get notified about fresh news updates.


Hello everybody. First of all, I should say hi to everyone. I'm talking to you from upstate New York today And I'm Honoured to introduce one of my old friends When I say old friends, I mean When we were younger, we were the same age. I don't know what happened that he got older and I didn't somehow but Said Said Nuri was born in Tehran. He received his BA and MA both from Tehran and Left Tehran for Paris to study In the field and they're in Paris for a couple of years. He stayed and he studied with the giants of the field Hopefully I'm correct in pronouncing the names as Nicole Brunner and Brunez Yeah, Brunez and Jean Duache for Jean Duchet Duchet. Thank you, Said. And Said primarily is interested in history and understanding of the Iranian cinema particularly before the Revolution of 1979 however, he has done a lot of work on issues related to cinema and movie and Related to after the revolution He has numerous articles. He has 17 Documentary films short films and hopefully we will be able to show one of his film and here one day at Code Pink and He's here and I really appreciate Said Jean You accepted my invitation to come and help us to understand this film and based on Thank you for inviting based on the culture and history and the cinema of Iran so and People who are here and are joining us in this call and mostly have Seen the film before and today we are going to just talk about the film I will start with my own so I have this privilege to start with my own question and as it's recording I would like to mention that it's about the salesman by Asghar Farhad. Yeah, we are talking about this movie Yes, and so my yeah salesman by Asghar Farhad and because Man, it was actually nominated for many prize internationally and got the best actor prize I guess for Shaheba Hussaini the yes and the screenplay Yeah, and the screenplay got the prize. So that's good Yes in in France, I guess and I can't fail and And So it was a praise the film and it's really Many foreign actually audience were really they really liked it And I personally as an with my Iranian American lens I also love the film, but I always when I watch something from Iran something cultural. I think how People who don't know much about Iran they perceive this Film or they're you know, this story and everything so it there are a couple of things that I wanted to just start this conversation with Say John one is Some parts of the film it's very cultural For instance when the teacher shows the film in his classroom We know they are talking about a film cow Which was really famous at the beginning of the revolution got many prize in Iran How and this film cow is related to the whole movie and do American or non Iranian Audience can see some relationship between the film and also the the film cow that it shows at the beginning of course the teacher has some Very brief conversation the student asked how a person can be a cow and the teacher said The years gradually and through of the years can this happen or somewhere in the film It's relate to the city and the guy said this city is ruined. This building is ruined and The other guy says this city or this building have been ruined many times and just stood up again So we who knew Tehran historically we understand that but I always think about it Where in the film and non Iranian? audience can connect these small Points together. Okay, or it is is it important at all if they get these small parts or not We have a story that talks about the reputation privacy security, you know and relation between a couple and We have some subtexts that are related to Iranian culture and There are more local. Let's say And that's what the points that you mentioned, you know For example when you say that the movie cow which was made before the revolution was the Maybe one of the major films that was approved of the revolution So it was an example, you know for Iranian cinema after the revolution to make a movie You know like the films like cow. It's about the peasants You know the people who live in a village, you know and a cow that feeds people but Here in this movie. He's talking about Mostly he's talking about writer the author of the Movie who had written the screenplay and it has been adapted from a short story You know and his name is Saidi Saidi was a leftist And and the position to Shah's regime, you know, who wrote screenplays Plays for the theater and short stories before the revolution and there are About four or five films made of his stories before the revolution, you know and It's you know when I saw the movie today. I saw in parallel there is an An American author Arthur Miller in the movie and the salesman the play and the the theater that they are playing and Saidi as an Iranian author, you know Which is represented in the classroom, you know and the Arthur Miller, which is represented In a theater hall, you know in parallel you can see and you can compare inside these story of the cow Women do not have a major role But in the salesman of Arthur Miller, you know There is a whore in the center of the play and that's where you see a woman Getting out of the bathroom with a monto, you know, where who is covered completely But she says I'm naked. How could I get out of the house? Undressed you are talking about this And they start to laugh Here as far as I think wants to talk about censorship, you know and to say We cannot show a woman naked. We cannot show a woman undressed and that's why if you see The woman which plays in my film Is with this car all the time. It's the censorship that says that she must wear You know like this In in his in her own house, you know and that's why that Saidi was censored before the revolution, you know and after the revolution, you know We have women who cannot show themselves as they are and they have to you know Accept and obey the law that tells them, you know, how to cover themselves for the movies Interesting So basically you are saying some of these scenes that we saw for example in the theater It was for making it clear for the non-Iranian audience and that We have to deal with some of the rules and regulations of making it Exactly Another very Interesting part going back to this also is what I saw As a woman myself that In the film in this story a woman's body was attacked But because of you know, she was ashamed or she didn't want to talk about it She didn't want to go and report it to the police And I saw a man who is frustrated and trying to find a way to defend his Wife or his or the body of another woman. I these are some Complication I guess to me at least you know, you know, you know here in our culture There have there has always been something named reputation What we say in Iranian aberu, you know reputation and You know, it's it's a taboo to talk about what happened to your body as a woman You know, and that's why the woman says that he she doesn't want to express Or recite what happened to her in front of a police You know, or when his husband says that some of the neighbors Took you out of the bathroom. He wants to know who he was If he was a man or he was a woman but Unfortunately for her it has been a man taking her out of the bathroom and She insists on leaving these these apartment Because she thinks that somebody has seen her body naked in the bathroom when She was not, you know awake And that's these are the details that women, you know, the the shame I don't say the shame that they did the protection. Maybe it's the protection that an Iranian woman Is educated, you know to to have In her life and I don't know if Some are against or some are for These kind of education that mothers, you know transfer to their daughters You know and and you say that that this is the man who wants to defend her woman and he wants to find out what happened when he's in the Stir case and one of the neighbors is passing by and says that Mr. Iks took your Wife out of the bathroom he's he's he gazes the woman and Tries to digest what happened to her wife, but he cannot you know, but the woman can exactly switch off This subject after a while, you know After passing by the the harassment the the mental harassment that She cannot go to the bathroom anymore. She cannot Stay alone at home anymore But at the moment she tries to cook again She tries to find herself up, you know, because she sees that she's losing her points He she he she's losing her role in the theater You know and she has to Resist against this and switch it off You know and let it be archived Unsolved That's that's that's the education, you know, that's the education the Iranian education to the women Mm-hmm So you you mentioned before we start this call you mentioned that you saw the film again today Yes, and you were and it was so heavy for me It took a lot of energy Of me because you know, as you know, I'm working And studying the Iranian film history before the revolution and we have 47 years of making movies before the revolution It started fiction filmmaking started in Iran from 1932 and After you buy the revolution in 1979 We had More than 1200 fiction films made You know in these 50 years and when I studied these movies Comparing to what I will see and I see these days in Iranian movies. I see that Iranian life Is much more complicated than before Before the revolution. I mean, yes people were very naive very simple and the social trust Was very high everybody trusted everybody else and they made friends very very easily But now you see that even The husband tries to hide some things from his wife, you know, when he finds the the The truck of the man who wanted to come into the house He brings it to the parking and doesn't say anything to His wife, you know Everybody is surprised Uh, everybody is surprised by the information that that the others Are conveying With themselves and don't talk about it. You know Babak The the character that gives them the apartment He doesn't talk about the past and Oh who who lived in this apartment before and what happened? You know and everybody is surprised because they try to hide from each other the information that can prevent the catastrophe The horrible events.  I'm talking individually. I think if I hide So many information from my friends or my wife or The people who live around me. I've been security Which was not this is not what We see in Iranian movies before the revolution, you know, everybody knows everything about The one who is living with yeah, I guess for that in my perspective, there are many probably issues So of course evolution war Like or also, you know international intervening In iran in domestic issues in iran as long as you know, also the Population and Tehran then probably had exactly four million population and today has 12 15 million At the end of 50s, we had at the end of 50s. We had about two million Iranians living in Tehran By the revolution we had four million and half And today we have 12 million people living in this city And when in the movie they say we have to ruin this City and build it again. It's because of the compression, you know, the compact of the population That we have in this city Uh, they all come to Tehran, you know to live Uh, a better life the the immigrate even these two Junges there these two These couple, you know, they have come from a province I saw the movie for the first time in can film festival 2016 And now today when I saw the movie I saw that three minutes of the film has been cut Has been taken out of the movie and it was a sequence that It was the second sequence of the of the movie when they are obliged, you know to evacuate The building they go somewhere, you know in an agent for Mass country leadership in an agent for for fine again for for finding yes to for for finding another Apartment and they do not have enough money and they say that their parents Parents live in the provinces, you know, they have come for a better life in Tehran, but such horrible things Can happen in a cosmopolitan that nobody knows nobody else Yeah, exactly. So, um, you know, I have to I have to explain you something that existed before the revolution And does not exist today We had neighborhoods before the revolution neighborhoods mean mean meant that when we were To the walking in the street everybody says hello to everybody else and everybody knows everybody by the name And by the first name by the family name and the first name and everybody knew that this is the girl of mr X, you know, yeah, but but after the revolution because of the huge tall Sky crepers and the uh, you know, uh towers, you know, we have we have the neighbors that we don't know, you know We have a A character in this movie named ahu. We don't see her But we see the consequences of her life style and it's effect it's effect to to the couple's life Yeah, you know to the to the new ones who come to this house But now you are talking about yeah, exactly. So we don't we don't see her but now you are talking about ahu um, I want to bring um a question that one of our Viewers is asked it says why in many, um Of these um occasions when specifically and mr. Farhad these films he's referring to is um Mostly are the middle class that we see And in this one also and how come most people who understand things and in these dilemmas they are middle class Do you think is that something to consider?  So he is in the middle class of the society, but ahu is not No, but ahu. No, no, we don't know We we know the ambitious things about ahu And it's it's vague. We don't know who she is Everybody says that she has had complicated relations But we don't see her, you know to to judge her by the appearance of how she is You know how she uh wears, you know What he says what she says, you know and how she lives her lifestyle is unknown to us You know, but everybody has some guests, you know about her they they try to judge her You know and afterwards you see that She is maybe a victim That the girl who plays the role of a prostitute In the theater, you know is a mirror Character that you can see there is she is an independent woman, you know wearing the red, you know, monto and she has a Boy of three four year old and we don't know anything about her Either her personal life, but we know that She is in In a complicated situation too, you know, uh, she is ahu too. She is another ahu She is Ahu is the future of this girl maybe We can we can see such things because they're all there are two parallel stories One is going on in the theater and one is in the real world Which is located in Tehran. Yes, exactly Interesting um I have another question here that what is now you are talking about the theater someone else What is the role of the theater in the iranian culture? very important Very important since 150 years ago theater Always had a great role in iranian History and iranian in Among iranian intellectuals. I have to tell you that before the coup d'etat of 1953 In lolezor a place in the Just in the center of Tehran. Yes There were more than 15 theaters And they were all leftists and communists They had come from france. They had come from russia and they tried to represent The the intellectual theater Mixed with the politics Excuse me. When you say they came from france and russia Do you mean the stories the plays or no no no the ones the ones they they were educated in france Oh, the iranians Yes, they had studied theater in france And they had studied theater in russia, you know, they were stanislavsky's students You know From the school of stanislavsky. They were graduated and they were all politicians, you know It's that's why after the coup d'etat of 1953, you know They banned all the serious theaters. They Put them in jail for some years and they repented And they came out and they became the the next generation of the translators in iranian culture And they started to translate the political or the contemporary Novels, you know from english from russian to iranian language to persian to farce Interesting. So you are saying that's why theater has always been a part of intellectualism in iran Interesting, okay, and I have to mention that I knew I knew you in the theater We were in the same play A mid-summer night stream 22 years ago And it was considered political because When everybody searched for the grief days, we were representing a comedy We were reciting a comedy. We tried to give joy to the people Mm-hmm. So you are saying the language of theater in general in iran has been the language of politics So people talk about their Before exactly, but especially before the coup d'etat of 1953 And afterwards it's it's transferred transformed and transferred to the poetry Contemporary poetry and then to the literature and then to the cinema You know in the political language Yes, the intellectuals. Yes, the intellectuals immigrated in another media Interesting, but what happened to theater then after 1953 the modern, you know, when the all of these activists You know for for about For about 15 years. We didn't have anything serious But afterwards the it was a an atelier a workshop place Kargah Nama Yesh Which was the iranian national television who founded a place for those who wanted to experiment theater and that was because of the We had a Festival in shiro's named the festival of arts just known as shiro's and that's where the great theatrical groups like yershi grotowski peter brooke and Others from the west invited. Yes. They were invited to iran and in parallel iranians started to experiment The theater again, but it was not political Well They were experimenting the language of theater, you know as a media of expression But it was not as political as it was because you know, we we are a neighbor to the russia and at that time communism was a danger For iranian government, you know considered as a danger So that was why Whoever wanted to be an opposition became communist Yeah, so thank you. There are a couple of questions about the role of women and men and Like for instance one question is um Was it very difficult for the woman to talk to her husband because she was fearful of him Or what do you think it was happening? No, no, no, no, I talked about the education. You know, it's not the fear You know, it's a part of uh novelty In iranian culture to keep to reserve what is inside you as a woman You know, you see this this is a It's not the the modern education. It's a custom, you know, traditional education of iranian iranian Women, you know, and no, she's she's not afraid of her husband But she does not want to talk about it About her body Yes, about her body and she does not want Either to remember You know, she doesn't want to remember when she starts to recite, you know, she's uh, exactly completely, you know Bulverse, you know set up she she's she's upset when she talks about it It's about her education because she's not from tehran. You have to know that she comes from the provinces And what makes the difference? The difference is the difference between modernity and the tradition You know the tradition So in the provinces people are more traditional than exactly exactly and the education is the education that your mother transfers to you But in the huge cities that you learn everything In the streets, you know You are under the Verbal violence, you know violence Yeah, first of all everybody tries to say some words to you and then they try to Touch you to catch you and you start to defend yourself After a while, you know, because you see you cannot be so You know silent about it, but when you come from the provinces It's a shame to talk about it. That's the difference of the culture of bigger city or Yes, or probably this is kind of Global in many places in the bigger cities people Exactly open to them. Yeah. Yes, but again, there is another question almost the same A subject area that um the gender role in iranian society How you can define it and what do you say about that? I'm very proud to say that the future belongs to women in iran And everybody says the next revolution will be the revolution of women You know, how do you say that not not in the uh traditional way of revolution You know, they have started to change things from the house By working on their parents on their brothers to change their views their Point of views their minds, you know By wearing what how they want to wear in their houses You know by saying what they desire to say By studying the disciplines that they like to follow Mm-hmm, you know and nobody can prevent them of the participating in the society So an art and You have to know that the new generation of men for example me We do give Much more liberty to our women. That's my father gave to my mother You know So because I you have to know that the men are not the same that they were For example 30 years ago Men have changed too and that's why I say women, you know, they can They can't defend themselves by Conversation, you know by talking about their problems When I was a child for example 40 years ago I saw people talking by violence the bodies Talked by violence to each other and even in this movie you see that when two men at the end at the Ending sequence of the movie when two men are talking about a violence against a woman they try to keep calm and talk about it You know and they talk about it But if it was before the revolution One would take out a knife and put it in the body of the You know the the body the the body of the person who had violated His woman Interesting so basically I hear that you are talking about the maturity of a nation Exactly, exactly collective maturity a democracy An informal democracy Through conversation And the the the main subject of ascar farhadi is the main topic of ascar farhadi's movies is You know is talking to each other Instead of instead of reacting with your bodies or your manner try to talk That's why you will see more than 2000 subtitles You know in each movie of ascar farhadi they talk too much Yeah, so there are a lot of conversations in the film. Yes, there are a lot of customers conversation The sometimes that they are Bavarian, you know, they are trying to To to to Represent the logic that they are living with So we get connected to these in characters based on their logics and how they exactly Exactly. This is the maturity in the the the evolution of the society, you know They try everybody tries to communicate through the exact words Interesting so but you say this is in general ascar farhadi's work like in other movies of him Yes, yes Separation yes, exactly Exactly and that's why when we when we talk about the middle class of the society middle class of the society are normally The people who are educated enough to talk about their issues You know not to react and let us discover what he wanted to say. They say it directly directly You know with the words they pronounce it so You say this happens mostly among educated people or middle class people, but we see more violence among on like the economically Just or Yes, we don't see this Yes, yes in proportion, you know, we we we we have more than 40 million people who are educated from the universities Which was Very rare before the revolution, you know, they did not people did not have access to the universities easily, but after the revolution By the azad university Which was founded in each little city, you know, it was a An opportunity for the people to go and be educated, you know and we we must not Neglect the role of the virtual world and the internet Which has spread out Of the country and everybody knows So many things and the satellites, you know, there are more than 2000 satellite channels in the houses So everybody Can uh, you know can can can follow what he desires Yeah, it's you are talking about how it's easier for people to have connection with the outside And basically we are living another period of time another era Yeah, we are in the 21st century and there are some things that you cannot prevent I'm sitting in my apartment, you know talking to you in the states From terra, it was not possible 20 years ago to to have a video talk like this Yeah, of course So side john, we have um almost 20 minutes and I want to give this 20 minutes to you Um Not all of that. I I need the last five minutes, but I want to give it to you to see um What did you think in general about the film itself and are you going, you know, if we were in a different world Are you going to recommend it to more people to watch it and why exactly exactly? You recommended to watch because it shows how human relation is uh fragile these days And every word every act Counts in your destiny You know When a man says when when the man who has who who tempted, you know to to the violence He says I was tempted You know a temptation must may result in your death These days, you know That shows that the the world is very very complicated and you must be enough educated, you know to react In the in a in a good situation and talk enough Of your problem, you know and uh try to resolve your problem By communicating to the others and these are the new ways of communication Because we as the human beings are more complicated than the ones who live on the earth before us you know, uh Today a five-year-old child can You know can do the things with the telephone that I can't do with the 45 years old You know the new generation are coming and the we have to Educate them well You know to for peace and talk peacefully, you know to the others and try to communicate and try to have A resulting conversation to the others And try to eliminate threatening others, you know and trying to trying to Eliminating the violence and the reacting violence Reactions of violence, you know in our manners in our attitudes That's why the psychology these days Has a great role in the movies And if you see the movie Psychologically, you know, you will see that this is a couple Who are very very ready to have a child When you see a child is a guest, you know, they treat I guess give me Um, it is the Connection is lost So while I hope saeed is trying to come back to the conversation I want to announce that next week also at code pink. We have a Very interesting program It is for the august 23rd at 2 p.m. It is a program with the Orchestra chamber orchestra of Tehran and the program basically it's organized by Fatemeh Keshavarz at The university at the college park and with her distinguished guests the ruse Amaritabrizi and Kousal Gohari And we will watch when you join us. We will watch a musical collaboration between These groups and the between the solidarity chamber orchestra of Tehran and singers from the washington dc Based of raw so it is a collaboration between Tehran and washington dc And hopefully we will see you here again. It's the august 23rd at 2 p.m. And um, we will Send you further information as well as you can find more information on our website at code pink dot org So i'm glad to say and to see saeed is back and We are here saeed john Yes, do you see me? Yes, and we hear you Okay I said what I wanted to say is is If you guess yes, I do recommend recommend the movie and the other Iranian movies too, you know Iranian culture is very vast and very How how can I explain it it's because we don't we have so many yes so many tribes in Iran You know, it's it's like a mosaic Culture in Iran and everywhere you can find very surprising Reactions, you know as as you know better than me Iranian people are so receptive, you know To the people who come to their country to visit, you know, they they they help Everybody and that's why I do recommend you to watch more Iranian movies even from before the revolution, you know that that's Let's you compare how This society is trying to uh, you know develop itself Mm-hmm. Yeah. Yes, and so actually, um, this is a series and then we are very honored that you are here with us and This program will be a series of Programs that we are going to invite different people from different art industry or sections including movie and Soon, hopefully we are going to have you again And to talk about your own film Women on the from the men's perspective, I guess if I'm correct with the name and then we will According to men to men and we will send more information to our members and Friends and so we will have you uh later so, um Someone because of you Suggested right now that it is it is good also to see some films Relate to before the revolution before 1979 And so what kind of films you are recommending for us to see And actually my this is a question from one of our friends here, but my Personal question and do they have subtitles those old films? Some of them they have for example the cow you you may be find it With the English subtitles The cow that they they talk yeah this movie the salesman Yes But if you want to see what was happening before the revolution The best way is to watch my film because I watched more than 1000 movies And you will see how women were reflected You know during 50 years in Iranian cinema You know how they were treated how they were written how they were directed You know and and how they reacted You know to the situations In which they were trapped Before the revolution and how they tried to To Through a path to to pass from the tradition to the modernity, you know, which was the politics of the era Of the government. Yes interesting It was interesting to me you Choose the word trapped, but I would personally I would love to see your film and hopefully we will soon and we will Announce the further information about that and date and everything to our members and groups and I don't have any other question and I don't know I see there are I see there are 12 other questions Do you see these questions? And do you see if I see some of them and I guess I Oh, you have asked. Yeah Some of them. Yeah And but is there if there is anything you want to mention about this particular movie or In general in in a very brief basically About the So The cinemas of Askar Farhadi is very important for Iranian culture Of these days Because you know, he has come from the theater. He knows the drama very well And he knows the Iranian mentality very well, you know, and that's why but I I'm not very very for Askar Farhadi cinema because the violence That are shown or Reflected in the movies, you know, it agitates me. It's it's a It's not from maybe his films, but in general, you know, I I do Like the peaceful more peaceful movies, you know, which try to tell you in a very More subtle ways, you know to to Tell their story in a very more subtle ways Askar Farhadi is very fond of Alfred Hitchcock And as you can see in this movie, there are many Suspensions, you know suspension in his movies and It's it's a kind of taking the audience as a hostage And I don't like it, you know Because I talked very much Of the details of his movies. I would like to mention that personally When I see his movies it takes a lot of energy of me and Maybe instead of a little bit entertaining me After finishing the movie I'm a little bit scared to live in my country You know because I see this security Even you you don't have the security even in your apartment And that's not true, you know, I I think personally that's not true You know because I have lived in my country so many years Yes, it can happen, but it's not general Yeah, you know, it cannot happen generally for everybody, you know Mm-hmm You can be you can live a peaceful life in Tehran. You can have many good friends, you know You don't need to hide so much information From the others, you know, that is what his movies suggest Interesting propose I do personally see people Much more Relying We can rely on them much more than what you will see in Asa Farhadis movies They try to provoke each other in his movies You know, for example in this movie you will see the neighbors that everybody tries to provoke the man Against Ahu and against the one who lived Before them in this very apartment But in reality Yes, in reality people are people are a little much much more positive than this You know And that's why there are a little bit differences, you know from what is the reality of Iran It's a movie, you know, he wants to be tense His movie, but the life is not so tense here. Yeah. Yeah, interesting. So I guess that's why I don't leave my country Because I could I had I lived for nine years in France. I could stay there No, I prefer to come back to my country and live among my people Yes, and so I guess um what I hear from you is Basically, yes, this is a film and the characteristic of any film is just exaggerate something into In order to make it interesting. Yeah in order to make an interesting story But at the same time we should remember this is not The whole story of one country of one nation Is exactly what you know, sometimes I have to say this sometimes politicians say, you know Things about Iran or about the rest of the Middle East or other places and try to make that specific place very scary So but that is not the reality even Exactly, but always the very strangest Listen to medias don't ever listen to the newspapers and what they Try to discover the countries and the cultures by yourself, you know, exactly Beautiful. Yeah, you know, when I see the the european films or the american movies, you know I I fall in love To los angeles Maybe in the reality it's not As as well as I see it in the movies, you know, but I fall in love. I I have a very very You know tenderness To the openness of the people american people You know, but the same openness I I see here among the iranian people As I say they are receptive Yeah And I saw exactly the same Uh Manor the same reaction From the french people when I was in france. I had very very good French it depends on us, you know, yeah, it depends on us when we are resentful, you know Uh, it's very our point of view is very different from when we are uh Confronting the issues, you know with a with an openness Of a spree, you know Yeah, yeah, it transfers you some somewhere else All right, and so And the last question I want to ask you um, if you could also um If you could also send us a list of films that you suggest and iranian films and if you can tell me this is I'm my personal interest. I would like to know who is your favorite Do you like then you said you don't like that much as far for these films because of the tension it has and all of these Do you explain which makes sense, but um, I want to know who is your favorite iranian director? Uh, it's obviously from before the revolution Okay, not sir. Ta boy not sir. Ta boy the one who hate uncle Uncle not alone Uh, tranquility in the presence of others Is what is one of his movies? That is based on the side is story You know Not sir. Ta boy is My favorite because he knows iranian the cinematographic language I I saw somebody has asked me if I want to explore some other country and come out of iran, which is the country. It's obviously united the states of america You have to know I love united the states of america because of what He had done With the cinema with the theater and with the culture You know during the last century even, you know, mostly during the last century, I love American movies and I love european movies I leave some years in france, but if I want to live in europe, I prefer to live in paris Because I know they're and I speak french and I have so many frames, you know, and it's Majorly because of the cinematic frances, which is the most The the the most wealthy, let's say Of the archives of the world of the world Interesting I see one I'm sorry. I see one question here that we didn't We didn't get the answer Is someone talked about a prostitution and said is it unusual to have a prostitute? Even unseen as part of a film plot in iran. No, no, you have to know that before the revolution majorly Iranian women were shown as the girls who danced in the bars I mean after the revolution I'm mostly after the revolution. Yes, but after the revolution they were Eliminated from the movies, you know, it is not because We cannot only show them in their real life it's because you know There are other ways to show the movies because the the love Have been changed the censorship has been changed and You have to do in a symbolic way, you know Using the metaphors, you know to say something Even here you see that as far as Takes Arthur Miller as a metaphor, you know a girl coming out of the bathroom Naked but She has everything on that shows that you cannot really show What is the real life of a prostitute these days Interesting it's it's it's not an issue for women either because we have so many female filmmakers By they do not but they do not try to show a prostitute You know in their movies I don't know if there is a shame To show it they have an inside shame and they they are maybe More cautious, you know to be to be afraid of the judges that come afterwards Maybe it depends to the society, you know But you cannot show it in In an obvious way of life Of course But you can't refer to them as this person Yes, the second road And usually it's interesting this one actually we don't have much time But i'm going to say this this this part was I was thinking about the american audience when in the movie They open the door of the The closet the closet door of the you know prostitute woman And we saw a who and we saw a couple of red shoes So I wanted to say probably I don't know if side if i'm drawing tell me for the iranian audience Showing red shoes or you know very those colors screaming It's it's it's very nice.  Why these colors? Yeah, why not why not for example white or solid or yes, yes or gray You know, why do you want to pronounce yourself? Through the color the color has been eliminated from the society gradually and It's a pity It's a pity because it shows that joy has been eliminated from the society Gradually, you know, but I want to actually Take This word of yours to the beginning of the conversation that you mentioned if there is any revolution I mean evolution that you correctly mentioned is from the women because I was in iran last time in 2018 and while growing up And I learned that I shouldn't have or shouldn't wear We called it a screaming colors like you know red yellow right colors But in 2018 when I was in iran, I saw younger women Or many many different from different ages. They all are wearing Colorful outfits. They are showing it outside and they are more comfortable with these colors It was really interesting. It's it's very recent and you have to know Well I forgot what I wanted to say I guess If I if I'm alone, I want to say probably this is iran is going toward a very good Conditions of life itself Please leave iran to the iranians and let them to make any decision they want to make So any any pressure from outside will destroy this beautiful move and this beautiful evolution So exactly. This is my evolution is gradual and from inside Not from an outside and not by force Yes, exactly. Okay. Perfect. Thank you very much say john You have been perfect Or 3 a.m at your time in tehran We will let you do to 230 a.m And um, I wish you the best so we will have you soon and we will announce it in our website and with further emails to our friends and allies at the code pink and Hopefully we will have you soon again with your film your own film. Yes. Yes. Thank you It's it will be an honor. You know, you will have an ontology of iranian history With your temporary history through my film because I'm fond of history, you know You can see more than 122 excerpts from The movies made before the revolution, you know to how they directed how they You know were Before the revolution how they talked before the revolution and how they Reacted Mm-hmm. Perfect. We cannot wait. Thank you very much. Love you all. Thank you We love you and thank you. Bye. See you soon. Bye. Bye. Bye. Bye.