- I'm just gonna say at the start that I spoke to Tom Scott
before making this video
and he's happy for me to use his idea.
So thank-you, Tom, for your blessing.
I'll also say at the start like Tom did in his video,
the thumbnail and title are unlikely to match
the view count and like count exactly,
but it should be quite close
unless you're really early to the video
in which case it might be off by quite a bit
more on that in a minute.
So Tom Scott made a video recently
where the title contains the number of views
that the video has and it's always updating.
So anytime you choose to go and watch Tom's video
you'll see the number of views the video
has is in the title, they match up.
It's a great video,
if you haven't seen it already I recommend it,
the link is in the description and in the card.
Anyway, I thought it was really cool
and I wanted try it for myself
because I actually really enjoy coding.
I don't get to do it very often,
but when a challenge comes along that is fun and interesting
I just can't resist.
But actually also the content of my video
is gonna be different to Tom's.
So I hope that I'm adding something to discussion
and not just copying him.
Tom's video, the meat of it is about APIs.
And actually I'm gonna talk about APIs as well.
And given that Tom covers everything from the invention
of APIs all the way through to the eventual heat death
of the universe, what could I possibly add?
Well, what I wanna talk to you
about is it's a really interesting story
about how Amazon transformed from being a company
that sells books and loses money
to a company that sells anything it dawn well pleases
and makes lots of money and it's all to do with APIs.
But before that I wanna talk about two ways
that my video is different to Tom's
from a technical point of view
because they have interesting consequences.
The first is that the view count is in the thumbnail
not the title.
And the second is that the title contains the number
of likes not the number of views.
And those two changes have an interesting effect.
Tom says in his video
that if the title matches the view count
exactly it'll be a miracle,
but actually if you go and look at his video
now the chances are the title will match the view count
exactly, but it's not a miracle.
The reason it's happening is because the view count
doesn't update every time you hit refresh,
it updates every three minutes or so.
In other words the view count is stale most of the time,
but importantly when you refresh the page
or load the page for the first time
that stale view count you get is the same
as the stale view counts that Tom's software
gets when it requests the view count programmatically,
so that's why they match exactly.
Both systems are getting the same stale information.
But for me using the thumbnail to show the view count
I suspect it will be out most of the time.
That's because in my experience
when you change the thumbnail it takes about five minutes
for that new thumbnail to appear for viewers of YouTube.
And if the view count updates every three minutes
or so then most of the time the thumbnail
will be out of sync with the view count.
The title of this video is a different story
again because the number of likes seems to change every time
you refresh a page
so long as there's new likes coming in,
like if it's a popular video.
I'm not saying the video likes are counted instantly
like there's probably a delay
between you liking a video and that like getting counted.
I'm just saying the like count does become stale
in the same way the view count does.
And because I only update the title every few minutes
I really do expect there to be just a slight mismatch
all the time,
well, until the video gets over a 1,000 likes
at which point YouTube starts to abbreviate the like count.
So it'll say 1.1k likes meaning 1,100 likes
at which point the title will be accurate
or at least to the number of significant figures
that YouTube will allow you to check.
All of this explains a phenomenon you might've noticed
by the way, which is if you arrive early to a popular video
it'll have more likes than views
which doesn't seem possible.
The reason it happens is because views and likes
have to be validated by YouTube to stop people
tryna get in the system using bots and click forms
to artificially inflate those figures.
And the validation system for views and likes are different
and it seems as though the foundation system
for likes is quicker.
So if you're early to a video
you'll see the likes outstripped the views.
So what is an API?
Well, Tommy explains it well in his video
but here's a quick recap.
It stands for application programming interface
and it's a way for different bits of software to communicate
with each other usually over the internet.
For example the public transport system in London
has a service where you can check the arrival times
at a station or you can plan a journey,
or you can look at a bus stop
and see which buses are coming and how far away they are.
For example, on this page here you can see the buses
that are due to arrive at Balgonie Road
heading towards Chingford.
But if you change the URL a little bit
to this you'll notice that the ID for the bus stop
is still the same.
You get this webpage, it's actually not a webpage,
it's just a block of text.
And it's designed to be easily read by software.
I've actually written software that talks to this API
because I want it to show on my Pebble watch
how many minutes before the next bus arrives at the stop
outside my house.
It'll actually show the next three buses
if there were three buses coming up.
And of course, YouTube has an API
which is why I was able to write software
not only to get information about a video
but also then to update the video.
What's all this got to do with Amazon?
Well, the story comes from a memo posted
by a software engineer working at Google, Steve Yegge.
He thought the post was internal
but it turned out that it was public
and everyone could see it.
But thanks to the good nature of everyone involved
it was allowed to remain up.
The post was about the differences between working at Google
and working at Amazon where he used to work.
It's actually quite critical of Amazon
but it talks about a few ways
in which Amazon does things better than Google.
It might not be the case anymore
'cause the post is quite old by the way.
You actually can't see it anymore
because it was posted to Google Plus
which isn't a thing now
but you can see it the Wayback Machine.
So I've left a link in the description
if you want to read the whole thing for yourself.
Yegge recounts the day in about 2002
that a big mandates came down from on high from Jeff Bezos
himself that said that every team working in Amazon
must look at the data
that they have and look at the functionality they have.
And they must make that data and functionality available
via a service interface,
in other words via an API.
So for example, if you're in the marketing department
and you wanna get some data from the fulfillment department
like how much of the same products is being shipped out,
you can't just call them up anymore
and say can you run the numbers and send me a spreadsheet?
Instead the fulfillment department needs to write an API
and then the marketing department needs to write software
that can talk to the API.
And if you do it any other way you're gonna be fired.
Jeff Bezos was dead serious.
And it seems as though that was the culture back then,
people were genuinely scared of being fired
so they did as they were told.
Why was this mandate so important to Jeff Bezos?
Well, to see why you need to look at the consequences of it.
This is just hypothetical,
but suppose there's someone at Amazon
whose job it is to put books on the sale.
Well, there's someone else in Amazon that looks at the API
of putting books on sale
and they think, well I can use that to put jewelry on sale,
I'm gonna start a new team that sells jewelry on Amazon
or computer parts or something like that.
That's just the beginning of it.
This is the internal phase of changing the architecture
of Amazon to this API system.
During that time they learned an awful lot
like for example, I'm in department here with an API
and the department next door
could accidentally issue a denial of service attack
on my API because I've got some really useful data.
So they're querying my API every second
to refresh it on their screen and it's killing my servers.
So they very quickly needed to learn about quotas.
YouTube API has a quota
which is why I would love to update the title of this video
every five seconds,
but I'd quickly run out of my quota
so it has to be every few minutes.
They need to learn about authentication,
making their APIs discoverable
to everyone on like a sexual registry, for example.
And after all these learnings
they eventually reached a point where they could start
to expose some of their APIs to the public.
And so now members of the public can sell things on Amazon
and they can even do it programmatically with software.
For example, I can link the my Shopify shop
using their APIs to Amazon using their APIS.
But it goes beyond that.
You can use APIS to host a website on Amazon
using website hosting APIS.
That whole system is called Amazon Web Services, AWS.
And in 2018, AWS accounted
for over half of Amazon's revenue.
Amazon is predominantly a cloud service provider
which is weird 'cause we tend to think
about Amazon as a retailer.
Netflix is hosted on Amazon Web Services,
Reddit is hosted on Amazon Web Services.
It's incredible, really.
And that's the power of APIS.
Thank-you again to Tom Scott,
for the idea and for being okay with me making this video.
Once again, if you haven't seen his,
I really recommend it.
The link is in the description.
I've been thinking a lot recently about phone use,
my phone use and how it affects my mood,
and how it affects my relationships with other people.
And I've been going through a process
of stripping away the sorts of phone use
that is net negative leaving behind the types of phone use
that is net positive.
And it's surprisingly difficult to distinguish
between the two sometimes.
But what I figured out is it's all down
to finding good quality sources of information
and consuming that information at appropriate times.
And the sponsor of this video can really help with that.
Blinkist is an app that takes the key insights
from popular non-fiction titles
and condenses them down to 15-minute reads.
It also audio and narrate it so you can listen
to them as well.
I recommend appropriately digital minimalism
since they last sponsored one of my videos
they've added audio books.
So you can buy audio books for a vastly reduced price.
Members get about 65% off compared to buying it for price.
I recommend, for example, "American Sniper."
The first 100 people to go to blinkist.com/stevemould
will get one week of full membership absolutely free,
no strings attached.
You can cancel at any time.
And then 25% of membership if you choose to continue.
The link is also in the description.
So check out Blinkist today.
Hope you enjoyed this video.
If you did don't forget to hit subscribe
and I'll see you next time.
(upbeat music)