In all the units of this module up until now, we talked about the specifications of the Jack language, the various commands that the language features, and so on and so forth. In this unit and then the next two units were going to talk about how can we use this language to developed all sorts of cool applications. So let me start by showing you some screenshots of existing applications beginning with this rather trivial program that interacts with the user, gets some names and grades in some course and then it produces the average of all the grades and the name of the student that got the highest grade. So a very simple program that presumably uses some loop to interact with user. Here is a classical Tetris game implemented in a certain way. Here is the bouncing ball, it's not exactly a game but rather a wonderful demonstration of what can be done in terms of dynamic graphics with the Jack. Here's a classical Space Invaders game and, finally in this set of example, is Sokoban game. A very cool game that came from Japan, I believe. And all these games and numerous others were developed mostly by students who took this course. And by now you're going to join this camp and develop some cool applications of your own. So how you should go about it? Well, we recommend going through the following sequence. First of all create a new directory and give it a name. The name should be the name of the application that you develop. For example Tetris, so call this directory Tetris. Then write and later on edit your Jack class files using a standard text editor and put all these files in the directory that you created previously. If you have access to a more sophisticated text editor that can be customised to help you write Jack programs using the Jack syntax. You should feel free to use it, but let's not make a big deal out of it. You simply have to write your program using some standard editor. Once the program is ready for compilation, you can apply the supplied JackCompiler to the program to either to the individual Jack files that make your program. Or you can apply the directory, or you can apply the JackCompiler to the entire directory and the JackCompiler is clever enough to go through everyone of the Jack files within the directory and compile them one at a time. So for each one of these Jack files the compiler will produce the corresponding VM file which is the compiled version of the jack file. Then you can execute your program in several different ways. And the most natural approach is to simply load the entire directory into the VM emulator and by doing this the emulator will ignore the Jack files it will load the VM files, the VM code into the emulator's environment and then you can go on and run your program. So that's how you do it. Here's an example of a screenshot of the VM emulator running a certain program and once again this is the environment that we recommend using for executing the programs that you will write as well. All right, now how should you handle input and output. Well it depends on what you want to do. If you're developing a textual application that deals with a simple characters and strings. Then you should view the screen, the screen that you saw before, the screen of the VM emulator or the hex screen in general. You should view it as a grid consisting of 23 rows each of 64 characters black and white. And if you're using the supplied Jack operating system for writing your outputs, then the operating system features a fixed font that you are welcome to use, and here's the API of this class. The class is called output, and it features a bunch of self-explanatory functions for handling textual output. So you're welcome to use this class in order to generate your textual outputs. Now what about if you decide to develop a graphical application like Pong, or Space Invaders, or Snake, or something like that? Well in that case, you should view the same physical screen that we saw earlier, the same hex screen as a grid consisting of 256 rows of 512 pixels each, once again, black and white. And if you want to generate graphics, we recommend that you use the supplied Jack OS screen class or you can do graphics using your own libraries. Something that we will discuss in separate unit later on in this module. So here's the API of the screen class which is the name of our graphics package so to speak. And as you see it features once again a bunch of self explanatory functions for drawing pixels on the screen. The setColor function is used to set a global color which is either black and white for all the subsequent drawing operations until the next invocation of setColor. So if you want to draw in black we invoke setColor true. And then all the subsequent drawPixel, drawLine, and so on. If you have those method invocations or method calls in your code, will draw in black. If you, all of a sudden, want to erase stuff or draw in white, then you set color to white and, once again, all the subsequent graphics operations will use the background color. And we're switching occasionally from black and white when we want to create animation effect, and we'll talk about this and demonstrate it later on in the next module actually, not in the next module in next unit in this module. What about inputs? Well, the standard input device of the head computer is a standard keyboard like the one that you are presently using on your own computer. And in order to control input that comes from the keyboard we supply a class called keyboard. It is part of the operating system. And this class once again provides a set of four self-explanatory methods or functions for handling the keyboards. And we recommend that you use it in order to control what the user wants to do. Well here's the character set, which is recognized by the hack computer of which the arrow keys, up arrow, left arrow, down arrow, left and right are very useful in all sorts of interactive games. But you are welcome to use other keys as well. And given this context of character set I want to say a few words about the key press method. The key press method is such that it always returns the scan code of the key that the user is currently pressing. So as long as my finger is down on a certain key, let's say on left arrow, keypress is going to return the number 130. Once I lift my finger and don't touch the keyboard anymore, keypress will return zero. So one basic way to interact with the user is to continuously sample the keyboard using key press and check what this method returns. We'll do this later on when we'll demonstrate an interactive jack application that does just that. Moving along, the OS supplies all sorts of other classes as well. Here is our math library and it fishes all sorts of useful, I shouldn't say useful, but functions that you may need in your applications. If you need a certain function that is not found here you should develop it yourself. Multiply and divide are two functions that you don't actually need when you develop regular applications in Jack because the Jack language features a multiply operator, asterisk and a divide operator. Slash but you will need these functions for some other purposes when writing the compiler and so on. So don't worry about it, but once again, you won't need it for Jack programming. So this class is quite similar to the math class of Java. With a small difference that Java's math class features about, I don't know, several dozens of mathematical functions and ours features only six or seven such functions. Clearly, we can add more to future versions of the Jack language and operating system. Then we have just like Java, we have another very useful class which is a string. And the string class provides a string obstruction and so it features a constructor for creating strings, a bunch of self explanatory methods for manipulating the current string as well as special characters like backspace, double quote and new line. Moving along, we also have an array class in the operating system. And this somewhat unique to the Jack language. If you want to create an array in a Jack program you have to make a call to array.new. And this will create the array, and later on you can access this array just like you do in other languages using an index which is surrounded by square brackets. This syntax is supported by the Jack compiler. When you no longer need the array we recommend to dispose it. We also have a memory class that allows Jack programs to access the host RAM directly. And you do it using the peek and poke methods which are highly dangerous, obviously. Because you can get into all sorts of addresses that you shouldn't play with. Addresses that are perhaps in the stack or some pointers so it's up to you to use this functions with greater caution and we'll make a lot of views from them when we develop this operating system later on. We also provide alloc and dealloc functions which are used to create memory blocks and dispose them when they are no longer needed. Once again, the best way to learn how to use these classes is to see examples and that's what we'll do in the next unit. The Sys class provides a set of three utilities, halt, error, and wait. You can read the API later on and see what each one of them does. The wait function is quite useful. For example, if you create an animation that runs within some loop, and you think that the animation is too fast, you can slow it down or add some delay factor by putting the wait command Into this loop. The output class we saw and discussed before likewise a screen was discussed and so was keyboard. And this pretty much wraps up the description of our operating system. So just like java has a standard library that accompanies the language. This is our library, the Jack library, with once again a small difference that the standard library that accompanies Java contains as of 2016, I think about 4,000 classes. And the library that accompanies the Jack language contains as of 2016 eight classes. All right moving along, I guess that the best way to appreciate Jack programming is to look at existing Jack programs. So during this module we showed you many such programs like fractions and linked lists and so on. And in addition we are going to show you another program called Square which consists of three classes and gives a demonstration of a simple interactive game. We also provide the complete code of Pong, which is a more elaborate, interactive, multiclass object oriented application and then, there's a set of programs, Average, ComplexArrays and ConvertToBin. That are supplied actually as part of project 11. We are now in this module going to do project 9. But if you want you can go to the project 11 directory and take a look at the code of these programs also. These programs are used in the context of developing the primary. We use them as test programs that will test your evolving JackCompiler. But you can certainly look at them also in the context of project nine if you feel that you want to see more examples of Jack programming. Now here are a few guidelines as to what we think is the best way to develop your application. First of all, watch some existing Jack apps. You can do it by going to the course website. Play with some of the supplied applications like Square and Pong. Understand the user experience limitations and the style of Jack input/output. Obviously, you should invest time in planning your application carefully. You have to decide exactly what the user is allowed and prompted to do. And then you have to plan how you're going to implement it. You will have to decide on how many classes and which classes you will need in your application and so on and obviously it's always recommended to think about your testing strategy early on in the application's development. Once you do this just implement the program test it and have fun. You should enjoy the fruits of your work and I'm sure that some of you will come up with great examples of Jack programming. Here are a few technical tips. We talked about them before. You should write your programs using a text editor. Make sure that you understand and you know or you get familiar with the operating system. You can optimize your graphics if you want your graphics to sail on the screen more smoothly using some tricks that we'll discuss in a later unit. You should document your code just like a document Java, Python programs and so on so it's up to you to decide how much documentation you should use following conventional practices. In order to compile your code use the supplied JackCompiler and then to execute it use the VM emulator. As you use the VM emulator we recommend that you remember that you have a slider that controls the speed of the execution and also some animation controls that you should use in order to enable various modes of operation within the within the emulators environment. If you're not sure look at the VM emulator tutorial which is available in the course website. So that's it. That's what I wanted to say about some general ideas and notions of developing Jack applications and using the operating system. And what we'll do next is we're going to go through the code of an entire Jack application consisting of several classes.