4 ms·
Know what happens every time people like you say this here on HN? They post the one-liner they would have manually implemented in their code base and it's wrong
by exogen 6y ago
Know what happens every time people like you say this here on HN? They post the one-liner they would have manually implemented in their code base and it's wrong. The one that comes to mind is the "is-negative-number" package. Yes, the geniuses of Hacker News, after finding out there was an npm package for determining whether something was a negative number, could not correctly implement that function.
You and everyone here are not as clever as you think you are. This is why people prefer known-good implementations. The maintainer here did a bad release, big fucking deal.
- vel0city 6y agoMaybe its a failure of the language when it takes a third party package to determine if a number is greater than or less than zero?
- exogen 6y agoTheir code would have been wrong even in strongly typed languages because it considered 0 to be a negative number. What language prevents you from making that mistake?
- krapp 6y ago> Maybe its a failure of the language when it takes a third party package to determine if a number is greater than or less than zero? It's not a failure of the language. Javascript has comparison operators like every other language, it's entirely possible to determine if a number is greater than or less than zero without importing a third-party package. What it is is a failure of modern JS development culture, because apparently it's anathema to even write a simple expression on your own rather than import a dependency tree of arbitrary depth and complexity and call a function that does the same thing.
- andrewzah 6y ago> COULD NOT CORRECTLY IMPLEMENT THAT FUNCTION As opposed to blindly trusting and adding a dependency for a random library with a one liner? I don't think the "don't roll your own crypto" argument really applies here. Of course we can come up with hypothetical situations where developers are incompetent or don't test their code at all. This includes armchair analysis for a post on HN, by non-javascript developers. I would argue that it's still better than adding a dependency. Heck, you could even copy/paste the correct code. I know I'm not a perfect programmer, so important functionality like this gets unit tested as necessary. :-)
- exogen 6y agoA package with over 11 million weekly installs vs. a brand new implementation by a coworker, when I might not necessarily be around for the code review? Absolutely. I would blindly trust the package 100% of the time. Zero hesitation.
- quantummkv 6y agoAs demonstrated in this reply - https://news.ycombinator.com/item?id=22979718 https://news.ycombinator.com/item?id=22979718, this package is also wrong. So the argument is invalid?
- exogen 6y agoThe package isn't wrong, you're just confused about duck typing.
- dang 6y agoPlease don't use allcaps for emphasis on HN. This is in the site guidelines: https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html. As a stretch target: it's a bad idea to create demons out of an assortment of posts you randomly saw on HN. This site gets 3M posts a year. You can find basically anything in there. https://news.ycombinator.com/item?id=22098687 https://news.ycombinator.com/item?id=22098687 What happens is that we each have pre-existing images that bug us (e.g. for example, people who overrate their own genius) and as we move around in the statistical cloud, random bits of whatever we run into stick to the pre-existing image and give it form. Poof, you have a demon—but actually it just became visible. Readers with other images see other demons and arrive at other generalizations. It's not good discussion because it's really about one thing but we make it about another, and comments that are skewed in that way limit their own interestingness. (I definitely don't mean to pick on you personally. We all do this.)
- bdcravens 6y agoYou may be shocked to find that there are very novice developers as well as those with 20+ years of experience who frequent HN. Using a few poorly written comments is a strawman, unless the comments you're referring to are written by the same people you're addressing here.