And I'd just like to say that we and
Morgan Stanley been overwhelmed by
the moment of support and
interest in this evenings event.
I'd like to firstly give a huge thanks
to Bjarne for giving up his time
over the course of the next 2 days he's
going to be presenting his lecture
to probably close to 800 people
between Glasgow and Edinburgh which
must make it one of the biggest tech events I can remember recently in Scotland.
It's fascinating to see the spirit of
people in the audience with everything
from people who have managed to find
about the event who are still at school
through academia, students, and
I think there must be about
50 different Scottish technology
companies with representation here
so a bit of housekeeping for me 1st off
could have to make sure that their mobile
devices are on silent there aren't any
fire drills planned for this evening so
if the fire alarm goes off the exits are
each side at the front of the auditorium
once we go across the road we love you
all to come across and join us for
some drinks nibbles at a bit of networking
across in the informatics forum
right across the other side of the square
and again the fire doors there's one on
each wall there, but for any disabled
guests either go out the back wall or front entrance.
In terms of people i'd like to thank, firstly my own team I'd like to say a massive thanks to Rebecca Hastings and Joe Frolly
who've managed to pull together these events in just a couple of weeks.
I'd also like to thank Kalid Rafiq and his team from Morgan Stanley in Scotland for
all their support in making this this
happen and thank Professor Dave Robertson
and the Edinburgh University School of
Informatics as well for their support.
After the event when we go across for the
drinks a can of peas you'll see that there
is a pop up there from Beit
night which I'd like to take one
minutes promote it's the i.t. industry's
annual charity event series money for
Action for Children it's a sleep that
we do in a tool bar in Holyrood Park
we're aiming to get at least $200.00
technologists to sleep this year and
last year we raised over 100 days
of payments in one night and
it's to help prevent the causes
of youth homelessness So there's
500 people here tonight if I can try and
persuade even a fraction of you to go and
speak to them and
find a bit more that would be fantastic So
without further ado I'd
like to welcome Phil Carter
who's one of the managing directors for
technology at Morgan Stanley.
Was.
Just checking you can hear me too I
need to use the mike now that's good.
So my name is Phil culture
on I work in Stanley.
So I run the equity trading systems.
Here in Europe and focus a lot on
derivatives technology and so on and so
forth I hope that you watch
every single slide out of
the 160 slides that went up the most
you're waiting for the lecture to stop
won't have to tell you much about what we
do but and what the are going to stand
between you on the ongoing started I'm
looking forward to his lecture to.
I started my career very
much working as a c.
programmer trying to convince my
managers at the time were big for
turn pro programmers not
only to move to see but
to move to see postbox and
I was about 20 years ago and
I've succeeded in doing that I'm quite
pleased and I was among one of my biggest.
Achievements in life I think.
Anyway the to tell you a little
bit about Morgan Stanley who.
Now we have the great privilege of
having beyond to join as our so
I'll just tell you a little bit about
the just briefly I think you know before
I got into investment banking technology
I worked in the defense industry and
I didn't have a clue what those
kind of being counters that.
But now been in that industry for
15 to 20 years now the you know
the way I think of it more and
more over that 2 decades is it is
very very simple if you think and
I think of the firms like Google which
is essentially in my view an advertising
company where the technology is
really fundamental to that business.
You could say that for many many other
firms linked in really a recruiting agency
with technology being fundamental.
Oh well more and more I see what we do
as being they exactly the same thing and
I think you know maybe the cynics will
say well of course you'd say that.
Really you know I can say that
with my hand or my heart because
we really couldn't run our business
without it we don't run technology
to support our business we run it because
it's fundamental to our business.
And you know one of the things
we're very proud of is that.
In for example the area that I work
in we're number one in equity trading
in the world and
here in Europe and that is.
You know a big part of that is
because we like to think we build.
Superior technology than our
competitors so we spend a lot of time
trying to attract the best talent that
we can track to around the world.
We also try to do the best we can to
nurture the talent that we have and
they include languages such as c c plus
plus where we invest heavily in that but
also now the languages and
beyond will kill me afterwards but
you know other languages like
jobs more recently sculler.
And many many other things so
you know we've recently
built a new team building some of our most
sophisticated platforms in Glasgow so
we just I was just told we we've
now hit the 100 mark you know so
we have 100 programmers pin up in Glasgow
working on these systems alongside 3 or
4 other key development centers
we have in the world including
Budapest here in Europe and
in Asia we have Shanghai and
Montreal in the Americas so we really look
for 9 personally and I've been working.
With with teams here in Scotland
during Glasgow in particular for
the last 15 years and I have never had
any problem attracting great talent so
with that I am very
pleased to come here with.
Great like be on and you know be part
of a lecture like this I'm looking
forward to sitting down there and.
Listening to the lecture so thank you very
much and hope you enjoy the lecture as I'm
sure our art was.
So welcome.
And 1st of all I don't go
around killing people.
And as a matter of fact I don't
think you can be a professional
in the computing industry
knowing just one in language so
all if you actually want to be in
the field you should through should learn.
To preferably 5 maybe a few more.
But today I will of course talk about
the pros plus and I'm going to try and
see what's sort of special what's
essential to see plus plus and
I'm not trying to to drill down and
write and give you a really advanced.
Deep technical talk I'm trying to get
some of the key ideas across with
a simple presentation as I can get it and
I'm going to use examples for
a long time scale because I think it
is important that systems live for
a long time software tend to live
quite a lot longer than hardware
and people have this notion that
you get all language right for
the sign of figures it out and
it's all there for moral.
It's not takes about 10
years from inception to
serious industrial use and then it takes
more decades for Everything's get done so
that's what I'm going to do there
are some pictures here they have or
have something to do was
he plus plus except for
a few that obviously has nothing to do
with anything they're just landscapes and
such they are for
me to come down take a deep breath and
remember I'm going to shift the topic but
the ones that
appears to you straight something
probably has something to do with c.
plus plus that happens to be the channel
of the large garden collider at Cern and
one of the things I really like about
programming languages about I t.
is it is a perfect excuse for sticking
your nose into interesting projects
in just about any field and so if you're
interested in high energy physics in
the structure of the universe being
a programmer is one of the best ways of
getting there it's probably easier
than becoming a theoretical physicist.
Ok so I'm going to 1st talk
a little bit about what c.
plus plus is and
what it's supposed to be and.
How how how we're getting the f. and
then I'm going to go through some
practical details I'm very interested in
resource management mostly because
on the into systems programming and
building complex systems where resources
has to be don't we're dealing with object
oriented programming class hierarchies
which Ashu most of you have seen
then I'm going to get into a bit of
template programming generic programming
with templates and then out going to
point out that you know this this is
a real world language with real world
problems we can do better still.
So.
I listen in to.
Discussions in real life and
on the web and it seems that often
I'm the only one around who doesn't have
a firm opinion about what c. plus plus is.
Hit here we see the blind men and
the elephant and
if all you've seen is sort of the tail
you have some some firm idea of what
the elephant is like except
it's only right for the tail so
everything we see here is probably
true for somebody at some time
in some place and if you think that's
the whole story you're wrong and
so my problem is I actually know
the beast and it's a little bit hard
to generalize what what the beast is when
you have to take it all into account so
I'm trying to explain a little bit about
the beast here about that elephant So
let's go back and
see what I would like what I'd like when I
started see plus plus what I have
learned over the years that I want
type safety is a really
important aspect and.
When I started out a c.
program couldn't check
the chops of its function of there
was no function prototype so
it's no function declarations
of specified types and
this was actually fairly controversial
at the time people said you know if if
you have a declaration of type then when
I look at my core I do not know what
it's doing because it depends on something
I can't see of much rather have it just
like in a simply code I just do something
I never have to look anywhere else.
Ok so I have actually been trying to
increase the type safety of the c.c.
plus plus family of languages since
day one and that's not all that easy
because it's on the constraints of size
of programs performance of programs and
such resource a 50 I really don't want
to leak things if you are writing.
Code for foresee a space ship and
you should not run out of resources the
resources can be just about anything but
I think about things like memory file
handles communication connections
locks things like that
performance my my business by and
large chosen 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
memory manager and virtual machine and
things like that and c. plus plus more or
less by definition is that that's
the aim predictability if you get into
the heart real time you really
have to have every operation be.
Executed in a predictable time usually
a low constant maximum time and
over ations that can't do that are just
simply not allowed on planes are.
They takeoff I'm not talking about
the educate it is entertainment system of
course talking about the engine
controls and the things that deals with
the flipping of the wings and c. plus
plus photos that rule roughly except for
the use of Freestore and Amec memory
which is not all out there anyway and
you have to do something else Cheech
ability it really should be possible to
Cheech how to do this kind of stuff
how to use something you can't just.
Assume people will want to learn some
things you have to make it reasonably easy
and the complexity of the cool should be
proportional to the complexity of the tusk
you're doing that is a very
big statement very hard to do
it's an ideal it's something you can
try and hope and in different domains
you can get close on others but it's
definitely what I would like to see and
out like so
have the code be readable by humans and
machines again those of you will know c.
plus plus knows that this is just an ideal
because you can write really ugly code
in c. plus plus as men effect you write
really ugly code in in any language but
this is a c. plus plus I'm concerned about
is should be possible to write
really nice readable code and pen.
And I wondered for systems programming
embedded systems resource constrained
systems and for large systems that's
the sort of the domain I'm most interested
in it is not optimized for for
writing symbols web apps for
instance it's not it's not meant to be
the simplest programming language on earth
it's supposed to be the simplest we
can get it for real world constraint
applications superclasses is
frankly it's very expert friendly
I coined the phrase to point
out that that's not enough
if it's only expert friendly and
it's hostile to new users to novices
to casual uses when are helping a lot
of people that could be helped so
it has to be novice friendly to
that that's an important thing.
And I'll show you some code that
makes this statement portable.
Secret Plus comes from true traditions and
programming languages and
quite consciously So here is this
line here which is deliberately
towards a low end this is sort of close
to optimal exploitation of the hardware
very appealing the ability to manipulate
anything you haven't hardware and.
And do it well so we started with
a simple Oh God languages by the sea and
c c still around.
This Dennys Ritchie and
his genius was actually to
the define a model of hardware that
was sort of general and could be used
I mean if you add something use the add
instruction if you access memory memory or
sequences of objects when you want to
compose something out of all objects
you just put them next to each other you
stick things of the same type next to
each other and you get a raise you state
things of different types on another and
you get struck such That's a very
nice memory model has stood
the test of time very well
however this is low level stuff.
I don't really like programming with
bits and bytes and actresses and
things like that we need something
that is more fit for humans and
here we have back us who invented
Fortran Fortran was a language to sign for
a very particular kind of humans
engineers and scientists and
it was the 1st language
to lift the level of
programming from being focused on the
machine to be in focused on the problem it
was the 1st language that really was
fit for humans and once that was done.
We actually got portability I mean
Fortran was designed so that i.b.m.
could sell more machines.
And it puts turned out that after Fortran
you could take these programs and
with fairly minor changes move
them to see a Univac which
was a main competitor at the time and that
was I believe an unintentional effect but
it was very good for us and
lifting things up to a human level
is is a good idea however as
I pointed out scientists and
engineers are very peculiar subspecies and
so every once
they had it their own language everybody
else wanted one to Cobol being the most.
Prominent for for business but
be basically very soon we had.
A couple of 100 languages the problem
was they couldn't talk to each other
I mean when you write something and
Cobol or you can do really nice record and
file manipulation that was what it was for
that was what the business people wondered
it could add and subtract with anything
more sophisticated than that it was not
very good at Fortran was really good
at Linear Algebra computations could
handle floating point numbers now what do
I do if I as a scientist wants to read
some records when it's too late them and
compute on the resort the answer
roughly was you're out of luck.
And those many many salute you chanst for
this but
the breakthrough I think was this.
Close new gone with the language
Simula and said Why
why don't you let people build their own
abstractions instead of building in.
Matrices and read courts and
things like that why don't you just say
give people the language perceive
it is for building their own.
Abstractions into a language so if you
want a vector you build a vector if you
want to 3 d. make tricks you build a 3 d.
make sure if you have a record you build
a record that's where the class
system class concept came in and
they used higher keys of
classes to represent related
concepts some concepts are written
hierarchy oriented not or
and basically you got what Hume
currently known as object oriented
programming languages with processes and
class hierarchies and
I I found myself in a project
a long time ago at the lapse where
I needed to manipulate the lower levels of
the hardware right memory managers right.
And it worked drivers but I also needed to
construct something that had a fairly high
complexity of organization I wanted to be
able to say this bit here runs there this
big there once there no I changed
my mind this British should move or
there was a distributed system languages
at the time that could do the hot
close to the hardware programming
could not say what a bit was
all sort of a board of code it was still
is no no serious abstraction there and
so I took the Simula class concept and
put build it into c. and
some of the terminology
comes from Simula and
it's laid up inherited by
lots of all anguishes And
this happen in 1980 and
we've been going on for a while since.
We have a new stand at the end 11 we're
going to get a new one this year.
It's all of the technical works being done
it's going through voting procedures and
so so if you want to see
Explain what's he plus pluses
it's from this idea of taking this cd and
taking Simula and putting them together so
we want to direct map from heart to heart
where between the instructor structure and
data types in c.
plus plus coming initially from c. and
you want 0 had obstruction the ability
to take these things wrap them into.
New types with data or a presentation and.
And and sort of operations or.
Interfaces defined and then being
implemented later initially from Simula
one of the really key things that came
in very very early in the c. plus plus.
Development very early being like this
that we go there about constructors and
destructors because if you want to build
your abstraction should we want objects of
them very often the.
The object needs to be initialized and
if it holds something that needs to be
cleaned up you need to Cork
destructor to do it and so
a lot of us came in here as
the advance in understanding and
the number of abstract kind of
abstractions we dealing with could be done
and basically much of the Operate of
the inspiration at the time came from
operating systems my my background is
an operating systems and micro programming
machine architecture and such that it
that explains a lot for good and bad.
And basically I've been wondering this
question what will see plus plus want to
be what when when it grows up and
the answer.
Is wants to be better at that that is c.
plus plus is domain
if you are in a different domain you will
probably want different languages and
one plus thing that people point out is
that there's a lot of old crowd in c.
plus plus it's like a ship that's
been at sea for a long time and
is a choir Bonnie calls and such and
we would all like to get rid of them but
we can't because long term stability
compatibilities a feature he will
say we want all of these new great things
but we do not want you to break all coked.
This problem will probably be addressed
in the future through code analysis and
code transformation I hope
we will see more of that but
basically remember this one if you want to
cross cross to be different and better.
And the next question is
can I break your code and
I think I know the answer at least for
people with
large cool pieces that's that's important
as opposed to a hobbyist and so
here's my aversion of the elephant
it's a language to sign for
building basically efficient and
elegant abstractions
for areas were shot like software
infrastructure resource constrained
applications Ok so
this is one of these pictures
of the ads will get me to stop take
a deep breath think now comes a new topic
which is resource management how do
we deal with with good resources.
Basically every source is something that
you have to acquire and then when you're
finished with it you have to give it
back to wherever you got it from.
And this can be explicit
it can be implicit but
every step of the definition of resource
the example is man it is me its memory
give me some memory I have to give it
back over once we have a memory leak.
Itself I handle open the file crucified
get a lock acquire the lock release
the lock open the socket connection close
a socket connections things like that and
we don't want leaks we
really don't want the space
probe to to run out of
anything we don't want our
cell phones to to crash once a day
because it runs out of anything but
electricity we can't actually handle
battery life like this except of course
if you run more efficiently will use less
better it but that's a different issue.
And usually I mean a resource should
have a known because otherwise
it's really hard to know
who's responsible for.
Giving back resources the fact that
there's no obvious representation of
an owner in a in a language like c..
Plus is why these programs tend to leak.
Say I make myself shake
the shop on the screen
and I get a pointer to that
shape who is responsible for.
Getting the screen off the getting
the shape off the screen again
is the screen manager is Me Okey.
Then I give the pointer to the shape
to him this is now his job is it my
that is a source of a lot
of problems in n.c.
started programming we need to deal
with that so basically the rule is
there should be a no knock that's off
the handle like this that points to.
The real resource the real object and
the basically the handle should
represent something meaningful it
could be a vector it could be.
Pointed to something could
could be just about anything.
Ok so.
In the c. plus plus standard there's
actually a lot of things that behaves like
that you see all of this all of
the main data structures date
strings maps hash tables and
such or follow this model.
And so whenever you have one of
these it's a local object and
it points to something that
it manages on the side and
when it goes away goes out of scope
it cleans up its mist after it and
it's not just memory threads logs
file it's fire and streams and
ship pointers are in this category so this
is all over the concept was processed and
that and basically they are sort of
more or less look like this here
is an abstraction which is a vector
of cheese and so you can initialize
it in some way or the interesting classes
have some way of initialising them
in this place of case you can give
it an initializer list of cheese and
initialize a list of cheeses sort of
a list of things and curly braces so
here I'm saying that if you want to
make a vector you have to give me
an initializer list it will then make
a list and it'll actually represent some
way it'll set aside some memory it will
put the elements of the list into that.
They're turned into into that
memory it keeps track of
how many things the how many things
it's got coming elements it's got
That's about the simplest you can do and
now you can make a vector of double and
initialize it a vector of strings Minissha
lies it and the important thing here
is that when they go out of scope
they hold think it's clear at all.
Notice this is not not the simplest
of memory management at least
Victor strength strings
are themselves handled so
to clean up that vector of strings I have
to tell the victor to clean itself up and
the victor has to tell ordered
strings to clean themselves up and
we could do count more complicated
things like that having a vector
of records with locks associated
with them things like that but
anyway it's very simple model
you can create things and
you clean up your mess when you're
finished the clean up is implicit and so
here is a sort of classical
example you find it or
no 1000000 line code bases and
it's a mis Let's see what's
wrong here I want to get it and
say I'm a Java program or a c. plus
plus programmer that still thinks it's
cool to write code like in the ninety's
I make myself a gadget and
I assigned it to a point
with a point I get back and.
There's a lot of code like that
the point here is I didn't
tell you what's in the get it but
there could be all kinds of
interesting things think it has
a file handle for instance.
It opens a file or something so here I do
some code that might throw an exception
and do something that might return and
then I delete things and or
good Java programmers will complain
that the there has to write
that elite that such a pain neck and
we know that if you actually
have to write such code you'd get
it wrong a fair amount of time.
As a matter of fact my rule East is if I
see a new one I know I have to write it
leads somewhere therefore I'll get it
wrong if I shouldn't write the new.
But let's see.
A garbage collector could be an idea
it's just take away this one and
everything will work except that we
don't know what's inside to get it it
may hold things that needs to be
cleaned up so we want to do that so
the naked point has a problem also
if I throw an exception the gadget
if I return the gadgets this is actually
not good code so we can do something
like this this is fairly modern c.
plus plus it's been been used heavily for
the last of 1520 years in places we have
a share point or I'm here using a c.
plus plus 13 notation for
Aids says make me a gadget and
return a share point it's only a Share
Point is sort of a simple implementation
of garbage collection the 1st garbage
collectors will worship counterpoint
to things in several languages call it
garbage collection to this day the point
here being that if I throw
an exception the destructor for
that she had pointer there fires and
cleans up the mess Similarly if
I return the messages cleaned up
my code gets simpler There's nobody
down there the Whenever we get out it
gets cleaned up fine constructors and
destructors handle this problem there's
only one problem left is I'm not
sharing anything that get it is mine or
mine so why do I need to do
things like get a use count to keep
2 to count the number of uses of.
Of the gadget I know the number
of uses its me want so
we can simplify that if you want we can
make a unique pointer to a gadget and
everything works simple it's simple and
cheap.
One of the problems with.
Share pointers as they have
to maintain a use count and
use count as a shared resource it's
shared between or uses off the pointer
and so when you make more pointers to
that shared object the use count goes
up 12322 is when it gets to Ciro
the last guy out cleans up and
still cleans up everything and we don't
have any leaks of file handles and
such but it still if there's nothing
Scheana shouldn't introduce a shared
resource we are in a world where lots
of forms of concurrency happens and
anything shared cost more than you imagine
it goes so this is better but you know
I own that gadget Why am I dealing with
pointers I should have just done it simply
in the 1st place there are no need for
any pointers he I just make my gadget and
the destructor of a gadget gets thrown if
we get out of here we can get out here and
get out here we can get out here doesn't
matter destructor is court cleanups or
reception the exceptions and
that is good and
basically we have reached the point
where the code looks simple on
there are no pointers that there are some
behind the scene but it's easy to write
in construction at the struct a pair that
takes care of resources so there's good.
And this this this is known by
the amazing phrase resource acquisition
is initialization which I consider the
proof that I shouldn't be in marketing and
basically the dust does what we sit and
it happens to be a good way
of dealing with a system that
uses exceptions and exceptions is
the best way of dealing with error
handling because it will give the right
thing right happen things have to happen
especially when you have destructors to
help you clean out local resources and
so we can write a leak free code and
in general what you do is you establish
an invariant in the constructor and
tear it down if necessary
in the destructor fine and
if you don't need it destructor
Well the right one now.
Where do we then use pointers we use
them as references and iterators so
we don't use them to represent ownership
we use them to refer to objects
that are owned by somebody
every object should have at.
A known up and this leaves one problem
this problem has been there for
a long time in the community
people tend to want
to return a lot of stuff from a function
to its core like make something like
make a shape make a matrix of 100000
elements some things like that
it tend to use new to put it all on the
Freestore and then return a pointer and
the minute you do that all of
the problems with pointers come back.
The you have to decide who is in charge
of the objects is it the creator of
the pointer or is abuse of the pointer if
I share the pointer How do I know who or
she added Will you basically
can't solve those problems so
let's let's deal with this as we
have always been able to deal with
a lot of these things are not new a lot
of these things are not original but
we have easier ways of doing them now and
that's important it makes it easier for
sort of the the mythical average
programmer to deal with so
let's consider where this picture happens
the idea that you make a big thing and
you need to parse it out of a function my
examples with the catch it in search or
work within a single scope now
we're talking about communicating
between scopes so there's limits
to what I can do with scripts and
this happens with factory functions
functions that makes things and
functions returning lots of object
containers and things like that so
let's take a classical example
take an operator plus on matrices
a matrix can be big right so
I take into matrices and I'm supposed
to return a matrix that's a sum of
the others so make a new matrix fill it
up with the good stuff and return it back
now in the matrix Maybe
100-005-8000 extension 00 doubles so
even on a modern architecture you can tell
that you probably shouldn't copy it on
the way back so let's try and
return a pointer that's actually not such
a bright idea would get the pointer
problems but it also looks ugly.
I want to deal with matrices
not pointers to meters is and
I don't want to go around dereferencing
matrices to get their stock and
apart from that how many of you spotted
the bug before and I'll point it out to
you as a bug right there this should
not compile in any decent program and
it will so anyway people say they like
references better then point us so
let's try this with the passing references
off draw by passed by reference that's
good it's trying returned by
reference now this code looks nice
except who deletes the object who
who says delete to the point at.
Which point a where is it
it's I've hidden the problem
that doesn't mean that
the problem went away this is
almost certain to leak even faster
than the examples I've shown before.
Then people have solved this by
saying Ok so an add operation for.
Me it Major says something that generates
big object should take its arguments by
reference and return its occupant by
reference now you have to set up a target
and then program against it now we
are regressing to a simply code
we just lost 300 years of experience
of how to write down math and
related things I really don't
like that this works in places
a lot of this works just like dealing
with the pointers directly it works
if you have enough time to deal with
in your programs a simple enough but or
from the out so we have to deal
with them and the up years thing
is that if you are making a new object
you should return a new object right.
Plus operation says make me
a vector where the elements of
the sums of the elements of my
arguments so I have to return.
The problem is that
the semantics off returning
is the semantics of copy sometimes are.
Compilers can figure out how to optimize
that but it's not guaranteed so
what we do here is that we return.
10000000 elements and
it's painful so we try and
do tricks and least tricks by and
large and none did in general and try and
tricky Redell that's not good so
what we should do is something else and
the key here is something that we all
learned when we were about 6 months old
right here's an object here not sure
here there's nothing that so simple
as that now only a computer scientist
could get the idea that to get this
one over there we make a copy of it put it
over there and then destroy the original.
It's.
Just doesn't make sense right but
that's what people have more or
less been doing for a long time or they
built some candles with this one and moved
the handle over there leaving the original
in place of some more complicated stuff
we need to have something really simple
and the really simple looks like this Ok
very naive I want a matrix that is
a sum of the that has the elements of
all the sum of the 2 things in
return it that code should work and
we can make it work because we can make we
can simply steal the representation I make
are it's there it's filled with all kinds
of good stuff I want to do in the **** so
what I do is take this point to put it
over there and make this one point to
nothing so that when the destructor comes
and cleans up the mess there is basically
you know much to clean up and
as I mention that I have been compilers or
the last 20 years that could do
this kind of trickery by themselves
because it was an optimized version but
here I'm not relying on
any up to my solution so
we are moving the matrix by doing 2
word copies to copy the point and
if the optimizer works
we can get rid of that copy too
because that can be optimized away.
Anyway so this is dirt cheap and
the way that code is done is to
write what's called a move constructor we
have constructors to construct things from
basically arbitrary things we have covered
constructors that define what copy means
we have moved to structures that define
what move means this notation here and
the best c. style is cryptic and.
That means some new construct and so
basically copy the representation that set
the representations to nothing this is it
now this code works and it's sufficient
even if there's 10000000 intimate c.
So that is actually very simple and
by the way.
You don't have to write all of
these constructors yourself if you
if your representation knows
how to copy and move so
to you the language will generate the
constructors and destructors for you so
if I defined a matrix as object
of Davos that's the elements and
by the way the vector of doubles of course
knows how many doubles it contains then I
don't have to write any more coke because
if you move a matrix you move its
representation which is the elements which
knows how to move and you're finished
this code here is efficient.
And leak proof exception proof and
dramatically simpler than some of the code
we have seen over the last many years
Ok that's it so here's my comment
about garbage collection.
The garbage corrections neither general
nor no ideal it is not general because
it only takes care of memory and
a lot of my resources are not memory and
it's not ideal because it imposes a shared
resource on the system so some of the old.
Son servers have you could get
them with 64 processors and
a lot of the time 63 of
the processor sits waiting for
the 64th to garbage collect
we're better today.
Somewhat better but it's still
fundamentally a shared resource in
a distributed world where we don't
actually need to impose sharing so
I you may have heard of the notion of for
sharing there's an equivalent for
garbage collection so what do you
do keep your data in containers
like that Matrix or
that they are all that map but
that hash table or something like that and
a menage ship with our ai
the constructor destructor stuff I
showed you used to constructor this will
they are essentially free to move around
covered constructors when you want to copy
you smart pointers you need point
doesn't meant 6 when do do that c.
take the old shape example if I want
a pointer to the interface class shape and
I can deal with pointers to circles and
triangles and heaven knows what.
You just use smart pointers
if you are the only owner and
you just want to pass it around you can
use you need pointer if you are using
a shared pointer if you're
sharing this is the object so
that you don't know who's responsible for
to needing it uses yet
pointer I mean when would you need to
share point are classical example is that
you pass some data to 3 your it doesn't
task that runs in common
in parallel hopefully for
you you either have some docking
mechanism or you have a pointer to const.
And now the last of these
threads concurrent tox
is supposed to clean out and
the and delete the.
The object pointed to the she had object
and the Share Point is what really nicely
for that but if all you do is to see
the goose can't go one to one syrup
that's not the optimal way and that's
what the way they actually mostly used in
existing code people use them to parse
out information from inside functions.
Now then if you slowly came usually for
the old code you can do what's called
leader collection that is you ever so
infrequently run the garbage collector
like once every day because there's
not that much garbage so you don't have to
run it all the time and there's a standard
interface to that kind of of collectors
and they actually work rather well if you
have a lot of old code that you can't
convert to the the modern style.
So let me show some modern sucrose pass
code that sort of illustrates this
here I want to find all elements
in the container see that
that has the value of v This is
just a trivial example of course so
what are each turn I return a vector of
pointers to the elements the value type
of a container is the type of the elements
and so the way I write this function
obviously is make myself a container
to hold the things that match and
then for x. in c.
if it's a match push back its address
and using fair number of new c.
plus plus features here there's
orto that says find the type
statically from the element for
me to initialize a and so obviously this
is the element type of the container
I pass things by of reference
here I don't want to have copies.
And then I return by value and
I can write things like this
Mary Had a Little Lamb for p..
Pointers in there that comes back
from find or test that I actually.
Got got the right thing back.
It's a little test program that
just tests the sanity of this but
the point being it it may not look like
the c. plus plus you're used to in c.
plus plus $98.00 there's a major
performance bug right there but
fortunately you can't write it in c.
Per's plus 98 because I
loaded it up with a few c.
plus plus 11 features if I'm going to use.
Move semantics I am definitely
loading up the program with a few
explicit features so that it breaks if you
try and compile it with a c. plus plus.
98 compiler much trial on my code
breaks then to get a performance bug
that you might get the Ok let's look it
up to Korean programming I'm going to be
brief here because you all probably know
it better than itu So here's the good
ole shape example here except that it
take a victim of unique pointers to ship
through is the president example where
you want to put a morphic pointer I.
Loped a vector up with a call before
objects which I create using make unique
says make me a circle and give me back a
unique point of Ok nodes note the absence
of news note the absence of raw
pointers that are just the represent
station of the extras in memory and
now I said draw them or not go for
all of them and core drop I'll get back
to what a drop will sequences later.
So that that's fairly simple and it is
the classical object oriented example
except that this one hears is fairly
brief and doesn't leak at Tor.
Of course shape looks the way
it has done for a long time.
Would virtual from the senior guys
that invented the mechanism and
I book just as I borrowed the word.
Class from them why does
in court type Well it was
simular was invented by mathematicians and
it seemed natural to them.
And thin the only thing that's new here is
that you can be explicit about overriding
you want to say that must be a draw
with this type it takes no argument
to return to a void in the base class for
me to or I target some chick just
slight it will refinement that
some people like you don't have to
do it if you don't like it the protection
model is public protected and
private be aware of protected it will
cause blogs for you if you use it for
data there are people who think it is
really cool because it allows anybody to
molest my data story there's
usually a different explanation but
that's what it is you open the.
The representation to be modified later
makes it really hard to have
an invariant still this one he has for
functions only we have much more ahead
since so goes of course if we language
that provides a static interface it's just
that only provide interface inheritance we
have implementation inheritance too
we can discuss that if you want but
interface we need at least interface
inheritance inheritance and
abstract classes that classes abstract
it has no full implementation of
this minimal runtime type indication
we have not gone into the so
of the serious reflection
kind of world Ok so
object oriented programming inheritance
is great when you have hierarchy a hawk.
Concepts in your domain
that's why it is so
nice with the shape example
because obviously at.
Smiley faces a circle that's a shape or
something like that.
You can get into trouble even then but
basically it's if you have
a domain where you have hierarchical
relationships it works fine
the indirect function calls the virtual
functions are fairly cheap I am been
told by Michel ments recently that this
figure is too high that is it's closer to.
20 or head then than before
if you call it a few times
the branch predictors have
been improving dramatically so
I am actually being pissed mistake here
but the main problem is it doesn't.
It doesn't inline Well if
the operation you want to pass along
is something really simple you don't
get inlining and in high performance.
Uses that's important and anyway you tend
to use a location to a location exit or
exit or this is pretty good though you do
it get do get create a couple in between
programs for parts you can mitigate
that by having better interfaces
abstract base classes but
basically inheritance is seriously
unsystematic you used a machinist there
are people who think good programming
means object oriented programming and
object oriented programming means
use of enormous hierarchies certainly
the 1st part of that statement
is wrong there's lots of good code
that are not object oriented and
there's lots of lousy code that our
object oriented by that definition.
Ok so.
That said go on to the next thing which
is generic programming which has been
widely popular and successful in the last
sort of 1015 years so let's look at that.
I'd like to point out that
the 1st paper I ever wrote on c.
with classes he proposes and
precess I included generic programming
and I explained why I really wanted a
vector of t. words he was a parameter and
I really wanted operations of
victor of T.'s that had t.
as a parameter I mean if I have a vector
of cheese I want to sort of act of T.'s I
don't want to sort of fix the t.
arbitrarily for
Gratian So I wanted that and
I wrote gladly that.
You could do that with macros that did
not scale so allows a solution in 87 a so
I decided that we needed something better
we need to something extremely gentle and
frankly flexible I never trusted the
science of could only do what I imagined
and I want to Ciro hit because I wanted to
put c. arrays out of business if I could
the c. a re is my least favorite data
structure it is the ideal structure for
accessing memory directly but most of
the time that's not what we want to.
See arrays has a tendency of
losing their the size I mean with
the slightest excuse and or
a turns into a pointer to one or
more elements actually turns into
a port Yes that's what it does one or
more elements except that all of
pointers control it's good can refer to
Ciro or more elements this is
a source of a lot of problems so
basically I wanted to compete with that
because I wanted data structures that for
starters did not convert
to pointers in women but
their size and
then I wanted those specified interfaces
are pointed out one of the very
1st things I get with with was c.
plus plus with c. want to be of c. plus
plus what's right that aside changing.
Obviously I want to be interface checking
for for this and I looked at it and
at the time nobody knew how to the those
3 and I couldn't figure out how to do it
given the constraints of my horror or
problem I had to pick the 2 1st and
you know 2 out of 3 ain't bad but
it doesn't feel good it doesn't feel right
and so I've been trying to solve that ever
since and I actually do have a solution
which I'm going to show you in not too
great detail but let's 1st see how
templates have worked up till now you
can write yourself you can parameterize
a type then you can run a surprise and
Al Gore didn't with that type and
most of the time you have to be
explicit about the type of attack
sorry that the prime minister to
a type you don't have to be it for
him for
use of that type you simply deduce what t.
is if that if he happens to be a victim
of integers obviously the t.v.
the prime minister a sort can
be implicit and is it will
be a sort of integers if it's a picture of
strings it will be a sort strings fine.
What you can do here is anything that you.
Can you can call it
compile time Doc typing
duck typing is the general principle
that if it walks like a duck and
it quacks it's a duck in other words
you just use the argument type and
if it worked it worked and if it didn't
work you get an error message the only
good thing about the error messages
you get is you get it at compile or
link time before the program
gets shipped to the cost of.
The bad news is that these error
messages can be spectacularly bad.
Mike My basic Samba recently was I had.
7 line program.
That used one little.
Parameterized plus and
I was on the issues and
sick when on a Windows machine and
I never figured out what the 1st few
pages of the error messages was
because it blew my windows blown off.
Sequinned window box.
That's right on our compiler and
I got the same or
saw it except that the error
messages were totally different and
had nothing to do with the code I
wrote that was in any way obvious so
we really should deal with
this one try 1st of all or
let's see we need what we have found
is that people write compile time
programs and
they have really good reasons for it.
Mostly performance but also to
express things as directly as possible
why delay to runtime what you can do
at compile time to get your arrows and
things like that so people have been
doing this and so like any new feature
that's sort of cuckoo power for.
Expressive efficient it gets or
used and there's been serious or
use in particular people write template
metaprogramming to compute values so
you plus plus 11 provide to
the ability to write functions at
compile time which take care of some
of the worst abuses of templates
I'll get to all a waste of
improving that in a 2nd but
1st I'll show those of you who haven't
seen all that much see plus plus what
the code looks like we can
parameterize data types with
integers and
we can print size algorithms with that so
I can sort the vector of integers here and
I can find the find my
home town in the list of.
Of.
Strings and
the usual way we deal with returning at
Fadia is to return the end if I'm
looking through a list for something and
I found the end instead of what I was
looking for that's the way it is so
we can write code like this we
promise tries an element type and
container type I could also do
the find in the vector of integers so
it's generic code and
that's part of the appeal of this.
We can also premise for eyes on on
criteria's actions algorithms so
here I want to have find
something that not really
is equal to something but
has a problem see here we write.
A predicate is it less than Griffen and
it strings so that's that's meaningful.
And basically that's it's done by doing
what's known as function object you
write a little class that can hold state
so that you use in your Gratian and
when you can construct it of course
everything is constructors and
there is an application operator
that is invoked which record it and
it'll do something it's case case
it compares to x. And of course as
a destructor here to clean up that string
that we gave it it has to disappear and so
you can write code like this
once you have the list sent and
this people find it a bit of a nuisance to
write all of that it's all of 5 lines but.
Sometimes that's too much for people so
you can boost what color lambda expression
that basically writes the code for you so
now we can compare using compare
string compare to Griffen.
Lots of languages have
these these days Ok.
This is the code that that you write
to implement this if you think c.
code is beautiful this is beautiful if
you don't think it well this is what you
got anyway and it very closely
model else walk is being
done in the machine sold and
it generates very nice code whether
it is a list or of Excel or.
See a ray of something like that Sulu
says the way the code to start and
if you get time out of
writing new sequences.
Like.
Where it would have a sequence
from the beginning to the in
that's the way it's expressed and
that's the most general off form because
now you can sort half a sequence all.
Quarter of a sequence and
things like that composes very nicely but
it is unusual because the most common
case is to do a whole sequence so
you can do this sort the sequence
in using the predicate p.
and then I simply say use a stand of sorts
from the beginning to the end use and p.
is a predicate so you can easily
write a simpler form code so
that your code shrinks it will still
execute at exactly the same speed so.
Those who you were used to see plus plus
will know this is straight code that's not
a problem but
basically we're working on the 3rd part
of the definition of templates how do we
specify the interface to a template how do
we specify the requirements that
a templates has on its arguments and
the way we're doing it we're saying Dr
typing just isn't enough we want to state
the intent in other words you want to
specify a temperature Quien Mintz on
its arguments and
basically the program always knows that
I mean you can't get working code of
that's template sized on unless you have
a good idea about what requirements they
are what does this what are the template.
The extra temper documents
supposed to do for
you I mean if I'm having
an matrix of numbers.
I want numbers if I'm having a vector of
elements they have to have the property of
an element an element can be copied you
can take it satirist and things like that
the number is something you can add
much apply a something like that so
you know it already it's just
there's been no way of saying it so
what we can say here in a container.
For sot I want my the type
container current to be sort of
and what sort of wants a predicate it's
a predicate you apply it's either true or
forceful argument type I apply a sword or
bow to a vector and
it'll say something like.
Do you have random x. is this is your
something you can do random access to
and do you have an element type and
can the elements of that type be compared.
In this case using less than
which is the default So
that's what the sort of all those and
it will be if you look it up be about
3 lines of code that says
in code just what I do and
today I actually write code in c.
plus plus 11 I put a comment there and
I use this simply as my shorthand for
writing good requirements
I have a set of common concepts of so
I can provide the.
The specification in a concise way and
in sucrose plus 14 the concepts that
are coming there this will be code so.
We can also have some some notation here.
If I want to sort of sort of pull it means
that I want I can write it's fordable
type s. that you are sorting which means
that there has to be a type that is sort
of all and I pass it through it's just
a shorthand and you can use that for
lambda's to work in c. I want to
lend it work for sort of will see so
it will contain a c. So it all works
out and now let's see how it works
I have here the template of sortable
container of this finds not
quite the tensest notation we've got but
it's pretty you mind Numac there should be
a type that sort of bore and that's
the type of my container I make myself
a victim of doubles a way to make myself
a list of integers I sort the victim.
Everything's fine what
happens here is that it says
is there a container Nyala
can have random x. I can.
Have random access it has an element
type I can compare it's fine to
sort the list is it
a random access rate or
no it's not it you only have.
The you can only search through a list you
can't access the in filament directly so
the actual error message coming out here
list of integer does not satisfy
the constraint of sort so
those are you who has suffered from the
template definitions of the last 15 years
I'm sorry I didn't know how
to do that there now we do.
There is an implementation of
this stuff it's a project d c c
Look up concepts Andrew saw from and
you can find and try and play with it.
If your switch if you throw one of
the compiler switches it will then
tell you why list of in does not
satisfy sortable then you come back and
says the field is not sort of 0 because
it doesn't have a substitute operate it.
That symbol.
If you get the extra information will be
about 4 lines as opposed to pages and
that's what I said so
best to to something that.
Seems obvious but certainly is not what
I've been up the s. in the c. c. plus plus
in 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
use a different kind of logic when
you're writing template programming and
people invent very complicated ways of
doing it but let's look at some code here
is a square root function like we
learned about in the 1st day of our.
Programming.
When we were programming right we can give
it something that can be used as a dog
like an integer and everything's fine and
the function gets called to take
the give you back the square root of.
Of x. and.
Assuming that you know what a square
root is you don't have to look into
the implementation it just get caught if
you give it a square root of something
that isn't a double can't be made into
a double like the address of a double
you get an error message this is a square
root wants a double Now let's try
that with a container we take a container
we give it to the container and
it says everything's fine because of
a tough string is a container and it's
a sort of born whatever it works give us
something that's not a vector its is no.
Sort wants a vector and
the address of the victor is not a vector.
So we can get back to a world
where the code actually looks
very similar whether it
is generic on knock and
I don't think we have to learn
significantly new concepts we just have to
get back to 2 it's what we learnt about
on the 1st day of our programming course.
Writing the templates is a little
bit harder but not much harder and
it's significantly
easier than it is today.
This lets me into one of my
favorite rants which is that
the distinction between these
so-called paradigms are more or
less a function of the language
features people had available and
people have huge discussions about
should you do conventional c.
style programming to use Object Oriented
Programming putting things in hierarchies
issue to Primus arise from you programming
I think this is a function of.
Of poor language support and
the the discussions do harm so
here is the classical example off.
Of an object oriented programming
written in a slightly different style so
I am drawing more containers for
which the value type is shape and
I do that by calling the for each.
For the container using
the lambda that draws the shapes.
My point here is not good
may not be your ideal role
when it's it's pretty good I can actually
do it's like a bit of this is this this is
to make the point obviously this
is object oriented Coke I'm
doing runtime part of morphism
on a class hierarchy of ships.
Is it generic code obviously
that contain a is a prime
its rawest type and actually draw is
parameterized on the container type and
the element type of the container you go
in here this is perfectly ordinary code it
Corder for each algorithm on a container
using a lambda we're certainly pouring
styles from the functional programming
world where they have been very useful so.
To me a favor don't get
into a language wars or
paradigms I think the word
paradigm was seriously mis
defined by Kuhn when we 1st came it came
with it is was this idea that there is
a paradigm than to get another paradigm
the 1st one gets totally useless shouldn't
be used anymore the old guy should die or
for the world to be much better for it.
He used as an example a New Times
world and Einstein's world but
you know we still live in Newton's
world most of the time and
most of the calculations defined by new
sun still works yes you need gravitational
Stine logic to deal with
high precision g.p.s. but
that's very rare similarly Christ
new Gore who invented object
oriented programming had the same
kind of attitude to paradigm he used
to talk about the old days we had plus and
minus and there was what we had and
then somebody invented most of occasion
division now this is a new paradigm for
Clearly you have to get rid of
the old paradigm no more plus and
minus that's all fashion and you can
write everything you like with with.
With multiply and divide Well I do wonder
how people get negative numbers in that
world but
apart from that I think it's absurd.
The old way is sometimes a still
a simply absorbed in the new stuff and
we can do more and we can do it better so
that's it so challenge is basically.
I'm not claiming c.
plus pluses is perfect we have to
see what we can do to make it
better we have to make programmers
actually prefer modern code for
the kind of r.p.
cations the kind of things he proposes
good so I want the code like I showed
you to be used on close to
the hardware high performance
code because it works and
it works better than the old code
the unique pointer runs X.-Acto as fast so
the last cycle that well written
code with a role point to and
property leaks the sort
algorithm here blows away a c.q.
c.q. sort by factors Not percent so
you can afford it but
we have to convince people to to do it and
then we need to make c. plus plus a better
language under the constraints that it
still has to be the best language for
really low level code and abstraction
above that that that's the aim and
we at some point and we have
compatibility performance portability
range of education areas we cannot
improve the language just by making it at
domain specific language that that again
would violate some of the ground rules.
And there some more information
there's a new website moralist new
website I associate p.-p.
dot org that are off for you.
Access to the rights you have informations
including about the standards and
extent of stuff that floats
by the some books and
the website by me I'm especially
proud of this little book.
Process it explains all of c.
plus plus $180.00 pages.
Of course I have to leave
out some details it's.
It's at a reasonably high level but
there's lots and lots of code and
so that's $180.00.
Page version that's what you can read
on a long train or plane journey and
the rest is details Well there are let's
see 1300 pages of details in that book
same number of details even more details
and $3900.00 pages in the standard and
that's encrypted in standard d.s.
to stop you from reading it.
I did not invent the rules for the i.s.o.
standards but they can pretty gross but
if you want to know everything about c.
plus plus search for w.g.
$21.00 which is the official name off
the standards committee I told you
stand at these encrypts everything
including the name of standards committee.
And you can find the stand you can find
every committee dop document it's public
and available and then basically I will
switch to questions nonces Thank you.
Thank
you and so I'm sure after that master
class the be just one or 2 questions.
It can be anything from a technical
question are something broader more
general just yarns experiences in general
so if I can through a eights you and
that couple of roofing makes for
gayeties quickly as possible you can and
just yourself and firey to question one
of the things you put next to the c.
plus plus The elephant
was buffer overflow and
in the wake of heart bleed
I saw a tweet circulating
which said every security boat you've
ever faced was dead it's Richie's fault.
So I want to say is do you want
to claim any of the credit and
what do you think the way forward is to
avoid things like Hartley let's say it
this way we shouldn't be rude
to Danish Ritchie he was the guy
who more than anybody else
lifted the level of programming
from a simply coat to
higher level notation and
for that he deserves a lot of credit and
if we have to blame somebody it should
be the people still write code
as Denise Ritchie did in 1973.
Now I haven't had a bottle or
throw in a long time and
the reason is that I
actually only use the c.
arrays directly if I am doing hardware
operating system load store
everything else I use a vector and
I have the size sitting 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 awful awful.
Doesn't really happen in my coding
more and if people used vectors and
containers and
such that would be very very common
it's a similar thing that I
could have put into a poor.
Memory.
I mean 64 or
something on that list and again it it
just doesn't happen unless sure using
pointers in a in a fairly silly way and
again you don't have to do that anymore
you use the containers that has access
operations you use the smart pointers so
that they actually point to something
as opposed to do nothing and
so these problems are by and large gone.
By and
large is probably not good enough for
some people's taste but
it's better than the c. model here.
I know that processes for
me until at least will come with
hardware support for range checking.
In I think next year it
has been announced and
I expect to see post
plus compilers will then
take what is currently under find
which is accessing outside the a re.
And enforce it by hardware so
that it's to choose.
The you can you can do that and
I would like to
build a completely typesafe system around
this at the runtime speeds we've got.
I think it can be done provided you
provide a good poll when you are.
Accessing hardware and
operating system resources directory and
basically David pairing that some code
distrusted and beyond that you can be
fully Sipe safe I haven't done it yet
so it hasn't been proven but for
me personally that problem is
in the past by several years and
it could be yours too if you can move
to the modern world Erik Thomas Skinner
versity better it seems that one
of the hardest things about c.
plus plus is accessibility to large
projects for new developers so
if you're a new developer and you approach
a project with lots of metaprogramming
with templates inheriting from classes
impaired inheriting from templates and so
forth it's really hard to figure out that
flow of execution through the program and
the way the data moves
through the program so
1st question do you also think this is
a problem and 2nd question do you have any
ideas of helping you developers
get into a project a c.
person process obviously too complex and
it has Ollie's by McCall's
from its history and if you get a project
where people have gone hog wild.
On templates on class
hierarchy is on using c.
pointers you have a major
problem on your hands.
You can write bad code and
in lots of languages and c.
plus plus you can even do it
in many sixt separate ways.
I think there's a major problem
in the education where people
law professors insist teaching you the bad
ways of doing things 1st and a lot of them
never gets to the good ways because
after all they have software to learn c.
so why shouldn't you.
Probably builds character so.
I think partly it's an education
system education problem and
I'm trying to address that
with some of the books I
showed partly it's the fact that
if you are taking a 1000000 mine.
Codebase it's going to
be a been written or
years it's going to have
different styles in that.
We need better tools for
operating for understanding it
it's actually coming especially in
the playing world where you can
where they have a pretty good stat again
Eliza's Coverity has been doing it for
a while but a lot of people don't use them
because it costs money they're rather
waste their own time and money and then
pay all of those for solving problems.
And they will be much more coming out
of playing later this year I know so
I have some hope that state again
Eliseus will help you and that.
The study that code transformation will
become common to simplify cold now for
the specific problem of our template
metaprogramming I have been encouraging
people all of the time to not do
things as complicated as they can as
the old saying if you're writing the code
as complicated as you can handle you can't
maintain it because you just did the best
you could No you have to find the book so
my guess is that if you really have the
truly horrendous template metaprogramming
you should probably back it out and
with concepts you can
eliminate some template metaprogramming
by simply writing them simpler and
Biocon stakes for functions sure can
eliminate essentially every 10 primitive
program that generates a value
writing ordinary cope so.
They lose another question
somewhere up here.
When I stand a look at me
open my question is about
compile times one of the things I've heard
people say they suffer with c. in c.
plus plus is very long compiled times and
I believe one of the things that was
cited as a potential reason for it was
repeatedly reading of
headers things like not so
I wondered do you can you see
if there is is there anything
that you think could be done in terms of
language to design rather improvements
rather than just compiler optimization but
could improve the situation.
That's a very tricky question that we
have been trying to deal with for years.
And there are languages that are even
slower at compiling but not mention.
On the other hand we all suffer
from long compile times and
there actually is work
going on doing that with.
Fairly simple modules system put
in place if you don't repeat it.
Or compilers of the same head are fired I
mean if you include the same head of fire
in 100.
Source files you get to
compile it a 100 times and
that people are too much worse than that.
It is being developed
primarily at Apple and Google.
It is in use for c.
objective c. and c. plus plus.
I expect to hear much more about it
quite soon there is a study group
in the standards committee called
modules where you can go and
look at what they've got they're not
very good at publishing Erlich but
there are documents that
describe it I expect to see.
At least initial beta releases
widely available next year
the 2 organizations I mentioned are not
the only one that was interested and
not the only one you set out working
on that so it will not be solid for c.
principles for change but I expect
to get to be solved by a c. push for
17 and be available in major
compilers notion becoming.
Much sooner that there have may be some
start to sticks or do you know about
the transfer or programmers moving from
older standards to see plus plus 11 or
maybe the newer 100 they are to
do that because most are.
Like c. plus plus 11 it's here for
a few years already and
I haven't been reading a lot of the code
that's written in Dutch standard I
just read some older
Sundance code one of the.
Problems I listed on the challenge
is to get people to upgrade and
to get them to understand that and
they are a lot of organizations
that has code bases that
should be compilable by overt.
Compilers and therefore they can't
move forward this is very sad and
we have to do something about it I think
what we have to do is to point out
that the new our coding styles are safer
and actually generate faster code and
then we have to back this
observation with code analysis and
transformation to rejuvenate code or
modernize code with every record.
That's said there's actually a lot of c.
cost plus Kolarov down the c. even c.
plus plus $14.00 code shipping in products
it's mostly in organizations that
has a controller of their co-pays that is
have a unified code base have a unified
check in procedures as opposed to be
fragmented through many user groups
and so you find code in something
like Google being far more
modern then then the impression
you're getting the adoption of c.
plus plus 11 has been significantly
faster than the adoption was of c.
Per's plus $98.00 even though
the problem of moving ahead is
obviously larger now because there
are more old compilers and more.
We're talking about billions
of lines of code here
I'm sure you could spend the whole working
life never getting out of some of the old
dos styles Similarly you could
spend your whole working life from now
on never seen any of the older stuff.
It's a huge community.
Hello Vladimir universe defender
Mike riches the following
plain old see is pretty good at mit
inning binary compatibility with
various models Harmer in c.
plus plus that a bit more challenging and
most models compiled of different
compilers require bit more work
to make the work together do you
think the current situation is Ok Or
does it be an improvement it would give
it it would be really nice if you could
mix and match code compiled with any
compiler of any vintage of c. plus plus.
You can.
Origin of this proper I'm that
every vendor in the eighty's and
early ninety's thought they were going
to dominate the world and everybody
would agree to using their linkage
standards and they object format and
every vendor try to improve
their linkage formats and
their compilers and
therefore if they couldn't agree on that
on a standard There was
an attempt the Itanium a.b.i.
was adopted in some cases some hope for
better linkage for
the 64 bit take chess but
it is a real problem think about it
this way if you are a compiler vendor
with say a 1000000000 lines of user
code out there from your customers
what are you going to be compatible
with the other guy's compiler or
the compiler lead you shipped last
year as far as I can see every vendor.
Be it open source or not chooses to
maintain compatibility with their
previous compiler to the largest possible
extent and when they break compatibility
they don't actually quickly move to
something that's compatible something else
they put in some new up to my stations
that that suits them better so
it is a problem sees compatibility
is almost a historical accident
because there was compilers that was
popular on different platforms and
people imitate them with c. plus plus
when they put in a super plus compiler
they complete it so I've seen
examples where one compiler takes all
the implementation defined things and does
this to them and the next one comes along
look at the list and do really expect or
will see it in or most all the cases.
Linkages not standardized it's
not standardized by so for
see it's not standardized for c.
plus plus it is a real real problem and
it's a nuisance and I don't want to move
on Hi my name's Andrew I work Skyscanner.
East spoke about barnacles on c. plus
plus to maintain backwards compatibility
Have you ever considered writing it
completely new language from the ground up
using concepts that you want in c.
plus plus that might not
necessarily be able to put in and if you
did do you think you'd end up with Java.
The 2nd.
Part of that question is very easy to
answer No I wouldn't build something
that looked anyway like
Joe did it totally or.
Emphasizes object oriented programming and
hierarchies and
it uses a garbage collector and
it uses a virtual memory
it's in the way of everything I like
about the systems programming language.
It's probably feeling its own
design criteria very well
see post Cross doesn't fulfill the.
Criteria I.
Now of course I've dreamt of
building a new programming language
with their nicer syntax nicer semantics
nicer properties except her etc etc My.
First guess is that unless you
could embedded in the c. Plus class
community and
infrastructure it would fail very fast so
it's not an easy thing to do I don't want
to play since I'm not the only one who
is wanted to do something like that but.
It's only now a question
from up to your right.
Just one question we say No well yes
we see more system languages in the
hardware definition signed to attempt what
we see harder to finish line which is
trying to move up to system level.
C. plus plus is obviously operating
close to the metal do you see c.
plus plus moving downwards towards the
hardware definition languages at all or
do you think d.c. the hardware definition
language is moving up toward c. plus plus.
I don't know enough about that
particular area to be really certain but
I think you cannot cross
makes the problem nice.
Hardware definition language especially
if you use templates in a fairly moderate
way that way you can write things
that well anyway I would call full.
I don't know enough to to be sure Ok yeah
I had another question about barnacles so
of the $1300.00 pages in the c.
plus plus specification
about how many pages would you
say are barnacles and which once.
That's hard let me just
point out by the way
that $1300.00 pages is
also the size of the c.
sharp specific Utian and after job
a specific patient plus minus 5 percent.
So it is not specific to c. plus plus.
Of course.
There's some really
weird side effects of c.
in it in places certainly
I would like the rules for
say conversions not to go both ways I
mean it's fine to assign a character
to a long it is rarely side
nice to assign a long to a.
Char though in real code
obviously people have tested it so
most of the time that's not
a problem in existing code but
the type system gets seriously
complicated by that kind of stuff.
Similarly.
I don't actually say it's nice to have
a data type you can do bit operations some
engine or what but
why should that double as an integer.
And I really like a raise for dealing 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 you be
allowed to forget its size and
why should it convert to a point
of of potentially another
type when you're when you're
going into prosperities And so
these are sort of the worst barnacles then
there's something syntactic God It's isn't
so what let me go to war through a whole
list of these things because they
are there we learn we have been I mean
plus plus when you take into account c.
is more than 40 years old so
do expect some some barnacles and
we have tried many times to get rid of
them deprecating features options for
for not doing things doesn't work
the community when given the choice
between getting rid of dangerous
old features and not breaking their
coach chooses not breaking their
code if you get an oracle c.
plus plus compiler it'll come with
a minus option which says for
all the wrong worst of
my draft document for
starting the standards process from 988
a lot has happened since then what they
have not been able to remove that feature
because they have paying
customers that insist on it
if I could just ask me b.
if we could sue or if you cease and
thank you very much for
the effort to maintain the give
thanks
this production is brought to you
by the University of Edinburgh.
