So, to do a bit of recap let us see what exactly are the problems with manual deallocation that is using free etcetera. So, there can be memory leaks which are not detected in the program it is very hard to debug such memory leaks. So, memory leak is you know failing to delete data that cannot be referenced. So, basically we have forgotten to delete the nodes which we are not using anymore in a tree or in a graph etcetera and then there is a second problem of dangling pointer dereferencing. So, we have forgotten to you know remove the references to deleted data. So, this could be you know a program error which is very hard to debug as well the solution at least partial solution to these problems is automatic garbage collection. So, garbage collection is nothing, but reclamation of storage and the storage is not being used by the program. So, we want to free such locations and use them again it is possible to you know do this provided the types of objects are known to the garbage collector. The reason why we require the types of objects is that the sizes of these objects cannot be determined without knowing the type. Secondly it is possible that the pointers which are embedded inside the objects you know also refer to some you know runtime objects. And it is not possible to determine whether there are pointers inside an object without knowing the type of that particular object. So, java for example is you know is type safe because you can determine the types of objects either at compile time or at runtime c and c plus plus are not. So, the basic mechanism by which we claim garbage is using the concept of reachability of objects. So, what we really want is to determine the root set which is nothing, but the set of all data that can be accessed directly by a program without having to dereference any pointer. That is if you consider the pointer variables which have been declared by the programmer at the highest level in the program. We are looking at these pointers as pointer variables as the root set. So, from that point you know from that set we reach the objects you know using one level of dereferencing. And we also look at the objects which can be reached from the at the second level and so on and so forth. So, let us see how this reachability can be used in garbage collection. So, it is also possible I forgot to mention that parameter passing assignments can propagate reachability. And of course, assignments and ends of procedures can terminate reachability of these objects. Similarly, an object that becomes unreachable can cause more objects to become reachable unreachable. So, that is you know if you have a pointer you can reach an object through it and if that object has more pointers in it you can reach more objects through it etcetera. Similarly, if you actually free an object which was being you know reached by a pointer. Now, the objects which were reached from the pointers within the object also become unreachable through this pointer. So, this is what we mean by the propagation of unreachability. The garbage collector you know periodically finds all the unreachable objects using one of the two methods. First one says we know that the objects change state. So, when the objects become unreachable at that transition from reachable to unreachable we catch the you know object and say now let me free it. So, second is periodically we scan the entire heap of the program and then locate the reachable objects and whatever is left over is the unreachable set. The first method that is the reference counting garbage collector is an approximation to the approach that I know the first approach that is we catch the objects which become unreachable at the time of transition. So, how do we do this basically we maintain a count of the references to an object. So, and when the count becomes 0 the object becomes unreachable, but how do we maintain the count. So, whenever you know the program performs actions and that changes the reachability of that object we modify the count as well. I will give you more details of this very soon and the reference count requires an extra field in the object. So, we maintain it you know using these rules. So, now the rules for maintaining reference counts there is a let us say there is a new object allocation. So, that means the object comes into you know become is born right. So, using new or any other mechanism. So, we set the reference count as 1 for this new object. So, that is quite fair because we have created a new object and that is being pointed 2 by a pointer. So, the reference count is 1 at that time parameter passing. So, let us say objects are being passed into a procedure as parameters. So, that means from now on the parameter also refers to the object apart from the original number of references to that object. So, it is only fair that we do an increment operation for each object on the reference count counter for each object passed into a procedure. So, this is a parameter passing and its effect on the reference count then there are reference assignments. So, that is u and v are references. So, and we are saying u equal to v this is an assignment. So, u is pointing to some object v is also pointing to some other object and from now on you will point to the object that v is pointing to. So, this is a pointer copy operation. So, obviously for the object which is pointed to by v that is star v the reference count has to be incremented by 1 because now from now on you will also point to it. And now you know you has kind of sees to point to the old object. So, reference count is reduced for the object which is pointed to by u that is star u. So, this is how the reference assignment propagates you know reachability and then of course, it ends the reachability for the objects pointed to by u as well. What about procedure returns? So, we know that the local variables die once a procedure returns. So, we do a reference count minus minus that is decrement operation on reference counts for each object which is pointed to by the local variables local pointers. Then there is transitive loss of reachability as well. So, whenever an object gets its reference count to 0 we must now trace further we must look at the reference count of each object pointed to you know by a reference within the object. So, we have an object there are more pointers within it those pointers will also be pointing to some objects. So, if an object to gets its reference count to 0 then you know we must decrement the reference count of the objects pointed to by the pointers inside as well. So, this must be done transitively and it will go on until no more decrement operation can be performed in any reference count of any particular object. So, this is the reference counting you know method of garbage collection. So, basically we whenever we find that the reference count becomes 0 we return that object to the heap. So, garbage collection is in some sense incremental. So, overheads are distributed to the mutator as operations and are spread out throughout the lifetime of the mutator. So, we do not have you know a huge amount of time which is spent in garbage collection at a single point in time, but it is distributed throughout the you know programs operation. So, garbage is collected immediately and hence space usage is low and usage is also very efficient if we are not delaying you know the collection of garbage. So, for real time systems and interactive applications such garbage collection is very useful because long and sudden passes are unacceptable in such a environment. So, if we take away too much time during the applications run to perform garbage collection it would obviously introduce long and sudden passes. So, to avoid this incremental garbage collection using reference counting is a very useful mechanism, but then these are the advantages. So, then there are also a few disadvantages there is a very high overhead due to reference maintenance because every time the reference changes we know that the reference counter has to be either incremented or decremented. And there is also a more serious problem the reference counting garbage collector cannot collect unreachable cyclic data structures such as circularly linkless. I will show you an example of this very soon since the reference counts never really become 0 this is something very serious. So, take this data structure. So, each of these is a four field object. So, this pointer inside this object points to this node and this points to this node. So, here is a cycle of references this pointer points to this node and then this pointer points to this node and again this pointer points to this node. So, here is another cycle and the second pointer here also points to this node. So, this object has a reference count of 1 because of this pointer pointing to it. This object has a reference count of 1 again because of this pointer pointing to it. This This object has reference count 2, because there are 2 objects 2 pointers pointing to it and then this object also has a reference count of 2, because there are 2 objects pointing to it this and this. So, what it so happens that none of the objects here can be reached through any other useful program variable pointer variable or any other variable any other pointer inside the program. So, this is basically garbage none of these nodes can be reached from anywhere in the program, but unfortunately the reference counts have not become 0. Therefore, none of these nodes will be returned to the storage pool the heap. So, this is a serious issue none of these nodes are in the root set either or transitively even in the root set. So, this storage will be permanently claimed and it remains in the program. So, if such circular data structures keep accumulating then even though they are all useless it will not be possible to return them to the storage pool.  So, how do we get rid of this problem. So, let us look at different type of garbage collector mark and sweep garbage collector. So, the where to briefly again the memory recycling steps in such a garbage collector are the program runs it requires memory locations. The garbage collector traces and finds reachable objects then the garbage collector reclaim storage from unreachable objects. So, the entire heap memory is scanned by the garbage collector in both these passes finding reachable objects and claiming unreachable objects. So, as the name indicates there is a marking phase to mark the reachable objects and there is a sweeping phase to reclaim the unreachable objects and return them to the storage pool. The advantage of this is it can claim unreachable data structures such as circularly linked list and so on. And the other feature is the in the nature of the algorithm it is a stop the world algorithm in other words when the program runs out of memory the program you know calls the garbage collector when the when an allocation is made the allocation fails.  So, it this is called as a stop the world algorithm and this is the one which may introduce pauses in the program and it hurts real time and interactive programs. So, let us look at the details of the algorithm the algorithm basically is quite simple there are many variations of the marking sweep algorithm. We are going to look at one variety the simplest one and rest can be read from the text books. So, what is the marking phase start scanning from the root set first step in the marking phase is start scanning from the root set mark all the reachable objects that is set reachable be reached bit equal to 1 and place them on the list called unscanned. So, the root set is as usual the set of pointer variables which are declared by the programmer. So, all these all the objects which are reached from the root set will be marked as marked with reached bit equal to 1 and they will be placed on a list called unscanned. Now, we must do the marking recursion or rather progressively. So, there is a loop which continues until unscanned does not contain any object. So, unscanned while unscanned not equal to 5 do. So, take out an object from the unscanned list. So, object o equal to delete unscanned and then for each object o 1 referenced in o. So, there are pointers within the object. So, each one of these pointers is now actually traced. So, if the object is already you know is not yet reached. So, reached bit o 1 equal to 0 then we say the we make it 1 reached bit o 1 equal to 1 and place o 1 on unscanned. So, this goes on and on. So, once all the pointers in the object o you know object o are completed we take the next object from the unscanned list and continue. So, in this process every one of the objects which actually can be reached will be reached and each of these objects will have their reached bit set to 1. All the you know objects which have reached bit equal to 0 will be unreachable and they can be claimed during the next phase. So, here is an example to show how mark works. So, this is the root set the blue variety. So, these are the two variables programmer variables which used to access these data structures and this is the storage which cannot be reached.  So, we start from the root set and then mark the objects these two objects as 1. And then from these two objects we progressively go to these and these and so on. So, we mark these two as 1 and these two again as 1. Then in the next step we go to these two objects and mark them as 1. So, we now have all the reachable objects marked as 1 and the unreachable object remains with reached bit equal to 0. The unscanned list now is empty. So, the marking phase ends. The next phase is the sweep phase. So, again the entire heap is scanned here. So, sweep phase each object in the heap is inspected exactly once not more than once. We will see why it is incorrect to look at it more than once. So, to begin with the free list is 5. We had nothing on it and we look at every object in the heap and if the reached bit is of that object is 0, we just dispose it of add it to the free list. If the reached bit was 1, then that means the object was useful. So, we set it to 0. So, you see for the objects which had the reached bit equal to 1, we have now reset it to 0. So, looking at the object again would be incorrect because it would send all these objects to the free space. These were really useful objects. So, we should not be looking at them again. So, let us see how it works in this case. So, up to this was the marking phase. So, all the reachable objects have been marked. These are the unreachable ones. So, again as we inspect every one of the objects here, we take this, take this and take this, return it to the storage pool and that ends the garbage collector operation. So, this gives you an overview of garbage collection. There are obviously many varieties of garbage collectors which are in operation.  They are all useful in different circumstances.  So, with this the runtime system lecture ends and we will continue with local optimizations. So, welcome to part 1 of the lecture on control flow graph and local optimizations. So, you know in the past lectures, we have seen different phases of the compiler. For example, to begin with we saw lexical analysis, then we saw syntax analysis, then we discussed semantic analysis and after that we discussed you know intermediate code generation and of course, we also saw the runtime support that is necessary. Now, before we generate machine code, I mentioned in the early lectures that there is something called machine independent optimization which needs to be performed. So, in this lecture, we are going to see one type of machine independent code optimization called as the local optimization and the other types of optimization will be discussed later. So, in this lecture we will see the reasons what rather the definition of code optimization, its purpose and then the types of optimizations. We are going to study what are basic blocks, what are control flow graphs, the different types of local optimizations, the procedure for building a control flow graph and then of course, methods of storing basic blocks efficiently using you know value numbering directed acyclic graphs etcetera. So, what exactly is machine independent code optimization and why is it necessary. So, the intermediate we have discussed intermediate code generation in great detail and we know that it is a fairly straightforward process, it introduces a large number of inefficiencies into the intermediate code that is generated. For example, whenever there is an expression a equal to b plus c, you know we would first do t 1 equal to b plus c and then do a equal to t 1. So, now we have really introduced an extra copy of a in the temporary t 1. So, this is what I mean by extra copies of variables and using variables instead of constants. So, well there are many constants that we would like to use in the program, there is no straightforward way of using the may not be a straightforward way of using the constants in some cases. So, the intermediate code generator would generate an assignment statement to assign a constant to a variable and then use that variable instead of the constant itself. Then there are repeated evaluation of expressions. So, even though an expression such as a star b has not changed its value, we may be evaluating a star b all over again within a short period of time instead of trying to reuse the value which was computed earlier. So, these are all things which happen you know a famous example of this repeated evaluation is that i star 4 in the case of a of i plus b of i etcetera etcetera. So, these are the sources of inefficiency in the intermediate code, the reason we did not bother about such inefficiencies is that we know code optimization would remove such inefficiencies and make the code better. Of course, improvement of the code may be this are only a minor examples, there are many more examples which we will see in the future, the improvement may be in time in space or in power consumption. So, when we improve the time requirement which is probably what we do most of the time, we would be making the program run faster and faster. When do we require improvement in space? In other words, we would like the program to take as little space as possible. So, in embedded systems memory is actually very expensive to incorporate. So, we may have to pack all our programs into the into a very small memory and in such cases memory based optimizations to reduce the space requirements becomes very important. The same is true in embedded systems and sensor network systems and so on, power consumption it becomes a very important factor in such cases. So, the embedded systems and sensor networks you know they run on small size batteries. So, it is necessary that the battery can be used over a large period of time. To do this the power consumption of the program has to be minimized. If we simply make the program run faster of course, the power consumption will reduce because the program is now running for a shorter period of time, but there may be very subtle optimizations possible you know by compilers such as reducing the voltage of the chip, switching of certain function units etcetera. So, the compiler may be able to perform you know optimizations keeping these features in mind. So, power consumption reduction is another type of optimization which is sometimes possible. So, the in general optimizations change the structure of programs. In fact, sometimes beyond recognition for example, optimizers in line functions you know. So, the function call disappears the body of the function replaces the call it unrolls loops. So, instead of running the loop you know 300,000 times it can possibly unroll the loop for three times and then say now I will run it only 100,000 number of times. So, why should it do such things the unrolling of loops etcetera will increase the opportunities available for instruction scheduling etcetera and it may actually increase the parallelism in the program. So, the same is true for inlining of functions. So, these are all desirable optimizations. It may also eliminate some of the programmer defined variables. So, for example, in induction variable elimination the variable which is defined as an induction variable may eventually get eliminated from the program. The effect of all this would be that we cannot use a debugger on optimized programs because the program has now changed and the mapping to the source code is no more possible. So, debugging an optimized program may not give out appropriate hints to the programmer at all. So, in GCC for example, kind of stops all the optimizations if you choose the debugger option. Code optimization in general consists of a bunch of heuristics. So, in other words the percentage improvement is not guaranteed by any optimizer. The simplest example would be you know if there is a set of statements which cannot be improved further then applying any number of heuristics on it will not improve the program. So, in such a case the code optimizer cannot do anything. So, you cannot guarantee the amount of improvement that a code optimizer provides. So, sometimes it may be 0 as well. Optimizations may be very broadly classified as local optimizations and global optimizations. So, let me give you a few examples of these optimizations. All local optimizations are within what are known as basic blocks. We will know what these are in a very short period of time. To be very brief basic blocks are single entry single exit areas of code and in such basic blocks whatever optimization we perform the effect will not go beyond the basic block. That is why they are called local optimizations whereas the other type of optimizations are global optimizations. So, the effect of the optimization is on the whole procedure or even the whole program. Some of the optimizations the important ones are local commons of expression elimination then dead code elimination. So, what is dead code instructions that computer value that is never used that is really dead code elimination of such dead code and reordering computations using algebraic laws such as commutativity associativity etcetera. So, these are all called as local optimizations. We are going to see in this lecture how to perform such local optimizations. There are the some of the very important global optimizations are listed here. The global common sub expression elimination which is similar to in effect as the local commons of expression elimination then there is constant propagation constant folding loop invariant code motion partial redundancy elimination loop unrolling function inlining vectorization concurrentization. There are a host of others as well more than another dozen important optimizations which are possible and GCC performs quite a few of them. So, we will you know perform we will understand how to perform local optimizations in this lecture and then in the later lectures we will see how to perform global optimizations as well. So, as I said local optimizations are all performed on basic blocks. So, we must understand the definition of basic blocks how to construct basic blocks etcetera before we go to optimizations. So, basic blocks are sequences of intermediate code with a single entry and a single as the. So, let me show you an example before we consider further before we go further. So, for example, this entire piece of code is one basic block. So, you can see that there is a single entry here and there is a single exit at this point as well. Similarly, these two statements together form a single basic block. So, here is the entry to the whole procedure and here is the exit from the basic block. So, but at the same time this piece of code which corresponds to the entire high level language program which is written here. So, this is the simple dot product program is not a basic block why. So, as we go on here is an entry then we go down and then there is a go to which actually re enters the program I know. So, the B 2 part is the beginning of this T 1. So, here is the B 2 part. So, this is re entering the program again at this point. So, this is not a basic block this whole thing has to be still carved into basic blocks. So, we consider the quadruple version of intermediate code here. We already saw that in the picture to make explanations easier and control flow graphs show control flow among basic blocks. So, this is actually a control flow graph. So, control flow between this and this block is shown by this arc this and this block is shown by this arc and this is a loop again goes back to the beginning of the same block. So, these are all arcs in the control flow graphs and the entire structure is called as a control flow graph. Basic blocks are represented as directed acyclic graphs. So, they do not have any loops within them. So, they are really directed acyclic graphs and we will see how to represent them using value numbering method applied on quadruples and we will also see how to perform the local optimizations on basic blocks.  So, we must determine what are known as the set of leaders that is the set of first statements of the basic blocks. And once we actually get all the leaders in the program you know getting basic blocks is very easy a leader and all statements which follow it up to but not including the next leader or the end of the procedure is the corresponding block basic block corresponding to that leader. So, that is very easy. So, the basic idea is to form leaders and any statements not placed in a block can never be executed and can be removed. So, this is the dead code elimination that we perform. So, if code does not get into a block then it can be it is unreachable and it can be removed. Now, how to get the leaders? The first statement of the program is obviously a leader. So, you must begin somewhere. So, this is the first statement then any statement which is the target of a conditional or unconditional go to is a leader. So, please understand this carefully. We are not talking about the conditional go to statement per say, but we are talking about the target of the conditional statement. So, the target is an entry point to the basic blocks. So, that is why it is a leader and any statement which immediately follows a conditional go to is a leader. So, let me show you how to carve out these basic blocks from this procedure. So, the first statement is a leader. So, this particular thing you know prod equal to 0 is a leader. Then we continue scanning we come here. If i less than equal to 20 b 2 b 2 of course, begins with t 1. So, that is this. So, this statement t 1 equal to 4 star i is a leader. So, we have said prod equal to 0 is a leader t 1 equal to 4 star i is another leader. Then here is this is a conditional go to statement. The statement which follows it is also a leader. So, stop is also a leader. So, we have formed three leaders. Why is it we say the statement following a conditional go to is a leader and not an unconditional go to? The reason is very simple a conditional go to has two exits. One is going back of course, in this case and the other one is if the value of i is greater than 20 the code falls through and executes stop. So, this is the other exit. So, control can go either backwards or forwards that is why the next statement after the conditional go to is an executable statement and that can be marked as a leader of course. And of course, since the entry is the target target is nothing but another entry into the program this will also be called as a leader. Now, suppose this were to be just go to b 2 instead of if i less than equal to 20 go to b 2 suppose this statement was just go to b 2. Then if you observe we will actually go into an infinite loop and we will never be able to reach this statement stop. So, we should never mark this stop as a leader you know this is really dead code and it will get eliminated. Once we have formed the set of leaders. So, this is a leader then this T 1 is a leader and stop is a leader. So, from prod to T 1. So, not inclusive is the first basic block and from T 1 up to stop not inclusive is the second basic block and from stop till the end of the program which is stop itself is the third basic block. So, this is how basic blocks are called out of a program. Now, to do a little of little bit of work on these basic blocks we must also add the arcs into between these basic blocks in order to form the control flow graph. So, how do we add these arcs of course, the first thing is we look at the you know look at the basic block look at the last statement in the basic block. Then if it is not a you know unconditional go to statement then the statement following it can be actually taken as the target of this particular arc. So, in this case we have i equal to 1 which is not a go to and therefore, we mark you know we place an arc between these two to indicate the flow of control. Similarly, we go to the last statement of this particular block it is not an unconditional go to if it were then this would have been decode. So, this is conditional go to. So, the next statement will be executed if the condition is false. So, we place an arc from here to here indicating that control flow can happen here as well. Then of course, we have this arc to show that this is the target of this conditional go to. So, we place the arc between this point the end of the basic block to the target b 2. So, this is how we place arcs to form a control flow graph. So, this is what I just now explain the nodes of the control flow graph or basic blocks one node is distinguished as the initial node. So, this is the procedure entry there is a directed edge b 1 to b 2 if b 2 can immediately follow b 1 in some execution sequence. So, this is what I just explain that is there is a conditional or unconditional jump from the last statement of b 1 to the first statement of b 2. So, here from the last statement of this to the first statement of this and this of course, is not at all a go to. So, from here to here b 2 immediately follows b 1 in the order of the program and b 1 does not end in an unconditional jump. So, this is the other case. Now, how do we represent a basic block? We represent it as a record the record has a count of the number of quadruples in the block a pointer to the leader of the block then we need the predecessors and successors of the block as well. So, with this we can actually form the control flow graph as well. So, the jumps to points to the basic blocks and not quadruples and this makes code movement easy. So, let me explain why this is. So, just imagine that this statement if says if i less than equal to 20 go to 3 because this is statement number 3 really 1 2 and 3. Suppose, we really you know add a few more statements here some statements from here may move to this statement this particular basic block during some optimization. In such a case what happens is the number of this particular quadruple the first quadruple in the basic block b 2 its number will change it may become 5 or 6 let us say. So, if we had maintained go to 3 here we would have had to change that as well you know this number will have to be changed to 5 or 6 appropriately. Whereas, if we simply say go to b 2 where b 2 is nothing but a pointer to the basic block record then we know that in spite of the changes made to the number of quadruples in this basic block this pointer does not change. So, there is really no harm no change that is necessary. So, this makes code movement easy. So, we do not have to worry about changing any numbers if we move code from here to here or to some other place. So, now let us understand how to represent the basic block using directed acyclic graphs. So, what I said here you know this is the extra statement corresponding to a basic block we still have all the quadruples in the basic block and we must actually represent them using directed acyclic graphs this is meta information corresponding to a basic block. Here is a basic block there are 10 statements in this basic block. So, I have observed that there are no jumps here it is just one block of statements. So, let us understand what this structure is this is obviously a directed acyclic graph there is no loop here and let us understand how to build this dag from this set of quadruples. So, the procedure is what I am going to describe now. So, here is a quadruple a equal to 10. So, we form a node a a node containing the value 10 and we attach a label to it called a and then there is an assignment statement b equal to 4 star a. Now, we know we search the dag how to do the search we will see later we search the dag find that there is a node with label a in it. So, this node b can be I know this star node can be created with left child as 4 and the right child as this a and we attach a label b to it. So, we have formed this computation tree as far as these two statements are concerned third one says t 1 equal to i star j. So, similarly we have i here we have j here we create the new nodes i and j then we create a new node star attach these two arcs and attach a label t 1 to it. So, the notation that I have used is the first time that we create a node the value is put inside whether it is a variable or a constant and any extra variables are attached as labels then we have c equal to t 1 plus b. So, we must form actually a node called plus and label it as c. So, this node plus will have t 1 as it is left child and it will have a b as it is right child. So, we can search the dag find out the appropriate nodes corresponding to b and t 1 and establish these links. Then we have t 2 equal to 15 star a. So, we have t 2 here. So, 15 is a new node that we want to create a is already present. So, we can create a star node and attach the links and label it as t 2 then we have d equal to t 2 star c which is very similar. So, we search for t 2 we find it then we search for c we find it and then we form the star node and label it as d. We have e equal to i we find i. So, we do not have to really do any extra creation of node we just attach a label e to it. Then we find t 3 equal to e star j. So, e is here already available then you know t 3 is this. So, e and i are the same j is also here already. So, we are just simply do not create another node for t 3 we attach it to the star node. So, this has two labels now t 1 and t 3. Then the next statement is t 4 equal to i star a. So, we have t 4 here this is a new node that star is a new node that needs to be created i is already there a is also already there. So, we create a new star node and attach a label to it as t 4 the last one is important it says c equal to t 3 plus t 4. So, we find you know t 3 already available and we also find t 4 which is available here, but the point is the variable c is being reassigned. So, there was already a c variable here. So, we need to actually kill the occurrence of the old variable it is not relevant anymore create a new node plus attach a label c to it. So, what are the advantages of this particular approach well if you observe carefully you know we never created the node for t 3 all over again. So, t 1 corresponds to i star j and t 3 even though it is written as e star j because of the assignment equal to i it is really i star j. That means the expression i star j is now both t 1 is available in t 1 and t 3 you know we would have recomputed i star j 2 times if we had used this code. Whereas, if we use the dagger representation we are not going to recomputed i star j all over again it is available in t 1. So, we will simply use t 1 in place of t 3 in our entire program. So, this is an example of common sub expression elimination. Then the second advantage for example, here we have b equal to 4 star a. So, we of course, have created a node for star for the example I showed that we established links to 4 and 10 here a is 10 of course. And instead of doing that when we search for a since we get a value 10 and 4 is actually a constant as it is we could have performed this multiplication 4 into 10 as 40 replaced this entire structure by having one you know node b with the value of 40 this entire computation could have been eliminated. So, this is known as constant folding the we have propagated the value of a from here to here. So, that is constant propagation then we can evaluate 4 star 10 as 40. So, that would be constant folding. So, there is a possibility of constant propagation constant folding and also common sub expression elimination if we use the directed acyclic graph representation here. The only difficulty is if we really build a directed acyclic graph using the pointers and links as we have seen as we see in this picture this is the way we build trees you see. So, if we build such a structure physically by establishing these links and nodes and so on and so forth it is not of much use really let me explain why. So, at some point we want to search for you know say b or something like that right. So, we want to search for or a even better there is no simple mechanism to search for a we will have to start at the root of the directed acyclic graph search the possibly the entire DAG systematically and then at some point in the search we may we will end up getting this a. So, in the worst case you will search the entire DAG this is a you know very expensive process if we had some 1000 statements in the basic block then you know searching the entire DAG of 1000 nodes is very time consuming. So, construction you know of the DAG and trying to find common sub expressions or nodes in the DAG by exhaustive search of the directed acyclic graph is a time waste you know is a time consuming procedure and is a waste of time. If we use links and tree like structures like this this is the only way whereas, if we avoid using these links represent this entire directed acyclic graph using hash table structures then you know the entire operation becomes much much faster. So, this process is known as value numbering and it is used in the construction of basic blocks. So, a simple way to represent DAGs is via value numbering and value numbering uses hash tables. So, searching for expressions and variables is very quick very time efficient the basic idea is to assign numbers to expressions and these numbers are called value numbers. So, when we assign such numbers we when we want to check whether two expressions are the same we simply compare their value numbers if the value numbers are the same then the two expressions are equivalent they will produce the value at all times. So, this is the idea behind value numbering again we are going to assume quadruples with binary or unary operators the algorithm will use different types of tables. For example, for expressions it uses hash tables and then for variables it uses Valnum tables and for constants it uses name tables. So, these you know value numbering methods can be used to eliminate common sub expressions do constant folding then they can be used to perform constant propagation in basic blocks and they can of course be used to extra you know take advantage of the commutativity of operators addition of 0 multiplication of 1 and so on and so forth. So, at this point we will stop the lecture and continue with details in the next lecture. Thank you.


