Hacker News new | ask | show | jobs
by jek0 2848 days ago
The authors is quite lazy or cannot type fast enough, so he has to create all those cryptic abbreviations: `rks` for `ranks`, `unv` for `unvote`, etc. Which makes it really hard to read.

But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.

6 comments

Hard to read? The sum total of the script fits on 2-3 pages at most, no single function exceeds about 10 lines, if you have trouble reading and reasoning about that code then something is wrong.
functions will not be any line longer by writing ranks instead of rks, but it will greatly improve readability.

You can have the exact same code wihtout abbreviations, and I can assure you that it will still be 2-3 pages long, with very short functions.

You can't evaluate readability without knowing the conventions that a system is working with. (That means knowing something about the people as well, btw.)

In this system, 'rks' communicates something that 'ranks' does not: that this is a local variable denoting a collection, and that it is a collection of the things that 'rk' denotes one of. So actually it adds quite a bit to readability.

If I were going to edit that code to make it more readable, the one change I'd consider is using 'r' (or maybe 'n', because these are integers) instead of 'rk'. One can argue either way whether the k adds information or just noise.

Yeah, I also like to minify the code before reading. It makes up to 5 times less code and it's fun to guess which letter stands for which function.
This is the only part that I thought could be significantly improved for the use case they have here. But to each his own.
Maybe the author used to write C
>But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.

Despite its size, this .js file has been modified throughout many many years probably by various authors.

A real amateur would have figured out how to write everything in a single function.
Yeah, just looks like a grease monkey script I would have banged out a decade ago in about an hour. Nothing wrong with that. It's far more interesting how much people are reading into this code haha. It was clearly not written to be read by us today IMHO.