Live data from Hacker News

Left-pad as a service

left-pad.io

251–260 of 269 posts

Re: Left-pad as a service

#251
post #248

Earlier quoted context omitted.

And wait till you hear what a sufficiently smart compiler can do! http://c2.com/cgi/wiki?SufficientlySmartCompiler

But there already exist package managers that let you pin to a specific version like he's saying they should e.g. Maven, so I don't think your link quite applies here.

Npm allows that too -- you just specify an explicit version number, e.g. "1.5.3" instead of "*" or "^1.5.3" etc.

My comment was against this belief that "smarter" tools in general are some sort of panacea.

For example pining to a specific version won't help you match if the package is removed altogether (as in this case), and ever worse if it's replaced afterwards by another (newly registered) with an incompatible same version out. It won't try to overwrite your specific install of course (since the version already matches what you have), but you'll feel the pain when you try to duplicate/deploy etc a new install with the same package listing -- suddenly the package either won't be there (or will be modified in the worst case scenario).

So, then we opt for ever more features of a "sufficiently smart package manager", e.g. signatures, permanence of anything published etc...

Re: Left-pad as a service

#252

Earlier quoted context omitted.

Best practice for performance for large left-pad jobs is to call the service recursively using mapreduce. Remember that left-pad(str,pad,n) is equal to left-pad(left-pad(str,pad,n/2),left-pad("",pad,n/2),n). This should run in logarithmic time and is highly parallelizable. If you don't like the "" magic string in there you could replace it with a call to left-pad(null, null,0).

oh god it's too real

Poe's law for programming culture extremists

Re: Left-pad as a service

#253
post #233

Earlier quoted context omitted.

> `I shouldn't do ${foo} because people will make fun of me...` `... but why are they laughing from ${foo} in the first place? They're smart people, so there might be a reason. Let me research it more first...`. This is how self-regulation works.

I think there's a fundamental difference between, say [0] (thoughtful, nuanced), and [1] (just plain silly). The initial posts are all worthwhile and interesting, with the latter clearly being satire. It would be even funnier if the OP exposed a more robust string-handling library from ruby or python to the javascript runtime in node by way of a native lib binding. [2] is kind of just elitist, "get off my lawn" yelli…

There is another aspect that is worth considering: when someone is doing something particularly "stupid", this "stupidity" often isn't seen by the actor. Their self analysis can sometimes correct itself over time, but the usual biases can interfere. The point is it is far too easy to fall into really bad habits while blind to just how bad everyone else sees those habits.

While I'm speaking about a somewhat more general pattern of behavior, a very closely related phenomena is the "normalization of deviance"[1].

Part of the problem is that without an outside assessment, the actor isn't really working with accurate information. Criticism can be a way of giving that data. Quality "constructive criticism" is great, but the message is sometimes ignored or avoided. In those cases, a harsher criticism - and possibly a bit insulting - is necessary to convey both the severity of the situation and to get the recipients attention. This is where some of what you cal "'get off my lawn' yelling" is about. Sometimes we've seen these mistakes before, and we've tried being patient and nice; when that didn't work, the occasional "get off my lawn" may be appropriate. As others have said, this how a community self-corrects; when someone is being "stupid", they need to know that. They certainly aren't going to change without this necessary information.

Now I'll certainly agree that there is a very fine line here, and as long as fallible humans are involved mistakes will be made. I've certainly made mistakes in this area in the past. However, avoiding problems is not the answer, as unfixed small problems tend to become larger problems in the future.

[1] http://www.rapp.org/archives/2015/12/normalization-of-devian...

Re: Left-pad as a service

#254
post #83
post #80

Earlier quoted context omitted.

This is true. One wonders if OP has actually seen the vastness of Java SE or is just "hating" to "hate".

I've seen it, and more often than not frustratedly turned to Apache Commons because the Java standard library is as vast as it is useless.

The JRE lib seems to be a compromise between "common types for everybody, but leave the convenience to external libraries" and "batteries included". This leaves both camps deeply dissatisfied, but allows for a great deal of integration between libraries. Maybe I have looked at Microsoft flavored C++ one time too often, but the fact that a single string type could reign unchallenged for twenty years makes it easy for me to accept that I need to use weird imports to tackle exotic convenience desires via statics (that, and the sad underutilization of CharSequence).

Re: Left-pad as a service

#255

I get an error {"message": "Could not parse request body into json: Unexpected character (\'o\' (code 111)): was expecting comma to separate OBJECT entries\n at [Source: [B@6859f1ef; line: 2, column: 22]"} when using double quotes. It seems some JSON parsing fails. Not sure if this can be exploited, so I wanted to let you know. Demo link: https://api.left-pad.io/?str=%22 ;

I get an error changing the example request from 68 to 67 characters:

https://api.left-pad.io/?str=paddin%27%20oswalt&len=67&ch=@ {"message": "Could not parse request body into json: Unrecognized character escape \'\'\' (code 39)\n at [Source: [B@38ac0021; line: 2, column: 21]"}

Re: Left-pad as a service

#256
Can someone explain to me why I might need this? I checked the site and the documentation is horrible. The site isn't professionally done and there are no videos.

Can I rely on this service going to be around in 5 years? It just seems like this company might be, you know, a feature rather than a company.

Re: Left-pad as a service

#258
post #62

Earlier quoted context omitted.

Javascript has an excellent standard library - lodash. Here is its string padding: https://lodash.com/docs#pad . Lodash also ships hundreds of independent npm modules for those who don't need the entire package. Here is pad as an independent package: https://www.npmjs.com/package/lodash.pad . Lodash is here today, it works, it is reliable, and it doesn't pull the rug from under you.

Lodash only got padLeft in version 3.0.0 (released last January), and then that method was renamed to padStart in 4.0.0 this January, so it's not exactly the paragon of reliability (although I understand your sentiment)

Naw, I changed it on a major bump which requires opt-in and didn't pull the rug out from underneath people.

As @sod pointed out the change is based on the newish ES7 proposal.

Re: Left-pad as a service

#259
post #228

Earlier quoted context omitted.

> Convenient proxy factory bean superclass for proxy factory beans that create only singletons. that actually makes sense to somebody?

Not sure what about that is hard to understand, it's a convenient proxy factory bean superclass for proxy factory beans that create only singletons. Says it right there on the page.

Exactly, just like a monad is just a monoid in the category of endofunctors!

Re: Left-pad as a service

#260
Do you have any client libraries available for different languages?

I don't want to create a direct dependency between my code and your API. I'd rather create a dependency between my code and your client library's code, as I'm sure you will always keep that up to date with any API changes.

Post reply on HN