Now that Twitter auto-shortens URLs (and expands them in the UI), is there really a use left for URL-shorteners? Are there any other major platforms where text length matters?
The biggest advantage of URL shorteners, outside of the length, is the ability to quickly generate URLs that are track-able, instead of constantly adding campaigns with something like grasswire.com/1234?refid=twitter, which is how a lot of marketers track where their clicks come from.
In print: I like how net magazine uses netm.ag/description-123 for any links so it's easy to type and doesn't take up too much space. This also gives analytics for print articles where you normally can't watch whether anyone followed a link
You don't need to rely on routing through Twitter. Works when Twitter blocked or down. Branding.
Also tracking.
Also you can modify where the link points after distributing it in case you notice a mistake.
Good catch - it doesn't. We'd need to add a line to check for collision and retry. Better yet is to use hashing instead of random string as some folks mentioned in the comments on the blog.
As far as I am aware, the standard implementation of a URL shortening algorithm is to convert the number to a higher base, not to generate a random string. This has the advantages of greater loading speed, and smaller storage size.
I know scala is very powerful, but I think this code proofs to me that scala code is difficult to read. I'm a pro functional programmer, but scala mixes too many concepts.
'pseudo' Python url shorterner in 14 lines of code:
I believe you'll have a lot of collisions that way, as two URLs with the same 7-byte suffix in base64 will have the same key. The Scala version uses 7 random characters, which I think will lead to a collision after about sqrt(36^7) entries due to the birthday paradox (62^7 if alphanumeric includes both uppercase and lowercase). That's better, but I'd recommend just using something autoincrementing instead, which in theory makes collisions impossible.
reply