4 ms·
> What exactly does colors do? A picture is worth a thousand words → https://i.imgur.com/inxA7Pg.png https://i.imgur.com/inxA7Pg.png The library inserts ANSI
by guessmyname 5y ago
> What exactly does colors do?
A picture is worth a thousand words → https://i.imgur.com/inxA7Pg.png https://i.imgur.com/inxA7Pg.png
The library inserts ANSI escape sequences [1] between the text you want to colorize in order to, well, colorize it ¯\_(ツ)_/¯
Many people are obsessed with colors in the Terminal, and so, they reach out to libraries like this. They exist in every major programming language ecosystem, even though colorizing text is as simple as writing this \x1b[48;5;011<TEXT>\x1[0m . One of the disadvantages of this rudimentary colorization technique is that if you have short-term memory, you will quickly forget the meaning of these numbers, but you can solve that problem with constants, there is no reason to install a third-party library with potentially malicious code to add this type of functionality to a high-profile project like AWS-CDK [2].
I wish these libraries would support NO_COLOR [3] more consistently.
I have seen many “modern” CLI tools (the ones people like to build using Rust or Go) overuse colors with no option to disable them.
[1] https://stackoverflow.com/a/33206814 https://stackoverflow.com/a/33206814
[2] https://github.com/aws/aws-cdk/pull/18324/files https://github.com/aws/aws-cdk/pull/18324/files
[3] https://no-color.org https://no-color.org
- hnthrowaway0315 5y agoWhy wouldn't everyone roll their own solution? Doesn't seem to be a huge thing to me, but I could be wrong...
- guessmyname 5y ago> Why wouldn't everyone roll their own solution? Doesn't seem to be a huge thing to me, but I could be wrong... Laziness; and people’s infatuation for dependency trees, especially those in the Node.js & JavaScript ecosystems.
- cerved 5y agoexhibit A > even though colorizing text is as simple as writing this \x1b[48;5;011<TEXT>\x1[0m
- jamil7 5y ago> Why wouldn't everyone roll their own solution? JS devs will do anything to avoid this.
- gitgrump 5y agoHonestly? They probably don't know how, or that's just not part of the JS culture. I've met a lot of JS-only developers, and most probably don't even know what ANSI escape sequences are, let alone how to work with them. The lack of basic computer knowledge from the JS ecosystem is shocking. I don't expect this to poll well in Peoria, as it were, but this has been my consistent observation.
- phkahler 5y agoSo the big question is why someone is bent out of shape for not getting MRR for writing that.