Man of God, please, may Jesus use you to heal my stepfather. Man of God, please, he loves the Lord so much. For how long has it been like this? He had a terrible, he was hit by a log, he was a logger and it blew his lungs, blew him open. And the air lifted him and they had to remove his liners and staples. He's got staples holding himself together inside. So he uses the machine? Worse, to where the machines can't... I feel like I'm going to die. I feel, I want God to save me. I don't want to die. You will not die, but live to testify to the goodness of God. He has been using this machine. Yes, it takes the oxygen, concentrates it from the air so that it goes into his bloodstream and they don't make him strong enough to keep him going and so they have to put him on the bottles and they go too fast and then eventually he has a monitor. He's fighting me all the way. So what do you want Jesus Christ to do for you now? He'll be able to serve you in every way I can.  When the oxygen can't get into your blood his lungs won't hold oxygen for his blood. He's a prisoner of his own home. He hasn't been able to walk. He just stays home. That's all he does. He doesn't even have a wheelchair. He just stays home and just breathes on the machine, just goes to his room and to the kitchen. That's all he does. Restore him, Lord, back to the original position in which you create him to be. Continue to watch the screen. In the name of Jesus Christ. In the mighty name of Jesus Christ. In the mighty name of Jesus Christ. Thank you, Lord. Can you remove him? This man was suffering from sephatic cirrhosis, depression, apnea of sleep, and he was using a machine with a lot of time to breathe. Thank you, Lord. Thank you. Thank you. I love you, Lord. You can go. You are healed. Thank you, Lord. Thank you. Thank you. Hallelujah. It's all in the Lord knows what I know. I've only been at 250. This is ... Awesome! Oxygen tank by you. It's been one year. How are you feeling? Awesome. How long did you have this oxygen tank by you that was permanently with you at all times? Fifteen years.    To ask you, what would you advise people that are here tonight in expectation? Maybe they're in a hopeless situation and those that are watching on livestream. Vic, what would you tell them? I want to tell you all something. Last year, before Christmas, I was supposed to die. I came here from Sister Michelle. My angel brought me to Apostle. He healed me. Okay? The Lord healed me through Apostle. Amen? I can't hear you. That's what I'm talking about. Okay? I gotta tell you guys something. Jesus Christ is very real. You have to believe. You have to have faith. And you have to follow through. Amen? I have one last question for you. Through all this 15 years, were doctors able to help in such a way to remove the oxygen tank away from you permanently? No. Only thing they could do is keep me doped up and out of pain. They said I was gonna die. That's the Lord talking through me. And just remember what I gotta say. Love God, have faith, and follow through. Because if you don't, you might as well forget about it. Just follow through. I love you all. Amen. Give God a hand of applause.


