Earlier quoted context omitted.
Of course you can use `asprintf` to pad a string like you can use a for loop to pad a string in JS. But it's not a dedicated named function to pad strings like the `leftpad` we're discussing. Kind of missing the point of the argument. Given how simple and popular `left-pad` module is (indicating the principle the community uses to determine granularity), I'd guess that if `String.format` was available in JavaScript t…
It's a memset followed by a strncpy, hardly worth linking to a library for. You'd be done writing the function before you finish googling for an existing one.
Left-pad as a service
141–150 of 269 posts
Re: Left-pad as a service
#142Re: Left-pad as a service
#143Cool, but it would be more useful if they had a npm module for accessing the service.
Re: Left-pad as a service
#144Hahaha - isn't it hysterical how everyone using npm for small reusable code pieces! Aren't they morons! How stupid of people to trust their package manager to be consistent and correct and return packages they were expecting. How stupid of people to reuse small often used functions that only do one thing well. How does everyone taking the piss intend to protect themselves from this in their OS package manager, or PPM…
Correct, it's the fault of the devs who prioritize their ego and feeling trendy over the practicalities of software design. JavaScript is not a good platform for Real Work(TM). The fact that the stdlib is tiny and such basic functions have to be imported from some random guy's library is a testament to this fact.
Personally I can't wait for the JS-everywhere fad to die out.
Re: Left-pad as a service
#145Nice, it is even bug compatible http://api.left-pad.io/?str=foo&len=7&ch=12 return {"str":"12121212foo"} and not {"str":"1212foo"}
Re: Left-pad as a service
#146Earlier quoted context omitted.
Of course you can use `asprintf` to pad a string like you can use a for loop to pad a string in JS. But it's not a dedicated named function to pad strings like the `leftpad` we're discussing. Kind of missing the point of the argument. Given how simple and popular `left-pad` module is (indicating the principle the community uses to determine granularity), I'd guess that if `String.format` was available in JavaScript t…
A function is dedicated if it is well-suited for a use case. It does not require it to be ill-suited for other use cases. Either you arguing that `left-pad` is not a "dedicated" function for padding by 42 characters, because it can also pad for 43 or 41, or I don't understand you at all?
The examples were really secondary to the point of my argument, which was about packaging functions into modules, not about the C language.
Re: Left-pad as a service
#147Earlier quoted context omitted.
Everybody makes fun of PHP.
Except people busy running businesses and creating with it.
Re: Left-pad as a service
#148Earlier quoted context omitted.
That still isn't enough to refute "The reason so many people are criticizing left-pad et al is about the cost of adding a dependency.". Sure, npm may be a bad package manager. If you do have a bad package manager, there is a cost of adding a dependency, and you should consider it. That's what pdkl95's point was. Most other ecosystems, with good or bad package managers, do not have tiny one-function packages -- it's p…
> If you do have a bad package manager, there is a cost of adding a dependency, and you should consider it. That's what pdkl95's point was. That's great, and my point was that with a good package manager, that cost is effectively zero. > And the dependency cost I talk about is universal -- any package manager that allows for easy package updates is open to critical packages being broken. Automatic updates are a terri…
yes, which doesn't refute pdkl95's point. If you're not in the world with a good package manager, you should consider the cost of the dependency. The Node ecosystem seems to not have done that. That's the bottom line here, if there is a cost to dependencies (which you don't seem to disagree with, at least wrt NPM), then you shouldn't have dependencies for 11-line functions. Everything else is orthogonal.
Re: Left-pad as a service
#149Earlier quoted context omitted.
Except people busy running businesses and creating with it.
We run almost everything on Wordpress and still make fun of PHP. And JS. And Java. And ObjC. And Ruby. And Python. Every language has its share of problems and sometimes you just have to vent.
Re: Left-pad as a service
#150Earlier quoted context omitted.
Of course you can use `asprintf` to pad a string like you can use a for loop to pad a string in JS. But it's not a dedicated named function to pad strings like the `leftpad` we're discussing. Kind of missing the point of the argument. Given how simple and popular `left-pad` module is (indicating the principle the community uses to determine granularity), I'd guess that if `String.format` was available in JavaScript t…
It's a memset followed by a strncpy, hardly worth linking to a library for. You'd be done writing the function before you finish googling for an existing one.