620
Find yourself (lemmy.ml)
submitted 11 months ago by coja@lemmy.ml to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] auf@lemmy.ml 92 points 11 months ago

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

[-] platypode@sh.itjust.works 89 points 11 months ago

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

[-] GlitterInfection@lemmy.world 22 points 11 months ago

Like pair programming.

[-] auf@lemmy.ml 3 points 11 months ago

Fr. People like to reimplement wheels tho

[-] Natanael@slrpnk.net 3 points 11 months ago

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

[-] el_abuelo@lemmy.ml 10 points 11 months ago

Why would you be using JS in this scenario?

[-] Natanael@slrpnk.net 2 points 11 months ago* (last edited 11 months ago)

Node.js, electron 🤷‍♂️

[-] el_abuelo@lemmy.ml 2 points 11 months ago

Something has gone horribly wrong if you're trying to do such optimisations when you've already chosen JavaScript...let alone Electron.

[-] Natanael@slrpnk.net 2 points 11 months ago

And yet it happens, just look at the molasses that is Teams

[-] el_abuelo@lemmy.ml 2 points 11 months ago

Thankfully the only interaction I have with teams is when a supplier arranges the call. Once every two weeks. It grosses me out every time...and that's the Web app.

Do you really think they have done such optimisation efforts as minimising function calls? I can't imagine it's required for what is actually a fairly simple frontend app. The complexity is the enabling stack on the backend.

[-] MajorHavoc@lemmy.world 1 points 11 months ago* (last edited 11 months ago)

Good answer.

Even if it made me throw up in my mouth a little. /s

Edit: Not the concept of Electron, itself - but being asked to write highly performant code in Electron.

[-] Aceticon@lemmy.world 5 points 11 months ago* (last edited 11 months ago)

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.

[-] demonen@lemmy.ml 3 points 11 months ago

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...

[-] xmunk@sh.itjust.works 2 points 11 months ago

Sometimes, but practically never. Just be a thief.

[-] snowe@programming.dev 21 points 11 months ago

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.

[-] platypode@sh.itjust.works 11 points 11 months ago

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

[-] snowe@programming.dev 7 points 11 months ago

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

[-] demonen@lemmy.ml 3 points 11 months ago

Yeah, that's my reading as well.

[-] Templa@beehaw.org 3 points 11 months ago

Sounds good to me

this post was submitted on 22 Oct 2023
620 points (95.7% liked)

Programmer Humor

32197 readers
416 users here now

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

Rules:

founded 5 years ago
MODERATORS