 Since you've come across this video, I assume you want to learn AIDA programming. Now, whether you're a completely new programmer or somebody who already knows programming but doesn't know AIDA yet and need to for whatever reason, I got you covered. I've been programming in AIDA for about 12 years now. I know the language pretty well at this point. And something I've noticed over the years and even from my own experience of learning is there's not a lot in terms of the resources available. There are some good books, but books really aren't for everybody. So in this video, we're going to be covering AIDA. It's history, it's purpose, as well as a lot of the language features. Everything's going to get covered in great detail, but by the end of this video, you will be left knowing how to do many common tasks in the language. You will be able to read source code that is out in a while and actually understand it. After this, I will be doing more specific videos on specific topics. Those will be what you want to cover to really understand a specific part of the language, but you will wind up knowing the language after the end of this. So for the overview of the language, let's begin with its purpose. The US military was at a point using a wide variety of languages. Many of them you probably never even heard of, even if you've been programming for a decade or two. Obviously, it's very hard to keep a staff who knows how to use all those languages, and so they began an effort to consolidate that down. Now there were a bunch of language revisions going from, I believe it started with the straw man, then wood man, tin man, iron man, and then steel man language requirements. But basically what they wanted to see in a language, what they felt it should have. The military, obviously this is going to be focused on embedded in real-time systems, because missile systems, tanks, all that kind of stuff is controlled by software. And you really don't want these things to fail. So a lot of the language requirements that they were focused on were about making the code as safe as possible, as error resistant as possible. You'll never get bug-free code unless the program is super trivial, but you can make steps to make it less buggy. And so as a result, a lot of common uses of AIDA are with avionics, like the, I believe it's the Boeing 747 is programmed almost entirely in AIDA, but it's not the only jet that is done that way. These kind of things aren't always publicly available, but there are quite a bit of jets that are known to be programmed, partially or overwhelmingly, in AIDA. So railways, this can be either like standard trains or subways. One big example of this is the Paris Metro. Banking, this is one where we don't really have a ton of information. Compiler vendors like AIDA-CAR and now PTC know that they're selling the commercially supported compilers to banks, but they're not super open about which ones. And obviously the military, and anybody who makes things for the military is going to wind up using AIDA at some point. Now for a while with the military, there was a hard requirement for a few select languages. It's been loosened up, but Addis is still used a lot there. And space technology. Parts of the ISS are programmed in AIDA. There was a satellite, the CubeSat project, which was programmed almost entirely in AIDA. I believe there was a bit of a similar scene along with that, but a huge portion of it was done in AIDA. And so like most languages, it's gone through a bunch of versions or revisions. The original AIDA, the one that was really just focused on military embedded purposes, was AIDA83. This was the one that actually was part of the design competition the US Department of Defense engaged in. Back then it was known as green before it was selected. This was led by a small team led by Giannif Baya. Essentially the steelman documents, the language requirements that the Department of Defense put forward, they had a bunch of teams competing to who could sort of best implement a language that could meet those requirements. Other than the language requirements, the Department of Defense didn't have a whole lot of say in the language itself, it was just a bunch of people competing, but it goes forward. Giannif Baya's team was the one who won. And like I had said, this pretty much only targeted embedded in real-time systems. It was overwhelmingly just a military focused language. But there were some really good things about the language and so it was revised in a way that expanded it greatly for other purposes. This would be what I consider the first version of AIDA that's useful for anything other than just embedded in real-time programming. The first general purpose version of AIDA. And this was led by a small team led by Tucker Taft. This was revised again in 2004-2005 which added some more advanced features on top of the language and revised again for 2012 adding even more advanced features. Now it's sort of an ugly part of languages that need to be covered because this is a thing in your experience developer, you know what I'm talking about here. But every language has dialects, slight differences, and you see this with spoken languages as well. There's differences between the United States and Canadian English. There's considerably bigger differences between English and the Northern Atlantic versus English, the UK or Australia. This happens with programming languages too. Microsoft's Visual C implementation is different than the GNUGC's C implementation. This was something that they tried to nip in the butt with AIDA and as a result there's almost no dialects. I say almost because there are some slight differences but the AIDA language requirements are very strictly defined and help to ensure very consistent behavior and ensure that everything is very well-defined and predictable. Essentially the differences that occur between different implementations of the AIDA language are with some slight features that you can often ignore or work around very easily. In practice you will not have much trouble moving from one compiler to another. Now there is the Ravenscar profile which is not so much a dialect but more like a limited version of AIDA. Reduce a lot of the additional stuff and it's meant for using like AIDA 95 through 2012 in embedded environments still. And you also have Spark which is sort of a subset, sort of a superset of the language. I'm not gonna delve too much into that because in its own right it should get its own video. Even still Spark is pretty well-defined. So if you have one compiler vendor that implements Spark and another that implements Spark, chances are everything will work cleanly between them too. And Spark was even designed in such a way that its additions would not cause it to fail, a compilation to fail on a compiler that did not implement Spark. So as for the typing discipline, AIDA is very statically typed. So that is when you declare a variable and we'll get into that in just a little bit. Whatever type it's assigned to will not change. So if you say that you have a variable A and that it's an integer it will always be an integer for the lifetime of that variable. You will not be able to say, hey it's actually now a person for whatever reason. You can't do that. This is sometimes considered inflexible but does help a lot when it comes to code safety and ensuring correct behavior. Now it's also very strongly typed. Really has to go along with the static typing but when you say that it is a person you can't then take something that's similar to a person but not quite and assign it to it. And specifically it uses what's known as nominative typing. So we'll see this a little bit when we get into records which are basically structures. Even if a type is structurally compatible so that is it shares the same record layout and everything you cannot assign it to a value of a different type with the same layout if the name is different. By putting a higher emphasis on the name that if it's name different it's probably a different thing and should be incompatible. Now of course there are ways of converting what you do actually need to do that. That's the approach it takes. So some criticisms of the language because I'm a firm believer that there's nothing perfect out there. In fact I also program quite extensively with C-sharp because it doesn't do everything well. Major criticism especially in its introduction was that it was overly complex. One thing to keep in mind is this was at a time where a lot of the popular programming languages were things like C and Algol and Fortran and those are very simple languages, remarkably simple compared to what's commonly used nowadays. And so it does have a huge specification and I just said Ida is very complex it's very sophisticated there's a lot in the language there's a lot we need to go through in this video. And while that huge specification is really nice in that everything is very thoroughly defined and there's tons of things built right into the language that you don't need third party support for it does mean that there is a lot to cover for the language that there's a lot a compiler vendor needs to implement that there's a lot you need to learn to be a good at a programmer. It's a valid criticism. It's also a valid compliment. It all depends on what you're trying to do. If you're implementing some trivial little program I would really not recommend Ida. If you're implementing something that just needs to do a little bit of automation like a script Ida is really bad for that. But if you're designing a whole control system well that's more what it's made for. Another criticism is that there's too many types. This is like anything yes there are a lot of types in Ida especially with these characters and strings and will that definitely make a point of that because there are a lot of different strings. Now in practice you're probably only going to use one or two of these I promise. The overwhelming majority of these are for edge cases that you will not need to touch. So while it looks remarkably complex on paper because it is in practice it's much simpler and when we get to these strings specifically I will make a point of which you want to use where and some recommendations on what you stick with. Another criticism which is also sort of a compliment as well it depends what you're doing is that there's many integrated features and this does contribute to the amount of overhead when it comes to learning the actual language itself. But tasking is a great example of this. Tasking is how Ida handles concurrency or threads or parallelism. That is built right into the language which of course means that there's an additional language feature you need to know but that you don't need to grab a third party library to get tasking you know you don't need to pull in like a p-threads library with C or C++ it's right in the language. Whether that's a good thing or not is debatable many but not all modern languages have this as a built-in thing C-Sharp is a great example of that with Async totally different model but still built right into the language and there's also a massive runtime library compared to its introduction nowadays when you look at things like the absolutely massive Java library or the absolutely massive C-Sharp library Ida doesn't look too big anymore Ida looks pretty normal now but at least at its introduction Ida had an insanely large runtime library. Another criticism is that it's overly strict and I'm not even going to pretend it's not it is it's a good thing it's a bad thing it's going to drive you nuts it'll also help you not drive you nuts because it'll catch a lot of bugs it's one of those things that like when it does good you don't notice it it's a very strict language though. This criticism however I will not partially agree with or even wholly agree with that it was designed by committee and I think this was a huge misconception dealing with the the government influence when it came to the the different language requirement documents from the Department of Defense I'm sure those were designed by committee it was the government but if it wasn't designed by committee then there's something else weird going on with the design process that probably shouldn't happen but when it comes to language itself green and then when it was renamed to Ida it was a small team that created the language itself and a small team that revised the language that's not designed by committee for getting ready wrote on my own slides but they're mostly here just to keep me on track anyways but yeah so now let's actually get into the language because that's why you're really here right start with the standard hello world now of course we'll get into all the different components of this but I would just want to give you an idea of what's this this is like this was interestingly considered rather verbose for its time when you look at say like the C implementation of hello world there's definitely less actual writing going on nowadays though with object-oriented programming becoming so incredibly popular you can see hello worlds that are quite a bit bigger than this because you have to write out a namespace and then a class inside that and then the actual main method whereas with Ida you can get away with a program with just the main method but then you know like functional programming and the scripting languages this is pretty verbose compared to those so Ida sort of has a middle ground when it comes to verbosity which is interesting it didn't historically but nowadays it's a pretty middle ground one interesting thing about Ida is there's actually two different ways to write out a program and I'm not going to delve into when you want to use each of these but one way as you saw with the hello world is that you can write it out as a procedure which doesn't actually return anything to the runtime so that is the the operating system doesn't actually get a return value unless there are certain instances where it has to like on Unix and then it'll either get a 0 or a 1 depending on an exception is raised but basically you use a program where you don't when you don't care about returning a specific return value so like if you're on Windows you probably want to stick with just procedures same with I believe VMS works that way as well but you can also write it as function and while it is possible to return other things than an integer in a program you probably want to stick with just the just the integer and that's when you care about return codes which is especially important when working on Unix so you can't build everything into a language and you need includes in some way so that you can say hey this is the other thing I need this that's done with a with statement so it's just with and then whatever the name of the package you need is one important thing to keep in mind is that unlike some other languages that are a little bit more succinct about this just with a package does not immediately scope to that that is when you with it you still have to write out the full name of the package and then everything that you're using within the package to avoid that you can wind up using a use statement with the same name and that scopes to it so that you can no longer need to use the full name now I'll go more in depth in this into another video so that you can get a good idea of how scoping and visibility actually works on Ida because it is actually pretty different from other common languages despite using a lot of the same terms so especially if you're coming from another language you really need to brush up on some of those differences as for assignment you know I talked about variables earlier and that I was going to delve a bit into this now we're beginning that something you'll notice here is that in the declare part of this function there's the a which is an integer and a b which is a constant integer by default variables well by default a value is a variable so we can do things like assign a new value to a and this is actually done inside the actual execution part of this function but it is possible to declare constants by just prefixing a constant but like literally constant in front of the type name if you try to assign be a new value it will fail but if you try to assign a a new value it will work now attributes this is again something that will get its own more dedicated video but attributes are really sort of a odd thing that Ida has that pretty much no other language has and you'll see attribute used in like to describe something in other languages C sharp has this with the the attribute classes that you can attach to other classes which change some little things about the class that's not at all like they are in Ida but they they're presented like this with an apostrophe and then the name of the attribute and they're generally like information about an object or a type there's somewhat like an intrinsic function which is something that's automatically defined by the compiler it's not something that needs to be provided by the by another library but they're also somewhat like reflection and like I said this will be something that gets covered in other videos because it it's it's a subject very unique to Ida so it needs to be covered when you have pragmas and aspects now pragmas are something that pretty much every language has in some form in Ida they're presented rather obviously as just pragma and then whatever the pragma name is now some of these except options which then cause them to look a bit like a function but they're all presented in that general way with pragma and then the name aspects on the other hand immediately after whatever the aspect is applied to you have with and then the name now there are many pragmas and aspects that share names generally speaking with at a 2012 where they were introduced instead of the pragma they have you using aspects instead but this isn't always the case and both of them are director directives which control the compiler they're a way of providing additional information about things and with that in mind aspects especially are pretty similar to the C sharp attributes they're also used for contracts if you've ever used a language that supports contracts Eiffel I believe is one of these they're preconditions post conditions and a few other things that help asserts how the does function or procedure or whatever it is is supposed to behave and they're also used for restrictions which is a way of limiting how many features the at a runtime library is actually providing for your code that is a way of eliminating unnecessary cruft like if your program doesn't actually use casking why bring in all the tasking overhead you can restrict that out and it does wind up sometimes providing some performance improvements sometimes just cutting out some of the fat so we have the operators some of the logical operators if not a and be a and then be now this is important because in a lot of languages it the logical and and as well the logical or short circuit by default in either the default I guess the most straightforward writing one actually evaluates both sides even if you already know the end result with that in mind I would strongly recommend using the short circuit forms unless you absolutely know you need to evaluate both sides overwhelming majority of the time you should not need to so just stick with short circuit form until you find out you need to use the standard form then we also have the XOR operator with an actual word name and not some weird symbol which I kind of like that for relational operators these are all pretty straightforward the one thing you will notice is that with the equal to operator it's just a stick single equal sign it's not the double equal sign met a lot of languages use and that's because assignment has its own operator operator will get that arithmetic all pretty straightforward one thing that is worth pointing out is there is an actual exponentiation operator so I know that's sort of something that drives me nuts when I program with C sharp as you have to call math dot pow and then the stuff there's an actual operator you can use with Ida string concatenation I really enjoy that this uses a different operator so that it's clear when you're doing addition and clear when you're doing concatenation if you've ever done JavaScript programming and have intermixed strings and numbers trying to concatenate them and getting weird results you know exactly what I'm talking about and why I appreciate this now this is something I don't want to say unique to Ida but definitely not something seen in most other languages at least that I've encountered but there's actual membership operators and so that's to test whether something exists in a in a set or container so for some examples because I know this isn't super obvious we can do a range membership test with checking if five is within the range of one to ten and of course it is so that would evaluate to true another one where we tested five is in an integer this is a type membership because integer is a type and so what this actually does is uses the range of the type to essentially perform a range membership test just using the name instead now five is yes an integer so that would evaluate to true but then we can also do class membership tests now if you know what object oriented programming is then you understand what this is if you don't I'll cover it in object oriented programming more specifically but well actually I'll have an example when we cover tag types which is part of how Ida implements object oriented programming it'll we'll cover that then so an assignment I want to make a point that this is not actually an operator in Ida assignment works very differently in Ida than in some other languages and that will also deserve its own video because it actually gets rather complex but I'll do a whole deep dive on how assignment works in Ida and why I think it works really well that I think it's the right approach and I think it says a lot that C-sharp is actually shifting over to try to get as close to possible as how Ida actually does assignment so some numbers most of this will be pretty straightforward if you already know programming integer types you can declare actually before I forget in Ida you can declare new types now there are a few other languages that can actually do this Ida is definitely one of the few where you can declare new base types this isn't always useful don't declare your new type just because you you feel like it generally stick as much as possible with the standard types but if you do need to enforce a specific range for whatever reason or any other property about the type you do actually have a mechanism to do that but for an integer it's just a range obviously it's going to be whole numbers modulars are sometimes mistaken for unsigned numbers because they sort of are unsigned numbers but the way modular arithmetic works is that when you reach the highest value and you increment one more it wraps all the way around this might sound a little bit weird but it's actually something that you've seen throughout your life clocks work this way where you know you go from one o'clock two o'clock three o'clock all the way around to 11 o'clock 12 o'clock one o'clock now generally speaking with programming and this is definitely how it works with Ida you actually start from zero and then wrap around at the modulus so using the clock analogy be zero o'clock one o'clock two o'clock all the way around to 10 o'clock 11 o'clock zero o'clock floating points if you don't know programming it's scientific notation basically if you do know programming you could probably understand why the ability to declare new floating point types is really really really nice and Ida I don't know if you can do the really small like I think it's a eight bit float the graphics cards use I don't know if you can do that but you can actually access a wide variety of floating point types with different precision and everything in Ida it's super handy and yes if you're on an x86 or AMD 64 or whatever you want to call a different variations of it you can get the 80 bit floating point in either you can totally get that it's actually the default long-long float on that platform now fixed point generally speaking these are being phased out because floating point performance is actually really good now I didn't used to be but they're pretty close to on par nowadays now Ida separates this out into two different floating point types with the ordinary and decimal ordinary is essentially a binary representation of it the you know ordinary for the computer not for you but for the computer it's ordinary if you need decimal precision or radix precision but it's the fractional part of it but you can't use a floating point type maybe the ordinary floating point ordinary fixed point type will fit your needs decimal on the other hand is really what you want to use for financial systems there's something called floating point rounding error if you happen to be involved in fintech at all you know what I'm talking about and you're probably giddy as shit looking at the ability to define your own decimal types because oh my god this is amazing for financial systems and you can probably not at all surprised to see that banks buy out of compilers now now another similar basic type is enumerations and they look like this you can specify any number of values and it is actually possible to do layout type stuff so that if you're doing bit flags it is actually possible to implement this fairly easily and Ida they're pretty simple types there's not really a whole lot to discuss with this enumerations work the exact same way and Ida well pretty much the exact same way and Ida as they do in other languages there isn't a whole lot of differences that really need to be covered you'll you'll figure that out totally fine if already program arrays definitely deserve some unique discussion so here in this example we have be honest I'm not sure if that's actually valid a thing I wrote it in there just for the sake of sickness but I don't think you can actually do anonymous arrays I may be wrong some of my knowledge goes from very old versions of Ida that this may be a thing now but the point here is just to get you familiar with how arrays look and everything arrays in Ida you can actually specify the index now this has to be done with any discrete type and that basically means any enumeration integer or modular in this case we use a subtype of an integer positives because it's a little bit cleaner saner less error prone if you index the array from one to whatever size it is in this case it would be you know one to five that helps something called a one-off or off by one error that happens a lot with indexing in Ida but it is worth noting that you can index with any range so I could actually specify after the positive a range of like negative 27 to negative 22 this seems weird it's rarely used but especially when doing hardware interfacing can be extremely useful because you can map that to specific ports on like a controller's interface then after this we specify the type the array is actually of and this can basically be anything if it's a definable type you can have an array of it and you actually assign the array after this in the actual execution part of the function you can see how indexing works pass the index in to parentheses I to uses parentheses for pretty much everything I don't really like it I'd like to have unique actual symbols for that but that's what they decided to do a race can also be done with comprehensions though a very limited support for comprehensions but there are comprehensions and the only one it implements is a step comprehension which is still useful to have though so in this case we have it's done by declaring two initial values and then the actual rest of the range in this case because it's two and four what it does is finds the step between them and then applies the step the entire way to the end of the range so this array would be the same as the previous two two four six eight and ten because of the step of two you cannot declare more complicated steps like it can't be a step of two then three then four it has to be the just a simple step now matrices or multi-dimensional arrays are pretty straightforward as well you just declare another additional index and it is actually possible to intermix the indexes this is done when defining tables which are similar layout wise to a matrix but very different conceptually where you might have a one of the index would be a number while another in while the other index would be a character like an excel spreadsheet basically and here we actually have a matrix that's using comprehensions now you can only use comprehensions for the absolute innermost array you can't use them for the top level arrays as far as I know anyways and indexing of course is done very similarly to defining them you just pass in the two different values strings said we're gonna cover this give you an idea of what's actually useful what you'll actually encounter regularly with strings and explain what all that other crap was so strings are an array and of course then you have to ask of what they're an array of character but there's also many types of characters less so than strengths though but there are several different characters we need to touch on and so as a result of there being many characters there's also many types of shrinks so let's cover the character first it's a special type of enumeration and represents all of the different you know characters code points glyphs that make up text and so there's three types of characters that need to be considered the character a wide character and a wide wide character let's go back to that so I'll just say first unless you're working in an embedded environment you want to use wide wide character because wide wide character supports the entire Unicode range all of the Unicode code points are supported if you use wide wide character the only times you want to use the smaller ones like character or wide character is like I had said with embedded systems where reducing the amount of code points you can actually represent saves space otherwise just stick with wide wide so then with that covered let's get back into strings and actually explain all this so it said it's an array and it corresponds very simply for characters the equivalent array is a string for wide characters is wide string and for wide wide characters it's wide wide string but there are different types or variations of this string you fix it bounded superbounded and unbounded and what the heck are these for fixed it's just the one known as the string or wide string so it must have an assigned size because it's like any other array so if you have a string of 10 characters so the index is 1 through 10 it must always have 10 characters you can assign it a new value but that new value must be 10 characters long this probably seems very un-flexible and it is it is this was chosen as the default behavior for the strings going back to as initial introduction as a embedded focused language this does happen to be really good for performance reasons and so even though there's more like developer friendly strings available the base string the fixed string is still what's often used for textile purposes just because it is fast it's a very very efficient representation for text bounded is a bit more flexible and this is most of the time what you want to use when interfacing with databases so it's you know in a similar vein known as a bounded string or a bounded wide walk bounded wide string and so on it must have an assigned size and that size can be calculated at runtime like you saw with the array and with the string but it may be a smaller size it does a little bit of a padding trend to hold it in a string while wrapping up the expected behavior so if you say it's originally 10 characters long then you can never assign it a string of longer than 10 characters but you can assign it shorter ones that if you've worked with databases you'll know that that's the default behavior for text in databases and that's what makes this good for interfacing with databases that you can have the same behavior in your add a code as your database actually has super bounded I'm just gonna breeze through this but basically it's just a special version of bounded if you need to know which to use when ask me to cover it I'll do a video of it I don't have one planned just because this really isn't touched very often unbounded is where we get into the strings that you want to use if you're not doing embedded programming or database programming if you're doing anything else so this means most developers you want to use the unbounded string and this because it's the most flexible so similarly the other ones it's known as unbounded string or unbounded wide string and so on there's no assigned size so this allows it to actually be a smaller size or a larger size if you define it as a string of 10 characters long you can then go and assign it of a string of 143 characters long and then one of two characters long it's very flexible like that so it's actually implemented as a container of sorts not an array although it can actually be done as a reasonable array which is actually very flexible this also does mean it's extremely slow now I'm saying extremely slow relative to a normal string in it it's performance really isn't that bad if you're trying to squeeze as much performance as possible out of your code feel sorry for you this is going to be something you'd want to look into then but if if you're using this you're probably doing a lot of heavy text I have stuff anyways and your input output is going to be far slower than strings actually are these absolutely what you want to use in the majority of cases they're actually more flexible than strings and other languages they're they're lovely so sub programs because I actually has a different quite a few of these and it's not like it's not like in C where they're all functions and yeah void return value which makes it kind of like a procedure but it's not the same thing or not like object-oriented languages where they're all methods that there's actually a few of these going on so the procedure this is going to look similar again because it's it's what you saw with the actual with the actual implementing programs it's one of the ways to implement a program you will notice here just to help you get at least somewhat familiar with attributes we actually have the image attribute and this is where you see a little bit of the sort of reflection like behavior going on the integer image attribute gets the what the integer looks like you know string wise character wise this is often called like a two string method in languages that have to rely on that but it's done as an attribute in it so this isn't something that you need to define or anything like that it just exists function very similarly has an actual return value and so you need to return that somewhere within the code in this instance we have a very simple one which just immediately returns value after doing a slight computation because that's such a common thing to do with functions you also have what's known as a function expression and doing that same code before as a function expression it looks like this which is now actually just a one-liner a lot simpler to write and we have operate this is done as a function and yes I actually supports operator overloading only for it to define types you cannot define new or only for it to define operators you cannot define new operators but you can use any of the already defined operators like the the ad or the and or absolute value or anything like that to define a new operator and this is one of the important things about noting that assignment is not an operator there's other implications behind that as well but it does mean that you can't use operator overloading to define new assignment behavior now in this specific example I don't have anything actually written because for the ad operator because it's already intrinsic for integer there's no way to actually do anything here it would actually be assembly code but it's just providing for you but I just wrote this out here so that you can see how operator defining is actually done just take I shouldn't have wrote an example at the end that's my bad that's what I get for copying slides and then editing them but it's done by instead of a name just putting the operator in double quotes you still call it like normal low and it's also worth noting then it's possible and edit to write the sub programs whether it's procedure or function or even an operator as a generic and that's done with this generic prefix on top of the actual definition so in this instance we define it as having a generic integer type parameter that gets used and operated upon and here you can see how it's actually instantiated we give it a new name of integer double and just perform the instantiation happens now integer double can be called anywhere after this and operates upon integers so now conditionals because programming isn't that useful if you're doing just one thing after another with no considerations the most basic if else so you can see that we test if a value is greater than zero we return true otherwise we return false and this just works out as a simple positivity if else if else just a slight expansion upon the if else and I have it just saying a bunch of goofy stuff but you can see how multiple checks are done within the same if else block now case statements this is usually called switch in a lot of other languages there's a slight little bit of syntactic difference between the two so you can see that it's introduced by a case instead of a switch and that the individual parts of it are done as a when with whatever the condition is rather than a case different cases can be combined by putting a bar between them and the what would be called a default for switch case blocks is just done as a when others and you have exit when now this only applies for inside of loops but is a way to exit a loop a little bit of syntactic sugar for exiting a loop rather than doing a if test and then exit so here we have what would otherwise be an infinite loop of just constantly incrementing the integer but we have a very succinct test for if the I is 5 then just exit the loop so this no longer becomes an infinite loop now there's a bunch of different loop syntaxes we'll get to and just a little bit but this is a rather convenient way of putting exit conditions anywhere within the loop and it is actually possible to have multiple exit statements within the multiple exit when conditions so let's get into loops we have the standard loop just an infinite loop one that literally does nothing but it is an infinite loop so if you were to run this program it would never stop but also never do anything but it would never stop you have a while loop pretty standard thing for other programming languages so tests for a condition as long as that conditions evaluates to true it executes the loop if the value is not true if the value winds up not being true at the very beginning then it doesn't execute the loop at all then we have a for in loop so this sort of takes advantage of the range membership test so as long as I is within the range of whatever you specify the floor and ceiling as it will execute loop otherwise it goes at the to the end of it and in this case there's nothing else to do so it's done program also before each loop also sometimes called an iterator go to skip ahead there you can see an attribute is being used again in this case the range attribute gets the full range of well it an array in this instance so this array being what the step of 1 to 3 up to 100 should have I think 50 values within it so the range would wind up being 1 to 50 then packages packages are for the most part at his way of packaging up other values other functions other procedures into reusable components with that in mind they're kind of similar to static classes from C sharp of Java kind of similar to modules from visual basic I don't really want to give analogies to something like Python or Ruby because I'm not super familiar with those languages and reusable components in JavaScript is really complicated so I'm not going to give an analogy to that packages come in two parts in Ida you have a package spec which goes in one file and it looks something like this where you have a package followed by its name is and then it stops at the end followed by the name the private part is optional but know that if you don't include it that everything within the package is publicly visible the I'll touch on this a little bit for here although there's there's going to be a deeper dive into this where you can see some more advanced stuff about packages and explain how this works but private in Ida doesn't mean the same thing as private in say C or C sharp or Java private is not visible by packages that use this package or anything that uses this package so if I have another package or a program that depends on example I will not be able to call anything within the private part but a child package of example like example.child will use really simple name can actually see everything within private so with that in mind it's kind of kind of more like internal but even still there are differences but then the other part of the package you have is the package body and this goes in another separate file and this is where you have all the implementations for everything that was declared in the spec if you need something that is private in the sense of the C languages you put it in here because then not only is something that depends on example not able to see it not able to use it but even child packages are not able to interact with it and then one little note just so that you'll be aware that this is a thing and that packages aren't quite just like static classes or modules or that kind of stuff is that they can actually have initialization code which is like a constructor and that is weird coming from other languages I'm not gonna get into explaining this and why it exists and how to use it just know that if you see that in somebody else's code you're not losing your mind that is valid code it's not often done but it does have purposes and like I said there'll be a video covering this in great detail so that you understand packages better especially this ball initializer constructor thing and much like the subroutines packages can also be generic and it's implemented the exact same way before the package you put the generic and then whatever the generic whatever the generic parameters are with generic packages what winds up happening is any anything inside of it at all is initialized all at once so if you say need to initialize a large collection of functions or procedures all for the same type you probably want to use a package rather than a bunch of generic functions procedures all laid out not always but that's probably the route you're gonna want to take and exactly like with the generic subroutines they're initialized the same way the new name of it and then the actual initializer now records or structs these are one of the first more sophisticated types and then it's not just a simple one value type records hold multiple values together if you've worked with database programming you should recognize why they're called records there's a pretty strong mapping between the two actually I does database friendly which is sort of weird to think about but I think it's a little bit complicated with its records there's a lot going on with them and this makes them quite a bit more powerful than structs in a lot of other languages one of the first differences variations of records you can have is the discriminated record which for the most part is going to look basically the same but you'll notice that there is actually a size parameter property that's in a weird place now you can still access size like any other property but it's placed immediately after the type name and when you declare values of this type of this example record if you have a e of example record you need to put in the size as well sometimes this is used just as like a mandatory initial value that needs to be sent but it can be used to modify other values other other I'm saying value because that's what it's called here but other like properties within the record other fields other entries whatever you want to refer to them in this instance the actual length of value because remember strings are raised they have to have a defined size and since we're not assigning it can't determine the size so you need to tell it the size in this instance we're actually telling it the size in the discriminant this actually goes even further to create a variant record and this is it's gonna take a little bit for this it's actually got to write quite a bit of stuff out but you can see we have the discriminant just like before but then something very unlike what you see in almost any other language where we have actual logic inside of the record now I have a bunch of entries where nothing's really all that different we have seats property and the doors property and then there's a bunch of these entries where it gets considerably different is with the pickup where it has another additional property so if you were to say vehicle is specifically the option of a sedan and you try to access the towing capacity property of that it would fail because it literally does not exist in that record but if you create another vehicle with a pickup as the option you actually have the towing capacity property to get to this should kind of seem like a class inheritance hierarchy polymorphism thing that you'd see from object oriented programming and it essentially is a more limited form of that now there are other uses for this other than just the object oriented light stuff but if you only if you're interested in object oriented programming and are have a very simple hierarchy going on you might want to consider a variant record instead but I do have some content about explaining these in more detail and giving examples of how these are actually used when you want this versus actual object orientation so we have the tag record which as I had said earlier is part of how I had to implement object oriented programming I had it takes a different approach from a lot of popular object oriented programming languages in that it doesn't force everything all together there's not a class type that has all of the components of object oriented programming walked into one you can actually select different parts of it and of course even combine all of it for a true experience tag records are just a record that has an associated tag or like a v-table if you're coming from C++ it's information about the dispatching OOP is sort of a complicated subjects to explain in detail but it allows you to do things like what's demonstrated here and with the this is where we'll actually cover a little bit about class membership so we have a person record it has an associated tag and for the person they have a defined name and age we also have a defined procedure which renames them then we have another tag record this time a programmer that inherits from person so that is programmer has everything that the person actually has as well so the programmer has an actual name and age property that you can get you can also call rename on a programmer and it works programmer has an additional string array of known languages now string array isn't a default type but a figure you get the idea this is showing up tag records more than being valid code and it also has a defined procedure for learning a new language which you'd expect would add a new language to the array learn language cannot be called on a person but as I had said rename can be called on a person or a programmer and then to explain a little bit about how class membership works if we have a very me and it's a person I can say me in a person class and it will evaluate to true because of course I am but if I try to do something like me in programmer class it will fail now obviously that's a little bit nonsensical I should probably be defined as a programmer but in this instance I decided not to this is because I am specifically in this case defined as a programmer as a person not as the programmer which inherits from it working the other way around now I can have say another variable John who is defined as a program John in person class will evaluate to true because programmer happens to inherit from person John in programmer class will also work in this instance will also value true because yes he's actually specifically the programmer and then just something to consider is that record types can be combined so it is possible to have a variant tagged record this might seem a little bit redundant but there are actually uses for it it's rare but there are uses for it and so record is a type like any other and so you can have a record which includes another record and just a little quote because I happen to actually find this very important and a useful thing to program by is get your data structures correct first and the rest of the program will write itself David Jones now let's cover interfaces these work the same as any other language that has interfaces and basically it's a way of saying for a tag type things that it needs to implement it doesn't provide an implementation for them just says that anything that anything that implements this interface will have these different properties are different functions of procedures rather so to use the classes we had last time if we have a programmer that happens to inherit from person and I example which we have here then programmer should also be expected to have a do do something procedure now whatever it does I don't know but it will need to be implemented by whoever by whatever uses this utilizes this interface getting ahead of myself bit you know what I what I just said and just to cover some of the little differences in interfaces because there are different interfaces I realize I didn't touch on this with the with the records a record can be declared limited as well it has specific meaning this slide should not exist here but at a specific meaning when involving assignment a record being limited changes how assignment works and whether it's possible in certain situations limited interfaces can only be applied to limited types and we have synchronized interfaces I realize we haven't touched on these yet but this applies to tasks and protected types will touch on those and should be coming up I don't know if it's right after this but it should be coming up somewhere in here and then you have tasks and protected interfaces which are just more specific versions of the synchronized so if you have an interface that can be applied to either a task or protected type you want to use synchronized if it should only be on one of those you can use the specific task or protected so access types are sort of how I handle pointers if we have a type that we want to access we'll just give another example integer the access looks like this now you can have anything defined as an integer access and it accesses the integer what this means is a complicated subject as a new programmer you can sort of view it as that a value assigned to the access is just like the value itself there are actually some important differences but when reading code when learning the language you can view it like that it'll at least get you through understanding how the code works so some things to note about access types is that they are not a pointer not quite anyways sure they do point to something but they definitely don't work the same way as pointers there isn't integer there isn't any pointer arithmetic stuff going on now it is possible to actually get that through specific type that exists in it but we're not gonna cover that here and it with this in mind it's much closer to a reference although it's still not quite that either but it is probably best to view it as a reference that refers to another thing rather than actually being that thing and exceptions because it does and pretty much has always had built-in support for exceptions classic example of one divide by zero you can't do it so if we attempt to do it the handler goes after whatever the code execution is so this makes it a little bit different from try catch blocks where instead of wrapping a specific portion we just have the entire exception handling at the very end and this looks basically the same way as a case statement and can largely be viewed the same way as a case statement you can even group multiple exceptions together with the more between them I'm not showing that off here but that is how you do it and for the default just like with cases it's when others so if we run this code with a divisor of zero of course it's going to throw a divide by zero exception which we catch and print out the line one cannot divide by zero concurrency this is where we cover the tasks and protected types I'm not going to get into this in the great detail just some basic introduction to the stuff so you have tasks task types and protected types and yeah these are getting covered in another video just know that they're they're they're a thing so hopefully this leaves you at least familiar with the language you should be able to read I had a code that exists out there now even write some basic programs and I don't I'm currently in the process of redoing a lot of videos if you happen to have come across my channel before you've probably seen this content already just it was kind of crap when I originally did it and I'm trying to get all this stuff done better so a lot of the other videos that came after the initial ad introduction and at a basics video which got combined into here rating redone hopefully much better let me know how this video is I really like to hear so I know like how I've come how I've improved from when I started because it was it was not but I'm also continuously looking to improve to get these videos better and I really like your feedback with that in mind also because of how YouTube ranks videos and helps people find videos and everything please consider giving this a thumbs up that's one of the best things you can do to help more people be able to find this video and learn about how to learn how to get familiar with the language I have a good