Welcome to this discussion of the Jack Language Data Types. In the previous unit, we talked about the language's syntax, and now we talk about what kind of data Jack programs are allowed to create and manipulate. And, as usual, we'll start with an example. So, here's some Jack code that does something. It's not terribly important what the program is doing. And, let us focus on these three statements here. In which the programmer goes on to create an array called A. An integer variable called length, and two more integer variables called I and sum. And what we see from this is that the Jack language has, first of all, primitive types, of which we have three only. The int data type can hold values in the range of 0 to 32,767. Then we have a Boolean types, which either true or false. And we have car types, which are essentially numbers that represent characters using the Unicode character scheme, or the ASCII scheme. Which happens to be the same in the subset of characters that we use in this course. Now you may ask yourself well, if an entry value can be only a non-negative, how do I represent negative numbers in Jack. Well you can always precede a value with a minus, but this will not be a constant. It will be, actually, an expression, in which we apply the money minus operator to the non-negative value that follows it. So from the programmer's perspective, negative numbers are just as easy to use as positive ones, but the implementation is somewhat a little bit more involved. Moving along, we also have class types. For example, in this piece of code here, we see the A variable whose type is array. And they're either class types that come from the Jack operating systems, like string and array. And they may be class types that the user has created. And when we say user here, we mean the practicing Jack programmer, who may have well, design classes like fraction, and list, and stack, and whatnot. And therefore he or she is free to create variables that have these data types as they, as they please. So like, you know, any other high level object based language, we have primitive types as well as class types. Moving along, I'd like to demonstrate the type conversions in Jack, which may well be quite wild. So first of all, characters and integers can be converted into each other at will and as needed. This is quite similar to what can be done in other languages. So if we have a character variable called C, I can say C=33, where 33 is just an integer value. And this will give me the representation of capital A according to the ASCII code. Equivalently, I can also create a string called S. I can assign the string upper case A to S with two double quotes. And if I want to convert it into a character, then I must use the charAt function, which is part of our operating system. And I do it by calling the charAt function on the s character. And this is a little bit cumbersome, because ideally we would like to say simply c="A". But this idiom is not supported by the Jack language. Which may create some inconveniences to someone who wants to do a lot of string and character processing. And yet, it will make the writing of the compiler much easier, so not much easier but easier. So we will thank these concessions later on when we develop the compiler. Now an integer can be assigned to reference variables, in which case it is treated as a memory address. So consider this piece of code here will create an array called arr. And then we happily say arr = 5000. Which is somewhat crazy isn't it? Because arr is supposed to be an array. And yet the Jack language supports this kind of assignment. And if you do it you basically tell the system that there are error array ought to start in base address 5000. So from now on, if you say arr = 17, well, the compiler will generate code that will cause the REM application 5000 and 100, which is 5000 plus 100, to become 17. So as you see this kind of casting is quite exotic and wild. And in the wrong hands, it can create havoc because it allows programmers to take control over the RAM and do whatever they want with it. And yet, these tricks here will once again prove extremely useful when we develop the operating system later on in the course. So it's nice that we can do all sorts of exotic hacks, and we will certainly exploit them down the road. What else? An object can be easily converted into an Array and vice versa. So for example, if I create an object X of type of fraction, then I recall that fraction objects have two fields, numerator and denominator. So let's put this in the back of our mind. Then I create an array called arr. I construct the array to be two entries long. And then I say arr =2, arr = 5, and now I do something strange. I say x=arr. So x, which is a fraction, now points at the arr array. And once I do this, I can say, for example, do x.print, and this will invoke the print method of the fraction class on x. And even though x points to an array, it will treat this array as a fraction. And therefore, it will print it as 2 slash 5. So once again, quite a wild casting, and yet, makes perfect sense, because internally, arrays and objects are handled almost the same. That's why in languages like Java and C-Sharp, you can easily serialize an object into an array and so on. So in Jack, this relationship is more explicit, I think. More clear. So that's it. That's what I wanted to say about data types in Jack. And to sum up, we can conclude that Jack has a rather primitive set of types. We have only three of them. Java has eight, we have three. We could easily add more, but we didn't find it necessary from pedagogical values. And the Jack language is also weakly typed. In fact, it's very weakly typed. Any variable can be assigned to any variable in respective to its type. And on the one hand, this sounds like chaos. On the other hand, it provides some very interesting hacking possibilities, that we'll definitely use later on. We could easily impose those sorts of restrictions and not allow to do certain things, but we decided not to bother about it. So this is the Jack type system, and in the next unit, we'll turn to discuss classes and methods.