Hasty Briefsbeta

I decided to make a worse UUID for the pettiest of reasons

21 days ago
  • #UUID-alternative
  • #database-indexing
  • #Go-programming
  • The author created 'smolid', a shorter alternative to UUID for aesthetic and practical reasons in API projects.
  • Smolid is URL-friendly, temporally ordered, and fits into 8 bytes (a uint64 in Go), making it suitable for database indexing.
  • It includes a 41-bit millisecond-precision timestamp, 2-bit versioning, a type flag, and random bits for uniqueness.
  • The timestamp uses a custom epoch starting from 2025-01-01, with an overflow date in 2094.
  • Smolid allows embedding a 7-bit type identifier, useful for distinguishing between different kinds of IDs (e.g., user, post, comment).
  • Collision probability is higher than UUID, especially under high generation rates (e.g., 100,000 IDs per second).
  • The author acknowledges UUID's superiority in global uniqueness but prefers smolid for specific use cases.
  • Smolid is implemented in Go with support for JSON marshaling, database operations, and other standard interfaces.
  • The author plans to use smolid in personal projects but doesn't recommend it universally due to its limitations.