Placeholder Image

字幕列表 影片播放

  • Every YouTube video has a unique ID.

    每一部 YouTube 的影片都有自己的代號。

  • It's up in the URL: a string of eleven characters


  • that uniquely identifies which video you want.


  • Now, YouTube has millions and millions of videos.

    時至今日,YouTube 上有數以百萬計的影片。

  • The last stats that they released said they have

    最近有統計指出在 YouTube

  • 400 hours of video being uploaded every minute.


  • So: are they ever going to run out of those IDs?


  • Well, to find out, let's talk about counting systems.


  • People count in Base 10. 0 to 9.

    我們人類數數以 10 為底,從 0 到 9。

  • That'll be, hopefully, familiar to you.


  • Computers count in base 2, in binary,

    電腦 (計算機) 則是以 2 為底的 2 進位,

  • but that's difficult for humans to read,


  • it gets too long to write really, really quickly,


  • so often computers will display it in base 16, hexadecimal.

    所以來說一般在電腦 (計算機) 上是以 16為底的 16 進位

  • You have 0 to 9, and then A to F,

    你會從 0 算到 9 再來是 A 到 F (10 ~ 15),

  • and then you start adding to the next column.


  • Humans can't understand that easily,

    對於 16 進位人類無法一看就懂,

  • but it's efficient if we have to type it in somewhere,


  • and 16 - 2 to the power of 4 - is also easy for computers to deal with.

    再說16,也就是 2 的 4 次方,對電腦 (計算機) 來說也是很容易處理的。

  • So how about Base 64?

    那麼 64 進位呢?

  • That'd be a ridiculous counting system, right? Except.


  • 64 is another one of those easy numbers for computers,

    64 對電腦 (計算機) 來說只不過是另一個簡單的數字罷了

  • it is 2 to the power of 6.

    它 (64) 是 2 的 6 次方

  • And humans can get to 64 very easily:

    人類想要湊出 64 也並非難事:

  • 0 to 9, then capital letters A to Z,

    從 0 到 9,然後大寫的 A 到 Z

  • then small letters a to z, and two other characters.

    再加上小寫的 a 到 z,最後再加兩個其他符號。

  • Most Base 64 uses slash and plus,

    大部分的時候是用 / 和 + (斜線和加號)

  • but they don't work so well in URLs,


  • so YouTube uses hyphen and underscore.

    所以 YouTube 改用 - 和 _ (連字號和底線)

  • That YouTube URL, that unique ID,

    我們說的 YouTube 的網址,那串獨一無二的代碼

  • is really just a random number in base 64.

    就只是一串以 64 為底的亂碼罷了。

  • They could have have picked base 10 or base 16,

    他們 (YouTube) 大可選用以 10 為底或是以 16 為底,

  • but they didn't: they went with 64,

    但他們 (YouTube) 沒有:他們選擇以 64 為底,

  • because it will let you cram a huge number into a small space


  • and still make it vaguely human readable.


  • Author and programmer Sam Hughes, by the way,

    順帶一提,身為作家和工程師的 Sam hughes

  • pushed this to the limit, and invented Base 65,536,

    將此一方法發揮到了極致,創造了 65536 進位,

  • which includes basically every character from every language.


  • It is ridiculous and unnecessary,


  • but when has that ever stopped programmers?


  • So why didn't YouTube just start counting at 1 and work up?

    那麼為什麼 YouTube 不從 1 開始然後往上加就好了呢?

  • Well, first, they would have to synchronise their counting


  • between all the servers handling the video uploads,


  • or they'd have to assign each server a block of numbers.


  • Either way, there's a lot of tracking to do,


  • a lot of making sure that it's never duplicated.


  • Instead, they just generate a random number for each video,


  • see if it's already taken, and if not, use it.


  • And secondly, it is a really, really bad idea


  • to just count 1, 2, 3 and so on in URLs.

    1, 2, 3 等等的數字絕對不是一個好主意。

  • Incremental counters, as they're called, can be a big security flaw:


  • if you see video 283 up there, then you might wonder:

    如果你看見了一個編號 283 的影片,你一定會想:

  • what's video 284? Or video 282?

    編號 284 的影片是什麼?那 282 呢?

  • It's easy to enumerate, as it's called,


  • to run through the entire list.


  • YouTube Unlisted videos, the ones that don't appear publicly

    用遞增記數的話就做不到影片非公開了(YouTube 上的非公開影片,

  • but that you can send the link to people, those wouldn't work.


  • And by the way? Lots of badly designed sites do use incremental counters.


  • And it is a terrible idea.


  • It might tell your competitors exactly how many customers you have,


  • 'cos they can just count them.


  • It might let people download all your records easily,


  • 'cos they can just run through them.


  • And in one site that someone in Florida emailed me about this week,


  • it lets you look at other people's personal details.


  • Don't use incremental counters if you're building a web site. Use a random number.

    如果你要架設網站的話請記住要用『亂數』, 『不、要、用、遞、增、記、數』

  • Which brings me to the question:


  • just how big are the numbers that YouTube uses?

    YouTube 到底用了多大的數字?

  • Well, let's work it out.


  • One character of base 64 lets you have 64 ID numbers.

    64 進位的一位數可以有 64 個不同的 ID

  • Two characters? That's 64 by 64, or 4,096.

    兩位數?就是 64 x 64 = 4096

  • Three characters? 64 times 64 times 64 -- or 64 to the power of 3.

    三位?64 x 64 x64 或是 64 的三次方。

  • That is already more than a quarter of a million.

    而這個數字已經超過 25 萬了

  • And if we go to four? Well, now we're above 16 million.

    四位數呢?那就是大於 1600 萬了

  • If you use Base 64, then you can assign an ID number

    如果用 64 進位的話,就可以生產出足以

  • to everyone who lives in London down there twice over,


  • and you'll only need four characters.


  • This gets big fast. We can keep on doing this,


  • and by seven characters we're already at four quadrillion.

    當我們用了七位數的時候就會得到超過 四兆 組的代碼。

  • Now, I assume that YouTube checks through a dictionary,

    呃...在這邊我希望 YouTube 有先檢查過,

  • and doesn't allow any actual words to appear up there --


  • particularly anything rude.


  • But that is going to be a tiny minority of the URLs,


  • so for our purposes, we can pretty much just ignore that.


  • At YouTube's 11 characters, we are at 73 quintillion 786 quadrillion

    而 YouTube 用 11 位數產生的代碼可供 7378 京 (京:10^16)

  • 976 trillion 294 billion 838 million

    6976 兆 2948 億

  • 206 thousand and 464 videos.

    3820 萬 6464 部影片使用

  • That's enough for every single human on planet Earth

    而這足以讓這顆星球上的 每、一、個、人

  • to upload a video every minute for around 18,000 years.


  • YouTube planned ahead.

    YouTube 在這方面領先群雄啊

  • Can they run out of URLs? Technically, yes.

    他們的網址會有用完的一天嗎? 理論上來說,會。

  • Practically? No. And if they did?

    實際上呢?並不會。 但如果真的用完的話呢?

  • They could just add one more character.


  • [Translating these subtitles? Add your name here!]

    翻譯:Andy Lin

  • Ha! One take! One take! Yes!


Every YouTube video has a unique ID.

每一部 YouTube 的影片都有自己的代號。


影片操作 你可以在這邊進行「影片」的調整,以及「字幕」的顯示

B1 中級 中文 英國腔 網址 位數 影片 代碼 數字 計算機

Will YouTube Ever Run Out Of Video IDs?

  • 807 39
    Samuel 發佈於 2018 年 05 月 25 日