Welcome back to The Breakfast Here on Plus TV Africa. Let's go a little bit back in history. I'm taking us back to 1967. It was on this day that a very, very sad three years of Nigerian history, you know, took place. The start of the Nigerian Civil War also called the Biafran War. It started on this day in 1967 and of course this was as a result of other incidents that are taking place months earlier and a fallout from the Aburi Accord which had, of course, had taken place on the 4th and 5th of July in 1967 also. The Biafran War, of course, the build-up had initially started on the 15th of July 1966 with the first coup led by Cardinal Zogo and, of course, other military officers. It was termed the Igbo coup and then there was a counter coup later in the year in May or July, I believe, of 1966 also that, of course, was called the counter coup, the reprisal coup that led to the killing of Agui Ronci and Fajri and a couple of other people. That was also led by, most of them, the Theophilus, Danjumar, Ulushegon Basinji and a couple of other people. The chaos, of course, that ensued after that, the killings of Igbos in the North and what they call it a program of Igbos in the North and then eventually the Aburi Accord which was meant to ensure some type of peace between both sides, the South Eastern side led by Ojukku and, of course, the Northern or the Nigerian side. That happened in Ghana on the 4th and 5th of July in 1967. But after that Aburi Accord, there were challenges with some sections of the Aburi Accord. I think section 70 and 71 and Ojukku had pointed out that these things were not part of the agreements that they had had and it seemed like it was a totally different draft that was put forward, different from what they had agreed in Aburi. And with some of all this thing, I think one of them was stating that, you know, a military administrator can declare a state of emergency across certain states and when they do that, they take control of those states regardless of whoever their governors are and they can be in control of those states for as long as they choose. And it was one of the things that Ojukku had pointed out that he didn't want as part of the Aburi Accord. Also, the withdrawal of Northern military officers from the Southeast and withdrawal of Southeast military officers from the North. Ojukku then also pointed out the way that he wanted the country to be run and wear their military to be placed at certain times. So those were some of the issues with the Aburi Accord. But with all of that, Ojukku declared Biafra and of course Nigerians military attacked Biafra and that went on for about three years 1967 all the way till the 15th of January in 1971. It was eventually called off. Three million lives were lost according to reports about three million Igbo lives were lost through the war and of course through a shortage of food. There was, of course, the destruction of certain bridges and a blockade of food moving to the Southeast. And those were some of the things that led to the starvation and the loss of that many lives. There was also the Asaba massacre. For other aspects of all these conversations, people have also, people from South-South have also stated that the Biafran soldiers also carried out their own atrocities against people who weren't from the Southeast and all of that. So, well, anyway, it was a sad moment in Nigeria's history. Still is. The sad part for me also is the fact that since 1967, 1970, we still see some elements of that level of hatred and division in our country today. In 2021, we still hear statements from the administration and from people who should know better that seem to point out those same divisions and still try to divide the country even more. That for me is the sad part of this conversation. Wow. The story of the Nigerian Civil War, questions about lessons, what have we learned? Because you still see the president alluding to that particular incident, alluding to that particular event in history and making threats. So, it still seems that we haven't learned much from that, rather than the conversations being nationally about unity and peace, it seems otherwise. And we just hope, really, that we can learn lessons from that and that, you know, the 2023 elections can be peaceful, you know, and will proceed in unity, love, peace, and oneness. And that the Huruba man, the Hausa man, the Igbo man, can appreciate the beauty and diversity and just move along and get along as one great people. And also, on this day in history, on 5.30 a.m., on the 6th of July, 2013, what happened today was that Boko Ram terrorist matched into a boarding school in a place called Mamudu in Yobes state. They assembled students and staff off that school in a room. They threw explosives in there and they basically killed those people. Some others died of gunshot wounds. It was a gory sight. You know, people saw 42 bodies. All international groups condemned this. Just talking about the United Nations, describing this as a terrorist attack, a very terrible situation. Parents struggled to identify their kids because they were burnt beyond recognition. Just imagine being assembled with your friend, your teachers in a room and, you know, boom, the fireworks go off and everybody's toast. It was a very sad day in Nigeria's history and people at that time regarded that as a reprisal for, you know, a military attack on Boko Ram terrorists that had killed about 22 people just a few weeks before. And it was a third, you know, Boko Ram attack in recent time, you know, in those few weeks in the community in Bonu state, in Yobes state. Such a very terrible situation there. A few months before in May, the government of Good Luck Ability Jonathan had declared the state of emergency in Bonu, in Yobes, in Adamoa. That didn't help so much because we continued to see these attacks in states in northern Nigeria. And if anything, the Boko Ram terrorist, despite thoughts and statements from the presidency of them being decimated, we still see innings of them being even emboldened. And I mean, talking about today, many years later, 6th of July, 2021, we're talking about stories here about, you know, how Boko Ram reportedly attacked a school in Kaduna state and abducted about 140 persons, 140 students. Just so sad. Different times, different tactics, you know, but still the same Boko Ram, still the same terrorism, still the same eyeswap, bandits, kidnappers, you know, different names that they are being called.  And now it's spread across not, you know, Yobes. I think in 2013, I know that I think it was Burma and Yobes that were like the hot spots. But now it has gotten, you know, far, you know, beyond those areas. And it's still a very, very sad moment. I remember this story very well. I remember also the stories that were shared by survivors and how insane it is. Yeah, there were about five of them who also had gunshot wounds, yes.  And those who tried to escape the burning of the building were shot, you know, outside. It's just a really, really terrible time in Nigeria's history. But I hope that we heal. A few people have said it, that Nigeria as a country needs healing. Not from just, you know, the suffering, but there's so much pain, so much pain that Nigeria as a country has experienced that the country needs healing, the country needs therapy. There's no way that we can just move on from some of these atrocities. I hope that there is, in the future, maybe another similar or put a panel that people can actually come out to express themselves. And, you know, some of these things can be spoken about again. And we can all come together as a country and, you know, point out one or two days as a day of national mourning for the lives that have been lost, the injustice, the killings, the tears, the sadness, the pain that has been through Nigeria in the last decade. It is unimaginable. It can't even be described the level of pain that people have been through. And the failure also of government to address this pain and address this injustice. Not long ago, a couple of days ago, we were speaking about a 14-year-old girl who was killed by a stray bullet. The Nigerian government has not even been able to take responsibility for the death of that Nigerian. They've not even been able to see her life as important enough, as valuable enough to take responsibility for her death, regardless of whatever explanation that they want to have that, oh, maybe the bullet fell from the sky. Maybe, you know, someone was frying bullets next to a door and one of the bullets popped like popcorn and hit her. They've not been able to even take responsibility for that death. And that is the pain that I'm speaking about, the value of the Nigerian life that has been reduced to almost nothing. Nigeria needs therapy. You need serious therapy and it's not stuff that we can just talk about in the news and move on from. We'll take a break here. Our first big conversation today would be about the southern governor's meeting that occurred yesterday in Kina Laosa, Lagos.


