Why does reddit use base36 for article id?
Why does reddit use bas开发者_运维问答e36 for article id?
For example:
a2xki
Probably because:
Base 36 is... the most compact case-insensitive alphanumeric numeral system using ASCII characters
By using only alphanumeric characters and being case-insensitive, two types of errors are dispensed with: input in the wrong case (or filesystem issues and confusion due to case-sensitivity), and special characters in the URL. When a URL has characters that are reserved according to RFC 2396, those characters must be escaped (which would elongate and uglify the URL). But various application-level bugs also make use even of unreserved characters like '
and !
undesirable (some examples: 1 2 3).
Even with the alphanumeric and case-sensitive restrictions, base 36 still provides a much more compact representation than decimal, allowing for short and (arguably) clean-looking IDs. The ID of this article would be 36351705 in decimal; it's 3 fewer characters when represented in base 36.
Second Just Some Guy (you can represent with [a-z0-9]), Also,
- This scheme should produce very short IDs.
- Easy to use these IDs to create on disk structure.
- Easy to convert to numeric IDs to look up database, etc.
It's easy to give to others in email, verbally, chat windows, etc. The URL would certainly allow more characters, but this is less confusing, especially if you have to read the link over the phone, in a video, on TV, or even typing it in from a printed article or newspaper.
It's very human friendly.
Because you can represent it with [a-z0-9], most likely.
精彩评论