Live data from Hacker News

Micro-libraries should never be used

bvisness.me

171–179 of 179 posts

Re: Micro-libraries should never be used

#171

Earlier quoted context omitted.

> Micro-libraries are really good actually, they're highly modular, self-contained code Well I think that is the point, they're not self-contained. You are adding mystery stuff and who knows how deep the chain of dependencies go. See the left-pad fiasco that broke so much stuff, because the chain of transitive dependencies ran deep and wide. NPM is a dumpster fire in this regard. I try to avoid it - is there a flag y…

There is a "no downstream dependencies" option; it's called writing/auditing everything yourself. Everything else -- be it libraries, monolithic SaaS platforms, a coworker's PR, etc. -- is a trade off between your time and your trust. Past that, we're all just playing musical chairs with where to place that trust. There's no right answer.

The article doesn't claim to have an answer for everything. The article argues that tiny i.e. micro libraries are a almost always a bad tradeoff.

Re: Micro-libraries should never be used

#173

Earlier quoted context omitted.

They are not designed for modern use cases and certainly not well-designed according to modern understanding of this word. In fact they did not stood the test of time as something worthy of preservation, they only survived and mutated, because it is extremely hard to replace them. And of course we should blame the technology: the sole purpose of a standard is to be used by people. If people struggle with it the stand…

> And of course we should blame the technology: the sole purpose of a standard is to be used by people. If people struggle with it the standard is unfit for its purpose. 'People' is equivocal here. While complex, and (as you point out, in so many words) an evolved standard, the HTML/CSS/JS stack is arguably one of humanity's greatest achievements, up there with the invention of paper, or perhaps cuneiform. It's imper…

> HTML/CSS/JS stack is arguably one of humanity's greatest achievements

We deserve to go extinct.

Re: Micro-libraries should never be used

#174
post #86

Earlier quoted context omitted.

This is just a discourse based on "I need to churn out something, I need that fast and I didn't start in the web game when Backbone and E4X were solid corporate choices". If you are not in a hurry, work in a solid team and have a good attention span, a lot of clickbait idiocy around JS may not happen. It's just that the lone inexperienced guy is one of millions inexperienced guys who are taught the wrong ways everyda…

I don't really see the problem with the CRA docs.

You will never see it, blinded by a sound experience in UNIX.

Re: Micro-libraries should never be used

#175
post #21
post #15

Micro-libraries are really good actually, they're highly modular, self-contained code, often making it really easy to understand what's going on. Another advantage is that because they're so minimal and self-contained, they're often "completed", because they achieved what they set out to do. So there's no need to continually patch it for security updates, or at least you need to do it less often, and it's less likely…

> I would argue the problem is how dependencies in general are added to projects But you need the functionality anyway, so there are two dependencies: on your own code, or on someone else's code. But you can't avoid a dependency, and it comes at a cost. If you don't know how to code the functionality, or it will take too much time, a library is an outcome. But if you need leftPad or isNumber as an external dependency…

If incompetent it provides a way to be sure?

Could you for laughs explain for which cases these are, why they are needed and why they did it this way?

1) num-num === 0

2) num.trim() !== ''

3) Number.isFinite(+num)

4) isFinite(+num)

5) return false;

6) Why this specific order of testing? Why prefer Number.isFinite over isFinite?

https://www.npmjs.com/package/is-number

   module.exports = function(num) {
     if (typeof num === 'number') {
       return num - num === 0;
     }
     if (typeof num === 'string' && num.trim() !== '') {
       return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
     }
     return false;
   };
I would have just....

    isNumber = num => isFinite(num+''.trim());