The average American probably doesn't really appreciate the truck drivers.  This side of the economy and the market is really overlooked and underappreciated by a lot of people. And you don't really think about the drivers who are working behind the scenes to get us what we need. But in reality, they're the reason that we are able to live the way we live. The food on our tables, the roof over our head, the clothes on our back. The way of life that we are so used to living is honestly because of our drivers. You know, for the ones who are out there being able to run thousands of miles, it does take a different type of work at me. Truck driving is not a job. It's a lifestyle. Every day they live that lifestyle out there on the road. And it's dangerous. I just appreciate all the sacrifices they make. They're away from their family and their friends. I appreciate our drivers, I would say, first and foremost as individuals. People that are working very hard to make a living and have chosen to do it here with our team at Night Transportation. My drivers helped me grow my career. I wouldn't be where I am today without my drivers. They taught me all the things I needed with each role that I've been in. They're the ones that taught me the most, not the ones in the office. My dad was a driver and so he's on that million mile wall that's right here in our building. So whenever I think of drivers, I think of how can I make that next person that get up on that wall. I'm very grateful for all the men and women that work for Night and that have chosen this honorable profession as a truck driver. I think the pandemic was one of the greatest examples of selfless service for them to put their lives on the line and continue to take all of these loads wherever they needed to go when this country was shut down. And for that, I'll be forever grateful for them. Thank you for everything that you do. I know driving isn't an easy job and I just want to take the time to say I appreciate you. Keep on doing what you're doing and I hope you feel loved here at Night Transportation.


