YTread Logo
YTread Logo

Bjarne Stroustrup - The Essence of C++

May 01, 2020
and I would just like to say that we and Morgan Stanley have been overwhelmed by the amount of support and interest in tonight's event. First of all, I would like to say a huge thank you to bjn for taking his time over the next two. days um, you'll be presenting your conference to probably around 800 people between Glasgow and Edinburgh, which must make it one of the biggest tech events I can remember recently in Scotland um, it's fascinating to see the distribution of people in the audience that I have from everything from people who managed to find out about the event who are still at school to students at the Academy and I think there must be around 50 different Scottish tech companies with representation here, so first a bit of housekeeping for me?
bjarne stroustrup   the essence of c
Can everyone do something? Please make sure your mobile devices are on silent, there are no fire drills planned for tonight so if the fire alarm goes off, the exits are on each side at the front of the auditorium once we cross the street, we would love it. let everyone come and join us for a few drinks and a bit of networking, um, in the IT forum just across the square and again the fire doors, there's one on each wall and, except for disabled guests , come out. the back wall or the front entrance in terms of people, I would like to first thank my own team.
bjarne stroustrup   the essence of c

More Interesting Facts About,

bjarne stroustrup the essence of c...

I would like to say a huge thank you to Rebecca Hastings and Joe Froley who managed to put these events together in just a couple of weeks I would also like to thank Khaled Rafi and his team at Morgan Stanley in Scotland for all their support in making this happen and thank Professor Dave Robertson and the School of Computing at the University of Edinburgh also for their support after the event when Go for drinks and awnings, you'll see there's a pop-up there from the bites night which I'd like to take a minute to promote. It is the industry's annual charity event to raise money for Action for Children.
bjarne stroustrup   the essence of c
It's a sleeping party that we. we will do it in October in Hollywood Park, our aim is to have at least 200 um techs sleep outside this year and last year we raised over £100,000 in one night and it is to help prevent the causes of youth homelessness, so there are 500 people here tonight. If I can try to persuade even a fraction of you to go and talk to them and find out a little more, that would be fantastic, so without further ado, I'd like to welcome Phil Carter, one of the chief technology officers at Morgan. Stanley, hello, just checking, can you hear me.
bjarne stroustrup   the essence of c
Do I need to use the microphone? No, that's fine. So my name is Phil Carter. I'm, um, I work at Morgan Stanley, so I manage the stock trading systems, um, here. in Europe and focus a lot on derivatives technology and so on. I hope you saw every one of the 160 slides that appeared there while you were waiting for the conference to start, so I won't have much to tell you about what we do, but anyway I don't understand between you and Beyond to begin with. I also look forward to your lecture. I started my career largely working as a C programmer trying to convince my managers in At that time, the big Fortran Pro programmers not only moved on to see but moved on to C++ um and that was about 20 years ago and I managed to do it.
I'm pretty satisfied and that was one of my biggest um uh. achievements in life, I think anyway, I want to tell you a little bit about Morgan Stanley, who, you know, we're very privileged to have Bean with us and I thought I'd tell you a little bit about us. briefly, I think you know before I got into investment banking technology, I worked in the defense industry and I had no idea what those types of bean counters did, but so far I've been in that industry for 15 to 20 years ago. years, um, you know, the way I think about it more and more over these two decades is very, very simple, um, you know, if you think about, I think about companies like Google, which is essentially, in my opinion, a company of advertising where the technology is.
Really fundamental to that business. You could say that for many other companies, LinkedIn is really a recruiting agency and technology is essential. Well, more and more I see what we do as exactly the same thing and I think maybe the cynics would say. Well of course you say that, but you really know I can say that with my hand on my heart because we really couldn't run our business without it, we don't use technology to support our business, we run it because it's fundamental. to our business, and you know, one of the things that we are very proud of is that, for example, in the area that I work in, we are number one in stock trading in the world and here in Europe, and that is , you already know.
A big part of this is because we like to think that we build technology far superior to that of our competitors, which is why we spend a lot of time trying to attract the best talent we hire from around the world. We also try to do the best we can. to nurture the talent that we have and they include languages ​​like cc++ where we invest a lot in that but also other languages ​​um and the ban will kill me later, but you know other languages ​​like Java more recently Scola um and many many other things. So, you know, we've recently set up a new team building some of our most sophisticated platforms in Glasgow, so I've just been told that we've now hit the 100 mark, you know, so we've got 100 programmers in um.
We are in Glasgow working on these systems alongside three or four other key Development Centres. We have um in the world, including um uh, Budapest here in Europe and Asia, we have Shanghai and Montreal in the Americas, so you know, we really look. And I've personally been working with teams here in Scotland and Glasgow in particular for the last 15 years and I've never had any problems with big talent on the track, so I'm very happy with that. coming here with a great like Bean and, you know, being part of a conference like this, so I'm looking forward to sitting there and listening to the conference, so thank you very much and I hope you enjoy the conferences.
I'm sure I will, so welcome, and first of all, I'm not out killing people, and in fact, I don't think you can be a professional in the IT industry knowing only one language. If you really want to be in the field, you should learn at least two, preferably five, maybe a few more, but until today, of course, I'm going to talk about C C++ and I'm going to give it a try. see what's special, what's essential to C++ and I'm not trying to go in depth and write and give you a really advanced or deep technical talk.
I'm trying to convey some of the key ideas with a simple presentation like I can understand it and I'm going to use examples for a long time at scale because I think it's important for systems to live for a long time. Software tends to live much longer than hardware and people have this notion that you get a language right, the designer figures it out and it will all be there tomorrow. It doesn't take about 10 years from start to serious industrial use and then it takes more decades for everything to be finished, so that's what I'm going to do there.
Here are some images, they all have something to do with C++, except for a few that obviously have nothing to do with anything, they are just landscapes and they are for me to calm down, take a deep breath and remember that I am going to change. the topic, but the ones that seem to illustrate something probably have something to do with C++, which happens to be the large hon collider tunnel at CERN and one of the things I really like about programming languages ​​is that it's a perfect excuse to stick your nose into interesting projects in almost any field, so if you're interested in high energy physics and the structure of the universe, being a programmer is one of the best ways to get there, probably easier than becoming a programmer. in radical physics, okay, first I'm going to talk a little bit about what C++ is and what it's supposed to be and how we're getting there and then I'll go over some practical details.
I'm very interested in resource management, especially because I do systems programming and building complex systems where you have to deal with resources and deal with object-oriented programming class hierarchies, which I guess the most of you will have seen, then I'll go into a little more. of template programming generic programming with templates and then I'm going to point out that you know this is a real world language with real world problems we can do it even better um so um I listen to the discussions in in real in life and on the web, and it seems like I'm often the only one who doesn't have a firm opinion on what C++ is, um, here we see the blind men and the elephant, and if all you've seen is tail type, you have a firm idea of ​​what it's like the elephant, except it's only correct for the tail, so everything we see here is probably true for someone at some time and somewhere and if you think that's the whole story, I'm wrong and my problem is that in I actually know the Beast and it's a little harder to generalize what the Beast is when you have to take everything into account, so I'm trying to explain a little about the Beast here. about that elephant so let's go back and see what I would like what I would like when I started with C++ what I've learned over the years that I want uh type safety is a really important aspect and um when I started uh a c program no you could check the types of your function arguments, there were no function prototypes, there were no function declarations that specified the types and this was quite controversial at the time, people say, well, you know if you have a type declaration. then when I look at my call I don't know what it's doing because it depends on something I can't see, I'd rather have it as simple code, I just do something and I don't have to look anywhere else, okay?
So I've been trying to increase the type safety of the cc+ plus language family since day one and that's not so easy because it's under constraints of program size, program performance and resource safety. I really don't. I want to filter things out if you're writing code for, say, a spaceship, uh, you shouldn't run out of resources, the resources can be almost anything, but I think about things like the memory file handling the communication connections, uh , it blocks, uh, things like that, my performance. My business, in general, chosen by myself is to be able to, among other things, run as fast as possible, close to the hardware, some language has to be able to implement a memory manager and a virtual machine and things like that and C++ more. or less, by definition, that's the goal of predictability if you're in tough real time.
You really have to execute each trade in a predictable time, usually a constant low max time, and trades that can't do that simply aren't. allowed on airplanes after they take off. I'm not talking about the educa entertainment system, of course, I'm talking about the engine controls and things that have to do with the movement of the wings, and C++ roughly follows that rule, except for the use of dynamic memory free storage which is not allowed there anyway and you have to do something else, uh, teaching ability, it should really be possible to teach how to do this kind of thing, how to use something that you can't just assume that people will do it.
If you want to learn something, you should make it reasonably easy and the complexity of the code should be proportional to the complexity of the task you are performing. It's a very big statement, very difficult to make, it's ideal, it's something you can try to tackle and in different domains you can get closer than others, but it's definitely what I would like to see and I would like the code to be human and machine readable. again. Those of you who know C++ know that this is ideal because you can type. really ugly code in C++, in fact, you can write really ugly code in any language, but this is C++.
I'm concerned that it should be possible to write really nice, readable code and you can, um, and I want it for systems programming. embedded systems resource constrained systems and for large systems eh, that's the type of domain that interests me the most. um it's not optimized for writing simple web applications, for example, it's not intended to be the simplest programming language on Earth, it's supposed to be the simplest we can get for restricted real-world applications uh C++ is expert friendly , it is very friendly for experts. I uh Co, the phrase to point out that that's not enough if it's only friendly to experts and hostile to new users and newbies.
Casual users, we're not helping many people who could be helped, so it also has to be knowledge friendly, that's an important thing, and I'll show you some code that makes this statement plausible. C++ comes from two. traditions and programming languages ​​and quite consciously, so here is this line that is deliberately towards the lower end, this is close to the optimal exploitation of the hardware, it is very capable of manipulating anywhatever you have in the hardware and, um, and do it right. so we started with a simpler one, we got Languages ​​by bcpl and C uh C still exists um, this is dennise Richie and his genius was actually defining a hardware model that was somewhat general and could be used, I mean if you add something, use the add statement if you access memory are sequences of objects when you want to compose something from orother objects you simply place them next to each other, you stack things of the same type next to each other and you get arrays, you stack things of different types over others and you get structure uh, that's a very good memory model that has stood the test of time very well, however, this is some low level stuff, um, I don't really like programming with bits, addresses and stuff like that , we need something that is more suitable for humans and here we have sponsors who invented forine forine. a language designed for a very particular type of human engineers and scientists and was the first language that raised the level of programming from being machine focused to being problem focused.
It was the first language that was truly suitable for humans. and once that was done, we actually got portability, I mean, Trine was designed so that IBM could sell more machines and it turned out that after Trine you could take these programs and with fairly minor changes move them to, say, a UNC which was a main competitor at the time and I think it was an unintentional effect, but it was very good for us and raising things to a human level is a good idea, however, as I pointed out, scientists and engineers are very peculiar subspecies and um, like this. each time they had their own language, everyone else wanted one too cobalt, the most Pro being um uh prominent for business, but basically, pretty soon we had about a couple of hundred languages, the problem was that they couldn't talk to each other I mean, when you write something in Cobal you can do really good manipulation of records and files so that was what business people wanted.
You could add and subtract but anything more sophisticated than that wasn't very good for Tran. It was really good. Linear algebra for calculations could handle floating point numbers. Now what do I do if I, as a scientist, want to read some records, manipulate them and calculate the result? The approximate answer was: you're out of luck and, um, there were many solutions to this. but I think the big breakthrough was this, CH nugged the language simultaneously and said: why don't you let people build their own abstractions instead of building arrays and records and stuff like that? Why don't you just say give it to the people? the facilities of the language to build your own abstractions in the language, so if you want a vector, you build a vector, if you want a 3D Array, you build a 3D Array and if you have a record, you build a record, that's where the class is uh class uh the concept came along and they used class hierarchies to represent related concepts, some concepts are hierarchically oriented, not all of them and basically you have what are currently known as object-oriented programming languages ​​with classes and class hierarchies and, um , I found myself in a project.
A long time ago at Bell Labs, where I needed to manipulate the lower levels of hardware, WR memory managers wrote network drivers, but I also needed to build something that had a fairly high organizational complexity. I wanted to be able to say this here. it runs there this bit there it runs there no I changed my mind this bit here should move there was a distributed system languages ​​at the time that could do the heart uh close to hardware programming I couldn't tell what a bit was it was kind of It was a ball of code, there was no serious abstraction there, so I took the concept of the simulate class and built it in C and some of the terminology comes from simulate and then has been inherited by many other languages ​​and this happened. in 1980 and we've been dating for a while since we have a new standard there in 11 we're going to get a new one this year um it's all the technical work that's being done, it's going through voting procedures under the iso, so if you want explain what C++ is, it's from this idea of ​​taking C and taking simulations and, uh, putting them together, so we want a direct map from the Hardware between the inst instructions and the data types in C++ that initially come from C and we want zero abstraction or reading, the ability to take these things and wrap them in new types with data representation and the set of operations or interfaces defined and then implemented later initially from a simulation of one of the really key things that came very early in C++ development um, very early, like the third week or so.
Constructors and destructors because if you want to build your own abstractions and you want objects from them very often, the object needs to be initialized. and if it contains something that needs to be cleaned up, you have to call a Destroyer to do it, so a lot of that came here as the advancement in understanding and the amount of abst abstractions that we deal with. it could be done and basically a lot of the inspiration at the time came from operating systems. My background is in operating systems and microprogramming machine architecture and that explains a lot, good and bad.
And I've basically been wondering. This question, what does C++ want to be?, when?, when you grow up, and the answer is: you want to be better at it, that is the domain of C++. If you're in a different domain, you'll probably want different languages ​​and one thing that people point out. is that there are a lot of old C++ crons, it's like a ship that's been in C for a long time, has acquired barnacles and things like that and we'd all like to get rid of them, but we can't because supporting long term stability is a problem.
Feature people say we want all this cool new stuff, but we don't want you to break our code. This issue will probably be fixed in the future through code analysis and transformation. I hope we see more of that, but basically remember. um, uh, if you want C++ to be different and better, the next question is: can I crack your code? I think I know the answer, at least for people with large code bases, that's important compared to an amateur, so here's my version of Elephant is a language designed to basically build efficient and elegant abstractions in four areas like infrastructure. software applications with limited resources okay, so this is one of these images that are there to make me stop, take a deep breath, I think now comes a new topic which is resource management, how do we deal with resources?
Basically, a resource is something you have to acquire and then when you're done with it, you have to return it to where you got it. this can be explicit, it can be implicit, but in Le that is the definition of resource, the example is manage, it is memory, give me some memory, I have to give it back, otherwise we have a memory leak, it is an identifier of file, give me open the file. close the file get a lock acquire the lock release the lock open a socket connection close the socket connection things like that and uh we don't want leaks we really don't want the space probe We're left with nothing uh we don't want our, let's say Cell phones crash once a day because they run out of nothing but electricity.
We can't actually manage battery life this way, except of course if we run more efficiently. I will use less battery, but that is a different problem, and I usually mean that a resource must have an owner because otherwise it is very difficult to know who is responsible for returning the resources, the fact that there is no obvious representation of an owner in a language like C or C style C++ is the reason why these programs tend to leak. Let's say I make a shape to appear on the screen and I am appointed to that shape, who is responsible for removing the screen and removing the shape from the screen.
Again, is it the display manager or is it me? Then I give the indicated point to the form. Is it your job now or is it mine? That is a source of many problems in SE style programming that we must deal with. Basically the rule is that there must be an owner which is often an identifier like this that points to the actual resource, the actual object and basically the identifier must represent something meaningful, it could be a vector, it could be a pointer to something. It could be almost anything, so in the C++ standard, there are actually a lot of things that behave like this, you see all sorts of core data structures, vectors, strings, map hash tables and so on, they all follow this model, and so on as long as you have. one of these is a local object and it points to something that it manages on the side and when it exits, it goes out of scope, it cleans up its mess afterwards and it's not just, uh, memory threads, registering files, file streams and sharing pointers. are in this category, so this is all over the current C++ standard and they basically all look more or less like this.
Here is an abstraction that is a vector of T and therefore you can initialize it somehow. All the interesting classes have some way of initializing them in this case place, you can give it a list of Tes initializers and initializing a list of cheeses is kind of a list of things and braces, so here I say it if you want to make a vector. you have to give me a list of initializers, then it will make a list and render it somewhere, reserve some memory, put the list elements in that um Vector in that memory, keep track of how many things how many things it has how many elements you have that's the simplest thing you can do and now you can make a vector of doubles and initialize it a vector of strings and initialize it and the important thing here is that when they go out of scope everything becomes clear, note that this is not the management of simplest memory, at least the string vector, the strings are handled by themselves, so to clean that string vector, I have to tell the vector to clean itself and the vector has to tell all its strings to clean themselves alone and we could do more complicated things like that by having a vector of records with locks associated with them, things like that, but it's a very simple model anyway, you can create things and you clean up your mess when you're done, the cleanup is implicit, so here's kind of a classic example.
You find it in millions of line code bases and it's a bug. Let's see what's wrong here. I want a device and let's say I'm a Java programmer. or a C++ programmer who still thinks it's cool to write code like in the 90s. I make myself a gadget and I assign it to a pointer, the pointer I get and um, there's a lot of code like that, the point here is I didn't do it , I won't tell you what's on the device, but it could be all kinds of interesting things. Think you have a file handle, for example, you open a file or something, so here I make some code that might throw an exception.
I make something that could come back and then I delete things and all the good Java programmers will complain that having to write to delete that is a pain in the ass and we know that if you really have to write that code, you do it wrong. a good amount of time uh in fact my rule is days if I see something new I know I have to write somewhere therefore I will get it wrong therefore I shouldn't write the new but let's see, Uh, rubbish. The collector might be an idea, just remove this one and everything will work except we don't know what's inside the device.
It may contain things that need to be cleaned up, so we won't do that, so the naked pointer. It's also a problem if I throw an exception. I have leaked the gadget. If I return. I have leaked the gadget. Last 15 or 20 years in places we have a shared pointer. I'm here using a C++13 notation uh because it says: make me a gadget and return me a shared pointer. a shared pointer is kind of a simple garbage collection implementation, uh. The first garbage collectors were counterpointer things and several languages ​​call it garbage collection to this day. The point here is that if I throw an exception the destructor for that Shar pointer is triggered and cleans up the mess similarly if I return the mess is cleaned up. up top my code gets simpler there is no deletion down there every time we exit it cleans up fine Constructors and destructors handle this problem only one problem left is that I'm not going to share anything Gadget is mine it's all mine so why do I need to do it ? do things like a usage count to keep counting the number of users of the gadget.
I know the number of users, it's me, so we can simplify that, if you want, we can create a single pointer to a gadget and everything works simply. It is simple and economical. One of the problems with shared pointers is that they have to maintain a usage count. A usage count is a shared resource that is shared among all users of the pointer, so when we create more pointers to that shared object, the usage count. goes up one two 3 two when it reaches zero the last guy that comes out cleans things, cleans everything and we don't have any leaksfile handles and so on, but still, if there is nothing shared, I shouldn't introduce a share.
We are in a world where many forms of concurrency occur and anything shared costs more than you imagine, so this is better, but You know I own that Gadget, why am I dealing with suggestions? I should have just done it in the First of all, there is no need for any advice here, I just make my Gadget and the Gadget destructor is launched if we get out of here, we can get out of here, we can get out of here, we can get out of here, no it matters. The destroyer is called. cleanup or exceptions and that's good and basically we've gotten to the point where the code looks simpler and there are no hints, there are some behind the scenes but it's easy to write a pair of Constructor and Destructor that takes care of resources as well that this is good and this is known by the amazing phrase resource acquisition is initialization, which I consider proof that you shouldn't be in marketing and Basically, it just does what we said and turns out to be a good way to deal with a system that uses exceptions and exceptions are the best way to deal with error handling because it will give the right thing if things were to happen, especially when you have destructors to help you clean up local resources so we can write leak-free code and generally what you do is set an invariant in the Constructor and remove it if necessary in the destructor, and if you don't need a Destructor, well, don't write one now.
Where do we use pointers? We use them as references and iterators, so we don't use them to represent the property. We use them to refer to objects that are owned by someone. Each object must have a uh. an owner and this leaves a problem, this problem has been there for a long time in the C++ community, people tend to want to return a lot of things from a function to its caller, like doing something like making a shape, making an array of 100,000 elements . so you tend to use new to put it in the free store and then return a pointer and the moment you do that all the problems with pointers come back, you have to decide who is in charge of the object, is it the creator of? the pointer or is the user of the pointer and if I share the pointer, how do I know who I shared it with?
Basically, I can't solve those problems, so let's solve this like we've always been able to solve it. A lot of these things aren't new, a lot of these things aren't original, but now we have easier ways to do them and that's important, it makes it easier for the mythical average programmer to deal with, so let's consider where this image happens. , the idea that you do something big and need to pass it outside of a function, my examples with the device and such worked within a single scope, now we are talking about communication between scopes, so there are limits to what I can do with scopes and this happens with factory functions functions that make things and functions return a lot of object containers and things like that, so let's take a classic example, let's take an operator Also, in arrays, one array could be big, so I take two matrices and I'm supposed to return a Matrix mat that is the sum of the others, so make a new Matrix, fill it with the good stuff and return it now.
Matrix can have 100,000 by 100,000 doubles, so even in a modern architecture it can be noticed. You probably shouldn't copy it on the way back, so let's try returning a pointer which is actually not that bright of an idea. We have problems with the pointer, but it also looks ugly. I want to deal with arrays, not pointers to arrays, and no. I don't want to go around D referencing uh arrays to get the result and aside from that, how many of you caught the error before? Now I pointed out to you that there is a bug right there, this shouldn't compile into any decent program and it won't.
Anyway, people say they like references more than pointers, so let's try this, we pass references after all, passing by reference, that's good, let's try returning by reference now, this code looks good, except who removes the object, who, who, who says. remove the pointer, well, what a pointer, where is it. I have hidden the problem, that doesn't mean the problem went away. This will almost certainly leak even faster than the examples I've shown before. So people figured this out. saying okay, then an ad operation for M arrays, something that generates a large object, should take its arguments by reference and return its argument by reference.
Now you have to set a goal and then program against it. Now we are returning to simple code. I just lost 300 years of experience on how to write math and related stuff uh, I really don't like this working in places, a lot of this works like dealing with pointers directly, it works if you have enough time to deal with them. Yes your programs are quite simple, but often they are not, so we have to deal with that and the obvious thing is that if you are creating a new object, you have to return a new object.
The operation else says, "Make me a vector where the elements" are the sums of the elements of my arguments, so I have to return a um um an array. The problem is that the semantics of return are the semantics of copy. Sometimes compilers can figure out how to optimize that, but it's not guaranteed. Then what do we do? What we do here is we return 10 million items and it's painful, so we try to do tricks and these tricks are generally not general and they are complicated and fragile, that's not good, so what we have to do is something else and the key here. it's something we all learned when we were about 6 months old here's an object here now it's all here there's nothing there it's as simple as now only a computer scientist could have the idea that to get this there we make a copy put it there and then destroy the original, it just doesn't make sense, but that's what people have been doing more or less for a long time or they build some handle for it and move the L handle, leaving the original. instead or some other complicated things, we need to have something really simple and the really simple thing looks like this, okay, very naive.
I want an array that is a sum of elements that are the sum of the two things and then I return it. that code should work and we can make it work because we can just steal the rendering that I make. R is there, it's full of all kinds of good stuff. I want it there, so what I do is I take this poter and put it. there and make this point to nothing so that when the destructor comes and cleans up the mess, there's basically no mess to clean up and as I mentioned there have been compilers in the last 20 years that could do these kinds of tricks themselves because It was an optimized version, but here I don't rely on any optimization, so we are moving the array by making two word copies to copy the pointer and if the optimizer works, we can also get rid of that copy because well, that can be optimized.
Anyway, this is very cheap and the way the code is done is that we write what's called a move constructor. We have constructors that build things from basically arbitrary things. We have copy constructors that define what copy means. We have move destructors that define what move. means uh this notation here and the best C style is cryptic and uh uh that means a Move Constructor and basically copy the representation set the representation to nothing, this is it, now this code works and is efficient even if there are 10 million elements here so it's actually very simple and by the way you don't have to write all these constructors yourself if your representation knows how to copy and move the language will generate the constructors and destructors for you so if I define a matrix as a vector of doubles those are the elements and by the way the vector of doubles of course knows how many doubles it contains so I don't have to write more code because if you move a matrix you move its representation which is the element that knows how to move and it's done, this code here is efficient and leak-proof, exception-proof and dramatically simpler than some of the code we've seen in recent years.
Well, that's it, so here's my comment on garbage collection. garbage collection is not general nor ideal, it is not general because it only deals with memory and many of my resources are not memory and it is not ideal because it imposes a shared resource on the system, so some of the old Sun servers If you could have gotten them with 64 processors and a lot of times 63 of the processors are waiting for the 6 4th to pick up the garbage, we're better off today, a little bit better, but it's still fundamentally a shared resource in a distributed world where, uh, we, we.
Trading doesn't actually need to be enforced, so you may have heard of the notion of fake trading. There is an equivalent to garbage collection, so what do you do to keep your data in containers like Matrix, that vector, that map or that hash table? or something like that and manage it with ra AI uh the Constructor Destructor uh things I showed you use move Constructors so they are essentially free to move copy Constructors when you want to copy use smart pointers if you need pointer semantics, when do you do that? that says take the form example above if I want a pointer to the interface class form and I can handle pointers to circles and triangles and god knows what just use smart pointers if you are the only owner and just want to pass it on you can use your single pointer if you're using a shared pointer, if you're sharing this object so you don't know who's responsible for deleting it, you use a sharp pointer.
I mean, when would you need to share it? pointer, a classic example is that it passes some data to three or a dozen tasks running in parallel. Hopefully you have some locking mechanism or you've passed a pointer to constant and now the last of these threads is performing concurrent tasks. you're supposed to clean up and and and delete um the object was pointing to the shared object and shared pointers work great for that, but if all you do is look at the usage count, go to 1 2 1 Z, that's not the way optimal and that's the way they're mostly used in existing code, people use them to pass information from internal functions, uh, now, so if you still have leaks, usually for old code, you can do the which is called garbage collection, which is what you do very infrequently. run the garbage collector once a day because there isn't that much garbage so you don't have to run it all the time and there is a standard interface for those types of collectors and they actually work quite well if you have a lot of old code that can't be convert to modern style, so let me show you some modern C++ code that illustrates this.
Here I want to find all the elements in container C that have the value V. This is just a trivial example of course, so what I return I return a vector of pointers to the elements, the value type of a container is the type of elements and so the way I write this function is obviously to become a container to hold the things that match and then for all the C++ features here, there's Auto which says to find the type statically from the element, from its initialization ER, and obviously this is the element type of the container uh I passed things by reference here I don't want to have copies um and then I return by value and now I can write things like this where I had a little lamb uh for all the P all the pointers and that comes It's a little test program that just tests the sanity of this, but the point is that it may not look like the C++ that you're dealing with. used to.
In C++ 98 there is a major performance bug right there, but fortunately you can't write it in C++ 98 because I loaded it with some features from C++ 11. If I'm going to use the um move semantics, I'm definitely loading the program with some explicit features. so that it breaks if you try to compile it with a C++ um 98 compiler. I'd rather my code break than have a performance bug. uh, that you could get there, well, let's look at object-oriented programming. I'll be brief. here because everyone probably knows better than me, so here's the good old fashioned example, except I take a vector of unique pointers to shapes, so this is a classic example of where you want a polymorphic pointer.
I loaded the vector with a couple of objects that I create using make unique says: circle me and return me a unique pointer, okay, don't notice the absence of news, notice the absence of raw pointers which are just a representation of the address in memory and now I said I drew them all, I go through all of them and call to draw. I'll come back to drawable sequences later, um, so it's pretty simple and it's the classic object-oriented example, except this one here is pretty short and doesn't filter at all um, of course, one shape looks like this. has done for a long time.
I borrowed the word virtual fromthe similar guys who invented the mechanism and I B, just like I borrowed the word um kind from them, um, why not? called good type, it was simultaneous, it was invented by mathematicians and it seemed natural to them um and then the only thing new here is that you can be explicit about overwriting, you mean there must be a tie with this type, no argument return needed. override in the base class so I can override or check a little bit, it's just a nice little refinement that some people like, you don't have to do it if you don't like it, the benefit protection model is public and private.
Be careful with the protection, it will cause errors if you use it for data. There are people who think it's really cool because it allows anyone to mess with my data. Sorry, there's usually a different explanation, but that's what opens it up. the representation will be modified later, which makes it very difficult to have an invariant, so this one is only for functions. We have multiple inheritance, of course, all languages ​​that provide a static interface only provide interface inheritance. We have implementation. inheritance we can also discuss that if you want, but interf, we need at least interface inheritance, inheritance or abstract classes, that class is abstract does not have a complete implementation, there is a minimum identification of the runtime type, we have not gone into the type of world of serious thought, okay, object-oriented programming inheritance is great when you have hierarchical concepts in your domain, that's why it is like that.
Well with the shape example because obviously a smiley face is a circle which is a shape or something, you can get into trouble even then, but basically it's, if you have a domain where you have hierarchical relationships, it works well, the indirect function. The so-called virtual functions are quite cheap. Recent measurements have told me that this figure is too high. That is, it is closer to zero than before. If you call it multiple times, the branch predictors have improved dramatically. I'm actually being pessimistic here, but the main problem is that it doesn't align well if the operation you want to stream is something really simple that doesn't align and in high performance, uh, that's important and anyway. you tend to use assignment, deallocation, etc., this is pretty good, although you get more coupling between programs.
Parts, you can mitigate it by having better interfaces, abstract based classes, but basically inheritance is overused and seriously and systematically, there are people who think. good programming means object oriented programming and object oriented programming means using huge hierarchies certainly the first part of that statement is wrong, there is a lot of good code that is not object oriented and there is a lot of lousy code that is object oriented by that definition um, okay. With that said, I move on to the next thing, which is generic programming that has been very popular and successful in the last 10 or 15 years, so let's look at that.
I would like to point out that the first article I wrote on C classes, c++ and its predecessor, included generic programming and I explained why I really wanted a vector of T where T was a parameter and I really wanted operations on vectors of T that had t as parameter, I mean, if I have a vector of T's I want to sort a vector of T's I don't want to arbitrarily fix it for the operation, so I wanted that and I blindly wrote that you could do that with macros that don't scale, it's a terrible solution in 87 I approximately decided that we needed something better, we needed something extremely general and flexible.
I never trusted science that could only do what I imagined and I want zero overhead because I wanted to put C arrays out of business if I could. Array C is my least favorite data structure is the ideal structure for accessing memory directly, but most of the time that is not what we want. CR arrays have a tendency to lose their size. I mean, with the slightest excuse, an array becomes a pointer to one. or more elements actually become a point, yes that's what it does, one or more elements, except other pointers can refer to zero or more elements.
This is the source of a lot of problems, so I basically wanted to compete with that because I wanted to. data structures that didn't become pointers to begin with and remembered their size and then you wanted well-specified interfaces. I pointed out one of the first things I did with C++ with C when I built C++ was correct, better HP check, obviously I wanted the interface to check this and I looked at it and at the time no one knew how to do those three and I couldn't figure out how to do them given the limitations of My general problem.
I had to choose the two first and you I know two out of three isn't bad, but it doesn't feel right, it doesn't feel right, so I've been trying to figure that out ever since and I actually have a solution that I'm going to show you. I'll go into it without much detail, but first let's see how the templates have worked so far. You can write it yourself, you can parameterize a type, then you can parameterize an algorithm with a type and most of the time you have to be explicit about it. the uh type of a type, sorry, the parameter of a type, it doesn't have to be for a um, for a use of that type, it just deduces what T is if that V happens to be a vector of integers, obviously, the T that parameterize sort can be implicit and it will be some kind of integers if it is a vector of strings it will be a ve will sort the strings okay um what you can do here is anything you can call it compile time dock write in dock write is a general principle that if it walks like a spring and quacks it's a spring, in other words you just use the type argument and if it worked it worked and if it didn't work you will get an error message, the only good thing.
The thing about the error messages you receive is that they appear at compile or link time before the program is shipped to a client. The bad news is that these error messages can be spectacularly bad. My best example recently was that I had a seven line program that I used a small parameterized class and I was using Sig win on a Windows machine and I never found out what the first pages of the error messages were because they messed up my Windows buffer, the window of wind, um, so I tried another compiler and got the same result, except the error messages were totally different and had nothing to do with the code I wrote, which was somehow obvious, so we should really deal with it of this, so I'll try it first of all.
Look, we need what we've discovered is that people write compiled programs and they have very good reasons for it, mainly performance, but also to express things as directly as possible, why delay until runtime what you can do at compile time so you can get your errors and stuff like that, so people have been doing this and like any new feature that's cool, powerful, expressive, efficient, it's overused and there's been serious overuse In particular, people write template metaprogramming to calculate values. C++11 gives you the ability to write functions that run at compile time and take care of some of the worst template abuse.
I'll talk about other ways to improve that in a second, but first I'll show them to those of you who haven't seen it. Both C++ as you see the code we can parameterize data types with integers and we can parameterize algorithms with that so I can sort the vector of integers here and I can find my hometown in a list of um of uh strings and the usual way that We try returning an error is to return the end if I'm looking for something in a list and I found the end instead of what I was looking for, that's how it is, so I can write code like this, we parameterize an element type and a type of container.
You could also search the vector of integers, so it's generic code and that's part of the appeal of this. We can also parameterize criteria action algorithms. here I want to find something that is not actually equal to something but has a property here we write uh a predicate is less than Griffin and its strings, so that is meaningful uh and basically that is done by doing what is known as a function object, you write a little class that can maintain state for you to use in your operation and when you can build it, of course, all as Constructors and there is an application operator that is invoked to call it and it will do it. something in this case is compared to S and of course there is a destructor here to clean up that string that we gave it, it has to go away so you can write code like this once you have less than and these people find it a bit strange.
It's a pain to write all that, it's five lines, but sometimes that's too much for people, so you can use what's called a Lambda expression which basically writes the code for you, so now we can compare using compare strings compare with Griffin, um, a lot. Languages ​​have these these days, okay this is the code you write to implement this, if you think C code is beautiful this is beautiful, if you don't think so this is what you have anyway and it models very up close what it is. it's done on the machine so it generates some pretty cool code, whether it's a list, a vector, a u c array or something like that, so this is the way the code is done and if you get tired of writing those sequences, like where Where did you have a sequence?
Yes, from the beginning to the end, that's how it is expressed. And that's the most general way because now you can order a half sequence or a quarter sequence and things like that, it composes very well, but it's a pain because the most common case is to do a full sequence, so you can do this. Sort the sequence using the predicate p and then I just say use the standard source from the beginning to the end using p is a predicate so you can easily. write a simpler form of code so your code will be reduced, it will still run at exactly the same speed, so those of you who are used to C++ will know that this is simple code, so it is not a problem, but basically we are working on it.
The third part of template definition, how do we specify the interface of a template? How do we specify the requirements that a template has on its arguments and how do we do this? We are saying that writing documents is simply not enough. we want to set the intent, in other words we want to specify the requirements of a template in its arguments and basically the programmer always knows what I mean, he can't work on the code that is templated unless he has a good idea of ​​what requirements exist. What is this? What is the template that is supposed to do the actual template argument for you?
I mean, if I have an array of numbers, I want numbers. If I have a vector of elements, they must have the property of an element. it can be copied, you can take its address and things like that, the number is something that you can add or multiply or something like that so you already know, there just hasn't been a way to say it, so what we can say here in a container to sort I want the container of type C to be sortable and what is sortable is a predicate, it is a predicate that you apply, it is true or false for a given type.
I apply sortable to a vector and it will say something like H, does X have random? just something you can do random if you look it up It's three lines of code that say in the code exactly what I do and today I actually write code in C++ 11. I put a comment in there and just use it as my shorthand for writing good requirements. I have a set of concepts. so I can provide the specification in a concise way and in C++14 the concepts that come there will be code, so we can also have some notation here.
If I want a sortable type, it means I want to I can write that it's a sortable S type that you're sorting, which means there has to be a type that's sortable and I pass it so it's just a short description and you can also use it for lambdas. I can say I want Lambda. that works for C sortable, then the C container, so everything works and now let's see how it works. I have the sortable container template here. Okay, it's not the densest notation we have, but it's pretty. There should be a type that is sortable and that is the type of my container.
I make myself a vector of doubles. I make a list of integers. I order the vector. Everything's fine. What happens here is that it says hm is Vector of a double container. Yes, I can have a random container. uh it has random access it has one element type I can compare okay sort the list it's a random access uh iterator no it's not you just have uh uh you can only search in a list you can't access the nth element directly so the actual error message that appears here list of integers does not satisfy thesortable constraint, so those of you who have suffered through template definitions for the last 15 years, sorry, I didn't know how to do it, so now Do it, there is an implementation of this stuff, it's a branch of GCC, look for Concepts Andrew S and you can find it and try to play with it.
If you change, if you activate one of the build changes, it will tell you why list. of in does not satisfy sortable and it will come back and say uh list of in cannot be sorted because it doesn't have a subscript operator which is simple uh, if you get additional information it will be about four lines instead of pages and Add, yeah, that's what that I said, so let's go back to something that seems obvious, but is certainly not what has been obvious in C C++ and many other communities for a long time. Generic programming is just programming.
There people develop strange theories and complicated theories. about how you write templates and you use a different type of logic when you write template programming and people make up very complicated ways to do it, but let's look at some code, here's a square root function like the one we learned on the first day of our programming um, uh, when we learned programming well, we can give it something that can be used as a double as an integer and everything is fine and the function is called Tak and it returns you the square root of um of X and um assuming you know what is a square root you don't have to look into the implementation it's just called if you give a square root of something that is not a double it can't be converted to a double like the address of a double you get an error message saying square root once a double now let's try that with a container we take a container we give it to the container and it says everything is fine because a string vector is a container and it is sortable and whatever works, give it something that is not a vector, says no, um guy wants a vector and the direction of a vector is not a vector, so we can go back to a world where the code actually looks very similar, whether generic. or not, and I don't think we have to learn significantly new concepts.
We just have to go back to what we learned on the first day of our programming course. Writing the templates is a little more difficult, but not much more. and it's significantly easier than it is today. This allows me to get into one of my favorite rats, which is that the distinction between these so-called paradigms is more or less a function of the language features that people had available and that people have. Great discussions about whether you should do conventional marine-style programming, whether you use object-oriented programming by putting things in hierarchies or whether you should parameterize and use generic programming, um, I think this is a function of uh, of, uh, of, uh , poor language support, and um, the discussions. do harm, so here's the classic um example of an object-oriented programming written in a slightly different style, so I'm drawing all the containers for which the value type is form and I do it by calling the algorithm for each uh for the container using the Lambda that draws the shapes um my point here is not that it may not be your ideal drawing, but it's pretty good.
In fact, I can do a little better, but this is to make the point, obviously, this is object-oriented code. doing runtime polymorphism in a hierarchy of shape classes, um, is it generic code? a for each algorithm in a container using Lambda, we are certainly borrowing styles from the world of functional programming, where they have been very useful, so do me a favor, don't get into languages, wars or paradigms, I think the word paradigm. It was seriously misdefined by Kon when he first came, he came with that, it was this idea that there is one paradigm, then you get another paradigm, the first one becomes totally useless, it shouldn't be used anymore, the old one should die and the world .
It would be much better for it, he used Newton's world and Einstein's world as an example, but you know we still live in Newton's world most of the time and most of the calculations defined by Newton still work. Yes, you need Einstein's gravitational logic to deal with that. high precision GPS, but that's very rare similarly, uh CHR Nugo, who invented object-oriented programming. He had the same kind of attitude towards Paradigm. He used to talk about the old days that we had more and less and that's what we had and then someone. I invented multiplication and division, now this is a new paradigm, so clearly you have to get rid of the old paradigm, no more plus and minus, that's out of fashion and you can write whatever you want with um with um with multiply and divide good.
I wonder how people manage it. negative numbers in that world, but other than that I think it's absurd, the old ways are sometimes still just absorbed in the new things and we can do more and we can do better, so that's it, so the challenges, basically , I am not claiming that it is C++. This is perfect, we have to see what we can do to improve it. We need to get programmers to prefer modern code for the kinds of applications, the kinds of things that C++ is good at, so I want code like the one I showed you. to be used near hardware high performance code because it works and performs better than the old code, the single pointer runs exactly as fast, so the last cycle that well written code with a proper raw pointer eliminates the sorting algorithm here eliminates a CQ CQ sorted by factors, not by percentage, so you can afford it, but we have to convince people to do it and then we have to make C++ a better language under the constraints that it still has to be the best language for, uh, really. low-level code and abstraction above, that's the goal and uh, we, uh, that's to improve and we have compatibility, performance, portability, range of application areas, we can't improve the language by simply making it a domain-specific language that again it would violate some of the basic rules and there is more information there is a new website more or less new isoc cp.org website that will offer you access to a variety of information, including about the standards and things etc. floating around there are some books and a website of I am especially proud of this little book tour on C++, it explains everything C plus plus and 180 pages.
Of course, I have to leave out some details. It's at a reasonably high level, but there's a ton of code, etc. that's the 180 page version, that's what you can read on a long train or plane ride and the rest is details, well there's uh, let's look at 1300 pages of details in that book, the same amount of details, even more details in 1300 pages in The Standard and that is encrypted in standard D is to prevent you from reading it. um. I didn't make up the rules for the ISO standards, but they can be pretty disgusting, but if you want to know everything about C++, look up wg21, which is the official name of the standards. committee, I told you that the standard e encrypts everything, including the name of the standards committee, uh, and you can find the booth, you can find the document of each committee, it's public and it's available and then basically I'll switch to questions and answers , thank you, so I am.
I'm sure after that masterclass there will be only one or two questions, it can be anything from a technical question or something broader, more general, about thread experiences in general, so if I can tell you and we have a couple of mobile microphones, we will contact you as quickly as possible if you can show up and respond to ER. Your question. One of the things that put C++ on the side of the elephant was buffer overflow, and in the wake of the bleeding heart, I saw a tweet. going around saying that every security bug you've ever faced was Dennis Richie's fault, so what I mean is do you want to claim some credit and what do you think is the way to go to avoid things like Heart Blade , Yeah come on.
Put it this way, we shouldn't be rude to Dennis Richie, he was the guy who more than anyone raised the level of programming from simple code to higher level notation and for that he deserves a lot of credit and if we have to do it Blame someone , they should be the people who still write code like Dennis Richie did in 1973. Now I haven't had a bug stream in a long time and the reason is that I only really use the cras, uh, directly if I'm making a hardware. uh, the operating system loads and stores everything else.
I use a vector and I have the size right there. If I write a loop, the easiest way to write the code is to ask for the size and use it, and for that reason buffer overflows don't happen. it actually happens in my code and if people used vectors and containers and things like that, that would be very common, it's something similar that I could have put in memory, I mean SEC for or something on that list, and again, it just doesn't happen unless you're using pointers in a pretty silly way and again you don't have to do that anymore, you use the containers that have access operations, you use the smart pointers so that they actually point to something instead of nothing and therefore these problems generally went away .
It's probably not good enough for some people's tastes, but it's better than the C model here. I know that Intel processors will at least come with Hardware Support for Range Checking, I think it will be announced next year and I hope that the C++ compilers will take what is currently undefined, which is accessed outside of the array, and do it. hardware apply it to be dirty, there's a uh, you can, you can do that and I'd like to build a completely secure system around this at the runtime speeds that we have. I think it can be done as long as you provide a loophole when accessing hardware and OS resources. directly and and basically declaring that some of the code is trusted and beyond that, it can be completely C-safe.
I haven't done that yet, so it hasn't been tested, but for me personally that problem goes back several years in the past and I might be in yours too if you can move to the modern world, Eric, so the better it will be at University, it seems like one of the hardest things about C++ is the accessibility of large projects for new developers, so if you are a new developer approaching a project. with a lot of metaprogramming with templates inherited from classes, templates inherited, etc., it is very difficult to determine the flow of execution through the program and the way data moves through the program, so the first question, does it also do you think this is a problem and second question, do you have any ideas to help new developers getting into a project?
Yes, C++ is obviously overly complex and has all these Barnacles of its history and if you get a project where people have gone Hog Wild with templates or on class hierarchies or on using CP pointers, you've got a major problem on your hands. You can write bad code in many languages ​​and then in C+ Plus+, you can even do it in many different ways. I think there is a major problem in education. where many teachers insist on teaching you the bad ways of doing things first and many of them never get to the good ones because after all they had to suffer to learn C, so why shouldn't you?
It probably builds character, so I think part of it is an education system, the problem of education and I'm trying to address that with some of the books that I showed, part of it is the fact that if you're attacking a codebase of a million lines, eh, it will have been written for years. It's going to have different styles, um, we need better tools to update it and understand it, it's actually coming, especially in the clang world, where you can do it, where they have pretty good static analyzers. Coar has been doing it for a while, but a lot of people. don't use them because it costs money, they'd rather waste their own time and money than pay others to solve problems um and uh, there's a lot more coming out of clang later this year.
I know, so I have some hope that static analysis will work. help you and that, um, that static code transformation will become common to simplify the code now for the specific problem of our template metaprogramming. I've been encouraging people all the time to not make things as complicated as they can. There's an old saying if you're writing code as complicated as you can handle, you can't maintain it because you just did the best you could and now you have to find the bug, so I guess if you really have truly horrendous templating metaprogramming, you should probably back off. and with Concepts you can eliminate some template metaprograms just by writing them simpler and using Conex functions you can eliminate essentially every template metaprogram that generates a value by writing ordinary code, so yeah, I think there's another question somewhere up here , Hello. uh my name is Dan um I work at Neo uh my question is about compile times, one of the things I've heard people say they suffer from, but with c and C++ they arequite long compile times and I think one of the things that was cited as a possible reason why was repeated re-reading of headers, things like that, so I was wondering if you can see if there's anything you think could be done in terms of of language design rather than improvements rather than just compiler optimization. might improve the situation um, that's a very complicated question that we've been trying to deal with for years um, there are languages ​​that are even slower to compile, but I'll be polite and not mention them uh, on the other hand, we all suffer from long build times and there is actually work being done to do this with a fairly simple module system implemented so that you don't do repeated builds of the same header file, I mean if you include the same header file in 100 source files you can compile it 100 times and there are people who do much worse than that.
It is being developed mainly at Apple and Google. It is in use for C Objective C and C++. I hope to hear a lot more about this very soon. There is a study group on the standards committee called modules where you can go and see what they have. They are not very good at publishing early, but there are documents that describe it. I hope to see at least initial beta versions widely. available next year, the two organizations I mentioned are not the only ones that are interested and they are not the only ones working on it, so it won't be resolved for C++14, but I hope it will be resolved with C++17 and be available in major compilers, notably clang um much earlier.
Maybe you have some statistics or know the trends of programmers moving from older standards to C++11 or maybe the newer one? How eager they are to do it because I feel it. like C++11, it's been here for a few years now and I haven't read much of the code written in that standard. I only read some code from older standards. One of the problems I listed in the challenges is getting people to upgrade and for them to understand it and there are many organizations that have codebases that should be compiled by old compilers and therefore cannot move forward, this is very sad and we have To do something about it, I think what we need to do is point out that newer coding styles are safer and actually generate code faster and then we need to back up this observation with code analysis and code transformation. code to rejuvenate the code or modernize the code whatever you want to call it. actually there is a lot of C++ code out there, there is even shipping C++14 code in products, mainly in organizations that have a control of their codebase, that is, they have a unified codebase, they have a unified registration procedure that is supposed to be fragmented across many users. groups and then you will find that code like Google's is much more modern than it gives the impression that the adoption of C++ 11 has been significantly faster than the adoption of C++ 98, although the problem moving forward is obviously elderly.
Now, because there are more older compilers and more code, I mean, we're talking billions of lines of code here, I'm sure you could go your entire working life without ever leaving some of the older styles, of Similarly, you could spend your entire working life. working life from now on I will never see any of the old stuff um it is a huge community hello Vladimir University of Edinburgh my question is the following um the old C is quite good at maintaining binary compatibility with various modules however in C++ that is a a little more challenging and Modules compiled with different compilers require a little more work to make them work together.
Do you think the current situation is good or does it need some improvement? It would be really nice if you could mix and match compiled code with any compiler from any version of C++, uh you can't, uh, the origin of this problem is that all the vendors in the 80s and early 90s thought they were going to dominate the world and everyone would agree to use their link standards and their object format, and all the providers, uh. They tried to improve their link formats and compilers and therefore could not agree on a standard. There was an attempt to adopt itanium ABI in some cases.
There is some hope for a better link for 64-bit architectures, but. It's a real problem. Think about it this way. If you are a compiler vendor with, say, a billion lines of user code from your customers, what is going to be compatible with other compiler types or with the compiler you last shipped? year, as far as I can see, all vendors, whether open source or not, choose to keep compatibility with their previous compiler as much as possible and when they break compatibility they don't really quickly move to something that is compatible with another stuff. They put in some new optimizations that suit them better, so it's a problem.
C compatibility is almost a historical accident because there were compilers that were popular on different platforms and people imitated them with C++ when they put out a C++ compiler, they competed. I've seen examples where a compiler takes all the implementation-defined things and does this to them and the next one comes up, looks at the list and does exactly the opposite in almost every case. The link is not standardized, it is not standardized for C. it is not standardized for C++, it is a real problem and it is a pain and I don't know what to do about it.
Hello, my name is Andrew. I work at Skyscanner. You talked about Barnacles in C++ to maintain backwards compatibility. Have you ever considered writing a completely new language from scratch using concepts that you want in C++ but may not necessarily be able to include? And if you did, do you think you'd end up with Java in part two? From that question it's very easy to answer no, I wouldn't build something that looks like Java anyway, since it emphasizes object-oriented programming and hierarchies and uses a garbage collector and uses virtual memory, it's in the way of all. I like a systems programming language.
It probably meets your own design criteria very well. C++ also does not meet Java's criteria. Now, of course, I've dreamed of building a new programming language with nicer syntax. Nicer semantics. properties, etc, etc, etc. My first assumption is that unless you can integrate it into the C++ community and infrastructure it would fail very quickly, so it's not an easy thing to do and it's not the only one. I'm not the only one who has wanted to do it. do something like that, but hello, very difficult question from the top on your right, sorry, just one question, we see more, yes, we see more system languages ​​on the hardware definition side.
Well, we see hardware definition languages ​​trying to go up to the system level. Obviously, C++ is operating close to the metal. Do you see C++ moving down towards hardware definition languages, or do you think you see hardware definition languages ​​moving towards C++? True, but I think C+ plus is a pretty nice hardware definition language, especially if you use templates fairly sparingly, that way you can write things that well anyway. I won't go beyond that. I do not do it. I know enough to be sure, okay, yeah, I had another question about Barnacles, so of the 1300 pages in the C++ spec, how many pages would you say are barnacles and which are hard?
Let me point out by the way that 1300 pages is also the size of the C spec and the Java spec plus 5% so it's not specific to C++ uh Barnacles um there are some really weird side effects to see uh and places um I certainly I'd like to know the rules for uh, let's say conversions shouldn't go both ways, I mean, it's okay to assign a character to a long, it's really okay to assign a long to a Char, although in real code, obviously, people do it. has been tested, so most of the time there is no problem in existing code. but the type system gets seriously complicated with that kind of thing, similarly, um, actually I don't know, it's nice to have a data type, you can do bit operations somehow, but why should it be duplicated like an integer? as arrays to deal with the lowest level of hardware.
I don't know how to write a systems programming language that doesn't have something like an array, but why should it be allowed to forget its size and why should it be converted to a pointer? of potentially another type when you're getting into class hierarchies, no, so these are the worst words, then there are some syntax audits, etc., but don't let me go through a whole list of these things because 'There we find out that we've been , I mean C++, considering that C is over 40 years old, so some Barnacles are to be expected and we have tried many times to get rid of them.
Deprecated functions, uh, options to not do things. It doesn't work for the community when given the choice between getting rid of old, dangerous features and not breaking their code. Choose not to decipher their codes. If you get an Oracle C++ compiler, it will come with a negative arm option that says to follow the rules in my draft document. For starting the confrontation process since 1988, a lot has happened since then, but they have not been able to remove that feature because they have paying customers who insist on it, but if you could ask, maybe we could all show our appreciation and thanks.
Thank you very much for the effort and amount of time you have dedicated to this production thanks to the University of Edinburgh.

If you have any copyright issue, please Contact