Why is that not precisely the same? (it isn't)

how about...

   function isNumber(num){
     switch(typeof num){
       case "number" : return !isNaN(num);
       case "string" : return isFinite(num) && !!num.trim();
     }
   }
Is there a difference?

IMHO NPM should have a discussion page for this. There are probably interesting answers for all of those looking to copy and paste.

Re: Micro-libraries should never be used

#176

Earlier quoted context omitted.

HTTP, HTML and to some extent CSS are solid technologies that are very well designed and has been standing thr test of time. How people use them is another matter. But don't blame that on the technology.

They are not designed for modern use cases and certainly not well-designed according to modern understanding of this word. In fact they did not stood the test of time as something worthy of preservation, they only survived and mutated, because it is extremely hard to replace them. And of course we should blame the technology: the sole purpose of a standard is to be used by people. If people struggle with it the stand…

You are 100% right but it's no reason to pick on web in particular! When you hit a site, you may have a virtual HTML environment running a JIT virtual machine from a server that's running a virtual python environment on a virtual python environment on a virtual machine on a virtual machine, and all that runs on a virtual x86 processor which in reality is a series of microcode processors. Yes, yes, it would be so much simpler to have your web go straight to the source, microcode, and yes, things would be simple and fast... .. but ... but ABSTRACTION!!!! LETS ABSTRACT EVERYTHING EVER AS MANY TIMES AS POSSIBLE WITH AS MANY ABSTRACTION LAYERS AS POSSIBLE IT GENERALIZES TO THE GENERAL CASE ABSTRACTION GENERALIZES ALL CASES WOOOOWWWW THE COMPUTER SCIENCE OF IT ALL

That is the state of things.

Re: Micro-libraries should never be used

#177
post #175
post #21

Earlier quoted context omitted.

> I would argue the problem is how dependencies in general are added to projects But you need the functionality anyway, so there are two dependencies: on your own code, or on someone else's code. But you can't avoid a dependency, and it comes at a cost. If you don't know how to code the functionality, or it will take too much time, a library is an outcome. But if you need leftPad or isNumber as an external dependency…

If incompetent it provides a way to be sure? Could you for laughs explain for which cases these are, why they are needed and why they did it this way? 1) num-num === 0 2) num.trim() !== '' 3) Number.isFinite(+num) 4) isFinite(+num) 5) return false; 6) Why this specific order of testing? Why prefer Number.isFinite over isFinite? https://www.npmjs.com/package/is-number module.exports = function(num) { if (typeof num ==…

I don't care. The problem in this case is that if you install "isNumber", you use someone else's definition of what a number is. If you ever have to check if something is a number, you should do that according to your own specs, not hope someone else got it right. In this case, strings with all kinds of weirdness seem to be allowed, and perhaps that's not acceptable.

Only the fact that you can write a bunch of slightly different versions because of Javascript's flaws/features should be a sign that you just can't grab an arbitrary implementation and hope it matches your use case, and especially not if you don't/can't pin the version.

Re: Micro-libraries should never be used

#178

Earlier quoted context omitted.

The whole web stack must die and be replaced. JS, CSS, HTML, HTTP are huge cost center for global economy.

Strongly disagree, but for JS. Current web stack is very complicated, HTML and CSS DOM is a rats nest and that's a superficial example. Adding asynchronous rpc pushes that way over the top. Luckily HTTP has been through the production crucible for 30 years. What I see is not a cost center but a reflection of basic truth: - UI and data representation is hard. - Developers use the tools they know about. But about micro…

Remind me which part of web has ===? I don't think it's HTML or CSS.

Re: Micro-libraries should never be used

#179
post #15

Micro-libraries are really good actually, they're highly modular, self-contained code, often making it really easy to understand what's going on. Another advantage is that because they're so minimal and self-contained, they're often "completed", because they achieved what they set out to do. So there's no need to continually patch it for security updates, or at least you need to do it less often, and it's less likely…

Micro libraries are ok - TFA even says you can use self-contained blocks as direct source . Mirco dependencies are a god damn nuisance, especially with all the transitive micro-dependencies that come along, often with different versions, alternative implementations, etc.

If you're writing micro libraries, without intending to reuse them, why are you making it a library?
Post reply on HN