Yeah, my name is Oscar. I work for a London-based digital agency called Binary Vision. We're pretty small, but we've got to work on some big projects. And one of the things that I got to experience working on some of those projects is building style guides and driving our development process through the use of style guides. So today I'm going to talk about component and style guide driven development of WordPress themes for developers. Sorry about the spelling mistake in the thing. Right, so the first thing I want to do is just explain what components are in the context of this talk. So it's a very overloaded term. You've got web components and you've got it used in lots of different places like trendy new things like React. I'm just talking about styled elements in your templates. So the building blocks of your user interface, like blocks of markup that you use repeatedly across your website, ideally with their styles encapsulated using modular CSS naming schemes to make them easy to reuse. And a component-focused approach to design is an alternative to building lots of bespoke layouts. So instead of building bespoke layouts, we identify patterns in our designs and we encapsulate them in blocks of markup that we can reuse and compose into other more complex components. And the aim of that is to improve the development process for implementers to stop us from re-implementing the same patterns over again across the website and to give users a more consistent and predictable experience. So using the conference news page as an example, I've highlighted some possible components. So they could be simple styled elements like... You can see that the paragraphs, they're all sharing the same styles no matter where they're being rendered on the page. And then you've got sort of more complicated, composed components like the sidebar boxes in green which have got a consistent header and then variable content inside them underneath. That's what components are, really. Pretty simple. And style guides in this context are catalogs of components that you've built for your website. So it's basically documentation for the different things that you can use to build your themes and layouts. If you've worked with design agencies before, you might be thinking of something more along the lines of brand guidelines. So a document that tells you what colors to use, where to put your logo, and things like that. And these kind of things are good to include in your website style guide. But when we're building for the web, we can go a lot further than that. So a good example of the kind of style guide that I'm talking about is the gov.uk design system. So the sort of essential features of a style guide are you've got a big list of components on the left and then it gives you an example of what the component you're viewing looks like and it gives you the markup that you use to create that component in your designs. And just to go through some more examples, I was in Australia recently with my family and that's where I did a lot of work on this talk. And so while I was there, I decided to see if the Australian government had a similar thing to the gov.uk design system. And I think there's another good example that I'll talk through some of the good features of in a second after I've introduced more. And then one that you're probably very familiar with, but that doesn't call itself a style guide, is bootstrap documentation. But it fits the model of what we're talking about. So it's a list of the components on the left and then example of how they can be used in the middle column with the markup underneath that you can copy into your designs. But all of the style guides I've shown so far are the products of massive development teams and big organizations. They're not necessarily what we would build if we were creating a WordPress website. A good example of the kind of style guide that we might create is a Perch UI pattern library. Now, this was built using a tool called Fractool which came out of a Brighton-based design consultancy called ClearLeft. And it's a tool specifically designed for creating style guides. And so I've explained the core functionality there, list of components, examples of what they'll look like and the markup that you need to use them in your designs. I want to go back through the examples and quickly highlight some of the other features I think make for a good style guide. So on the Gov.uk design system, they've got an open in a new window button and that might seem like a silly thing, but it lets you open an isolated view of just how the component looks which is really, really great for setting up automated tests and things to catch regressions of your important components. I don't know if you've ever worked with companies where they try and beat you over the head with the reputation of damage stick, but setting up automated tests so you can be confident that when you make changes, something like your payment form or something like that isn't going to break in a way that disrupts users is really essential. And having something like this which gives you a clear, consistent example that you can test against is brilliant because if you're testing against a live site, the content might change, you'll get false positives, people might ignore flags saying, oh, there's something changed because they think that it's just another content change or something like that. And then another thing that the Gov.uk design system does is it doesn't just give the HTML that you can copy to create components. It also provides the components as templates so you can use the templates in your designs and rather than duplicating the markup which you will then have to update if the component markup ever changes, you just update the dependency and it will update the markup for you. And getting people to adopt using Star Guides can be quite difficult. So convenience functions like the little copy in the right there can be really essential to just getting that critical mass of usage and keeping people coming back to the tool. And on the Australian design system website, I think one of their focuses has been on creating a Star Guide that is easily navigable. Star Guides can get really big. Even on a small website, you end up with lots and lots of components and if it becomes impossible to find stuff, people will stop using it or they'll start re-implementing the same patterns that you've already got because they can't find them. And so they're really focused on having a clear and easy-to-use search and they've got all of the important metadata that you might want about that component like a history of its changes, how to install it individually and tanks to find related components prominently featured at the top of the page. And another thing I like about this is so when I say Star Guide, what I really mean is kind of documentation for your website and one of the great things about having a tool like Star Guide is that you can highlight the things that are important to you as part of your design process. So here, they've prominently highlighted or I've drawn a box around, but they've got rationale and accessibility displayed there and those are things that kind of maybe happen at the start of the design process or at the end of the design process but are kind of lost in between a lot of the time. But by having those featured there, so as people are developing, as people are checking on the progress, it's clear where there are gaps or where something is straying away from the intention. Just helps to shorten the cycle of catching errors quite a lot. And on the Bootstrap site, the way that they've tackled the problem of sort of very dense long pages and making it easy for people to navigate is they've got a table of contents in the top right. I don't want to have to scroll to the bottom of the page and then up again to try and work out what's on that page and if it's relevant to me, I can just scan the headings in the right and see instantly whether or not there's something there for me. And then another thing that they do really well is they show you all of the variations of that component in one place so you can scan them all at once. I mean, if you would split this up and this is one of the things you might have to make at different times across multiple pages, say one page for each of those variations, it'd be very hard for people to quickly work out which one was appropriate for them or what are the different options they could use. With the Perch UI pattern library, so one of the great things that they've done is a feature of Fractal but the example is inside an iframe. So if you look at the pink bar on the right, that allows you to change the width of the viewport. So you can check the responsiveness of your elements in the browser like that. And I know we've got browser developer tools but those aren't accessible to everyone. I mean, I know a lot of designers that they could do it but they just don't feel comfortable doing it and so they wouldn't do it. Whereas with that, a designer or someone who's a client or a business owner or something can come in here and they can test it themselves and see if it's meeting their expectations really easily. And then another thing that I think Fractal does really well is it promotes the idea of not just displaying your components but also displaying examples of the actual layouts that you're going to have. So layout variations, they show up when we're doing Photoshop designs but when you move to a production website, how do you know how many variations of layout there are across your website? You know, if you're working on a website that's got thousands of pages, you might have one or two people that know where those variations are but it can get hidden. And so I think perpetuating the like, stunning mockups that you do in development and keeping them as part of your development process and documented in your style guide is a really good way of just making sure that everyone is aware of an overview of what you're doing or what you're trying to do and the context of how the components are supposed to be used. So there are a lot of different things that you can include in your style guides and I think that they're great but they have a very high cost to introduce into your development process potentially and there are some foundational things that you might want to establish before you start using them. So you really need to consider carefully if you really need one. If the site is a one-off and it won't be developed any further then you might not recoup the overhead that you invest in getting it set up and you need to make sure that your clients understand the overhead that you're introducing because maybe all they want when they're agreeing to your use or development of a style guide is a page on their website which gives them some examples of the things that they can do in their editor field or something like that and you really don't want to miss-sell this otherwise as soon as you hit a stumbling point you'll just be totally demotivated and stop maintaining it and then that's a massive waste. But there are a lot of situations where over time even if the adoption is hard work and takes a lot of time and effort you can get a really good return on your investment. I think that style guides shine when you need to coordinate development between lots of people and roles or when you have over time different people working on the site. Documentation is an essential part of successful projects but often it is absent from the front-ends of our websites and if you weren't there when the thing was designed then you have to reverse engineer the interface to work out what you can do and absent from that is any context around how that was supposed to be used or any considerations that you might need to have about decisions that were made around that and the people that originally worked and it might not be available anymore and so having this documentation in the form of a style guide that is kept up to date because it's using the same CSS and JavaScript that your FEMA is using and it's an everyday part of your development process is really helpful. And I mentioned this before but style guides are also amazing for facilitating user testing. So if you've got people that are tasked with going and testing your website and making sure it works as you expect in different browsers and different devices and things like that then often the things that they have to test against are vague descriptions of how stuff should work or very out of date design mockups. When you take a Photoshop design and you transfer it into templates stuff changes and so it's not always a good idea to be testing it so otherwise you might be fielding a lot of questions that you just have to say oh that's deliberate or that was intended. So users, so testers can take the style guide as a reference and they can test the production site to make sure that everything is working how it should work or they can just test directly against the style guide because the style guide gives them the ability to get a quick overview of all of the different components on the website and how they should look and to see where there are gaps. So for example are there hover styles missing from certain things or accessibility issues like this element doesn't have any focus styles. So a lot of people that I talk to don't need to be sold on the benefits. They already know that they want to do it but where they stumble is working out how to do it. A lot of the tools for creating style guides are in different languages than people are used to. They're in Node.js primarily and if you come in from maybe a background in PHP or building WordPress themes and you're not used to things like automating the build of your static assets and things with task runners like Grunt and Gulp then it can just be very overwhelming because you have a lot of stuff to learn all at once. And there are also a lot of different options at the moment but I don't think that they are all equivalent. I've got experience using two tools for building style guides and I'm going to introduce you to those and just make some recommendations about where I would start normally in my development process. So the first one is KSS Node. A bit of an inscrutable name but KSS stands for Nile Style Sheets and it's basically just a format for documenting your CSS with structured comments. So if you've ever, you know, I don't know what the equivalent in PHP would be, PHP doc, I don't know. But basically, KSS Node uses this documentation format and some conventions to pass the information it needs for the style guide out of the comments included in your CSS. And it's quite an actively maintained project. It gets quite a lot of use in the Drupal world and it supports twig templates which means that if you want to reuse the templates between your style guide and WordPress then there is a means for you to do that which can be quite important if you're working on a big project. So here is an example of the default style guide theme for KSS Node and it's just displaying a button component. So it's listing the different variations. It's also listing the hover styles at the bottom and the markup for that component and how you use it. And the information that you need to be able to create that is included in the comment at the top of the page here. It's a bit difficult to see maybe from the back but basically it just says the title of the component, a description of the component, a reference to the markup example for the component and then it lists the variations and the place in the style guide document where this component should be located. It's very simple and clear and I think that even if you didn't know what the style guide was and you're editing this CSS you would understand that this is something that should be kept up to date with any style changes that you make which is a very helpful thing if you've got a big team and you're struggling to get people to adopt this way of working. A problem with this approach though is that because it's passing CSS comments and it's relying on certain conventions it's quite difficult to do new things. If you're working outside the conventions that KSS Node sets out then it's challenged to update things. The next tool that I'm going to talk about is Fractal which does things a little bit differently and is maybe a little bit more flexible at the cost of being or requiring a little bit more work to maintain. So like I said, Fractal is a project from a design agency and the default theme kind of reflects this. I think it looks a lot prettier out of the box so if that's a concern for you then it's definitely a front runner. It's very similar. It has a list of components on the left an example of how the component looks and then the markup at the bottom but the way that it stores its configuration for components is just in separate files. I think JavaScript, JSON or YAML files are next to the components markup. And I think it's a really good tool. I was hesitant to include it because up until recently it was not very actively developed. It had kind of died so Clear Left is a design company and I think that the people that had originally worked on building this tool had kind of had other things come up and no one had stepped up to take over the development of it. But that was recently highlighted online by some people after a few blog posts or articles were published and now there's been a surge of support and people coming forward to say that they'll help maintain it and develop it into the future. So now it's actually probably looking quite strong as a choice for creating Star Guides. If I was going to recommend one, I mean when I was getting started I started with KSS Node but I very quickly came up against the limits of that tool and so I would probably recommend if you feel confident starting with Fractal. It might be a bit more confusing but the basic use case is pretty easy to work with so I would stay sort of laser focused on that when you're getting started and not get too stuck looking at the documentation and thinking, ah, paralyzed. So once you've chosen the tool that you're going to use, you need to answer some questions. So the first question I think is where will you create it? And it might seem like a silly, you know, does it matter? But if your first thought is I'm going to spin up another repository, I'm going to stick all the configuration in there. It's a separate thing to my theme. I think that's a mistake. The best place to put it is to just create a subfolder of your theme and shovel the configuration in there. So there's a high coupling between the Star Guide and your theme and you want them both to be in sync as much as possible because if you've got documentation published that's out of date, then people are not going to use it and if they stop using it, then it's just going to compound and eventually you've invested all this time for nothing. So removing as many roadblocks as you can, keeping them located close together is important, I think. And then the next question, which is maybe slightly bigger and a bit more ambiguous is how will you manage your component markup? So there are kind of two options here. The first and default one is that markup gets duplicated across your theme and your Star Guide. So when you go to your Star Guide and you say, oh, there's a component I want to use, you just select the markup and you paste it into your theme and then maybe you end up with, you know, lots of different instances of that across your theme which is difficult to maintain because even normally having your markup spread across would be difficult to maintain, but when you've got the Star Guide as well, you might have developers who are going in and they're editing the theme directly, making changes and forgetting, maybe deliberately forgetting that they also need to update the Star Guide markup as well. And if you have a very big site, then this can just become more and more of a problem. So one way to get around that is that you define your markup once in templates, just like with the gov.uk design systems website and then your theme and your Star Guide both use these. And I think one of the really good things about this approach as well is that if you have a large team of people building a website, multiple developers, then at the start of the development process, your front-end developers can get started building static HTML. They can build your components for you, mock it up and show it to the client before anyone is engaged in doing WordPress stuff. But then when someone comes to integrate those designs into WordPress, the HTML markup and the CSS and JavaScript is already there for them to use. So you're not doing the usual development process thing of saying, well, here's all this work I did. I'll just drop it in the bin and re-implement it. You're taking the assets from your earlier steps and you're using them in the later steps to save yourself time. The problem is that this is just quite a complicated thing to do.  And like I said, because the tool that you're using to build your Star Guide is likely in a different language to the tool that you're using to build your themes, PHP and Node.js. You need to use and create your components, templates in such a way that they will survive that translation, which can be done. It just requires some more thought and is more complexity. And then the next thing is where should you host your Star Guide? So it is super important that deploying your Star Guide just happens automatically, that there is no manual step that you have to do. It just happens as part of your development process. You might be tempted because the Star Guides that these tools create are just static websites. It's static HTML and CSS and JavaScript. So you could just drop them in your web route of your site under slash Star Guide. But then there's a dependency on you having your WordPress hosting set up from the start of development and things like that. And a lot of managed WordPress hosting environments, they don't allow you to run arbitrary build steps. You know, they might automatically deploy from Git, but there isn't a way for you to hook into that and say, when you do a checkout, build the Star Guide and put it here. So the recommendation from me is that you use a service to host your static site specifically. The one that I've got experience with is Netlify. And they're cheap. They're reliable. And what they have is ways to hook into the lifecycle events of your repositories on Git. So watch for changes being pushed. And when a change is being pushed to trigger builds of static websites, which is perfect for Star Guides, and it means that hosting a Star Guide initially for a front-end developer is as simple as changing into that directory and then running Netlify deploy. And then they've got something that they can share with other people, which is great. So I've talked about what components of Star Guides are, and I've talked about what my recommendations are for the tools that you might want to use when getting started with this. But the title of the talk is component in the Star Guide-driven development. And so I just wanted to go through a kind of, you know, tacky flowchart that sort of explains how I think using Star Guides changes your development process and sort of decouples some of the steps that sometimes you end up with things being blocked. So each of the columns here is stuff that can happen in parallel. So the normal development process that I've experienced is you define your requirements, you create sort of low-fidelity mock-ups so you sketch out what something's supposed to look like just to make sure in the cheapest possible way that you are building the right thing. Then you might create more high-fidelity designs, go into Photoshop or Sketch, and someone will take the brand guidelines and they'll create nice, beautiful designs for you. And then from there, normally, because of time constraints, things like that, you jump straight into putting stuff into WordPress templates, whereas I think that there is an important place for creating static HTML prototypes. I think it's much faster to build static HTML prototypes of designs to test them and to proof them. And I think that, as I mentioned with the purchase example, if you keep those static HTML layouts that you create and persist them in your documentation, then they can be a really valuable resource for future people who want to just quickly see an overview of what have we built, what is available to build on the website. And so with StarGuy-driven development, at the same time you're doing those initial free steps, your front-end developer can be bootstrapping the StarGuy, they can bootstrap the component template system if you're going to share components, and they can start the CSS and build setup if you're using sassins, you know, other JavaScript build things. And then once you've got the designs and that initial build system set up, you can create the HTML prototypes. And while all of that's happening, sort of in parallel, and it could sort of be in parallel to everything, to be honest, the WordPress environments are being set up and the final deployment pipeline for WordPress changes is being set up, which maybe needs a little bit more in terms of like... We've worked with a lot of clients who want to host their own websites. They have an internal IT department and there is a certain overhead in terms of getting environments provisioned that we don't really want to be blocked by. And so being able to detach ourselves from needing those environments, to be able to demo to clients and to work collaboratively on the designs is really important to us. And so, yeah, working in this way is for us been really good. And so we create our static HTML prototypes and once we've got those and we've got our WordPress thing set up, we create the WordPress content model, same thing that everyone does, you know, define our custom fields, that kind of stuff and our different content types. And then we create the WordPress templates. And the key thing is, when we get to create the WordPress templates, is that if you weren't using a style guide or you weren't using templates that you were going to share between your static HTML prototypes and the WordPress templates, then you would just have to copy and paste stuff from those that HTML you created originally and then modify it into the WordPress templates which is a bit of a waste. Whereas if you are sharing the templates, then when you're creating the WordPress templates, you can just jump straight in to output them without having to think about stuff and knowing that when you make changes in the future, everything will be kept in sync. And obviously, this isn't something that would happen, a process that would happen once in the development. This is a process that might be applied to each feature that you build or something like that, except as you build more features, you don't have to do the stuff that you're doing in parallel there to get stuff started. Thank you very much for listening. I hope that's been a helpful talk. And thank you for patiently sitting through what can be quite complex and new stuff. So if you have any questions, let me know now or grab me afterwards. And I'll put the slides up online afterwards. There are a lot of notes in my presenter notes that if you're interested in this, you can look through and pull out references and stuff. Okay, thank you, Oscar. So hands up, any questions? Gentleman just there. Hi, thanks. It was superbly useful. Do you have a favorite automated visual regression testing tool that you use? The one that we use is a service that's called Ghost Inspector, just because I don't want to have to set up the tests. I don't want to use Selenium or something as a test runner or a programming library that I have to maintain. I want something that I can give to a tester and that they can define the tests and create the tests themselves and take ownership of them. And that is a paid service, but it does that. That was a great talk. And how do patterns fit in with what you've been talking about with components today? I mean, pans are basically just design pans. So when you do your designs, if you have a... Thinking in terms of design pans is like, I'm going to have a section navigation on the left that's going to conform to certain conventions. I'm going to have buttons all kind of styled similarly. So rather than having 10 different kinds of button on my website, I'm just going to have one button style so that users have a consistent experience. And yeah, pans is just, you know, looking for in your designs where stuff is similar and where they should really look the same and then turning those into components. Hey, talking about how we all love to shortcut process, you mentioned that you can have your build tool build the style guide in situ or in sync with the production site. Can you talk a little bit about how you do that with Fractal, say, like a basic component? That'd be great. Yeah, I mean, so the way that we work when we deploy our websites, I mean, we use managed WordPress hosting. So I haven't done this development process on a lot of WordPress sites, but we normally use Jenkins as our deployment runner, basically, so it gives you a web interface where you can trigger stuff. And those things that you might be triggering might be I want to deploy the theme to production. And when you trigger that job, it's just running some scripts. You know, it might be pulling in the source code from a Git repository and then copying it into a folder on a server. And so what I mean about linking the processes together is basically at the same point in time that you copied the things to be deployed, you might also run the generation. It's basically the way that you trigger a build of the style guides. It's just a command line invocation of the library and then it outputs the static HTML. So as a part of that process, you would just also trigger the build and then copy those files to somewhere you want to keep them. Yeah, cool. Anymore? So I suppose I've got a question. So how long did it take you to get comfortable with all the tools? And maybe were there any hurdles that you wanted to get over? Yeah, I think wrapping my head around what the tools are trying to do was quite hard at the start. But basically it is just you've got a list of all of your components and it's taking some templates and it's just transforming that into a static website. But for some reason at the start, when I was first looking at it, I had this really strong idea in my head that there was magic involved or it was doing something that was really unintuitive. And I think that some of the documentation for these tools because a lot of the tools aren't built by large teams, they're built by individuals and so they can be a bit poorly maintained or have their idiosyncrasies and so they can be a bit overwhelming to look at because people have explained things in a way that they understand them but it's not necessarily intuitive to others. So when you actually deploy, you have some inline comments there with your CSS. Do you deploy the comments as well?  I mean, we normally use a build step for our CSS which just kind of... Or we normally work in SAS and so part of our build process is compiling our CSS, compressing it. And so that kind of strips out comments and things like that. But you don't have to, I don't think there's... It might be a bit confusing to people who are looking at it but there's no real reason that you have to or you don't have to. Yeah, I was kind of more wondering, you know, like on one of those big chunky sort of sites, you know, all the inline comments could end up doubling the size of it. Yeah, it does add a massive overhead, especially one of the things I found with CSS and it was over time as we were putting more and more information into the comments, you know, you had to kind of scroll a considerable amount before you actually got to the CSS that you wanted to edit, which was not ideal, which is part of why I'd probably recommend Fractal because it keeps stuff separate. Any more questions from anyone? Oh, we've got one right here. Jost. Not Jost himself. Maybe a bit open-ended question, but with Gutenberg versus seeing the introduction of blocks. And I was wondering, do you still see a use case for... Or do you see that impacting the use case for style guides in any way? I think it probably makes it more important because you've now got another way where you can have components to things to find. And so, again, it's another place that you've got to maintain stuff. And I mean, I don't know what the documentation for Gutenberg components is like at the moment. I guess you can see an overview of all the Gutenberg components that are available, but as those grow, you still want to have a way of kind of making sure that everyone is building stuff consistently. So if people have got hundreds of Gutenberg components, but you don't really want them to go and use all of those components, them to use a limited amount of them, then one of the things you can have in your style guide is just say, how you use this pattern. You can just use this Gutenberg component that we've customized so that it outputs the HTML in the right way so that it displays this component or something like that. Anymore? Oh, oh, you forgot mine. Hunter, you mentioned overhead halfway in your talk. At the end, I would also say there's efficiency. Yeah. What kind of... Are you still talking overhead in the end of the run? I mean, I think that the more you do this, the more comfortable you get with it, the less overhead there is and the more sense it makes to use it even on small projects and things like that. It's just like, for me, one of the things I need to evaluate is other developers are going to have to work in this way. And so it needs to be really simple and easy to use. And I can see that there are a lot of projects where, you know, getting people to learn how to use all these different things. One of the things that working this way does is it kind of... It requires people to use a specific development workflow locally to a certain extent. And in my experience, people all have their own customized ways of doing things locally. And so there is a resistance to changing things that you have to think about. And you don't want to... You don't want to get halfway and then discard it because it's... Yeah. What kind of percentage of a project would you say? Are we talking 5% overhead? If you just talk about a project you did? I think it depends. So, for example, if you've never worked with automated build steps before, like your CSS and your JavaScript just come in through WordPress on queue head and, you know, then you're going to struggle because there's going to be a massive learning curve for you in terms of getting up to speed on that kind of stuff. So it depends on the team and it depends on, yeah, what kind of project you're building. So I think that one of the things about Star Guides for me is that you can get started with them early before you've got a coherent design for everything and you can sort of quickly demo stuff to clients and get them to help you build things. So there are definitely some projects where just working out what it is you're supposed to build is quite a challenge and unless people can see something in front of them then they just kind of go, I don't know or, you know, they don't communicate. And so having a tool like this where you can put something functional in front of them and they can like Twitter the knobs and things like that very quickly is very useful and then you don't have the overhead of WordPress and stuff like that which can get in the way early on. Thanks. Another question. That's all right. I'm going. I'm going. I need the exercise. Hi. Thanks for the great talk. I suppose one of the more complex parts of Star Guides and building outsides is the duplicated markup and if you really want to maintain the consistency between a style guide and the site itself you really want to have that one source of truth for the markup and with SAS and JavaScript we have dependency management. But with the markup I suppose we can start using things like partials which are then written with handlebars. Is that kind of the approach that you've gone with and then be imported into the style guide and to the site? I mean, yeah, handlebars or mustache or twig. Like I said, in terms of where you put your style guide so for me the idea is that your component markup templates just live in a folder in your theme called components and your style guide configuration lives in a folder called style guide and then you've got your WordPress templates there as well. And so in your theme all you're doing is if you say using twig or mustache or something saying pulling in the library somehow however you want and then pointing it to that folder and getting your template loader and then using that maybe for a function or something as an API. And then the actual style guide tools themselves work with those template languages already internally. Fantastic, thank you. What I took away from that is you usually mustache to work with. Any more questions? No, all good. Round of applause please. Thank you very much.