NPM and Left-Pad: Have We Forgotten How to Program?
431–440 of 887 posts
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#432Re: NPM and Left-Pad: Have We Forgotten How to Program?
#433Holy moly-- is-positive-integer/index.js: var passAll = require('101/pass-all') var isPositive = require('is-positive') var isInteger = require('is-integer') module.exports = passAll(isPositive, isInteger) I retract my previous statements that Javascript programmers are going down the same enterprise-y mess that Java programmers went down a decade ago. They've already taken it to an entirely different level of insani…
Plus, if you think that's too small, write your own broader module that does a bunch of stuff. If people find it valuable, they'll use it. If they find it more valuable than a bunch of smaller modules, you'll get 10,000 downloads and they'll get 10.
The module you roundly ridicule has had 86 downloads in the last month, 53 of which were today (at the time of this writing). I imagine most of those 53 were after you posted. So that's 40 downloads in a month, as compared to the express framework which has had 5,653,990 downloads in the last month.
The wailing and gnashing of teeth over this module is ridiculous.
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#434Earlier quoted context omitted.
> TL;DR: Small modules are easy to reason about, and encourage code reuse and sharing across the entire community. How does that even remotely applies to the "is positive integer" test, and even more so to "it's positive" and "it's integer"? What's next? is-bigger-than-5? word-starts-with-capital-letter? add-1-to-a-number?
If you want to build is-bigger-than-5 yourself, I recommend pulling in fivejs[1] as a dependency. [1] https://github.com/jackdcrawford/five
We're doing a GSoC for efficient templating of real number though.
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#435Earlier quoted context omitted.
> TL;DR: Small modules are easy to reason about, and encourage code reuse and sharing across the entire community. How does that even remotely applies to the "is positive integer" test, and even more so to "it's positive" and "it's integer"? What's next? is-bigger-than-5? word-starts-with-capital-letter? add-1-to-a-number?
add-1-to-a-number This seems to be a very common example in educational materials about how to create a function in some programming language. Perhaps they should all be prefaced with "NOTE: you should not actually make such a function, because its triviality means that every time you use it you will be increasing the complexity of your code", or a longer discussion on when abstraction in general is appropriate and w…
That's the whole point. If you use is-positive-integer, you won't have to think about the negatives!
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#436Earlier quoted context omitted.
It really is the fault of the language that something this fundamentally horrible is allowed to exist in itself. When people ask why Javascript is terrible, show them this.
The same could be said for your post. When people ask why commenting on message boards is terrible, show them this. If you don't want to write modules this way, don't. Nothing about javascript requires that you even read articles about modules that you don't want to use. Or read articles and then follow up by posting on message boards about articles about modules you aren't going to use. Bang some code out instead. Y…
There's no such thing as "don't use it if you don't like it!" in this case.
Javascript is a completely broken, shameful system that rightfully deserves all the scorn it's gotten. It really is the worst.
(note that i actually write Python & VanillaJS, and avoid Node packages entirely for now.)
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#437Earlier quoted context omitted.
You'd have a good point, if all of those tiny but probably useful modules were given the use you're describing. Discoverability though is so poor that most of those modules are most likely just used by the author and the author's co-workers. If a typical npm user writes hundreds of packages, how the hell am I supposed to make use of them, when I can't even find them? Npm's search is horrendous, and is far from useful…
Can we ever achieve this? We can't exactly search the code to find out what it does, otherwise you'd basically be reading all the code to discover it's true behavior, which negates the usefulness of modules in the first place... Any search will have to rely on developer-made documentation, and/or meta data. This is great in theory, but documentation is rarely well maintained, and/or someone changes the code but negle…
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#438Re: NPM and Left-Pad: Have We Forgotten How to Program?
#439Earlier quoted context omitted.
You should then go dive into the passAll function: https://github.com/tjmehta/101/blob/master/pass-all.js It’s written in such a way that every time you call... passAll(f1, f2, ..., fn)(args..) ... there are something like 5 + 2n attribute accesses, 5 + 3n function calls, 3 + n new functions created, as well as some packing and unpacking of arguments, not including the actual application of the functions to the argum…
Lol, nice, I wrote "pass-any" first. I then copied the code and replaced "or" w/ "and" to create "pass-all". I will probably have go back and change this now that I know about it. In general though, not gonna a lie, I am not very concerned about micro performance optimizations.
Because if people start using it for such things as an "is positive integer" check (Which, to be fair, they should not be doing. Nobody should be constructing 2 new javascript functions every time they want to check if an object is a positive integer. But apparently they are...), then it could easily make its way into somebody’s inner loops.
The end result of this general culture (not picking on anyone in particular) is that trivial Javascript programs end up having their performance tank, because every tiny bit of useful real work gets weighed down by two orders of magnitude of incidental busywork creating and tearing down abstractions built on towers of other abstractions. Because CPUs aren’t very well optimized for this kind of workload, which involves lots of branching and cache misses, it’s worse still, probably more like 4–5 orders of magnitude slower than optimized code written in a low-level language.
Ultimately every idle facebook page and gmail page and news article in some background browser tab ends up sucking up noticeable amounts of my laptop’s CPU time and battery, even when they’re doing nothing at all for me as the user.
Re: NPM and Left-Pad: Have We Forgotten How to Program?
#440Earlier quoted context omitted.
> TL;DR: Small modules are easy to reason about, and encourage code reuse and sharing across the entire community. How does that even remotely applies to the "is positive integer" test, and even more so to "it's positive" and "it's integer"? What's next? is-bigger-than-5? word-starts-with-capital-letter? add-1-to-a-number?
If you want to build is-bigger-than-5 yourself, I recommend pulling in fivejs[1] as a dependency. [1] https://github.com/jackdcrawford/five