9 ms·
> By relying on these small rigorously tested libraries they are avoiding the need to test their own code, and thus avoiding basic null check or conversion erro
by saurik 11y ago
> By relying on these small rigorously tested libraries they are avoiding the need to test their own code, and thus avoiding basic null check or conversion errors.
In practice, many, if not most, of these one-line modules don't even work correctly, and it is difficult to get people to care to collaborate on fixing them instead of just replacing them with a new one-line module that works slightly better as the concept of complex collaboration to perfect one line of code is so foreign to a generation of developers who would rather just throw code to the world and never look back (an issue made all the worse as tiny bugs in these one-liners can almost seem dangerous to fix when you aren't really sure how they are being used: maybe it actually is better to not fix anything and just have people rely on the replacement better module :/).
- nailer 11y agoOdd, the ones I use all have tests, thousands of downloads, and active bug trackers. If I reinvented the wheel, or copy pasted, I wouldn't get those things.
- rantanplan 11y agoDoing a for loop is not equal to re-inventing the wheel. Words and phrases have lost their meaning nowadays. By the JS community's standards if I wanted code to capitalize the 3rd or sometimes 4th letters of a string, they would be 2 different npm modules. Maybe they didn't forget how to program, as the article implies; maybe they never knew how to program in the first place.
- nailer 11y agoWriting your own solution, when you could use a common widely known solution, exactly matches both writing your own left pad and inventing your own wheel. > By the JS community's standards if I wanted code to capitalize the 3rd or sometimes 4th letters of a string, they would be 2 different npm modules. If there was, it would have been published and people would be depending on it. Instead, people use the stdlib first, then big lego bricks like underscore, then (when they don't want the bulk of big lego bricks) smaller lego bricks. A single capitaliseMap() might be in there but it's a much more specific case than padding.
- rantanplan 11y agoA 1-line of code module matches your needs exactly just for today. When you have 100 such modules which don't quite work and don't quite need after a month(quite a long time for a JS project to exist untouched), then your dependency hell shows its ugly head. If you had years of experience in a wide array of technologies and languages, you'd be aware of that which is, and has been, obvious to the rest of us for the past 2-3 decades.
- nailer 11y ago> A 1-line of code module matches your needs exactly just for today. Nothing about function length determines utility. There are many one lines that match many people's needs repeatedly. > When you have 100 such modules which don't quite work This is worrying. How are you picking the modules you use? 100x popular modules from npm - with git repos, unit tests, READMEs, and hundreds of other users - beat 100x functions implemented in-house for NIH (or more likely, 100x functions copy pasted from Stack Overflow). > If you had years of experience in a wide array of technologies and languages Please don't assume things about other people. It's very rude, and it makes you look bad when you're wrong.
- rantanplan 11y agoWorry not my friend. I'll take the risk of being wrong. Up to now, it seems that there's consensus on the fact that the JS/frontend world is the worst offender when it comes to engineering robust software. At least there are JS programmers that seem aware of it and agree that this has to change. So there's still hope I guess.
- nailer 11y agoI think there are people who are aware of the problem, but that problem is people reinventing the wheel a thousand times, and relying on copypasta and needless work rather than package management.
- lotsoflumens 11y ago
- jmtd 11y agoThe OP's example ( is-positive-integer) has tests, and is only three lines long, and is on major release version 3.X, because despite all that, it had serious problems in versions 1 and 2.
- philh 11y ago"Serious problems in versions 1 and 2" suggests that it might be a good idea not to write your own version 1. But to be explicit about the history: version one[0] had dependencies. Version two[1] had no dependencies, and a comment on github suggests that it might be wrong but I can't immediately see how. Version three[2] is a different implementation, and adds another export. [0] https://github.com/tjmehta/is-positive-integer/commit/3003f948b8d95fa234e1d9d41d5423467ec593b0#diff-168726dbe96b3ce427e7fedce31bb0bcR1 https://github.com/tjmehta/is-positive-integer/commit/3003f9... [1] https://github.com/tjmehta/is-positive-integer/commit/b47e90cdb6111745e1dc10cd31a50d32341c0770 https://github.com/tjmehta/is-positive-integer/commit/b47e90... - it should return false for 0, so I'm not sure what the commenter is getting at [2] https://github.com/tjmehta/is-positive-integer/commit/3cdfe139e5dee859a958452e3833946dcec2ce41 https://github.com/tjmehta/is-positive-integer/commit/3cdfe1...
- x1024 11y agoCase in point: the left-pad package has quadratic complexity.
- mcguire 11y agoDepends on the JS implementation in question. And I think node uses one that optimizes string concatenation, possibly making that the fastest way to do it.
- emodendroket 11y agoYeah, as far as I know in modern JS engines += is actually faster than using an array.
- x1024 11y ago[citation needed] It's really nice how we once again depend on "I think some guys do it like this" for performance. What happened to standards? What's next? SEO for code?