TonyToniToneOfficial,
@TonyToniToneOfficial@lemmy.ml avatar

Last one should be // still a student

xmunk,

Every single entry other than thief is “still a student”

PeriodicallyPedantic, (edited )

If thief is actually an option, then thief.

Otherwise probably procreator or engineer 😅😬

Edit: errrrr that was supposed to say “procrastinator” 😬dyac

peyotecosmico,

I’m in this post and I’m offended.

SuperIce,

Why would you use anything other than Math.max?

SzethFriendOfNimi,

Some of us have trust issues. Or worked with Java.

Which, now that I think about it, comes to the same thing.

Zagorath,
@Zagorath@aussie.zone avatar

Well, the question sort of implies that you’re needing to implementing Math.max yourself, for whatever reason. Probably as an exercise. It doesn’t make sense to reuse a library that implements the feature if you’re explicitly being asked how you would implement it yourself.

demonen,
@demonen@lemmy.ml avatar

This is why I think school and interviews are like a whole different universe from the one where actual work gets done.

Zagorath,
@Zagorath@aussie.zone avatar

In some ways they can be wholly different, but I don’t think this is a good example of it.

Any programmer who cannot implement “take two numbers, return the larger one” is clearly not very competent. Even though you’re never going to literally need to implement Math.max yourself at work, you are going to need basically the same types of skills. Probably 95% of the work I do day-to-day is stuff you’d learn in your first year at uni, and this just shows that you’ve got that ability.

In practice, the best interviews I’ve had usually set a slightly more complicated task as a do-in-your-own-time problem and then go through what you did in the actual interview. Problems like “read a list of names in the form , each name on a separate line, from a text file. Sort the names by last name, then by other names. Output to another text file. Include unit tests.” They wouldn’t then expect you to re-implement the sorting algorithm itself, but more want to look at the quality of code, extensibility, etc.

More basic questions like the one in the OP, or fizzbuzz, are decent as well, and a big step up from lame questions like “what does SOLID stand for? What does the Liskov substitution principle mean to you?” Even if they’re not quite as valuable as a miniature project.

Rodeo,

In practice, the best interviews I’ve had usually set a slightly more complicated task as a do-in-your-own-time problem and then go through what you did in the actual interview.

The best interviews you’ve had are the ones where you’re doing free work on your own time?

Zagorath,
@Zagorath@aussie.zone avatar

“Work” is a debatable term. It’s not work that provides any direct value to the company, if that’s what you mean. But yes, it involves more effort on my part.

But yes. Not only does this method let me show that I’m good at what I do (far better than nonsense theory questions do), I have also found that companies that use this approach tend to come across as a better fit in other ways during the interview process.

hatchet,

I think you can probably make the question a lot more interesting by asking them to implement max without using any branching syntax. I’m not saying that is necessarily a good interview question, but it is certainly more interesting. That might also be where some of the more esoteric answers are coming from.

demonen,
@demonen@lemmy.ml avatar

For me, a good interview is a dialogue where the company representative shows me as much about the company as I do about me as a candidate. Take-home tasks are okay, I guess, but I suspect they might balk at me requesting they handle a mock HR issue, or whatever, for me!

MajorHavoc,

Why would you use anything other than Math.max?

I mean, I might be being paid by the hour or my performance measured by lines of code…

crandlecan,

I’m mostly lost and in over my head

auf,

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

platypode,
@platypode@sh.itjust.works avatar

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

GlitterInfection,

Like pair programming.

auf,

Fr. People like to reimplement wheels tho

Natanael,

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

xmunk,

Sometimes, but practically never. Just be a thief.

demonen,
@demonen@lemmy.ml avatar

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…

Aceticon,

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.

el_abuelo,

Why would you be using JS in this scenario?

Natanael,

Node.js, electron 🤷‍♂️

MajorHavoc,

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.

el_abuelo,

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

Natanael,

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

el_abuelo,

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.

snowe,
@snowe@programming.dev avatar

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,
@platypode@sh.itjust.works avatar

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

demonen,
@demonen@lemmy.ml avatar

Yeah, that’s my reading as well.

snowe,
@snowe@programming.dev avatar

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

Templa,

Sounds good to me

drew_belloc,
@drew_belloc@programming.dev avatar

I’m the first and the last, it depends on my mood

whaleross,
@whaleross@lemmy.world avatar

One, two and nine. Depending on the project, depending on the requirements.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines