by bmn__ · 9y ago · 0 comments
The nanoid implementation does not really bring anything new to the table except having fewer SLOC (which I personally don't find important). It is also incompatible with https://tools.ietf.org/html/rfc4648#section-5 for no good reason. It is noticable again and again that devs publishing to npm are not up to snuff, I wish I knew why, as this does not happen with other dynamic languages/their code repos.
It absolutely does happen with other languages. It just happens in Node with greater volume because of the greater volume of programmers, low barriers to entry for JavaScript, lack of a rich standard library, the convergence of server focused coders and frontend coders, and lack of consensus around best practices and frameworks for applications.
Kind of the way it's been possible to write decent code in PHP since version 5. Yet the overall ecosystem is still mostly bad.
Lots of need to fashion very basic tools + high volume of inexperience + democracy = A package repo full of nonsense where it's difficult to find the diamonds in the rough.
https://tools.ietf.org/html/rfc4648#page-7
Note that it excludes the use of ~ because it has special meaning in some file systems. Nano ID includes ~. It's a good demonstration of why sometimes a standards comittee is better than a lone developer: A group of people and reviewers are more likely to think of everything.
But then, there are people who'd like to use 62-character alphabet, avoiding any special characters. This package allows them do generate such strings.
> devs publishing to npm are not up to snuff
Indeed, there are tons of packages that use Math.random or take modulo without accounting for bias. This is why I'm glad there are new packages like nanoid appearing, created by people who know what they are doing, and this is why your negativity is unfounded.
Because it's a standard data type. It's supported by the database and the data abstraction layers. I can use other implementations for creating, storing and retrieving UUIDs because they backed by the standard and are interoperable. I don't get these advantages with your ad-hoc approach. The loss of 4 bits do not hurt me.
> this is why your negativity is unfounded
I was criticising the needless deviation from an encoding standard. You talk about how it's good that nanoid picked the correct random algorithm. That just does not fit together.
Btw, if you'd remove emotional "old crappy" from the sentence, it would sound pretty sacrastic.
JS stdlib has always be lacking in almost every possible aspects, and hence people have to reinvent the wheel again and again.
FWIW. I have also always done the exact Base64 UUID op suggested when I need a shortened unique identifier...