Beginner C++ for Expert Programmers w/Scott Seely
•
UGtastic Archive
Full Transcript Available
111 Minutes
C++ is still one of the most popular languages out there. Given that there are hundreds of languages, that still means that 80%+ of you have never seen it or needed to use it. C++ informs a lot of what we do in other languages. Come on out and learn about this thing called C++. We’ll teach you enough to read basic C++ code, understand the differences between a pointer and a reference, and maybe even show the dangers and benefits of this thing called multiple-inheritance. You’ll learn a lot—like why in C++ it’s cool when a friend touches your privates.
The Interviewer
Mike Hall
Interviewer, UGtastic
The Guest
Guest
Guest
The Conversation
Mike Hall
Interviewer, UGtastic
the last 10 years. They said, so why C++?
Guest
Guest
And I said, well, two things. One, Mike wanted to talk about C++. I think he looked around at the guys who knows it and said, that old son of a bitch probably knows it. So that's why I'm here. I've actually been doing C++ since about 1993. Last time I got paid for C++ code was 2006. So if you've ever installed Windows, code that I wrote in C++ actually is part of the install experience to make sure it's a transacted and installed. So really fun stuff there.
Mike Hall
Interviewer, UGtastic
Who the heck am I?
Guest
Guest
Scott Seeley, president of a little company called Freestown LLC. The president is not a big deal because it is a two-person shop. Somebody has to put their name on that line.
Mike Hall
Interviewer, UGtastic
What's that other guy's title?
Guest
Guest
The other guy's title is my wife. So she's the, she literally holds a checkbook in both our household and the business. And she tells me not to spend too much money on stupid things. So for example, I got a laptop here, want to put 32 gig in it. She told me to wait until the price drops. Price dropped to around 450 bucks for that recently. So finally got the go-ahead. Unfortunately, Noah still thinks 32 gig is worth $2,400. They can go do stuff to themselves. And also I've written a bunch of books on primarily web services. So first, early I wrote a book on, first book was on Windows Shell programming or how do you automate all the fun stuff that Windows does. Second book was on soap and the protocol is brand new and everybody thought it would save the world. So we're talking about 2001, not 2005. And that particular book was written covering a bunch of languages, C++, Perl, Java, and then also . NET.
Mike Hall
Interviewer, UGtastic
Since then I worked with Microsoft for a while, did the WCF, right?
Guest
Guest
Are there many .
Mike Hall
Interviewer, UGtastic
NET programmers in the room?
Guest
Guest
None.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
The former, yeah.
Mike Hall
Interviewer, UGtastic
Any what programmers?
Guest
Guest
. NET. I thought you said Dove. No, sorry. Also I have an instructor for a company called Pluralsight. Pluralsight, for a long time did a lot of . NET development and Microsoft stuff. In the past six months they started going off into another direction and they started doing more stuff on Apple development, Android. Recently released a course on Subversion. About half the authors now record, not half, about a quarter of the authors now record on Apple or something else other than the Microsoft platform. And if, just so you know, Scott has brought us in some free one-month training passes for Pluralsight. So they're back here if anybody wants to know those. The other thing I know is that I know from a number of the folks in the group in the room right now that you've presented at Chicago Code Camp. So I know a few of you are decent presenters. So you might be one of your presenters. Pluralsight is going into doing development, training across the board. They're getting out of that space. They've just recently hired somebody who will be focusing on nothing but getting that other content, you know. Big clients out there are using other languages than Microsoft these days. And people need training. Pluralsight doesn't care who you, which platform you're on. They want to help you learn stuff. So if anybody's interested in doing that kind of thing, I can talk to you later. It does pay well. Contact me. I'll hook you up. They'll figure out whether you're qualified. If you're interested, they'll help you get out of your way. Also regional director. Regional director is an honorary title. What that means is I do a lot of stuff in the community. And the best way to look at a regional director is a community MVP. So I help run Chicago Code Camp. I speak to a lot of different organizations. I talk to different clients, helping them understand Microsoft technology.
Mike Hall
Interviewer, UGtastic
So they said, Scott, will you be a regional director?
Guest
Guest
I said, okay. I'm also a connected systems MVP. All that means is that I read protocols. I know most HTTP, TCP, IP, all that kind of stuff. I've built it, been there, done that. And then at the very bottom you see here is contact information. So if you don't want to write it down, I've got business cards up here too. Feel free to grab that instead. Same information on there. Today we'll be talking about C++. The title is Beginner C++ for Expert Programmers. So the notion behind this is that you've actually gotten paid at one point or another for writing code. As a result, I don't want to have to talk to you about things like object orientation or what scope means.
Mike Hall
Interviewer, UGtastic
What's a for loop? What's compilation? What's a code unit?
Guest
Guest
These should all be things that are generally understood by you.
Mike Hall
Interviewer, UGtastic
If anything here, none of this looks foreign to anybody in the room? Nobody's?
Guest
Guest
Okay, yeah. It's easy stuff. I just want to make sure that nobody expects to actually have to learn. I have to assume something in order to make this talk work. The taste is going to be fairly fast. We're trying to drink from the fire hose today. It will be as fast as I can go while explaining everything. That said, feel free to slow me down. Feel free to ask questions. Feel free to derail me. I have a set of notes here of what I should do if I wanted to fill up an hour talking about C++. That's if you guys don't ask me anything. You ask me something, that thing's gone. We go down the other interesting path.
Mike Hall
Interviewer, UGtastic
Okay?
Guest
Guest
So it's not supposed to be IS-4. It's just supposed to be, "I'll be talking about C++. You ask questions. We'll see where it goes. " C++ is a language that largely goes back to one guy, Bjarne Strussro. Bjarne worked for AT&T. Which is also the home of C. Previously B and A. Also Unix and a bunch of other great things. Bjarne is the father of C++. He did the first implementation. The first implementation of C++ was done as a preprocessor that took your C++ code and compiled it into C code. And then used something that actually worked to build up all your bits. So like CoffeeScript. So it's like CoffeeScript, yes. Or a bunch of other languages. Pretty much anything you do today translates from one language into another. Even today, the compilers that we use, they go from C code or whatever, or Ruby, and eventually gets translated into machine code. Nobody programs against and does, you know, a little microcode. Because microcode is done by Intel, is done by AMD, is done by the folks who license the ARM processors. Not done by us. Anyhow, he wrote the language. He's been involved with the language since its beginning. He still sits on the language specification committees. However, Bjarne is not the most important person in the process anywhere. There's another guy named Herb Sutter, who happens to be paid by a very big evil corporation known as Microsoft. Herb is there. He joined the company in 2001. And he's largely been given cart launch to do what he wants, when he wants, how he wants. Herb's a really smart guy from Canada, and just gets stuff done. There's other big names in C++ as well. There's a guy named Scott. I'm blanking against Scott's name right now. Wrote some books like Essential C++, More Essential C++. It gives you ideas of how to write stuff. Scott is the second most well-known person in the C++ community besides Bjarne. And had a chance to have dinner with him one time. He said, I'll never be the most important person. He says, that's because you never wrote the language you don't, you know, think about it. There's a lot of interesting people, a lot of interesting history. Other interesting thing about C++ is that it's still the most popular language in use today. As a matter of fact, I would gamble that everything you use, whether it's Clojure, whether it's Ruby, whatever it is, eventually, if you want to really dig it to see how things were done, eventually, you would need to know this language to do anything. It's the system programming language that makes our computers work. When you want to go out and learn C++, there are some free tools you can go out and grab. If you want to use the editor that I'll be using tonight, there is a free version called Visual C++ Express. It's been free for the last, I don't know, probably about seven or eight years. It's a great compiler. It is standards compliant. As a matter of fact, because, so, one of the things that Herb did at Microsoft is he made sure that C++ always implemented features early so that they would be one of the most standard compliant compilers out there. If you don't want to go with Microsoft for whatever reason, GCC is another good one because everybody else on the committee makes sure GCC is up to date. GCC is the GNU Compiler Collection.
Mike Hall
Interviewer, UGtastic
Originally started up by Friesen Freedom, what's his face? Oh, Stalman?
Guest
Guest
Yes, Stalman started the GCC thing. That's not calm. No, it's Stalman, before Stalman stopped programming about 20 years ago. So, GCC's great toolset, and I'm not criticizing Stalman. Stalman's been doing his effect elsewhere. And there's also many commercial implementations. So, if you want something that works really well on Intel, Intel sells a compiler for about 3,000 bucks that does some really sick things with parallel programming. So, those are kind of your choices. Most folks are going to go this route or this route with GCC. I'm not too sure what the preferred platform is on Apple. I see a lot of Apple products out here. I'm going to guess it would be this. As far as commercial editors go, there are a lot of them. Find one, pick it, learn it live. I haven't really visual C++ because I've been using visual C++ since '94. So, I just know it inside out. I haven't seen a reason to change, but I do continually upgrades. I guess I've changed a dozen times. So, that's about all the talking, looking at slides a bit. I don't have any more slides in the entire deck. So, I'll shut this piece down. And because of it on a T in my laptop and when it's configured for video, I don't want to go ahead and update all the videos. So, I'll be staring at the screen just like the rest of you. We'll see how that works out.
Mike Hall
Interviewer, UGtastic
Oh, it doesn't mirror?
Guest
Guest
So, the reason why mine doesn't come up on here is because it's actually got some security features enabled, which means I have a certain video card enabled. And I have to put in my BitLocker key in order to make sure that I can actually switch the video card out. It's some funkiest. I've got actually two video cards in this thing. And the way it's set up, video card one runs this thing, video card two runs here in the docking. So, if I had my port replicator, which I should have brought along with me tonight, it would have been a much nicer experience. But I forgot to bring along my docking station, so we live. Anyhow, so what we're going to do is I'll just start from file a new project and start from scratch. What I'm going to do tonight is I'll start out with a console application. The reason why I go for a console application as opposed to a graphical user interface, a GUI has a lot of other things that differ from platform to platform. They teach you nothing about the language and teach you an awful lot about the message handling and how messages are passed between Windows and so on in your GUI of choice. No one cares in the C++ talk, so I'm not going to go down that path. We'll go ahead and create this thing in a place where I can then make sure I zip it up for you guys later. So, go to d/scmc/demo. And what we'll do is we'll put this into a project. We'll call this one cpp for scmc. And in here, let's tell this thing to finish. And this creates just a basic old application. Now, when we get here, when this thing's done, pushing all the files in place, and just pushing a number of them in here, what you're going to see is that it comes up with something you probably, is this big enough or do I need to make things bigger? It's good. That girl's happy. I got fresh glasses here. I'm good. Sweet. Okay, so one of the things you see here is there's an entry point called main. This particular one is called n_t_main. The reason behind this particular oddity is that the Visual C++ compiler worries about do you want to compile and use the ASCII character set, or do you want to use a double byte character set, and be able to handle internationalization. The underscore t graph is just a bunch of macros that are under the covers saying, if you have unicode, if you have ANSI defined, I'll go one way. If you have unicode defined, I go the other path. That's all we're really seeing here.
Mike Hall
Interviewer, UGtastic
What is the t?
Guest
Guest
So the underscore t actually points off to a macro.
Mike Hall
Interviewer, UGtastic
No, but I mean, does it go to ESCII or ANSI or to unicode? Is that defining that there?
Guest
Guest
By default, an underscore t chart in '95 through 2000 went to ASCII, and today I believe it still goes to ASCII. So I would have to do something like a hash defined. So interesting things you can do with C++ and C in general, if you don't remember your C class, is the preprocessor is this huge tool you have out there. The preprocessor tells your environment what to do. So if I do hash defined unicode, all of a sudden it turns a bunch of things on and another bunch of things off. And then you support unicode. And all of a sudden I magically support unicode at that point. I can also do it from the compilation line. There's usually this notion of a slash d switch. This is present to the C. It's present here again in the C++ and it allows me to define things in the compilation thing because it's a cross-cutting concern. The code unit doesn't care about this as much as everybody else outside is.
Mike Hall
Interviewer, UGtastic
How do I want to compile this thing?
Guest
Guest
That said, that really is the interesting bit here. The interesting bit was there's a main function. We've all seen mains in a lot of our other applications and languages. C and C++ are closer to the origin of this tradition than many other languages. It's also a C-based language, which means it's got fun curly braces going on. Statements are terminated with semicolons, just like a lot of other -- so it's a semicolon terminated language, just like another family of them, where JavaScript is sort of a semicolon terminated language. The other thing that it does, which is kind of interesting, is it has some of the old basics that you're used to seeing. So, for example, I can do loops. So say for integer i equals zero, i less than 10, increment i. And one of the things you'll see in here is that you can identify an old C++ program and how they write their for loops. Interesting thing about C++ or C in general is that a C++ program will do this optimization that makes no sense to anybody except someone who's really dug deep into C++. What we're doing in here is i++ or plus plus i, which does -- so when you do the plus plus i, what's happening is you're saying increment the thing, don't return r value. If I do i++, what you're saying is you have to do the increment generate a return value that can be assigned to something else which generates some wasted code on the back end. And if you're talking back in the days where we had chips that did 66 megahertz, saving two or three operations every time you went through the loop was a big deal. I'm a programmer who learned C++ in 1992. This is ingrained in me. I write all my JavaScript. Many languages don't have that optimization anymore. What they'll do is they'll look at this and they'll say, there's nobody receiving the value, don't care. So just again, if you want to -- I spy an old C++ programmer, look at how they do their formulas. By the way, some part of this code here looks just like what you would have done in JavaScript. The interesting bit here comes for how it handles output. Now, this is an idiom that I haven't seen in any other language, but it's an idiom that you'll see throughout the C++ language. And it's this notion of streaming things from point A to point B by using bit shift operators. So if I want to bring something to visibility into my namespace, I'll get into that in just a moment. In order to get that streaming interface present, I need to use what's called a hash include. Hash include says, I want to bring a set of names visible into my space. If you're using Node. js, the require statement will bring a certain library in and make it visible and do all the other magic stuff that's supposed to happen. Many other languages have this notion. For example, in . NET, you have a using statement. In F#, you have an import statement. In all these different languages, you have different ways of bringing things in. Even in assembly, you have a mechanism to bring other libraries in and make them visible. The way that C++ does it is through a hash include. Now, what's different about C++ and C-based languages in general is that this actually says go out, look for a file called I/O string. Because this thing is contained in angle brackets like this, it can actually be expected to be contained in a system path library at a special location somewhere on your hard drive that's known only by convention. The pilot knows where to look for these search directories. And what it does, it actually takes that file, opens it up, and during compilation, expands all I/O string into here. Most languages, what they'll do is they'll say, oh, this name makes sense, link it up later. C and C++ actually take the file, open it up, and expand it right here. So it does some interesting things, and you'll see C++ compilation sometimes takes longer because of the processing rules behind stuff. So anyhow, we got this thing called I/O string. I/O string is input/output strings. And the other thing I can do here is, well, we'll go through two different mechanisms. It has a notion of namespaces. Namespaces, again, valuable because what you might have is one instance where you have the word address means something here. For example, an address of memory. Another instance, address means a physical address that the post office uses. In either of those cases, you want to be able to make them unique. Namespaces allow you to make them unique. All of the names that are special to the C++ library live in a namespace called standard or STD. Not a disease. It just shortens the name for standard. So we have standard, and there's one of the things we have here is console-out, abbreviated as C-out. The other thing you're going to see about the C language is that it was done at a point in time where identifiers were small. Identifiers were being small because of the fact that we didn't have a lot of memory. So you didn't want to burn 32 bytes storing the name of a value. As a matter of fact, a lot of the names need to be compressed down to 8 bytes or less for the representation, or the compiler wouldn't work. But more importantly, if you had a representation longer than 8 bytes, only the first 8 were unique. Everything else was just readable. You compare it to a lot of languages we have today where they've said, that's stupid. You know, again, this machine's got 32 gig in it.
Mike Hall
Interviewer, UGtastic
What do I care if I burn it to 100 characters on storing the name?
Guest
Guest
Anyhow, you'll see a lot of names in C++ are very terse. C-out is one of those. Console-out. Like I said, to console-out, I would like to write information, hello SCMC, and after that I'd also like to write up the number of them, the iteration, and I'd like to write up the end line. Interesting thing about C++ again with its output is it recognizes that on a Windows machine, an end line is a carriage return line feed. On a Unix machine, it's just a carriage return. Because the Unix people said, well, I'm not on a goddamn typewriter. When you said carriage return, you probably want me to go to the beginning of the line as well.
Mike Hall
Interviewer, UGtastic
Fun stuff, right?
Guest
Guest
So we have this very simple program. It does a loop. If I go ahead and run, so stepping through it isn't very interesting. Oh, what the heck, untapify. Control F5 to run this thing. And of course, it pops up over the screen. So this is over, and it just goes through LSCMC 0 through 9. So real exciting stuff. We have a loop. As you can imagine, we have other constructs that you would expect as well. So I can rewrite this thing, for example, as a do while int i equals 0, do, and then here we could get rid of this, while i, i, sorry, less than 10. And if I want to make the i get incremented, all I would do is I would say in here. Again, run this one here is currently running. Run again. And ta-da. So exact same program. The other thing you'll see in here is when you see a C++ program to do some of this kind of stuff, you'll see some interesting ADMs from these folks. Again, another interesting one that you'll run into and you'll see in different languages is I might want to do something like, so let's say, for example, I want to change this so I only emit this line when the thing is even. We have if states, just like you might expect. They're all, you know, Boolean-type evaluations. So here's one thing that you'll see. I'm going to put a bug in here on purpose, show you what happens, and then explain a couple things. So I say, if i mod 2, let's go in. So let's say, yeah, i mod 2 equals 0.
Mike Hall
Interviewer, UGtastic
Does that actually compound or are going to be issues?
Guest
Guest
That may actually give me some fits. Okay, let's have to do a temp variable here to make it a little clearer. So if i is equal to 5, we want to process it. If i equals 5, STD, call them CL, have a 5. So we're going to do that, close off the brace, get rid of this goofy one. And the weird thing you're going to have in here is that we're going to see if i is equal to 5, it's going to say have a 5. Now it's going to be a little bit odd here, and I think this is going to wind up running forever. That'll show this to you. The reason why this runs forever is because we say if i equals 5, we're actually doing an assignment here. The bad thing that's happening in this particular statement is we're actually saying if the result of this expression is not 0, do this work. i equal 5, yield to 5, 5 is not 0, print things out. Because of this little code block in this particular thing, you'll see a couple interesting things happen in languages. First off, there are languages out there, a number of the functional languages have this that i know of, F# i know has it, F# is the only thing I know at the top of my head for sure has it, is that you'll actually say this particular item here is not a boolean. It doesn't yield a boolean expression. I think python has this as well. And it'll actually puke, you'll say try again, give me a boolean expression instead of a numeric. The reason why is because of this right here. This bug happens all the time. For C++ programmers, the way you'll see them defensively program against this is they will say, so let's control break.
Mike Hall
Interviewer, UGtastic
Would you consider bad programming to kill the loop within that statement? Within the statement here?
Guest
Guest
I mean just so that the loop ends automatically once that statement ends. No, you're saying just go ahead and go. Yeah, no, you can do that. That would actually work. But the other thing I was trying to show was just the infiniteness of the whole thing. So what you'll see C++ programmers do defensively is they'll say 5 equal i, because if you put the constant value on the left and the variable piece on the right, what you get instead is you get what we call a build. I get a compilation error saying the left operator must be an L value, it must be assignable. So again, I saw this a lot more in 2001 through 2004. I haven't seen this habit a lot since then. Because it seems everybody's gone over to garbage collected languages and said forget this stuff. But if you get somebody who's programmed from this era, what you'll see is it always has the constant value on the left-hand side, which is very well on the right. There's a name for that. It's Yoda expressions.
Mike Hall
Interviewer, UGtastic
Really? Yeah.
Guest
Guest
So you're really just making fun of the old people.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Well, you know, it's that you're putting the assignments after. If 5 equal i, i equals 5.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
So it's not very natural. And as Mike's pointing out, it's not a very natural way to read things. It's a very defensive way to program. Because if I do things like this, I never make this mistake. When I was doing C++, 10 years out, I was still making this mistake. If I didn't do it on the other side, I would just always defensively program things. Those are some of the basic bits. The notion I wanted to get across here was you probably know more of this language than you realize. Looping constructs, assignment, and so on are all there. As a matter of fact, there are some other things that you might like. So, for example, if you are used to languages that say, I can figure out what that value is. I don't need you to tell me. Well, C++ agrees. You don't need to type in the name all the time. I is being assigned a zero. Zero is an integer.
Mike Hall
Interviewer, UGtastic
Guess what?
Guest
Guest
I'll just treat it as an integer. If I'm saying I is equal to a new std colon colon string, whose value is hello. Now I is suddenly a string value, which means that this comparison no longer makes sense. Before the string line wasn't there. Auto is present. It's just like var, except the difference between var and auto, auto doesn't change at compilation time. So auto is a lot more. The type is implied. And the compiler can figure out based on the context of that particular expression. And there are a number of languages these days which are, so there's like typed functional languages out there that do this kind of stuff. You'll see it in other places too.
Mike Hall
Interviewer, UGtastic
Can you use auto if you don't sign it right away? You cannot use auto, so if you don't use, so the question is basically can I do this?
Guest
Guest
And let's see, I don't actually, no, it gives a little thing in the air. I'm going to guess is I'll substitute rid of this line here. It's actually, I get rid of the whole block of what the compilation issue is. So if I try to build this, it just says, I as a symbol whose type contains auto must have an initial answer.
Mike Hall
Interviewer, UGtastic
Can it then use auto type?
Guest
Guest
You were comparing it to var, but then just because most everybody was not developers here. In C#, a var can be assigned and then it's, it's immutable. Honestly, like JavaScript does a var too. Well, yeah, but you can change the type of a var. But in C#, if you assign the var, it stays that type. Yes. So it's, once you've assigned it an int, it stays an int. Yes.
Mike Hall
Interviewer, UGtastic
You're saying that auto stays an int or can it change?
Guest
Guest
Can it change, it's not a dynamic type. Okay, okay. Auto is not dynamic. Auto is lazy. And the reason behind this is because when you're doing most, a lot of programming that you do, what will happen is, is you're deciding your data structures that you're going to use to store things. You switch your ideas as things go along. For example, a real common thing for me to do is I'll start with a list. Then I go, oh crap, I need fast lookups. It's suddenly a hash table type. Whether it's a dictionary, whatever you call it in your language. I make that switch quite often. Or I'll go back and say, oh my gosh, I can simplify this thing if I did this other bit instead. So switching those data structures around, I do that a lot. And so having auto assignment in little areas like this is really helpful for switching up your algorithms and getting them right.
Mike Hall
Interviewer, UGtastic
Has that been around a long time?
Guest
Guest
Auto has been present since around 2007. Oh, okay. That explains what my C++ background goes back to 1999. So that's why I haven't seen it before. Yeah, the first time I saw it was in the . NET. Visual Studio 2008 I know had it. I think it was a little bit before because the other interesting thing that's here that I'm not going to get into tonight is they also have anonymous functions or lambda functions. Those are also present in the language now. And lambdas are just, they look like lambdas I've seen in Java and everything else. So if you know lambdas in one, they exist here. Syntax is fairly similar. You have arguments that come in. They go out in a different way. The interesting thing with these is that your arguments, it's the way that you know which order they're going to come and how they show up. I don't know it off the top of my head. I've used it enough to write a blog post or say that it was interesting and then haven't had to use it again. So I don't remember off the top of my head. So question about the COUT.
Mike Hall
Interviewer, UGtastic
Is it doing that with operator overloading with the OS operator?
Guest
Guest
Great question. So yes, one of the things that C++ does is it uses operator overloading very heavily and there are basic conventions. So if that's interesting to you guys, I can actually get into that now.
Mike Hall
Interviewer, UGtastic
It's not getting into one of the things that's not in the script but who cares?
Guest
Guest
So one of the things I can do is I can do operator overloading that compares left-hand side to right-hand side. And I'm trying to remember how that works. I believe it would be something like a bool operator equals equals. So if operator overload equals are... Let's see, I'm going to usually return some sort of a O stream. It depends on how you want to do this. I'm not going to get the syntax right. But there's usually like a val. So let's say we want to do a boolean operator equals. And we want to take int left-hand side, int right-hand side. And simply you'll do this on a class type itself. I'm trying to just go... I think there's some of the syntax for me here. I know I do. Generally it looks something like this. Operator followed by the name of the thing. I don't have it in here and again. This is one of the things that you use. It's a trick that you'll have in your bag to use to compare two things to each other. Or to do multiplication. So for example, if you have a matrix type, I could define matrix multiplication by defining an operation with the operator multiple times. Another thing that's fairly common is depending on what type of operator you're using, there are certain conventions. For example, the chaining operators, it would typically be defined as a class member function. So I would do something like, let's actually try to do this one. So class, food. And then I have... So let's get to this first. Classes also have a notion of public, private, protected. There are classes and there are also things called structs. Struct bar. The main... The only real difference between a class and a struct is your default for visibility. So in a lot of languages, the . NET ones that I know about off the top of my head, there's between class and struct, is one gets allocated on the stack, one gets allocated on the heap. That's not what happens in C++. Struct means all my functions are by default public. Class means by default all my functions and members are private. That's it. So not very exciting stuff. There is also private, public, protected. Assuming you've done operatorial programming before, same semantics here as everywhere else. Public. Everybody in the world can call it. Protected. Only me and my descendants can call these things. Private. Only I can look at them. C++ also has a notion of friends. So for example, I can create a class bar. And I can say friend foo. What this declaration now says, when I was learning C++ back in college, I had a teacher who had just learned literally the semester before for a project he was doing for a defense contractor. And he came back and he's like, I'm going to teach these guys C++. And so we always had questions for him that he had to go back to his office later on, find out the question, find out the answer, and come back to us. One time, I was sitting in the back of the class, which isn't a big thing. It's only a room about this big. So I was sitting at that wall while he was up there. And he showed us this friend thing. He said, what a friend allows you to do is a friend allows you to get access to things that are inside the foo class. So I can call private functions on foo. Private functions sounded interesting. There are other privates, though, too, private members.
Mike Hall
Interviewer, UGtastic
So I said, hey, Joe, can bar touch foo's private parts? He turns eight shades of red, comes back the next day, and says, hey, Joe, what's the answer?
Guest
Guest
He says, yes, your friends can touch your private parts. The interesting thing there is that it's -- so what friend does is it allows you to get access literally to the private member variables. It turns off all visibility checks. Now, an interesting side effect of C++ and the way that it does all these checks, these checks are conventions.
Mike Hall
Interviewer, UGtastic
Okay?
Guest
Guest
By convention, what I mean is that the compiler itself is going to look at this public thing, and if I, for example, have a function in foo called -- in the private area, so all you need to explicitly call private, I say, void, do, it, whatever it is. And then I say, in this one here, std, cout, doing it. It's completely valid. Let's get rid of this goofy thing here. I'm going to try the operator ability in a bit, I guess. I just go on foo, foo, foo dot do it.
Mike Hall
Interviewer, UGtastic
Do it's not invisible to me, right?
Guest
Guest
You can't build. If I don't like that fact, and let's say that void do it to find some other file, I just don't like it, there's a preprocessor in here. So what I can do, I can do hash, define, private, public. Which defines, which changes the visibility rules. Unexpected class bar or whatever. It's rare this one, so it's not unexpected. Oh, the other thing I got wrong here is class definitions. I have to put semicolons at the end. And this time, I'm saying kind of makes this private member variable declared that way. However, if I was to put this here into a separate file, let's say standardafx. h, which just happens to live there. And before I bring that one in, I'm going to say that it's private, it's not public. See, I was not going to remember standards, so let's go back here again. I'm going to prove that I can actually corrupt the compiler. Okay, this is something that didn't used to exist before. What's happening right now is the compiler is detecting them trying to subvert the meaning of private. Depending on your compiler, you used to be able to actually change what the meaning was. A number of projects I did in the mid-90s, I was actually able to pervert this. This one here is just a warning saying that you can't do it, and it's not allowing me to do the nasty thing. There used to be a point in time where you could actually change those meanings around. I had to test that one before I came in. So, I'll pull this one back out.
Mike Hall
Interviewer, UGtastic
Why did you have to move that into a separate file?
Guest
Guest
I was trying to move to a separate file to see if I could get the half defined. I would actually just change the meaning of the class definition.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
You just said that above the class definition. Yeah, I mean, that's what you would have had to do otherwise. I could change the class, we could bump the class definition. I mean, have it in order above the, I think it reads an order. It's been too long. So, it does, but it's not going to do private, public, which would be the right order. And do this building. Oh, well, thank you, Justin. You're exactly right. So, the order wasn't right, and it's approved.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
Well, because it gets to the defined, and now everything you're doing from there on is under that effect. You're right. Thank you very much. So, it reads top down.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
So, right now, yeah. So, thank you for helping me pervert the meaning of this great glorious language. But anyway, so, this is one of the interesting things we have here is that the point behind this one is that private is just a suggestion. You don't have to obey the suggestions, but you have to go out of your way not to. Yeah, and you have to know the compiler well. So, good deal. And again, what this would do to show you that it actually runs is when I try to run this thing, I, in fact, get the thing that says doing it.
Mike Hall
Interviewer, UGtastic
So, the other bit that we came into here is that we actually can do classes, right?
Guest
Guest
Classes have, again, the notion of private, public, protected. So, they do all the interesting things you can do. The other thing we'll get here is, for example, I have, let's call, one of the things that we don't have in C++ that we have in a lot of other languages, because we have this notion of interfaces. The reason why is because, again, C++ defines something as a pure interface. Let's get rid of this for a bit. Because I would do something along the lines of, I would make sure that I could never actually directly construct this thing. So, I would say shape. What I did there is I took what's called a constructor and a destructor. The interesting thing about these particular types of things in C++ is that it has what's called deterministic finalization. As a matter of fact, when you're looking at C++ code, in general, there's this notion of construction, resource acquisition is construction, resource release is destruction. So, C++ programmers love the language, because what happens is if I'm writing a printer driver, I can require them to the printer, set up all the context for the printer. When I'm done using it, the destructor runs, releases all the resources, and it goes away. It does this in a deterministic way. When you look at a garbage collector or anything else, a lot of garbage collectors have the notion of a destructor. Java has this. The languages have this. Even JavaScript has some sort of garbage collection that happens in the back end. And what a garbage collector will do is put it finalizes an object. It will then see is there a finalizer or some sort of destructor on this object, and it releases it. The bad thing that happens is that that destructor isn't run. Sometimes it's not run at all, so if the program is shutting down, you don't need to run your destructor because the fastest way to get rid of memory is to shut the process away. No work to do. The other thing that will happen is the destructor will run sometime in the future. If I, if a file, if I forget to close a file handle, and I don't call the dispose method, or whatever close is, eventually when memory is collected, the file will be let go. It will come available sometime in the future. C++ programmers are used to deterministic, which means when I exit my scope, my destructor is run. And they run exactly when I close. So that's what the destructor is. First thing is you want to make a, so I'll look at what an abstract-based class looks like first, or an interface, and then we'll actually start and do something a little bit more interesting with the constructor destructor craft to get you an idea of how that stuff works. So if I'm creating a shape, one of the things I have a shape is I might have something like a void draw method to show that this thing is virtual and not being used by anybody. I would do for the virtual keyword. The virtual keyword is a hint to the language saying this particular thing goes into a vtable.
Mike Hall
Interviewer, UGtastic
Folks know what vtables are? Anybody not know what vtables are?
Guest
Guest
All right. So a vtable, great. vtable is the old, this is how C++ got to be compiled into C.
Mike Hall
Interviewer, UGtastic
You all know how JavaScript works with monkey typing, right? Or other language, like is monkey typing something you guys know?
Guest
Guest
Duck typing is probably more common term.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
No, duck typing is, it looks like a duck and cracks like a duck, it's a duck. Monkey typing is, I wish to Christ this thing had function x. Oh, you mean monkey patching. Monkey, sorry, monkey patching. Thank you, I had the wrong word. Not a surprise. So with monkey patching, what you do is you would just tack things on. The way monkey patching works under the covers is you have a hash table. The hash table has a name that maps to either a function as a function, the first type of thing in your language, or a data number where it's an object, right? Same thing here with vtables. A vtable is a lookup that says in this slot, I have a pointer to a function. In this slot, I have a pointer to a variable. Virtual table has a pointer to the data segment and a pointer to each function within the thing. When I say virtual, what that says is instead of taking the type definition and just having a hard link, instead what you're going to have to do is, so prototypical languages, JavaScript will happen is you instantiate the object, you call a function, it looks at the function table, does one degree of lookup. You can then have what vtables allow you to do is it says look for the thing here and then keep, sorry, you can replace items at that slot for type definition. So you start with the base type definition. If the base type definition doesn't override this function, go up a level, go up a level, until you eventually hit somebody. That's how vtables are structured. Prototype languages do the same thing. They get this, the vtable notion came here first. Actually, no, Simula probably had it way before that, 1969. C++ made it mainstream. Yeah, Ruby does that. And matter of fact, any Ruby is here, Frank Thomas has a metaprogramming explain, or understanding metaprogramming, that explains in really intense detail how Ruby applies the lookup table for evaluating which method or class to resolve to. So I'm sure it would help.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
So the way you're describing it is like, just like what he does. But he goes on for like 45 minutes. No, it's a really hard concept.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
And he says it's slow, which helps. I don't talk slow, unfortunately. So that's what this says here. Now, what I can say is that I want to make sure everybody has to implement it. What I do is I put an entry in the vtable that says this thing here is null. I've now just created what's called an abstract base class. This is what an interface would look like. If I want more functions in my interface, I would implement more virtual functions that have no implementation. And I tell the compiler there will never be an implementation by saying equals zero. This does two things. One, it tells the compiler you can't instantiate a shape. Two, if someone does, sorry, class circle arise from shape and I try to build. I get an issue. So I've got a bunch of other things going on here. Let's get rid of these two lines. Okay, build succeed. Fine. If I try to say circle C.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
And the reason why I had to bring C into scope is because what happened is the compiler didn't look for an implementation of the thing. So I didn't try to figure out what was going on. What we see here is circle. I can't instantiate abstract base class because circle doesn't implement draw. Sorry, just going back to the assigning the zero to the declaration. I've never seen that kind of syntax before for anything. Because usually what you'll see is that most languages have said this is stupid. Yeah, an interface or an abstract or something. Like you would define abstract on the method name in C#.
Mike Hall
Interviewer, UGtastic
Yeah. But does zero have a special value or can you put something else there?
Guest
Guest
You have to put zero.
Mike Hall
Interviewer, UGtastic
Yeah. Okay.
Guest
Guest
It has to be zero.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
Yes.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
So if you like, you could also put, which is just a hash defined to zero. So that's one of the interesting things you get there. The only thing you get is with. So let's say I actually go ahead. I implemented public void. The public virtual void draw. Now let's get another C#, C++ idea before I go into this. Right now it said draw exists. Happened to find where it's compiled. So if I go ahead and build. And now I'll get another thing, which is CI as an undeclared identifier. I'll click and put circle C. It gives you an unresolved external simple shape, colon, colon, shape, void, whatever. What that says is that this constructor here doesn't exist. This destructor doesn't exist. And also we get this thing that says this function void draw doesn't exist. Typically what you're going to do when you're distributing your C++ apps is you put your headers in one file. You put your code in another. Because you, the decision there is people don't need to see my headers. They only need, they only need to see my headers. They don't need to see how the implementation works. Again, a lot of modern languages, what they do is they say that's really dumb. It's simple exposed metadata. And then you'll pull the metadata in whenever you import the library. This is before that. So your metadata is these, are these . h files. The . h file defines the interface. The implementation goes behind. And then you compile these things to like libraries where you then include them in linkers. And all this other magic stuff gets together and marries everything together to get you implementations. What we're seeing down here is the linker can't find implementations for some of our functions. The way you define what your functions are is I would go along the lines of shape, shape. And here let's say a standard. Let's do one other thing too, which is I'm getting sick of typing standard all the time. If I want to bring the namespace into global visibility, I just say using namespace std. Something that's going to be visible to you all over the place. And then I can say here just cout, shape ctor. And I can do the same for the destructor. Which is going to be a function called this. Shape destructor. And if I want to draw again, this is really exciting.
Mike Hall
Interviewer, UGtastic
What's the deal with the tilde? What's the deal with the tilde?
Guest
Guest
The tilde is a shorthand terse way of saying this particular thing is a destructor. Right, so it's just a shorthand. It's not even a shorthand. It's just that's the thing of the function is tilde. It's a convention. And it's totally valid to just add on to classes that way, even though you're out of the curly brace that originally defined it. So again, so the normal behavior of this thing would be I would have a file called circle. h. Right, okay. There you have this thing. I have another file called shape. h where you have the previous. And all this implementation details would live in a cpp file.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
I'm being really lazy to tell you about some things. If it's not clear to folks if it's making it confusing, I can go back and push into files. Just say the word and I'll have to make it happen. So the top circle curly braces would be in a header file. Yeah, so this would be in a header file as would, that's what the . h things are. So would the shape. This whole thing would be in a separate header. It's a little shocking to me how much I remember from the 1c class I took in 1984. And it was kind of weird for me tonight. It was kind of weird getting this thing prepped. It was like, oh my god, I remember this, I remember this, I remember this. Yeah, like I immediately knew the, like where you were doing the 5 equals equals I thing. And like having done seasons in college, it was just really weird. I guess it is like writing a mic.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Very mean, angry error message having a mic.
Mike Hall
Interviewer, UGtastic
Yeah. What's that? Which one?
Guest
Guest
No, no, the thing that always threw me off from C++ was the compiler warnings and errors that they're just, they're just meeting. It's like they're yelling at you. It's like all kinds of. Yeah, and when we, when you start working with generics, the other fun thing is that you're working with like the boost libraries or any of the standard libraries for algorithms and debugging a template, which we'll get into next. Those, those errors, it took me about five years before I could read those on a regular basis and parsing, right? So I remember on 97 or so, I suddenly got to the point where I, I reached zen for those things. So anyhow, what I want to show here then is this whole destructor, constructor thing and the order which they execute. We're going to show, so a short, show order to the magic of console write line. You're debugging write lines. Again, just running through this thing. I don't know what that would give you. Oh, not mine. So I had, I just had a little here pop up on my middle screen. It says, I can't talk to your TFS server. And so I, no, you can't. So here's something interesting that we get. First off, it just, it just says, shape constructor, drawing a circle, shape destructor. We see that the constructor ran even though we never explicitly called it. Then I'm going to go a little bit further. I can actually add implementations for circle to have its own constructor and destructor. So circle, tilde, circle. And then we're going to cheat by using the magic of search and replace. And here what we see is things are constructed base class first, then the most derived class. They're destructed in reverse order. Most derived class first, base class is last. It's also deterministic. They didn't do anything to call this thing to destroy itself. When the variable went out of scope, it went out of scope. The other thing you see here that, again, might be a little bit weird for folks who are used to garbage collected languages is that this particular function, the circle, it's not being allocated on the heap. It's being allocated on the stack. Which means its lifetime is literally curly brace to curly brace. A lot of class-based languages these days, you knew things up. And they go away eventually. Yeah, that was the first thing I was going to ask about is I at first thought there was going to be a compiler error. I'm so used to having to initialize. And also the other thing was that like in C#, if I had a derived class and I put a print line in the base class and in the derived class constructors, I'd only see the derived class. I'd have to explicitly call up to invoke the parent. Yeah, based on whatever. Yeah, so this just always goes up the entire chain.
Mike Hall
Interviewer, UGtastic
Yeah. Can constructors take arguments?
Guest
Guest
So I was going to do that one next. So let's say, for example, circle. I want it to be able to circle to remember something like its size. So we'll have it take a float diameter. By the way, one of the things I didn't mention here, a lot of basic primitive data types. The primitive data types that you know from Java or from any other type language, they're here too.
Mike Hall
Interviewer, UGtastic
But aren't there a lot of them like 64 in it?
Guest
Guest
Yes. Oh, so the question is there's something. So there are something in 64.
Mike Hall
Interviewer, UGtastic
Is there a double or a long?
Guest
Guest
Well, in 64 long. Double. There's not. There is a.
Mike Hall
Interviewer, UGtastic
What is it called?
Guest
Guest
There are some really big numbers. I think there's 120-inch bits. Or I can't remember what it is. But there's some very big numbers that they handle in here. For all the numerator types.
Mike Hall
Interviewer, UGtastic
Helper a little bit with the compiler compiler, right?
Guest
Guest
Yes. The other thing that's interesting here is that the size of an integer is not the size of an integer. The size of an integer is actually compatible with the word size on the CPU that you're running on. So an int when I'm running as a 64-bit application is 64 bits wide. An int when I'm running in a 32-bit mode is 32 bits wide. If I'm running on the little ARM processor, an int and a byte have the same width. So that's another fun thing about the language. I don't. I haven't checked the C plus. I imagine that might be something they may have normalized with C plus plus 11. But I don't know. Because I'm not that. I used to be that geeky. I don't have that kind of time in the rebuilding respects.
Mike Hall
Interviewer, UGtastic
Is it like C where you can basically do anything you want to any memory address?
Guest
Guest
And you can totally go outside your processes memory. That's how buffer overflows work, man. So it allows for all that. I mean, you can save it all very easily. Yeah, now one of the interesting things you see there is the number of compiler vendors, including Microsoft, have implemented things where you can say some assumptions that exist ahead of time. These are ideas that are stolen from languages like Eiffel. Where I put assumptions, and then the compiler behind the scenes will actually generate assumptions, take those assumptions, and generate preambles in your functions that verify the ranges. There's also a lot of type safety that's being done, for example, for handling the buffer overflow issues. What they will actually do is they will make sure there are certain things you can say about what type of string you're accepting. So the bane of most C++ programs or C programs are null-terminated strings. Null-terminated strings are considered dangerous. What a null-terminated string is, it's a string, it's a string, it's a string until you hit a null. Which is really bad if you have a string that needs a null character in it for whatever reason. It's also really bad if you're depending on that null to exist, because that's where you get the buffer overflows. You just pass in a buffer with no null. And then you...
Mike Hall
Interviewer, UGtastic
Like a random watch room? Yeah.
Guest
Guest
If you pass the pointer the right way, that's how you can use the buffer overflow to execute code that was secure. So a lot of the Unix-based hacks right now are doing that. As a matter of fact, one of the trophies... In the hacker community, one of the trophies you get is that you could actually get a buffer overflow exploit checked into the link space code. It's a fireable offense at Microsoft if you do that on purpose. In Linux, it's just a "haha, I got you lines. " Not trying to put fear about Microsoft or anything else. It's just that is a known... It's a thing. Take it for what it's worth. If you're trying to hack and you want to attack a big batch of machines that sit in enterprises, Linux is getting... Because Linux is almost once free. I had a client who had a Linux... Like Memcached is just as popular in the Windows world as it is everywhere else. And the best Memcached implementation is not on Windows. So you put your Memcached server out there, now you've got an actual tactical thing. So it's just where things are. So we get this diameter thing. What that means now is that my circle here needs to take a float. The name doesn't actually matter what it is. The names don't need to match, it's just the types that need to match. And what you'll see a lot of folks who have not done C programming before or C++, is they'll do something really, really dumb. They'll initialize diameter like that. That's horrifically stupid because when you... And I'll tell you why it's dumb. The reason why is because diameter gets allocated. That allocation is going to be assigned something, some memory. And then you're going to run the assignment again. What you really want to do is you want to go ahead and in here... I want to initialize diameter. Like that. What that's going to do is it's going to say at allocation time, find the in the detail where diameter is located and stuff this value in there right away. It's modestly more efficient. If you're doing lots and lots of small object creation, it's significant. It can really save you some time. And it's just one of the weird things. This is the only language I know that does something like this. Everybody else fills in defaults if they're there and merges the defaults with all the different construct implementations. And they just kind of chained together magically. This is the only language I know that does something like this. So once I have the diameter here, then what I can do is I can say something like drawing, drawing a circle with diameter. And then there's a weird thing that I showed before the this pointer. This is this magical thing that just happens to exist. This always points to the object instance. It's always a point to the V table saying, off of this particular location, remember, where do I have my bits? Not on the V table, sorry. Off of the function location. It's also implicitly there. So I don't really need this. It's just assumed to be there. The reason why you'll see C++ programs put this in, however, is if I have a big function with lots of local variables, I can get lost in what's going on. And Hungarian notation has lost favor even in the C++ community. So m_ is a member variable. For some reason, this is most cleaner. Well, you can read it. That's why it's not readable. Yeah, like m_d. m or f. m or whatever. So that's member variables. That's the this pointer. That's the draw function. And of course, one of the things you can do in here is you also do...
Mike Hall
Interviewer, UGtastic
How much time do we have, Mike? What time do you guys wrap up X?
Guest
Guest
Just by nine.
Mike Hall
Interviewer, UGtastic
By nine?
Guest
Guest
Oh, okay. Good. So you have circle. I can now create another class in here. So you get the idea behind this one. We've asked about what happens in the float. If I now run this bit, circle no appropriate default constructor available. So here's the weird thing, too, is that to pass the constructor argument, pretend C is now a function. And I just say 12. There's no new. There is no new. Well, the word new exists. So let's go with new. Let's say I don't like the way that that thing's working with circle. I can go, let's go auto because we're going to be cool like that. Equals new circle size 12. I've now got a pointer so I have to say C points to draw. And I've also got what's going to be called a potential memory link at this point in time. It won't be a bad thing here. I can go out as a merry way. I exit the function, no harm, no foul. But so I do have the notion of being able to new things up. I also have this thing where if I, and let's actually look at the output first. So remember we had that fun stuff going on with the constructors. And I can show you here that things never actually cleaned up. Constructor gets called, does the right, no instructor is being called. Let's say cleaning up is important because teaming is not actually. The only function of my program is when it's being called from somewhere else. I can include another library called memory. Guess what memory does. It manages memory. So if you've done C++ back in the late mid 90s there's this thing that was supposedly evil called autopointer. Autopointer was considered evil because it had copy on move semantics. What that basically meant was that ownership transferred freely and often. It was the hippie free love memory pointer. Whoever got it last was the one who got to do what it wanted to to the pointer. Not a great story. So what they did instead is they created something with almost the exact same semantics called unique pointer. And instead what I can say is so the auto keyword it's good in some cases not all the time. Unique pointer circle C equal boom. So I make this mod, I make this mod change. This changes the type definition of what this thing is. Not a lot of code changes. You notice it didn't change C points to draw or anything else. C points to draw is using operator overloading. It's overriding the points to operator. I run again. And this time we see constructor, constructor, destructor, destructor. So again one of the one of the interesting things you get out of here is that if you want to be able to new objects up make sure they get destroyed when they go out of scope. You can do that. The other thing I can do is then I have functions and there's these notions of void do work. This one here we can say let's say circle C. And then I can call here C dot draw. And now weird things you can do with the pointer that we have here. So I can, instead of doing this, I can call do work. Pass it C and what's going to happen here is that it should cause me a compilation error because C is a reference to something. I can call C dot get.
Mike Hall
Interviewer, UGtastic
Does that do anything for me?
Guest
Guest
No, C dot get still returns a pointer. However, I can take C, dereference it. Oh, come on. Let's see that again. Yeah, this is a weird part, or if I just dereference C, okay that's what I wanted to do. So if I call it star C, which is actually to dereference the pointer, I can now call it. What this does, though, is it. It's over here so everybody can see what I'm looking at. Now we see the shape instructor, circle constructor, drawing a circle diameter 12. And then we see two sets of destructors running. What's actually happening here is we have a copy that occurred. The copy doesn't run the constructor because the copy constructor is created for you automatically. A copy constructor doesn't have any semantics behind the scenes. It was going to be enforced automatically by the pilot so we didn't see that, but the destructors still ran. If you want to see the copy constructor that got created. Yeah, this is fun stuff. Let's just do it here and then you'll get the notion for it for what happens with circle. I move with shape. So circle, reference, other, and this time we're getting a, what's called a circle reference other, other dot diameter, circle copy constructor. So the ampersand at the end of a class name is how you say we're passing in a thing of this class. Yeah, and so it's, so there's, um, so in C++ you can pass by three mechanisms, pass by, pass a copy, pass a reference, pass a pointer. So the ampersand is reference. And an ampersand is a reference. A pointer is also a type of reference, the difference being that I used a dot mechanism instead of points to. So it's just a different operating in order to dereference them. The other nice thing about this that you'll see in C++ code is when I'm passing by reference, what I'm really saying is you don't own this thing, I still own it. Because what happens when you're doing code reviews for C++, large C++ code bases, if you want to look for memory leaks, what you do is you'll, everywhere that has a pointer is a potential memory leak. By passing by reference you're saying this code is not going to leak memory of the things that were passed in. And you don't have to, it eases up code reviews and it also helps to find ownership semantics. Again, because with C++ programs or C in general, your biggest problem is your memory leaks. You still have those issues with garbage collected languages, but the set of things that can cause memory leaks in garbage collected languages are much smaller than we can have here. Here you have memory leaks by breathing and running the programs. So going back a few steps.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Oh, I'm sorry, if you want to make my notes. So what I want to do right here is let me run this one first. And what you can see here is shape, circle, shape, constructor, circle copy, circle copy, constructor got run, drawing a circle diameter 12, and then the instructor's also running it. Because I employed the circle copy constructor, I often implicitly call the shape one again. So we had a little bit deeper stack all of a sudden. Real exciting stuff, I know. But these are some of the things that you'll see in here. That you don't see elsewhere. And if I wanted to get rid of that particular copy happening, I can just change this over to being a reference. Code doesn't change. Everything will experience the same. So I'm saying thing is passed by reference. The compiler will fix everything for me. And now I'm not writing the copy constructor anymore. So one of the things you run into with performance issues in C++ applications again is if you pass by copies, you have another bunch of code running implicitly for you that you don't expect. Knowing these things helps you to make your code faster and better. And the thing that people like about C++ is it gives you tons of control. The thing that people hate about C++ is you have to think about so many things. Good C++ programmers tend to be very detail oriented and tend to be able to keep a couple dozen things in their head at once. There are also pains in the ass. So they're really telling. If you do a code review of them, in general, what you'll see is that if you said something 20 minutes ago and you made a point, you were off on your point by just a little bit, they'll come back and nail you on for consistency. Again, it's because of this muscle they have to exercise.
Mike Hall
Interviewer, UGtastic
So what was your question?
Guest
Guest
You had changed, before you made the unique pointer, you had changed from the dot notation to the pointer notation. Yes.
Mike Hall
Interviewer, UGtastic
Is that essentially saying, yes, originally with the dot notation on the stack, but now it's on the heap?
Guest
Guest
Yep.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
With the heap, that means that it's just being managed by a different pool. It can be passed around. Its lifetime can exceed the lifetime of the function it was created in. If it was created on the heap, its lifetime can only, is limited by the lifetime of the function. So, when it asks the scope. It means stack.
Mike Hall
Interviewer, UGtastic
Yeah. Yeah.
Guest
Guest
That's the heap.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Sorry. Yeah, stack is lifetime of function. Yes.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
Thank you. No problem. Um, when Andy Lester did the, um, the SeaTalk, he talked about, uh, Valgrind. Valgrind. It's a, uh, static analysis, uh, tool.
Mike Hall
Interviewer, UGtastic
Is there anything like that?
Guest
Guest
Because I'm just thinking about, uh, how, how can you, is there anything like in Visual Studio that looks and says, all right, here's some, uh, potential, uh, places for memory leaks or anything like that? So, you may have, I'm certain everybody, there was a number of people who have heard of tools like JS Lint. It derives from an old tool called Lint.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
Lint is a C, C++ tool. Um, and that's static analysis of your code.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Now, beyond that, there are a number of other static analysis tools that come up from various vendors. Intel has a bunch of them. Microsoft has a bunch. Um, some of these are open, are, are, are freely distributed. Some of them are not. And there are some tools out there that will analyze these things and do some crazy, crazy stuff. Um, I know some of the tools Microsoft has internally will do things you didn't think were possible. They'll actually analyze the code and figure out that based on the stack and the typical allocation pattern that we have within the code, that these types of bugs probably exist. Is that kind of the, um... But they do really insane analysis.
Mike Hall
Interviewer, UGtastic
That's the Apex?
Guest
Guest
Or is that... No. Uh, something even... This is internal.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
I guess, I don't know how much it's been released and how much it hasn't been. I've been out of there for long enough now that I don't really care about talking about it. I mean, I know the tools exist. Um, and they do other things too. For example, there are tools that will watch your code when it's running. And we'll actually figure out where to place the, so you compile code. And then we usually run a typical set of use cases against that code. And we'll watch where, which pages are frequently hit near each other. If those code pages are, um, frequently accessed to the group, but they're compiled far apart, the compiler will, they have tools that will move those pages so that when they're loaded into memory, they'll be in the same 4k segment. And because they're in the same 4k segment, your program runs faster. Again, there's a lot of research papers out there that explain how this is done. Um, Microsoft has a lot of tools inside that they use to do this. I don't know. I know they're talking about releasing some of them in, when I was there in 06. I don't know what happened. And some of this stuff just finds its way into visual C++. Some of it doesn't. Um, we made a lot of code analysis that shows you where things are. So they may actually have that built in. So let's see. That's the references thing. That's that. Um, the next thing I wanted to show you was why, so. As far as I know, no other languages out there besides C++ and maybe some other niche ones allow for multiple inheritance of implementations. Emma, so multiple inheritance of interfaces. So, sorry, one thing before we move away from copy constructor.
Mike Hall
Interviewer, UGtastic
Can you have the copy constructor call the other constructor?
Guest
Guest
So they can have a single point of entry.
Mike Hall
Interviewer, UGtastic
Can I have the copy constructor call the other?
Guest
Guest
That's right. Oh, so could I just call. You want to do this instead. Um, that's just a common pattern. Yeah, no, no, I'm trying to think. I'm pretty sure. I believe. Because you're trying to chain constructors. I'm blanking. I'm pretty sure it's possible.
Mike Hall
Interviewer, UGtastic
Can I do that with super classes?
Guest
Guest
I'm not sure about same level. Yeah, I'm blanking if it's possible or not. Again, so this is like, this is one of the things where literally, um, I started, I started revising, revising myself on how C++ works about three weeks ago. And trying to get the basics down. I'm almost positive there's a way to chain them. But I'm blanking on it right now. So there are, there are ways to call the base, but I can't remember how you call other ones. I was hoping it would just be as easy as calling a circle or this. It would work. Also real quick before you move on. I was surprised to be a question. I noticed a while ago when you were using C out, first blank string, that you were including the S and everything before CL, but now you're not, that you include, that you haven't included same at the beginning. Oh, sorry. So what I did real quickly, as I said, I'm getting sick of typing STD. So I did, what I did is I typed in using namespace in STD. What that does, it brings all the names in STD into the non-namespace. And that's like, again, a lot of, a lot of languages do this kind of thing. So the weird thing about C++ is that given all the languages out there today, you probably know more of it than you realize. The bad thing about it is that it's so similar to things you already know, that you're going to get hung up on the little things. With the include statements, sorry to back up again. You were saying that those get expanded, like, I guess in a preprocessor or whatever, with the code that they find. Yep.
Mike Hall
Interviewer, UGtastic
If you were to call pound-include Iostream in another file as well, would it get sucked in twice?
Guest
Guest
So, no.
Mike Hall
Interviewer, UGtastic
Okay.
Guest
Guest
But the reason why it doesn't get included, let's go ahead and just look at that. I think that's more of a yes book. So, I actually have two things in here that make sure it gets included once. So, pragma-once is a thing that tells the compiler, only open this file once. Pragma-once is not part of the C++ standard. Pragma-once is something that Microsoft just had in their compilers. I remember using it in, like, Visual Studio 4. 5-ish, it's going to be about 97. It's been there for a while, but it's not part of the C++ standard. That said, they also have this thing called include guards. So, we see this bit over here that says, if ndef iostream, how to define iostream. It says, if iostream is not defined, define it. Which means that this thing says false. What the preprocessor does, it goes, let's find the matching end if, and it goes, and it goes, and it goes, and it goes, and it goes, and it goes, and eventually it gets here, and it goes, oh, nothing to include. It will scan the file every time. Sorry. A naive implementation of this will scan the file every time. Most compilers don't anymore. Build times on this one, I have a few notes, but they've been pretty snappy. This same program, back when we started doing it, would have taken a good 15 or 20 seconds to compile, not compiling. You know, I don't know how fast it's going. It's going fast enough, but I can't tell. And the reason why is because they've gotten smart about the compilation. But yeah, this is why it's not being uploaded multiple times. They're called them boot guards. Microsoft also has the application file. The extension. Yes. So the other thing we have in here is the standard afx. h. Which is a, this is an optimization they've had since at least 94. From Visual Studio 1. 5. 2. And standard afx. h is standard afx application frameworks. And they use this, they used to include a bunch of things for MFC and all this other happy horse stuff, you know. But the convention still exists in Microsoft libraries where standard afx and standard afx. cpp are things that get pre-compiled, which means that they're slowly changing files. If you include this file, it's going to include a bunch of headers and a bunch of other stuff. And so they'll cache the results of that compilation for future use. Again, just a little idiosyncrasy for the compiler. So the other fun thing like I was saying before is that you can actually create other classes. So we create another one here, let's call it rectangle. NGLE. Call it one side. Let's get rid of the copy constructed because it's not really interesting here. And then we'll go down to circle it, we're just going to steal all of its properties. And this one is actually, let's try a little bit of time. And this whole little thing exercise will have a point eventually. So here we are going to just do the circle. Square rectangle. I call it rectangle. I'm going to square. In there. Look at that. If it's a rectangle I have to get a length of width.
Mike Hall
Interviewer, UGtastic
Great.
Guest
Guest
And then over here, let's see. The last thing I have to do is I have to just say side whatever is for an instructor. Let's say drawing a square with diameter or whatever. So it's all super. I can have this one here. Take a shape now. Shape that I draw still works. Let's see. Accessible base class is not allowed. So what that thing just said was that I can't access the base class for square and for shape. So let's make this one public inheritance. The weird thing here I mentioned about C++ is that also with the inheritance you can define how the base class is inherited.
Mike Hall
Interviewer, UGtastic
So do you derive? Can people see that I am a shape or do they just see me as a circle?
Guest
Guest
The reason behind this is that I might want to have a common implementation behind me but I don't want polymorphism of the types. So that's why you would do that kind of loopiness. So now that should allow me to build again. Diameter is not a member of square. That's right. It's not. It's this type. Side. Try again. Build some seeds. Super. Which now means I can do the fine polymorphism of also doing. Do work. So square. S. Do work. Pass. Pass. And then you see the thing.
Mike Hall
Interviewer, UGtastic
So the A polymorphism works just like we expect, right?
Guest
Guest
So no big shocker there either. And it looks like my default, the inheritance is private. So the next thing we can do that's kind of interesting is that it do work. And so we did this through inheritance which was kind of interesting. Let's undo the public inheritance and let's see how else we could implement that particular function. So let's get rid of this. Let's break everything again. But make sure it works in spite of itself. Let's see. It's starting to get a little. Let's do UARE. So the other thing I can do here with this do work function is I could instead be a little bit more generic about it. Template. Class T. Now I have no idea what in the world C is. I'm not broken all hooks with it. As a matter of fact, I could create another class which would be class flux public. And then all the other draws are void. Let's be really weird about this. Let's do int draw. And yes, you can do implementation within the class too if you like. It doesn't really matter. It matters. The difference is that when you do the implementation individually, you can compile it ahead of time. You only need to distribute your header files in the compiled binaries. If you do the implementation inside the class, then what's happening is everybody who imports that class is getting their own unique implementation of that function. The link here will squish everything back down to one. But in the meantime, you've got different implementations. So, C outlets and quarks rocks. And what I can then do is I can, so I can do this. Do circle will work, square will work. I can do quarks Q, do work Q. And the interesting thing is there's a build error. All right, I've got to return a value. So, return. So, let's do five again. And here we see that quarks was able to go. Now, the interesting thing here is this is duck typing. It's duck typing, but instead of like a lot of the dynamic languages where you have to write unit tests and everything else around this to make sure that when I pass in all the different instantiations and possible permutations of use cases that I have, will it work? Here I have static type checking to say, does the thing that I passed in have a function that can be called in the context of this tablet and compiled correctly? Didn't care about the return value because remember, one is a void, one returns an integer. No one cares because the function doesn't use the return value, so it's okay. This thing just worked. And where this becomes really important is when you're doing basic algorithms. For example, if you're sorting on two items, a sort only requires that you'll be able to tell something is less than, greater than, actually less than, greater than, or equal to. And you can derive greater than. So, as long as you have less than and equals, you can sort a list of things. Whether they're numbers, people, whatever. So, in this case, this is where, you know, the generic algorithms come in play. The interesting thing that you can do here is you can use this to do what's called duck typing. Let's just say, if I have somebody that can call this function, I'm happy enough. Let's go our merry way. You can also use templates to do other weird things. So, for example, let's say that I have, I can, the template thing will also work on a class. So, if I do templates, class T, class mine, whatever. So, I can actually go ahead and, while I'm not going to do anything interesting here right now, you can use this also to inject things into your class hierarchy. So, for example, I can say that I have a template type that I want. And then, what you might do below is I'll have class, you know, interesting bit. Public, my, whatever of type int. Now, there's something that derives from integer. I don't know what that would mean. Let's say that it's meaningful to me. I can then inject something in between my class and the one that I'm really interested in to do other interesting work. So, if you're doing like a windowing API and you know that you always want to implement the decorator pattern in a certain way to decorate the window, what's going to show up on for your Chrome. And you want interesting bits to be in between, you want all sorts of windows to be intercepted, you know, so like buttons and sort, you know, whatever you can imagine. This is an interesting way where you can inject the one bit inside the other. I've used this technique in the MFC program and Microsoft Foundation classes to make it to, again, for like the decorator stuff to make sure that I have certain things available in my window no matter where it was. You know, be able to intercept clicks and whatnot. And there are lots of other places where you can do this. But Tempest like to do weird things that you can't do in other normal languages.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
So, what type of arrow would you get if you choose the definition of box draw to take in a variable?
Mike Hall
Interviewer, UGtastic
Oh, if you renamed draw, would it capture it? Oh, so if I named draw to draw?
Guest
Guest
Oh, no, no, no, no. So, draw it would fail. Yeah, yeah.
Mike Hall
Interviewer, UGtastic
Okay, yeah, but I mean, like, why would it draw?
Guest
Guest
You kept it draw, but now it takes an integer. I mean, we'll figure that out as well. So, I saw you draw.
Mike Hall
Interviewer, UGtastic
So, you know, so if I go int i, right?
Guest
Guest
Draw does not take zero arguments. Now, one of the weird things you can do here, though, is I can say that this one has a default value of zero. And that works. So, the other thing that you get with C++ is it has functions that have default values. So, you don't have to pass them along. The default values, interestingly enough, have to be declared in the . h file. So, let's copy this quick. And then it pulls out to what would be a little bit more as a normal line.
Mike Hall
Interviewer, UGtastic
That's just because the default value is going to be part of the method signature, right?
Guest
Guest
Yep. Because, yeah, sorry, so it's, what I was catching on to was, so I'm going to say int i equals nine.
Mike Hall
Interviewer, UGtastic
Right?
Guest
Guest
So, it looks like I'm overriding what it does. First of all, the default, I redefined the parameter. So, I can only define the parameter up here. And like I said, it's because it's a compile type thing. What this means is that if I was to change the definition of this header file, but not compile dependent other files, the value would continue to be zero from things that were compiled yesterday. And if I changed it to, say, 10, only things that were compiled since the change would get the change. Because it's a compiler, it's a hint to the compiler to what should be pushed on the stack when this function gets called. That said, when I go ahead and run this thing, it now captures the 10, spits it out. So, it's an interesting language.
Mike Hall
Interviewer, UGtastic
So, there's no class explicitly at the top of the hierarchy?
Guest
Guest
There is no class, sorry, so there is no, so in a lot of languages they say is there's a base class called object.
Mike Hall
Interviewer, UGtastic
Object is the root of all things?
Guest
Guest
No, in C++ the root of the hierarchy is what you say the root is. In class, Quox's root is Quox. It is the top, the king. So, it's, that's one of the things you get with the African language in the philosophy is, do I have a forest or do I have a tree? C++ is a forest, everybody else went with a tree. I'm trying to think if I know of any other. I'm enjoying languages that don't do this are ones post C++ I can't think of any. Pre C++, simula, small talkness. The small talk is object. It's unusual that they went this route. But the reason why is because when you have the base class that then imposes a whole bunch of other things that are great for simplifying algorithms, they're great for simplification of other assumptions, they're horrible for performance. And C++ is meant to be a systems programming language first. So, you can do weird things in here too, like keep in mind that this is a systems language. So, there is a keyword where I can go ahead and bust out and hit 21H and that's valid code. Which is a debugger break. So, I pulled the one thing I remember from programming assembly. You know, or if you want to do MOV EAX 12, it moves EAX registered value 12. So, tablets and C++ are much deeper than just the source code. Yes, I learned that wrong in school. So, templates and C++ actually allow for what's called metaprogramming.
Mike Hall
Interviewer, UGtastic
Yeah. Are they trying to complete or not quite? Huh? Are they trying to complete or not quite?
Guest
Guest
I don't remember the details of that.
Mike Hall
Interviewer, UGtastic
Are they trying to complete? Also, are they trying to complete or not?
Guest
Guest
I don't. So, yes, you can do, you can define like factorial and a bunch of other things. And then the weird thing is you can actually get the compiler to do the factorial computations for you before compilation time. So, if you say like... So, what the templates would like to do is if I can have like a template... This will be a stretch if I can even remember how to do this. Template. Oh, yeah. It's ugly, but you can do it. Class T, yeah. Say, double... I can have like an implementation of this one where I specialize for int i. And then what I would do is I... I'll do int, this is a horrible implementation. Let's just assume this is a good one. Factorial of i minus one. And then there's a way to say that when i is equal to one. And that's the part that I can't remember. But I can then say when i is equal to one, do the special order. If you just return to one, and then the pilot will do the rest of the work. Expand it all out. And make things happen. The thing I don't remember is how to do the factorial for the exact case of one. This is the specialization for when type of class T for factorial is an integer. I can do other ones for longs and doubles and floats. And then fold it all back in. If you really get interested in this kind of stuff, there's a guy named Andre Alex Andrescu. Who, everything, so if you ever go see a C++ panel, there's going to be a couple guys on the panel. Herb Sutter. The Scott I'm trying to remember is Scott Myers. He'll probably be there. And Bjarn, if they can find him. And Andre has done some sick things with templates. He first published a book on it back in the mid-90s. When he started building the name for himself. And he's still building his name today. But he's done other universities. He actually develops a couple other languages based on the C++ to correct the faults in C++ as he perceives it. He's a wicked smart Russian. And a fairly likable guy from what I've seen. He's not conceited. But he knows his stuff called. So that's the notion of metal program. And the thing I was going to get into next was, I just kind of want to wrap it up. There's also this notion of multiple inheritance. Where I could have two classes inherit from an implementation. The issue that you run into with multiple inheritance and the reason why most languages don't do it anymore is because when you inherit two implementations, what do you do if they both implement draw?
Mike Hall
Interviewer, UGtastic
Which one do you pick?
Guest
Guest
You have to explicitly state which branch you want to take when you do your compilation. Because in the D table when I walk up, one level I have two hits. Which gives me an ambiguous match. And so you have to be explicit about it. The explicitness means you're going to guess wrong half the time. Or a third time depending on, or two thirds of the time depending on how many implementations you inherit. And it's called a diamond pattern inheritance. I got a common base, two derives, and for some bizarre reason I want those two derives to inherit on my third level. And there are variations in it. But that's the general idea. So you'll see as most languages today don't do MI that way because of the ambiguous match problem. Instead what you do to work around that ambiguous match is you'll define your interfaces. You will consume, if you have implementations that you want to consume and service up. They'll get those via encapsulation. And then your implementation will say oh when you're looking at me as an iFood. Take this particular implementation of bar and use it. So I may know I have two competing implementations. I'll explicitly say that when you're using me, you want the bar version, not the once.
Mike Hall
Interviewer, UGtastic
Does that make sense or do I need to run through? Makes sense more or less?
Guest
Guest
Okay, but it's one of the things where you get encapsulation being used more heavily. This language was built up during a time when they thought inheritance and is-a relationships were important. You know, here we are a little over 24 years after language came out. And we decided this industry that has-a is more interesting. Well, it's 8:30 right now.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
And then also I've done like- I've hit all the things I wanted to hit on my list. Kind of a high level question.
Mike Hall
Interviewer, UGtastic
Yeah. What kind of like work opportunities are there in this space these days?
Guest
Guest
I mean, about 25% of all jobs out there are C++.
Mike Hall
Interviewer, UGtastic
Well, what are they doing? I mean, they're not building websites obviously, right? Are they working on like things like Ruby is written in C++, right?
Guest
Guest
C. C, MRI is C and I think the core of Ruby is C++.
Mike Hall
Interviewer, UGtastic
Yeah. So, I mean, would you be working on projects like that?
Guest
Guest
You know, like kind of- Let's open source projects. Well, so downtown in the, say, five blocks surrounding the Chicago border trade, there are about 3,000 developers using C++ right now because you can't make push a trading system any faster than with this language. The language that runs with the GPUs is C++. They're C++. So, if you want to write to NVIDIA and use the GPU to distribute your load, it's C++. If you want to do microcontrollers or robotics, it's C++. Websites are fairly popular, but websites only consume a fraction of the CPUs that are ever purchased. Most of them are being driven by C and C++.
Mike Hall
Interviewer, UGtastic
So, just north of Milwaukee, Rockwell Engineering, which is- I think it's- Alan Bradley's now owned by Rockwell, right?
Guest
Guest
Or they're merged somehow. At any rate, those guys all use C++ very heavily. Cars use C++, so Detroit's got a heavy usage of it. As bad as the industry is there for auto workers, programmers are still doing okay. It's- I mean, it's used in a lot, a lot of places. If you want to work at a company like Google, they use C++ a lot. So, there's a website that uses C++. They have two languages they use a lot. It's- you need to know Java and C++ there, I thought. It's the Python music- it's- Python's heavy out of the Chicago office, but I don't think it's heavy- I heard that they're like going out of favor a little bit, so they've got a lot of it because they're going to move towards, like, Go or Dart or something. Yeah, and the reason behind the Python thing is it's probably just being practical. Well, they have Guido. They use it for stuff where you do scripts.
Mike Hall
Interviewer, UGtastic
Did they hire you from Vaughan Austin? Yeah.
Guest
Guest
Yeah, yeah.
Mike Hall
Interviewer, UGtastic
Really?
Guest
Guest
I heard there was some sort of, like, more of like a people- first people issue that I think it wasn't necessarily something the community had issues. I don't know. I've never heard about that now. Chicago's the largest Python community, and I've yet to meet a professional Python developer. I know a few.
Mike Hall
Interviewer, UGtastic
You do? Yeah.
Guest
Guest
They're up in Evanston. Leapfrog marketing here. Oh, okay. Yeah, yeah, yeah. The Django back as a startup now. Oh, yeah, so- Oh, yeah. There was publishing.
Mike Hall
Interviewer, UGtastic
Well, I thought Adrian's- Is Adrian still working in everyone?
Guest
Guest
Yep. Yeah, so there's some. I think- I haven't met Adrian before. A few of his guys. But C++ is just used in a lot of places. And the other thing is that, as you guys were pointing out, at the end of the day, if you want to dig really deep into how your technology is being built, eventually you're going to hit C++. Well, I thought I had heard, and maybe this was indirectly attributed to you, about that Microsoft was kind of a little on the fence with . NET, and that if you really want to work on the Microsoft platform going forward, you really, really need to learn C++ again. So there's a fun one. I've attributed it to me to know that. I think it was something that Sergio was talking about. And he had said something about . NET. So we're talking about WinRT. WinRT allows you to program in three different styles. Neither use . NET. So WinRT is the Windows Runtime. And what they did is they took a look at, they took a look at COM. COM was really interesting from the binary compatibility, the ability to expose things to many languages. And that point in time was revolutionary. It was also a huge pain to work with. So what they did is they looked at it, and originally . NET was actually supposed to become plus two or three, a better way of exposing things. And then they went down another path, and they've been going down that path for 10 years. While they've been going down that path, the Windows division has been looking at . NET, trying to figure out how do I import this thing that gives us a lot of productivity. And I'm not saying . NET is a big productivity boost. It's if you have a language that has an active development community that makes it easy to bring things in without thinking too hard.
Mike Hall
Interviewer, UGtastic
Ruby gems, way in that hand, right?
Guest
Guest
As a matter of fact, that's one of the reasons why I picked up Ruby is because the gems were very easy to use. And then I was going to use Perl with CPAN. Again, Perl became very easy to use because I wanted something. CPAN, grab it, get it, go. No thinking. Apps get on Linux. Again, very nice. I want to pull the library in. I don't want to think about only dependencies. I grabbed it. So one of the issues with COM was that you had to know what type of interfaces you need to implement. You need to know which libraries you need to bring in. You need to be an expert in C++ if you wanted to manipulate the IDL that was exposing your objects. I did VB programming where I actually wrote the middle files and import the library and implemented those interfaces so I could freeze a bunch of things and work around VB limitations. Because VB, high productivity language, really bad for versioning. Because every time you compile, you create that a new version. So to freeze that, you had to know how to read middle files. So what RT is doing is it figured out how do I take a bunch of, let's face it, they're COM objects. Take those COM objects, surface them up in a way that works a lot better than it did when they first invented COM for Excel back in the early 90s. And then what you do is you have a bunch, then how do you take a bunch of languages that are really popular and allow them to bind into those things that are being surfaced up. So C++ works well, . NET works well, JavaScript works well. So that's what they really do is they're trying to figure out how you take the COM stuff, expose capabilities, where are the interfaces I implement, which give you the charms. Some of the charms, if you've done the COM stuff, there are ones that I like to, I expose things to the clipboard, I can search. I can, you know, the different capabilities that you want to expose to the shell, you implement those interfaces, they bubble up through iQuery interface. They implement it for you under the covers, but let's face it, it's iQuery interface. There's iDispatcher, you know, iDispatcher as well, which allows you to dispatch to various functions so you can discover other bits. But that's what they're really doing is they've improved the COM quite a bit. So I don't think... So it's not really the . NET's on the way out, it's still a... Well, let's face it, if you have three million developers who know your run time, do you want to kick them out the door? No, it's just like... No, it's just, I just, I've taken what I heard in a grapevine, and... No, I mean, that's kind of realistic about it, but I just didn't... I had a guy at work tell me, show me an article saying C# is dead.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
Again, there's, most of the . NET programmers these days have dropped VB, 90 plus percent aren't C#. You're not going to kill their skill set. Well, they killed the VB skill set. And there's still, and a lot of those VB programmers aren't on the Microsoft platform anymore.
Mike Hall
Interviewer, UGtastic
Okay. Where are they?
Guest
Guest
Uh, PHP. They want to, they're like using a really bad language, and they're like, "I got to find another really bad language.
Mike Hall
Interviewer, UGtastic
" And what's the worst language out there?
Guest
Guest
Well, but the thing is, the nice thing about PHP is that it's the classic orientation that they got with VB4. It's active server pages, which they knew from the late 90s.
Mike Hall
Interviewer, UGtastic
Yeah. It's not that those are bad, those are technologies that work, right?
Guest
Guest
And these guys aren't interested in doing cutting edge. They're interested in continuing to get a paycheck doing something they like to do. So, speaking of languages, Michael, since this is my first time here, I don't know people. Like, I'd be real interested in knowing what everybody does, like what languages they use, how I've been using it.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
I mean, is that, I'm sorry to kind of ask. Well, if we want to do a real quick around the room, we can't stay too much longer, because it's a quarter or two, and I know you've got to lock up. So, but I'll go first, and then go that way. I'm Mike, I do Ruby and Rails, and now I'm having to do some Java, and I'm a former . NET developer, and I'm dabbling with Clojure. This is the year of Clojure for me. I'm going to learn Clojure this year. That's my goal.
Mike Hall
Interviewer, UGtastic
Where do you work?
Guest
Guest
Groupon. Groupon. So, Colin, I'm going to do Ruby at work in Clojure on the side.
Mike Hall
Interviewer, UGtastic
You're a Groupon guy too, right?
Guest
Guest
8th Light. I'm Justin. I think C was my second language. I don't select C++. It's been a few years now. It's been an hour technically going through. I think it's probably where he's got to go. I'm Brian, I'm a student. I know a bit of trauma as well. And then I'm pretty much, you know, just starting to learn. I'm Dave. I work here at Wallet. And that's what you guys have to do that. And Java, Ruby, learning JavaScript, CoffeeScript, that kind of stuff. Trying to get more into the browser site. We do a lot of the server site stuff.
Mike Hall
Interviewer, UGtastic
What is Wallet's like main platform? Do they do a lot of web apps and stuff?
Guest
Guest
We do web apps as well as an install-based software. It's a web-based management tool for schools to manage their libraries. That's our primary bread and butter product. We're getting into some of the products. E-book management, classroom management, stuff like that. But the library has been our main product for a long time. And that's a Java, J-box stack type of application. I started doing Ruby on Rails about five years ago. And before that I was a project manager at a great big insurance company. And I hated it. So I wanted to get back to programming so I learned Ruby. But I started out in A. I. in a language you've probably never heard of called A. I. , which is . My name is . I work for Zeebens. And I'm . I've seen more and more of it. Without programs, marketing is still working. So it's going to be an entry now. So I'm Ryan, and I used to work in Bali. And then I do mostly . I'm Zeebens. That's a Bulgarian name. I work for Zeebens. I'm Brian, but I have the only one for you. So my language of choice is JavaScript. That's right.
Mike Hall
Interviewer, UGtastic
The service is JavaScript, JavaScript, right? So what do you do artistic design and stuff, or?
Guest
Guest
I'm doing the coding. So I can run a . I think that's . No, I'm . HTML, . CSS3.
Mike Hall
Interviewer, UGtastic
Yeah.
Guest
Guest
.
Mike Hall
Interviewer, UGtastic
What do you do, Scott?
Guest
Guest
Scott, I-- let's see, first paying gig, I was doing data coding on autopilot. So if you ever fly a 777 and don't crash, thank me. I did-- I'm sorry, I was at a verification validation team for that. I learned more role assembly. I was there, too, as well as . I did SQL+ for a long time. I've done JavaScript, a bunch of other languages as well. Most recently, I'm doing C# work. But under my belt, last time I counted was like 55 languages that I used at one point or another. And that's-- so the fun thing there is that it's not that I know so many languages, it's that I can learn them really quick because there's only so many ways to write the form. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up. I can't call this up.
Mike Hall
Interviewer, UGtastic
Yeah.