You are viewing a single thread.
View all comments
93 points

Thief way is actually the best among all of these imo, in terms of readability and efficiency.

permalink
report
reply
21 points

They’re setting a variable to a function. Just use the original function. All thief does is obfuscate for literally no gain except character count.

permalink
report
parent
reply
3 points

Sounds good to me

permalink
report
parent
reply
11 points

I presumed it to be a standin for just directly using Math.max, since there’s no nice way to show that in a valid code snippet

permalink
report
parent
reply
7 points

well it’s called Thief. They’re stealing the function and making it look like they wrote it. hence max1.

permalink
report
parent
reply
3 points

Yeah, that’s my reading as well.

permalink
report
parent
reply
89 points

Not using thief is professional incompetence unless you’re doing something deeply cursed

permalink
report
parent
reply
3 points

Fr. People like to reimplement wheels tho

permalink
report
parent
reply
3 points

Sometimes you need to minimize function calls in a tight loop, but otherwise yeah

permalink
report
parent
reply
5 points
*

I was under the impression that modern compilers just inline something like that, and even in older languages (like C) use trickeries are used to inline it (typically MAX is a macro rather than a real function, so its always inlined)

Ultimatelly it depends not just on what you’re doing but also the language and compiler you’re using.

permalink
report
parent
reply
10 points

Why would you be using JS in this scenario?

permalink
report
parent
reply
2 points

Sometimes, but practically never. Just be a thief.

permalink
report
parent
reply
3 points

If you’re optimizing that hard you should probably sort the data first anyway, but yeah, sometimes it’s absolutely called for. Not that I’ve actually needed that in my professional career, but then again I’ve never worked close enough to metal for it to actually matter.

That said, all of these are implemented as functions, so they’re already costing the function call anyway…

permalink
report
parent
reply
23 points

Like pair programming.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 3.7K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments