How to communicate to a junior that spending 2 hours to save the customer 10ms is not efficient?
Posted by MinimumArmadillo2394@reddit | ExperiencedDevs | View on Reddit | 287 comments
I started at a company where there's a desktop java app with this other dude. Dude is mid-30s, just graduated, and it's his first SWE job. I have about 4 YOE at 3 companies.
Today, he was describing an issue he had where he felt like the system could be more efficient. What was the inefficiency? He was turning one string into 8, then looping over those 8 strings, then putting them back together. This step would happen during our install, which in the whole process, takes around an hour to fully set up. The step he's working on is to remove specific parts of the string (special characters, primarily).
When I told him it doesn't really matter if he splits it up into 8 strings or not in terms of memory, he looked at me funny like he didn't believe me. This leads me to thinking that maybe I didn't describe it good enough.
So I told him that memory is cheap and time is a much better thing to try and save. He responded and said that if everyone was as memory efficient as he is attempting to be, then the application wouldn't be as bloated as it is. While true, it seems to me like his priorities are aligned more towards efficiency rather than solving the problem.
How do I tell him that being memory efficient, while good practice, isn't always the priority, especially with dealing with small amounts of data?
08148694@reddit
10ms is a long time in a game engine render loop
It’s nothing in a one time install
Try to teach him about perspective and micro optimisations
Goducks91@reddit
Lol I read this as 10 minutes and was kinda surprised by the responses. I was like damn 10 minutes seems like a pretty big win why are people being so negative lol.
duniyadnd@reddit
I had to read your comment to realize the same thing
Erik0xff0000@reddit
I had a junior dev proudly announce he found a way to reduce initialization runtime by 10 minutes, but it was more likely to fail. He spent two weeks on implementing it. I was not impressed, especially with the "failing" bit. Startup time isn't very relevant on something that runs for 16+ hours with a lot of waiting for data to come in. I told the guy I could get the startup to complete 10 minutes earlier with a few minutes of effort Just schedule the process to start 10 minutes earlier, but the end time would not change at all whether or not we made changes or not.
pydry@reddit
This is one of the "junior attitudes" I screen for in interview tasks I set. There's a surprising number of candidates who when asked "how would you refactor this?" earnestly believe I asked them "how would you speed this code up?".
I low key expect it in fresh grads because they spent about 3 years learning leetcode micro-optimizations, big o notation and algorithms but an inclination towards premature optimization is definitely something some people don't grow out of.
Slappehbag@reddit
Yeah. It depends on what the goal of the refactor is: performance, maintainability, reusability, readability, correctness etc.
tcpukl@reddit
It adds up to more over multiple frames.
Spleeeee@reddit
ms is the abbr for mars-seconds which would be about 10.275 earth seconds.
kagato87@reddit
It might as well be 10 minutes, if it's running every frame.
dllimport@reddit
OP says it's during the install.
kagato87@reddit
Context of this sub thread is game loop, where 10s does matter.
baldyd@reddit
Yeah, that's an insane amount of time for a game frame. It's the majority of your frame time if you're running at 60fps. No amount of cores would stop me from puking a little if I saw this in a profiler.
UnworthySyntax@reddit
Hard same lol
Fun-Dragonfly-4166@reddit
if millions of users use the one time install then it would still be a big issue
if I am putting out the game engine open source and uncompensated then if I don't feel like doing the fix, someone else can.
lipstickandchicken@reddit
The install is an hour. Saving 10ms reduces the install time from 3,600,000ms to 3,599,990ms.
marquoth_@reddit
The fact that it adds up to a lot of time across all users is technically true but totally irrelevant. From the perspective of any given user, the "improvement" is negligible - they won't even notice it, much less appreciate it.
Fun-Dragonfly-4166@reddit
My experience has been primarily with work software. The customer pays me to develop software for their employees to use. They are sensitive to small improvements because they add up.
I work on issues the client cares about. I would not decide for myself that something is or is not important
dbxp@reddit
You can do those installs in parallel and the amount of hardware resources scales with the number of installs you need to do. The performance at install would only be an issue if it was something like a centralised licensing server where all the installs are going to be connecting to a single instance.
-MtnsAreCalling-@reddit
Not really, because users don’t experience things in aggregate and 10ms times 1 million users is still less than 3 hours total.
yubario@reddit
No it won’t be an issue for a one time install even if there are millions of users. I have proof of this, literally every vendor application I’ve ever installed at my enterprise.
Fun-Dragonfly-4166@reddit
i did not think so, but you brought the receipts and you are right
ProduceAcceptable333@reddit
That is an interesting point.
zemdega@reddit
10 ms can be an eternity in the AI/ML world.
light-triad@reddit
I'd actually try to set him on a task to help him figure it out for himself. Okay so you want to improve latency and decrease memory consumption. Work with stakeholders to try to set SLOs for those things. If you're above the SLO then fine these optimizations are valid work. If not then they're a waste of time. Likely if there's no existing SLOs this isn't important enought to do.
BOSS_OF_THE_INTERNET@reddit
10ms is an eternity in fintech.
Brlala@reddit
Working in fintech too in fixed income, the parts other than HFT have so much more inefficiency than when I was working in a tech company.
Dyledion@reddit
I work in a different side of fintech. For us, 10 hours is, eh, probably nobody will notice.
Distinct_Bad_6276@reddit
HFT maybe, but not universally true for all fintech. My data makes a couple more round trips across the pacific than it really ought to, but that few hundred ms is not the end of the world for our application.
william_fontaine@reddit
Amdahl's law
petiejoe83@reddit
And premature optimizations. Sometimes the compiler is more clever than you realize. It's fine to think of order of magnitude problems while you're coding, but the only optimizations that are ever worth doing without measuring are optimizing for engineering time and maintainability.
Profile first, focus on the stuff that matters.
I say this even though I worked on the latency team of a very large website. I've detected and helped fix 2ms regressions in latency. There is absolutely no chance that I would try to do that without the right data.
metaphorm@reddit
you're both wrong.
the new guy is wrong because he's obsessing over micro-optimizations that don't impact the end user experience in a meaningful way.
you're wrong because you're not his boss and you're not that experienced yourself yet you're trying to set the priorities for someone else.
the real actual problem here is that whoever IS supposed to be setting priorities hasn't done so or hasn't communicated them effectively.
besseddrest@reddit
yeah i'm on this boat
if you were dependent on this change, and you needed him to focus on something more critical then i'd just quickly redirect them
if you're not mentoring him, or assigned to him to help ramp up, then just let them be. I think you told them all they need. No need to spend extra energy by assuming the responsibility to teach them the way. Let them make their mistakes, learn for themselves first.
Now that you said something, when they get critiqued for what they were working on, i'd imagine that they realize what you tried to do, then might actually ask you for more advice.
tjsr@reddit
I'm more in the "you're wrong" (OP) boat - this whole "memory is cheap" attitude is why software is so completely and utterly bloated today.
Also, OP is obsession over a junior spending 2 hours? Are you freaking kidding me? OP needs some perspective - how many meetings have you had this week that had 6 people in them that didn't require or utilise the time and input of everyone in attendance?
2 hours in the grand scheme of thing is nothing. If you're micro-managing and complaining about use of that level of time? Definitely sounds like the junior is going to go a lot further than OP in this field - and makes me wonder if there's some other bitterness that's really at play here that we're not being told about.
MinimumArmadillo2394@reddit (OP)
My coworker asked me for my opinion and my thoughts on what they were doing.
Im not trying to set priorities for the guy, which is why Im asking what a good way to approach this is. If Im ever going to be a good/decent senior, I need to be able to approach questions like this.
The priority is to do the task. The task wasnt done entirely, but my coworker was trying to be stupidly efficient on a n >= 10 sized problem and was concerned about breaking a string into pieces.
wraith_majestic@reddit
Good you’re thinking how to better yourself. Not sure coming here will necessarily bear fruit.
But all the opinions sure are fun to read.
Fun-Dragonfly-4166@reddit
correct. i work to my tickets. if someone else (the writer of the tickets) thinks it is worth my time to fix a problem then I will fix that problem. if they did not write a ticket then at most I would suggest they write a ticket.
MinimumArmadillo2394@reddit (OP)
The thing is, he invited me over to his desk to get advice from me.
So yeah, Im not his boss. Im not trying to fix his problem, but the fact he asked me directly if there was any way it could be done more efficiently while telling me he spent a few hours already and is trying to find other ways to do it should probably be mentioned here.
Would you let a coworker go down a useless path of thought for multiple hours?
Fun-Dragonfly-4166@reddit
I am ok if others think i am an asshole but YES. It is not my time.
MinimumArmadillo2394@reddit (OP)
Why would you be considered an asshole for answering a question asked of you?
Are team leads assholes for answering questions and guiding a junior who asked it?
fantasticpotatobeard@reddit
Or maybe the manager is a good enough manager that they're not micromanaging to the point that there isn't a few hours of flex time to work on improvements that the devs care about?
dbxp@reddit
It's normal to get all the devs on the team to help onboard new employees, that's not just the job of the manager
ttamimi@reddit
Lead the horse to water, by having a discussion with him about what adds value and what doesn't, from the perspective of the end user.
takenokosembe@reddit
… and the business. That’s wasted worker hours better spent.
fallen_lights@reddit
Better spent in reddit
pydry@reddit
This attitude doesn't change quickly in juniors.
They've spent 4 or so years learning about algorithms, big o notation, leetcode optimizations, etc. and it takes a good number of years before many of them twig that the stuff that gets hyperfocused on in academia and in interviews is relatively unimportant most of the time.
I still remember the excitement I saw in a junior once after months of despondency because a business problem cropped up that actually looked like something he studied at school. He was so fucking stoked.
danicriss@reddit
Use data: https://xkcd.com/1205/ Is it worth the time?
xelah1@reddit
Whether it's worth it isn't always just a comparison of time saved vs time put in. Perception of quality is affected by performance as well.
Whether that makes a piece of work commercially valuable remains a question - if you're writing shitty enterprise software where the person making the decision to pay doesn't care at all about the quality-of-working-life of the person using then it matters a lot less than if you're creating a premium product for rich individuals.
On top of that individual developers (indeed all employees from the bottom up to the CEO) are not going to be and will never be motivated primarily by maximizing commercial value for their employer, which is probably how this became a post in the first place.
armostallion2@reddit
since this comment is popping off, I'd also like to add:
The comic uses a singular point of reference, that being the person coding the feature. The person coding the feature isn't putting in the time for themselves to save the time. So the statement in the comic, "how long can you work on making a routine task more efficient before you're spending more time that you save (over the course of 5 years)", is bogus, because you're not the one saving the time. The person that's not spending a single second on the code is the one saving the time. So you can work as long as you want, and even at the minimum level of work to shave off even a second, the person using the software will have saved time, assuming the coder isn't coding for themselves. I hope this makes sense.
tommyk1210@reddit
Whilst everything you’ve said is true, this chart does have value. Although the premise is about the crossover point between time spent automating a task and the time spent on that task it is also a pretty decent chart to illustrate how long someone (a customer) will waste if this optimisation isn’t made.
For example, the chart shows 5 year time spent. If your install process takes 1 extra day (and they’re sat in front of the PC for the whole day), and they do it 1/year then over 5 years they will “waste” 5 days over 5 years.
In OP’s case, the customer will save 10ms, so even if they are installing it on 100 machines a year (ergo they waste 1 second per year), they’re only going to save 5 seconds over 5 years. This is still an excellent point to illustrate to the junior employee.
Of course, they might have many customers and they might install on many machines, but this goes a long way to demonstrating value to the user. Would the end user care that they’re wasting 1 second per year? Would the end user cancel their contract over the 1 wasted second?
Perhaps there’s something else, like a button click, that the users of those 100 machines do 50x a day. If that’s wasting 1 second per click, now you’re saving the customer 1 day over 5 years. Whilst that’s not massive it’s still quite a bit. If they’re paying $1m for the software that’s basically $550 pro rated.
The comic falls down a bit at these small scales of optimisation because it’s focused on tasks. In reality, 250ms API response time improvement can be huge for UX because it might be seen 100 times a day per end user (so 10,000 a day over our 100 hypothetical machines). But the mathematics can still be calculated using the xkcd comic as a base. If there’s 100 machines saving 25 seconds per day that’s 2500 seconds which is around 40 minutes. Based on the comic you’re saving your end users, collectively, about 6-7 weeks over 5 years of frustration/time. Massively more valuable than 10ms in a setup process.
The whole point of the comic is demonstrating value to a user of automating a task they do, but it can equally be used to demonstrate how value scales.
baldyd@reddit
Yeah, it needs a 3rd dimension, the number of people affected. When I optimise engine tools at work, like shaving off some load time, I'm considering the creative people who run that tool every day.
2cars1rik@reddit
Disagree. Even if OP’s app had 100m users, 10ms still would not be worth the effort if the rest of the install takes an hour.
DrShocker@reddit
I'm not even sure what function I'd use to map it, but I think you'd need to be moving between these categories for it to "matter" to a user.
1) Happens within human reaction speed
2) Happens within a noticable amount of time
3) Happens within an amount of time I'll wait for without complaining much most of the time (5-10s)
4) Happens within an amount of time where I can respond to an email or two while I wait
5) Happens within an amount of time where I'll start it and check in... eventually.
Of course this gets different with stuff like a game that is continusouly updating while you're using, but we're talking about an installer here.
baldyd@reddit
We were referring to something else. I agree with you that 10ms in OP's point is negligible. But this stuff is still super important in what I do for a living. 10ms to me is an enormous amount of time. Anything that takes 1ms requires serious attention.
DrShocker@reddit
I think more people should consider this since I generally agree with the criticism that modern software packages often try to add a ton of features and forget that speed is itself a feature.
baldyd@reddit
There's always the opinion that we can just add more resources, more RAM, more processors, to solve the problem. That's true to an extent, but if we actually took externalities into account (energy, resources to build and maintain systems, sustainability) then this shortcuts wouldn't be so attractive. It's not going to happen anytime soon, but I'm still happy that I get to make my chips scream efficiently in the meantime.
baldyd@reddit
Fair, but I wasn't referring to OP's point, we were drifting off into something else. For me, nostalgia, haha
danicriss@reddit
Good point - my comment was a mere kneejerk reaction suggesting the way to go, a grain of salt indeed should be applied
Is your comment essentially saying: factor the number of users in?
armostallion2@reddit
hey, thanks for your humble response. I wish I could say this more easily, but I'm having difficulty articulating it well. The graph is only considering the crossover point between time spent delivering a feature vs spending more time than the person implementing the feature is saving. Past that cutoff point, it wouldn't make sense for the person coding the feature, because they're the ones putting in the time in both development and use. For the person on the outside, the person paying to receive the feature, the external person hasn't sunk any of their own time, they're just getting the benefit, so it's not an accurate way to think about it.
DrShocker@reddit
Yeah and just extrapolating 1:1 time being valuable for others is not accurate since not everyone's time is valued the same. If I save a child 60 minutes on their homework, then generally that isn't considered as worth as much as saving a user a few seconds from reading spam emails. Mostly because the 60 minutes spent on the homework is (supposed to be) valuable in itself whereas I don't know anyone who claims reading my spam emails has any value.
programmer_etc@reddit
We got it
MoreRopePlease@reddit
In OP's scenario, you need to consider the cost to the business and the benefit to their users. Is it worth 2 person-days, plus testing, plus documentation, etc, for the users to save 2ms? Would the company be ok spending that money to this purpose?
Bakirelived@reddit
Does the comic talk about programming?
armostallion2@reddit
Does it not?
morosis1982@reddit
While I like this one, it doesn't take into account risk of human error. I can easily justify automating something that happens somewhat infrequently if it means that something now adheres to well defined data structures and process, and won't bring down customers because someone had fat fingers that day.
armostallion2@reddit
I can't imagine he'd understand this comic. It's not the easiest to digest IMO.
MinimumArmadillo2394@reddit (OP)
I also literally exposed him and my entire office to xkcd 2 days ago
dacydergoth@reddit
There's an XKCD for that, too
DigThatData@reddit
today's 10,000!
react__dev@reddit
I have learned these optimizations are unique to situations and what he is following is just best practices blindly.
ixampl@reddit
Why are you talking about 10ms (milliseconds) in the title but then discuss memory usage in your text?
Those can relate obviously but it has nothing to do with "bloat", so I'm a bit confused what's really his or your topic of discussion.
Anyway, I agree with you that in this instance it's likely not worth it.
Now, if the improvement also happens to make the code more readable (more easily maintainable) in the process I'd say it might be worth it. In the end that can save your team trouble and time down the road and if it also improves speed or memory use, even better.
It's all very context dependent.
puremourning@reddit
Send them to me, I’ll hire them.
We fix our broken windows.
BitNumerous5302@reddit
Yeah... On the one hand, 10ms of a 1hr installation process is a micro-optimization that helps no one, in-and-of-itself. On the other hand, an hour-long installation process sounds pretty bloated, and based on OP's attitude it is very conceivable to me that their system is laden with similar easily-remedied-yet-neglected inefficiencies (two whole hours of dev time! muh pearls!) as their colleague has dutifully tried to explain.
This usually boils down to a commons problem: No single inefficiency (and therefore no single engineer) causes the installation to take a whole-fucking-hour, so no single inefficiency looks worth fixing (and no single person feels responsible). That's an organizational issue that cannot be solved with code, which can be tremendously discouraging when coding is your primary skill. OP should indeed encourage their colleague to find more suitable employment at a firm which utilizes engineering talent fully instead of pitting them against one another in a war to see who can generate the hardest-to-account-for waste.
https://en.m.wikipedia.org/wiki/Tragedy_of_the_commons
InstructionMoney4965@reddit
As an intern many years ago I was tasked with determining why this backend software application was extremely slow to respond. My conclusion at the end? It was every single thing happening was adding a tiny bit of delay. Death by a thousand cuts.
I was really hoping to find one process that was causing the delays, but it did not exist
puremourning@reddit
Well said.
roynoise@reddit
Pragmatic Programmer reference! I appreciate you. Thumbs up there, bloke.
Exciting_Student1614@reddit
My companies install takes like twice as long as it should because "experienced devs" back in the day decided to add a bunch of sleeps of arbitrary length to avoid race conditions that may or may not be a problem. I don't blame them though, getting it to work was the priority at the time.
However this guy seems insane, I'd probably talk code readability and complexity to convince him
Confused_Dev_Q@reddit
Ignoring is not the right approach. The best you can do is, explain why it's not important, why one approach is better, but ultimately it's their decision what they put in a PR. If they chose to ignore your advice they can, but at least you know you told them.
Another colleague might not care and just approve. On the time aspect, that's something for your manager.
coredusk@reddit
Probably best to hear him out, listen and show interest in his initiatives, rather than going straight to disagreement and trying to prove your point.
fantasticpotatobeard@reddit
Why do you want to discourage him from trying to improve things if it only takes a couple of hours? If he was spending weeks on it, then maybe say something, but 2 hours on something that probably motivates him and makes him proud to make things better is a wash at least.
GrapefruitMammoth626@reddit
Refreshing take tbh, it’s only 2 hours. We waste 2 hours everyday anyway, let him waste it on something with value.
Sworn@reddit
Because that mindset leads to being extremely inefficient. I've worked with coworkers who don't approve PRs over a spelling mistake in a log message (think "its" instead of "it's") and similar ridiculous things, it's just not a good mindset to have as an engineer. Your job isn't to make everything perfect.
Juniors are juniors, and teaching them what's worth spending time on is much more important than shaving of a millisecond from a run-once function. If he wants to waste time, fine whatever, but the issue is if he doesn't understand that he's wasting time.
PoopsCodeAllTheTime@reddit
It's ok, it's not a PR review that we are speaking of
Sworn@reddit
It's the same concept of spending time and energy on things which have impact. Every hour you spend on things that don't matter is an hour you could have spent on useful things.
Sure, if the guy had nothing else to do at the time then who cares, but if he's actively choosing to work on the wrong things then it's good to teach him the value of time as early as possible instead of having a PIP do it for him.
PoopsCodeAllTheTime@reddit
Time is not linear like that, if I you tell me that I cannot do the work that I care about, I won't be doing the other work any faster. In general I disagree with seeing time as linerly as currency, as if your time coins were the same on any task.j
Sworn@reddit
Sure, if otherwise pointless work is important to you and doing it motivates you or in some other way benefits you, that's fine.
The issue is that juniors often get bogged down in pointless work that they don't realize is pointless (and vice versa, think important things are less important than they are). That's why they're juniors. My job as senior is to teach them which parts are important and worth spending time on, and for which parts "good enough" is enough.
Comfortable_Ask_102@reddit
Spelling its important. Code is written once and read 100s of times.
If it really bothers you, you could try some collaboration and "open" the PR so that others can quickly fix those mistakes instead of having discussions about it.
KitchenError@reddit
Did you do that on purpose?
Sworn@reddit
Log statements are not read 100s of times, unless it's some exceptional case.
I couldn't really care less if people want to pay me a few hundred bucks to fix a spelling mistake that doesn't matter, but I have a feeling the business owners wouldn't agree with the choice.
The type of people that will block a PR based on that will always have blocking suggestions for small things that don't matter in every review, which zaps productivity and motivation.
By the way, the correct way for nits on things that don't matter is to make the comment, but approve the PR and let the submitter either decide to fix it (and merge without further review), or decide to ignore it.
Comfortable_Ask_102@reddit
I agree with you. Nitpicking to the death is hurtful for the development lifecycle. But you're arguing against a clear mistake that will take seconds to fix, there's no reason to be sloppy with your work.
Sworn@reddit
It takes seconds to fix (in reality more like 5 minutes due to context switching), then who knows how long to get an approval again, average time is at least 30 minutes but probably more like an hour? (One of the cases where RTO is actually good I guess, because slack messages are often ignored if someone is deep into their work).
The point is that someone who blocks a PR due to that will usually find something to block every single PR. Virtually nothing is perfect, but spending time slightly clarifying test names, using syntactic sugar or improving the English in log statements that should never occur just isn't worth adding the extra time penalty the review feedback loop adds.
Make the comment, approve the PR. Save blocking PRs for actual issues.
Comfortable_Ask_102@reddit
It sounds more like an issue with the process and collaboration. Can't you really just take 5 mins. to pair program with your teammate and address all those issues? Or simply open the PR so that anyone can fix these mistakes when they see them? Or have an extra linter check for spelling?
Please note that I'm not advocating for blocking a PR until all nitpicks in the world have been addressed. I'm talking about clear, obvious mistakes that take seconds to fix.
Sworn@reddit
I don't understand your point. Obviously I roll my eyes and fix those types of comments, I'm not going to spend even more time arguing about it?
Dragging them in to pair on improving a temporary variable name inside a lambda function etc would admittedly be pretty funny, but I don't really see the point.
Linter checks for spelling doesn't work, not just because many spelling mistakes are real words (like my example), but also because the false positive rate would make you insane. Keep in mind that the spelling mistake is just an example, I can bring up a hundred possible nits that are unrelated to spelling but just as trivial.
DonkiestOfKongs@reddit
I once rejected a PR comment because the reviewer said "this function needs to be documentated"
HorribleUsername@reddit
The assumption there is that those wasted 2 hours will be replaced by this. I doubt it'd actually happen that way.
BitNumerous5302@reddit
The counter assumption that they had something more immediately productive to do with those two hours is equally faulty.
mountainunicycler@reddit
I think it’s quite likely; the point about motivation is a good one.
It can be very hard to feel like you’re having a measurable impact in “making things better” in a large enterprise app, and easy to feel like you’re personally adding more bloat.
icesurfer10@reddit
2 hours of development time for a savings of 2ms in an already over 1 hour long installation process is definitely not worth pursuing. Especially when, by the sounds of it, it's probably less readable than it was before.
I agree that giving people time and space to make optimisations is a good thing, but there needs to be a cost/value check to ensure it's worthwhile.
MinimumArmadillo2394@reddit (OP)
I'm not trying to discourage him, I am trying to tell him and show him how little time he's actually saving by agonizing over a small design decision that makes no real world impact. I'm all for him writing good code, but we still need to account for the fact that he has other things on his plate so spending time agonizing over a decision to split strings is not necessarily a good use of time
besseddrest@reddit
you didn't do anything wrong, they were asking for help, you gave your take, it sounds like they are a little stubborn. And honestly when they're stubborn sometimes they need to learn the hard way.
you'll spread yourself thin if you commit to these smaller things - this is their first role and personally i think new engineers need to make these mistakes
now you get the benefit of them coming back to you and giving in "yeah i probably shoulda listened to you the other day..."
AND THATS WHEN YOU CAN GIVE HIM ALL YOUR SHITTY TASKS
jk
DancingSouls@reddit
Is he behind on his other tasks? If not then an improvement is an improvement
ssrowavay@reddit
Is it going to be an improvement though? If the code is made more complex and difficult to understand in order to support a micro-optimization, that's a step backwards IMO.
Maxatar@reddit
Yes it's not only an improvement to the application, it's an improvement for this developer.
Please don't discourage new developers from forming good habits. Yes today it took him 2 hours to do this task that he cared about, next month it might take him 1 hour to do it, and a year from now he will write code like this naturally.
Writing code is not just about the end-user, it's also about the person doing it, forming good habits, learning, and caring. I actually applaud this guy for taking initiative and I think /u/MinimumArmadillo2394 is being somewhat myopic by focusing on 10ms as if every single hour of the day is spent doing some insanely valuable task and every minute counts when he likely spends 4 hours a day on reddit doing jacksquat.
lipstickandchicken@reddit
7,200,000 people would have to install the software for the time spent on the optimisation to be worth it. It takes us 10x longer to blink.
It is an egregious waste of time. Sending him home to relax for the afternoon would have a greater benefit.
zeehtech@reddit
Yeah, tell him that posting bs on reddit is a lot better. Let him cook, man.
MinimumArmadillo2394@reddit (OP)
Huh? I posted this outside of work hours?
shipandlake@reddit
This is his first SWE job. While studying they have likely been taught to optimize algorithms to be O(nlogn). Congratulate them on a successful optimization and point to an area that has a higher potential when optimized.
This person took initiative, took only 2 hours to learn to do something, make a successful change, and make the code better for someone new to the job and a profession. That’s a win. The fact that it’s only 10ms is irrelevant. Just the initiative alone is worthy of a praise.
If you want to make it a teaching moment too. Point out that performance optimization is usually about percentages and not absolute values. That’s a valuable lesson they can take with them in their career.
feaelin@reddit
Your clarification here points to a different conversation than the one in your original post. What you're saying in this reply is more about time-management: "Of all the tasks you've been assigned, which are more important? Which give everyone affected the largest/best benefit vs. the time spent? Which are more important to the stakeholders?"
While asking those questions, share with your colleague what criteria you consider when making those assessments. After 4 years there, I'm sure you have a lot of "lessons learned" to share. Particularly those things that are organization specific.
Also, make sure you're approaching the conversation in a way that your colleague feels heard and understood. Lot more progress is made if that step is met first.
---
Your original post had me thinking about "what should we optimize for?" kinds of questions. Even here, it is a question of priorities that fit your product and market. All optimizations come at the cost of something else. For example, we often trade memory for speed or vice versa. That one tends to be readily apparent, because its often discussed in education/training and is very "technical" in nature.
There are other costs. Some speed/memory/CPU optimizations produce a loss of code clarity and maintainability. Most come at the cost of our (the programmers) energy and time.
"He responded and said that if everyone was as memory efficient as he is attempting to be, then the application wouldn't be as bloated as it is."
It's tricky to address this specific idea without being argumentative, but here are some thoughts. There are a couple of assumptions here:
1) That the application is bloated
2) That "not bloated" is a high priority requirement.
The first offers a conversation about what qualifies as bloated. Memory usage? How much? Disk usage? How much? CPU cycles? How many on what kind of CPU? Network bandwidth...? I imagine you get the idea. Which of those are important to your product and market?
The second might get answered by the discussions of the first. For instance, if your market is folks with high memory laptops, memory usage isn't important at all. On the other hand, if you're aiming for embedded electronics, it might matter a great deal. Or your market might be "I've had my machine for 10 years, it runs just fine", in which case, you may need a middle ground. Have those conversations about what you're building means to the people using the product.
" While true, it seems to me like his priorities are aligned more towards efficiency rather than solving the problem."
That's likely. Part of that is how programming is taught, part of that is programmer nature. We love to optimize things. Often programming teaching emphasizes code and coding well, which is great. But often leaves out "bigger picture" discussions that come up with "real products". Consider: my degree program had an entire course focused on analyzing complexity (in effect, optimization) -- but there was only portions of another class that came in the ballpark of discussing the tension between "optimizing for product delivery" vs. "optimizing for amazingly written". Clarity, maintainability, and changeability didn't come up at all. Some schools I think have improved on these points, but probably not many.
BelatedDeath@reddit
why are you complaining so much? if you have a problem with him then fire him
redditonlygetsworse@reddit
Chill
PoopsCodeAllTheTime@reddit
Make it less about spending "time", because he might still be on time for other things so the point is moot, perhaps, make it about spending "energy".
gajop@reddit
If it just saves 10ms (by the sound of it it's more in the realm of 10us) of a 2h process then it's worthless. While not always true, optimizations often lead to less readable code and any change needs to be well tested.
cd_to_homedir@reddit
I've met many developers in my career that are so focused on "problem-solving" that they become careless and write poor quality code even though they are competent enough to make it better. This results in code that is difficult to maintain and causes headaches for other developers. If your refactoring saves time for other developers, it might be worth it. 2 hours is nothing.
cd_to_homedir@reddit
Finally, I was looking for this comment. Many developers are too focused on "problem-solving". They often forget the excellence of the craft itself, and spending two hours to solve a minuscule problem is nothing if it means that the developer becomes a better developer overall and produces better quality code (if that is indeed the case here).
kbielefe@reddit
I agree with you in general. I much prefer coworkers who take initiative to make improvements, and was one of the advocates for the 4 hours per week we now have set aside for each individual for that exact purpose. I also suspect this is one of those cases where sanitizing for reddit made the change seem to make less sense.
However, whether those experiments should be committed into production is another question. Sometimes you just have to take it as a learning opportunity and try again. True innovators have a lot of failures they learn from.
Darkitz@reddit
For real. Atleast he's spending 2hours working for something.
I dont know about any of you guys. But in the office (and homeoffice) half the people chill atleast 2hours a day.
twistnado@reddit
My exact thinking. Why micromanage the dude’s 2 hours? He found an inefficiency and is growing as an engineer. Down the line the “find the inefficiency” mindset may start really benefiting users.
ravixp@reddit
Yeah, save your energy for the devs that spend two days optimizing and end up making the code slower than when they started :p
Chaigidel@reddit
There was a nice framing of efficiency in the user interface layer I saw somewhere, where there are only two speeds, slow enough that the user feels things are too slow, and faster than that. If you know the code is only relevant to user interaction and not some load-bearing library system, as long as you stay above the threshold where the user notices things slowing down, you're good and should try to keep things simple, concise and maintainable instead of optimizing for speed.
Also it's good to have awareness that the cost of extra code complexity isn't just the time spent writing it, it's also maintenance load that will stay with the project forever. The smaller and more straightforward you can keep the codebase, the more maintainable it will be. Whenever you add something clever that takes more work to code than the most straightforward solution, that costs you in future maintainability, and you should be able to justify the cost.
Crafty-Artist921@reddit
Bless him.
Trained to be a Google AdSense worker. Forced to be a normal worker.
_your_face@reddit
Just ignoring them does often turn in to the way to go because when you think you’re smarter then everyone that came before you, you can’t be convinced otherwise with hypothetical discussion, they’ll have to go through it, at which point they’ll
A) realize things are harder than they seem, and people aren’t all dumb. Thingns are often a certain way once you’ve learned all the context.
B) they won’t see what they do as a waste, they’ll always think they are smarter then the world, and these guys get fired (hopefully)
Froot-Loop-Dingus@reddit
I spent 2hrs on Reddit today so he was more productive than me in that time.
grandeherisson@reddit
I feel like in our industry two hours can yield you a groundbreaking poc, absolutely nothing at all, hasty PR with negative net value or useless 30min meeting of four people
Doing some harmless micro optimization doesn't sound so bad in comparison.
FaultHaunting3434@reddit
I can see why you have been at 3 different companies in 4 year. It must be a real joy working with you. I bet you xhit ice cream too. I hope the 4th company works out, maybe a team of you, Claude, Grok, Gemini, and Chatgpt, is the best and only fit. #VibeCode all day, everyday is the only way.
kobel4k3r5@reddit
Funny how companies hire by asking DS&A but when some junior passes it and joins, it’s not as important cause it’s not a good use of time.
HademLeFashie@reddit
I have 4 YoE, and I've never once encountered a significant performance bottleneck that was caused by algorithmic complexity. It's always caused by unoptimized queries, or excessive network calls.
That's not to say I've never seen inefficient or redundant logic. But the input size was never large enough to make that into a performance issue.
audentis@reddit
I've gained order of magnitude speedups from replacing an O(n^(2)) operation with a set and membership testing. But although it's techically DSA, I'd fit this in the "unoptimized junk" category too.
Speaking of which, sets deserve more love.
Unfair_Abalone_2822@reddit
Distributed compute makes the lines between those categories very fuzzy. You can have an unoptimized Spark query which performs excessive network calls (shuffling) because the algorithm you’ve implemented has a span of O(n^2) when it could be O(n log n). Oh, and that’s one that has the potential to save your employer six figures on what they owe their cloud-crack dealer in Seattle, too. True story.
bwainfweeze@reddit
Not only that it’s murder on support costs if they do.
0x4ddd@reddit
To be honest, 2 hours is nothing. He most likely spends more time weekly on some useless meetings. I wouldn't bother.
If he would spend 2 days, then maybe it would be worth explaining.
tcpukl@reddit
Wow then a profile capture and teach data driven optimization.
I work in games, 10ms is an eternity.
lagstarxyz@reddit
If this happens during install and is a one time cost this seems like a dumb use of time debating.
flavius-as@reddit
I'd tell him.
"Sure, do it, but do it as a professional: profile the installation process and show me the hot spots. I want my smartest guy to work on impact, not on peanuts."
vasaris@reddit
This is golden!
havok_@reddit
But if performance isn’t an issue then spending time profiling is kind of a waste of time too. I get that you should keep your staff interested, but sounds like this guy is new, so I think the better lesson is just to nip it in the bud. Communicate that his role is to deliver customer and business value.
morosis1982@reddit
Eh, profiling is almost always worth it. You may not find the hotspot you think you will but in my experience unless it's something heavily profiled anyway there will be a hotspot worth looking at that you didn't even know was there.
WinterOil4431@reddit
profiling something that hasn't regressed, no one complained about, and no one asked for is very possibly a complete waste of time
flavius-as@reddit
True. However it's about refactoring the programmer's way of thinking without killing his enthusiasm.
havok_@reddit
But a “hot spot” doesn’t mean anything without context. If users do this thing only occasionally and the speed doesn’t bother them then you are optimising for no business gain. But you could have delivered a sellable feature instead
squashed_fly_biscuit@reddit
It's not totally hard to imagine profiling and optimizing an hour install process could reduce it by 10 minutes if it's not already been profiled, depending.
Massive-Prompt9170@reddit
This is the right answer. Any “performance improvements” must have data backing it up, otherwise it’s just vibes. But at the end of the day, regardless what level of improvement he gets out his 2 hours of effort, if it’s in an area the doesn’t matter, then his effort was completely wasted.
johnpeters42@reddit
Unless it's useful practice, but still, you should at least consider whether they could get the same amount of practice doing something more directly useful as well.
Massive-Prompt9170@reddit
In my experience, optimizing an algorithm is generally easy work and rarely requires genuine insight or discovery. Knowing when and where to do it is the hard part. If you’re going to practice anything, practice how to understand the tradeoffs being made in time and effort, practice how to gather data about what optimizations need to be made
cough_e@reddit
Great answer.
Take something he's clearly enthusiastic about and teach him to do it more effectively.
SnooPickles1042@reddit
Question yourself - is this change worth the argument? May be just give feedback and let this particular change happen?
zeehtech@reddit
I would bet that the original code was written by you and you are struggling to accept that someone with less experience could be able to rewrite it better. Anyways, he is starting and needs space to think critically in order to improve. Let him cook, you and the company have nothing to lose going this path. Just don't let him spend 2 days on something small as that. 2 hours is irrelevant.
MinimumArmadillo2394@reddit (OP)
Please read the first sentence.
I just started literally the same day. We are working on entirely different parts of the application. He asked my opinion about how he should tackle something after debating options for a few hours.
I dont know why youre being hostile when you didnt even read the post.
zeehtech@reddit
Yeah, I'm sorry. I just can't see all this spectacle being better than just let him learn and figure out things by himself. There are a lot of devs that do only what they are asked for. He is a valuable dev.
ssrowavay@reddit
Run a profile on the code and show him where time is being spent. The first time you run a profile it's almost always surprising what's using up the largest portion of the time, and often it's something easily whittled down. It surely won't be this little string manipulation stuff.
minn0w@reddit
I like this approach. As someone with Asperger's, this holistic view on the whole system would train my brain of the relative value of 10ms in a small area. Include metrics on how often that code is used as well. Sometimes 10ms on something that runs once a week can really bring home the relative value that a single trace wouldn't.
DrShocker@reddit
In fairness, I had something where I increased the speed of something by around 3-4x by eliminating some copies of `std::vector`s in C++. I did profile it to see that was happening, but still... it's the kind of thing that indicates certain patterns are/were common in the code which shouldn't be and if fixed would have impacts on other areas too more than likely.
Comfortable_Ask_102@reddit
I'm kinda disappointed that this comment is not upvoted more. From the beloved c2 wiki:
Derp_turnipton@reddit
https://www.youtube.com/watch?v=p5HwAdmefo4
das_Keks@reddit
It's not even 10ms but rather something like 10μs. 10ms would like the time for a fast HTTP request.
He should write the code that is easier to write, understand and maintain. Whether that be working with eight strings or one.
Epiphone56@reddit
If it was me, I'd lean into his desires to make things more efficient, and give him a project to identify all the reasons why the installation process takes AN HOUR, with an estimated time saving from each change. This can be done as a project given part time resource allocation delivering incremental value over time.
If you've got only corporate customers who will be refreshing their hardware every 3 years, then yes memory and processors are cheap, Moore's law etc. If your customers are consumers, who may not be updating their hardware anything like as often, then your installation process could be a major pain for them.
syklemil@reddit
Yeah, I can't recall the last time I had to spend an hour on an install outside bandwidth limitations. While this doesn't particularly come off as the spot that needed improvement the most, the company itself comes off a bit as at least a bunch of simmering frogs who think the recently-added frog is weird for struggling to turn down the heat.
Judging by OP here I wouldn't be too surprised if the young frog eventually leaps out of the pot and then starts telling stories about the time they were stuck in a simmering pot and all the other frogs in there were just fine with it.
MoreRopePlease@reddit
Installation is frequently the first impression people have of your software. So this could be argued as brand management, depending on what the product is and who uses it.
Weekly_Potato8103@reddit
The first rule of thumb is to profile and measure before getting crazy with optimisations. I've seen developers over-thinking in terms of optimizing memory and operations to save like 10ms, at the cost of adding codes that are hard to maintain.
The first rule is to always focus on codes that are easy to read and maintain, and only optimise when you are sure you need to, but with clear data that supports that. Without that you are just over optimizing, which is not ideal.
mincinashu@reddit
10ms sounds like an exaggeration or guesstimation. You should profile/benchmark first, get a baseline, and then measure the new changes. Who knows, maybe it turns into a regression.
It's a good learning opportunity, I wouldn't be dismissive, but only if they're thorough with the before and after measurements and of course if time and priorities allow.
bravopapa99@reddit
Ah yes, the time old technique of beating enthusiasm out of them! LMAO
In 40 years I have:
(a) been that junior back in 1984+, when I did cycle-counting for a living with fail safe railway embedded systems, and industrial control embedded solutions all in the name of 'efficiency', it mattered way more then I guess as resources tight!
(b) I have become the guy beating them down, but in a good wholesome way.
You learn, and eventually it hits you: nobody other than you and your fellow nerds give a monkeys how it works, business only cares they can maximise their bottom line out of it! Sure, you shaved off 0.5ms per page request, you saved the planet, lowered data centre temp by 0.0001 degree etc but to zero applause.
Technically the split costs more as each allocated has memory overhead.
So, at 30 years old he has life experience so can probably handle, and probably would enjoy a decent intellectual exchange instead of just getting knocked back with 'not doing that'. He might find the term 'junior' irritating at 30 and so he also might feel he has to put out a bit more? It's just a title, we all know that but his first SWE job at 30, he might be feeling a little uncomfortable too!
I'd ask him to first explain why he thinks splitting is a good idea?. Why 8? Is he thinking SIMD libraries? Has a read something about vector support in CPUs? Who knows, but asking him to explain will be good so you know where he 'is coming from' on this issue.
Then the string has to be rejoined, more memory heap thrashing. Hope 8 deallocations and then a bigger one to suck it up, thrash thrash thrash!
If you are not his manager I'd say you are far better placed to be a little -less- tactful but in a pleasant way; explaining for example that response time is preferred than server load. Sure we know we can throw more money at a cloud service to uprade if that's cosst effective. When it ceases to be so, then its time to profile and then make those efficiencies. I guess having just graduated his head is full of DSA-s and stuff like that and he's dying to use it all and make an impression.
So, ultimately, at my age, with my past, I am inclined to agree that making the 'algorithms' as efficient as possible is true, but you can maximise for memory or speed, rarely both, bot sometimes you get lucky, Knuth did that work for us! Maybe convince the company to buy all volumes and level everybody up?
But at my age, I realise that as you state, time is the preferred metric in this case, yes, memory efficiency is a small part of that, but mostly, networking delays, database delays, broker delays will usually swallow and small gains anyway.
This is in both your favours if played right, he sounds keen and hungry to cut-and-thrust the might magic bits we flip every day, so always hear him out but yes, make him clearly state his reasons, that's good for him and you as you learn how he is thinking, presumably you have a good hiring process and he's there for all the boxes he ticked, if not, well, "Let's face the music and dance..." as they say.
It sounds like you two could end up good coding buddies!
Good luck.
Becominghim-@reddit
You break it down in terms of costs : For arguments sake let’s say his hourly rate is $50 an hour. 2 hours of his time is $100, let’s say another hour for a senior dev to go over his PR etc which takes it up to $150. I.e total cost to company is $150. You then need to work out how much money that 10ms brings the company. This is much harder as you have no clue what the page is. But yeah, essentially a cost benefit analysis will explain this to him
radressss@reddit
You are not his boss. even if you were, id say keep him motivated so maybe he will own that 1-hour installation process and likely later will make much better impact. What do you install for 1hour btw?
thekwoka@reddit
Man, there are probably more important optimizations he can look at if the install takes one hour...
Odd-Entrepreneur-449@reddit
Yeah, new dev, asking for advice. He found something that was interesting to him, and asked for your advice on approaching it.
I'd suggest 1. Directly answer his question. Otherwise, it's going to keep bugging him. 2. Then, use a little time to explain some of the areas of the code that you really wish someone would take a look at with a mind for efficiency.
While time efficiency is important, so is your relationship with them, and so is their skillset. Invest in them if you expect them to be there.
cocoapuff_daddy@reddit
Is this ExperiencedDevs?
peripateticman2026@reddit
I'd say he's got the right attitude. You on the other hand...
MinimumArmadillo2394@reddit (OP)
Id love to know what you mean and how I can be better rather than just reading a sly jab on reddit.
Yabakebi@reddit
Probably best not to read into the other person's comment. Looks like they just came here to insult with little context
BanaenaeBread@reddit
He spent 2 hours of time by 0.0003% and reducing temporary memory by 1 MB when we have 16 GB of RAM.
Ask him if its a good idea to spend 40 hours and decrease the install time by 0.006%?
How about 400 hours and decrease the install time by 0.06%?
Then tell him, its so extremely obvious that he should not spend any time on that task for the sake of memory cleanup or time improvement. The only reason to consider it, is if it makes the code more readable.
randylush@reddit
How do I tell him that being memory efficient, while good practice, isn't always the priority, especially with dealing with small amounts of data?
Say to him: "being memory efficient, while good practice, isn't always the priority, especially with dealing with small amounts of data"
Temporary_Emu_5918@reddit
No I dislike this thinking. My lead made me implement something in a way that takes 2m instead of the 1.5m it could take. every subsequent user demo had them complain about slowness, but because the feature is now released he won't let me go back and refactor. Now I'm responsible for poor experience for my users
lipstickandchicken@reddit
Milliseconds, not minutes. 10 milliseconds.
Temporary_Emu_5918@reddit
oh rip I read that as minutes and was like 😒
BelatedDeath@reddit
you just spent 2 hours on reddit complaining about a junior spending 2 hours to save 10 minutes, at least he did something useful
lipstickandchicken@reddit
10 milliseconds, not minutes.
MinimumArmadillo2394@reddit (OP)
2 hours? Post took 3 minutes to write.
Also since when is asking for communication advice complaining?
BelatedDeath@reddit
if he has deadline requirements he's not meeting because of this then that's the evidence you need to tell him to focus on priorities. if he's meeting his deadlines, then why are you complaining? if he's not using his extra time as wise as you want, then give him other tasks he could focus on. I don't understand what's so difficult
magichronx@reddit
The biggest thing is the context here. A 1-off savings of a few minutes is practically worthless, but if you can frontload some work and save a few minutes across hundreds/thousands of times per day then you have a fair case justify the extra dev time
lipstickandchicken@reddit
It's milliseconds, not minutes.
13ae@reddit
i mean better code is better code but why is he taking 2 hours to split and join some strings lol
bodefuceta92@reddit
Java
sciences_bitch@reddit
I was gonna say C++
Maxatar@reddit
C++ appends strings in linear time as one would expect. Java appends strings in quadratic time unless you use a StringBuilder.
Nyefan@reddit
This hasn't been true for almost 20 years. Java string joins have been between O(1) and O(n) depending on how aggressive the hotspot compiler is on that section since 2006.
PretendOil8923@reddit
Doesn’t smell like “better code” to me.
turningsteel@reddit
5 minutes to split and join the strings, 115 minutes to write tests, run the tests, run the code coverage, push it up, see that the code quality scanner has now flagged something, make another change to appease that, and now copilot AI has something to say about the code so better address that…
Sir_lordtwiggles@reddit
To be fair, the tests probably should happen anyways if they are not covering the section. This is a 0 functionality change
renderDopamine@reddit
Then in a week, another 2 hours to fix the bug they likely introduced
besseddrest@reddit
cause there's 8 of em
tigerking615@reddit
Good thing there aren’t 32 of them, or he’d be there all day
besseddrest@reddit
he'd have to clear his calendar
delventhalz@reddit
I would argue more complex code with no noticeable performance benefit is not better code.
drumDev29@reddit
Actually really good use case to throw in an LLM and get it done in 30 seconds
MinimumArmadillo2394@reddit (OP)
Its more a "I need to parse these strings and the parses are somewhat ambiguous so I need to cover the cases and write tests" rather than a simple .split lll
lipstickandchicken@reddit
Explain to him that his optimisation saved around 1/10 of the time it takes a person to blink. Important in gaming or finance but a complete waste of time in an install process.
theunixman@reddit
Do the math. You build a model of time vs cost, let the other developer work through it with you, and let the facts and the analysis speak for itself.
Trineki@reddit
Honestly, school brain vs work brain. It took me a while to get out of this too. A lot of time in school we get hammered with most efficient and get marked down for being a bit in efficient.
Corporate world you gotta learn exactly what your trying to teach. But unlearning something you just learned is going to be hard so it will likely take some time and frankly just experience on their part. Maybe some push back from their lead or PM asking about that time and questioning whether that was truly time well spent.
Heck 8ish years on I still struggle with the should I make this better or is it fine argument. I normally make a TODO comment so I know to come back to it before I hand in the code and give it one last lookover.
But this is a skill and a fine line that, as others pointed out, heavily matters per industry and context. Shaving 10ms on an install vs a game frame... Massively different contexts.
Alternatively, does the junior have spare time to do this and grow and learn technically. Maybe his next up task is low priority or just nothing. So he is making this task all it can be Just my 2 cents from my little bit of experience
sanityjanity@reddit
"the juice is not worth the squeeze"
mrfredngo@reddit
No less a person said “premature optimization is the root of all evil” than Donald Knuth.
GaboureySidibe@reddit
Your install takes an hour?
MinimumArmadillo2394@reddit (OP)
Yes. Its around 8m lines of code. Has to do various things like setup a demo DB, setting up web sockets for connections to a C-application, and installing quite a few things.
GaboureySidibe@reddit
All of windows installs in 10 minutes
MinimumArmadillo2394@reddit (OP)
Okay? Microsoft employs about 30,000 more people than we do? They also use more up-to-date pieces of software? I'm not sure why it matters.
Entire PhD theses have gone into Microsoft's operating system and its efficiencies but our core products was made by a bunch of electrical engineers in someone's basement.
GaboureySidibe@reddit
Okay? Why is everything so slow? Copy the files and do things in parallel? Question marks after statements?
MinimumArmadillo2394@reddit (OP)
So the installer was made the '90s lol.
Windows 11 installer was made couple years ago.
You're asking me a question that I can't answer and you would know that I can't answer it. If you would read the first statement that said, I just started. I don't fucking know like
Legitimate_Plane_613@reddit
Show them this chart
For this specific situation, have them calculate how many installs would have to be performed before the 2 hours is made back up. (7.2 million if I did my calculations correctly)
Generated_by_Apple@reddit
Sarcastic reply here, but he’s just trying to get quantifiable metrics for his resume lol
confusedicious@reddit
The problem here is not the concept, it’s that he thinks what he knows compares to someone who has years of real world experience. You need to get past that problem before delving into the details. Also, it’s a huge red flag if someone is closed to listening to listening to others, that won’t turn out well for him
ummaycoc@reddit
One other perspective for this is that a junior engineer is still learning and if they spent 2 hours on this low benefit but also I imagine low cost problem, and they do that a bunch of times for a bunch of other work, then after a while they will have more well developed skills for some bigger problems that are higher benefit and higher risk.
This shouldn't be the only sort of work they do, but this sort of thing (for any level engineer) can be relaxing (you're not stressing out too much about risk, etc while getting *something* done) and a learning experience. A few years ago I took short breaks here and there to do random `bash` things. Like keep a somewhat up to date weather forecast to output to the terminal when I start a shell. It had nothing to do with my job, but this was part of me learning some things about `bash` and I still have some learnings from that which I share with others.
TLDR: Ask them to work but also let them take time to play. The play will help develop skills for later work.
curiouzzboutit@reddit
We take walks to the park taking an hour sometime. Acting like he wasted days. If he learned something in that 2 hours pretty valuable time. But yeah silly mistakes are expected and a great teaching moment if you want to help. If not just post on Reddit and don’t discuss with him :)
w1na@reddit
Just ask him how much money it will make the company from him spending the 2 hours. Also ask him to fix it on his own time if he really feels its worth it to do so. Then assign him critical bugfix tickets, that should keep him busy and productive.
zemdega@reddit
If it’s in your build then these things do matter, since it can add up over time. He will hopefully learn to do things more efficiently over time.
TRexRoboParty@reddit
Do you have performance metrics of the application?
Can he/you use a profiler to show him that the most "bloated" parts of the app are elsewhere? Then it's pretty simple to say a better of use of time is to fix the worst bottlenecks first that may net say a 10% improvement, rather than a few strings that might net 0.1%.
If there's no actual measurement happening then it's simply all guesswork for both of you and the first thing to do is measure.
talldean@reddit
The hardest one I have to explain to new folks is that quality is both a cost and a *variable* cost; perfect quality... isn't the goal of anyone coding for a paycheck, because perfect quality vs what else you personally could do with the time isn't worth it.
Some projects, the quality bar is in the middle. Some, it's way lower than that. Occasionally, it's fairly high, but those are the rare jobs.
sp106@reddit
Dont optimize if you don't have a reason to optimize. Keep things as simple as possible as default.
If you do need to optimize something, collect data so you know that you're optimizing the right thing and achieving the desired result.
A single 10ms on an hour long install is neither necessary or the right spot to do an optimization.
Western_Objective209@reddit
Did you run the application through the profiler and measure it took 10 ms or are you just assuming it only takes 10 ms? Did he run the application through the profiler?
This is something that can be easily proven empirically, which IMO is a lot better then trying to argue about it
MinimumArmadillo2394@reddit (OP)
I know what the function hes modifying does.
Its an estimate. The string is used once and sent to an exe as options for execution but needed to be modified to prevent injections.
Co worker is torn up about turning 1 string into a few strings then back into one. Worried about Java's immutable strings taking up too much memory. Max len for them is around 100 characters each
Western_Objective209@reddit
Okay I see what you're saying. So a good strategy is to talk in terms of bytes; 8 strings, max 100 chars, that is 800 bytes, I think java stores chars as 2 bytes, so 1600, then String class overhead, another 40 or something. So at most we're talking about 1.5 kb. A Java runtime like that takes what, like 200 mb? At that point, yeah it's pretty insignificant.
But if you have a bloated runtime I've seen them up to like multiple GB of RAM to run something pretty small, and at that point I would be encouraging people who find memory savings even if their first attempt was pretty insignificant.
So IDK, context is everything in this case, but just more general advice what I've seen works is talking about hard numbers. Like even 10 ms sounds high based on what you're describing, I have an application that can process a 20 MB JSON record in like 1-2 ms that's pure Java and it has a lot of string manipulation and building small lists, sets, and queues several times, so my guess is what you're saying requires ns level precision to measure a difference, and at that point the execution time doesn't matter even if it's being called many times
MangoTamer@reddit
Why is he focusing on string manipulation problems when he should be focusing on IO delays? That method he is optimizing better be called a couple million times for it to be worth it.
MinimumArmadillo2394@reddit (OP)
Because the things hes doing doesnt involve IO at all
dethswatch@reddit
I'm not sure you can fix people like this- they're purists, not pragmatists.
programmer_etc@reddit
I spent two weeks worth of evenings getting my zsh zprofile load time down to under 50ms from 300 something because I type as soon as I hit the shortcut for my terminal and anything over 50 annoys the hell out of me.
Sometimes the time saved is worth more than the time spent.
MinimumArmadillo2394@reddit (OP)
My coworker asked me about my thoughts and I gave them. He explained how he was concerned about memory of the application because a client could be on a machine with 4GB of RAM. Hes trying to be too efficient for any somewhat modern machine, as Java destructs strings when leaving the context the strings are created in so ultimately his attempt to be efficient wont do much but save maybe a KB in the heap for a split second.
So I gave my thoughts and he was hesitant to believe them. So Im here asking how I can do better.
bwainfweeze@reddit
It’s the energy not the time. That little spike of resentment occupies a corner of your working memory that may have been packed with one five working theories as to why machines are spontaneously rebooting in prod and it’s an hour until your most profitable period of the day.
The other important things to remember is that it’s a valid coping mechanism to put up with an error now that has been bugging the shit out of you by promising yourself you’ll work on it once the smoke clears. While a lot of people are lying any time they say “later” not all of us are. And if you try to stop them from fixing the problem, all of that frustration may get transferred onto you. Because now it’s not some accidental coding decision that’s pissing them off. Now it’s your fault for obstructing.
GaelTadh@reddit
At one point, I printed out a 6 foot high banner of Knuth's famous quote "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." And hung it in the engineering dept.
feeling_luckier@reddit
I like it. Question, what is the tipping point here though? When should optimisation enter the conversation?
Something I've seen is teams worrying about using select * vs the actual field names (negligible diff) but not using indexes. Meaning you need some kind of frame to understand performance in the first place.
Klinky1984@reddit
Wait, your installer takes 1 hour? I do agree that 10ms is nothing compared to 1 hour, but 1 hour? Really?
MinimumArmadillo2394@reddit (OP)
Yes. 1 hour. It has to do a ton of stuff, including setting up a demo database with around 50 tables and over 50k rows on those tables. Then devs have to re-sign all 45 jar files which, on our VMs (have 2-4GB) takes around 15-20 minutes ontop of the hour it takes
EvilTribble@reddit
Maybe introduce the concept of an application being "Uniformly Slow" and he'll understand that.
Also if it takes him 2 hours to fart around with strings I'd just let him learn something so maybe he can get a move on when there are more important features to implement.
thmaniac@reddit
Tell him he can save a lot more time and memory by improving the architecture, and completing features and stuff faster gives you more time to do that.
RelationshipIll9576@reddit
Ask him questions. Don't tell him.
What you need him to learn isn't to not optimze, but to apply better judgment when it comes to prioritization, trade-offs, and if something is worth it (especially in compairson to other things that need to get done).
They best way I've found to do that is to ask questions - questions that you would ask yourself to get to the right decision. Teaching him that skill is far more valuable.
SikhGamer@reddit
It's a scale;
bwainfweeze@reddit
I did enough changes of the “costs every team member ten minutes a day” that it added up to 40 hours a week.
More importantly, we had a shitty code-build-test-push process and once you subtracted meetings and other distractions, you could only reliably get through 4 full cycles a day without working much later than we usually did. I got it so that on a good day you could do five and still be out the door before six. That’s an additional 10-25% improvement in dev productivity, depending on how often they pull it off.
saposapot@reddit
There’s probably a gazillion of articles about premature optimization or in this case misguided optimization. Probably something even from Joel on software blog or coding horror you can send him.
This specific problem is very nuanced as it can be as you say and it’s over optimization or it can even be wrong to save memory here because it takes mor cpu time. Spending 2 hours is also very relative… would he be instead surfing the sports sites instead of working on that or would he be working on something useful?
Sometimes people embark in little “puzzles” like this to also relax a bit and make them happier in their job.
BUT if this is a trend that he wants to overoptimize and lose 1 day then 1 week in this stuff, that’s a different pattern…
At the end of the day you should teach them to actually have data for the discussion. Profile it. How long does it take? Is that a weak point in the process or are there better places to invest?
Even if the data is there, what’s the right process? Probably create a backlog ticket explaining and showing the data so the manager can decide if we should do it or delay it?
Also teach them what’s their job. During college their job was to code perfectly to the teachers as they wanted to get good grades. Now their job is to code for the business to fulfill clients needs, code perfection isn’t the end goal in itself.
AnnoyedVelociraptor@reddit
I wish more developers cared. Everything is so sluggish because of abstraction layer over abstraction layer, with garbage collection, and 0 memory management requirements.
My phone is I don't know how many times as fast as the one 10 years ago, but apps feel slower.
bwainfweeze@reddit
Something I’ve bumped into is a couple of devs using a bad coding idiom and justifying it by the fact that it’s still in the code. And in fact they might be using that code as a cut and paste target.
At some point someone may have to go change code that doesn’t need to be changed in order to expunge an antipattern. So if someone is changing code that doesn’t “need” to be changed I would like to know if it’s part of a pattern and we are either just beginning or just finishing addressing. For instance some subsystems may have fewer consequences in a production issue, and thus they make good guineapigs.
My last job we had a couple of services that would only be used at deployment time and I used the shit out of it to test more aggressive architectural changes in a sandbox.
I was loath to turn one of them off because I had a ladder of escalation of how much code a change ran and I would start with the simplest case and work my way up to our flagship app, and have a good estimate of what it would do to the system. From build process through to response times.
CarelessPackage1982@reddit
I don't disagree with you one bit, but it's hilarious that all these interviews are hyper focused on eeking out the best solution for algorithms. Then when you get a the job, naaaaah forget about it!
DoingItForEli@reddit
tell the jr the user would need to repeat the function 720,000 times to save as much time as it took them to code the optimization
kevinossia@reddit
10ms on a one-time install doesn’t mean anything to anyone. That should be obvious even to him.
10ms between network packets in a data stream, on the other hand, is basically one and a half eternities.
bwainfweeze@reddit
Little and Amdahl will catch you in an alley and beat your lunch money out of you.
10 ms of cpu time could shift the inflection point where P95 response times start violating your SLAs and result in another 5% cluster size and an uptick in deployment times which may add up in workflow time.
The reverse is also true. People don’t notice how that little feature they added increases the cost per request of the entire system and this reduces net revenue. When profit margins are less than 10% every little savings you manage is multiplied by eight or more, and then by ten or more on Wallstreet. That’s why consumer electronics cut corners to save pennies. Ever one of those pennies is multiplied and then multiplied again.
raekle@reddit
Premature optimization is the root of all evil.
derangement_syndrome@reddit
Bruv I spend 8 hours to save customers 0ms almost every day and I’m a senior.
Frenzeski@reddit
This happens to mid and senior engineers too, having SLOs helps articulate where the its valuable to put your effort
nemec@reddit
be kind to him, Big O is the only thing the poor guy knows
bestjaegerpilot@reddit
uh what is the dollar value of those 10mins for every customer.
it you have just 1000 customers and the dollar savings is just $1, then that dev just saved 1k... totally worth it
MinimumArmadillo2394@reddit (OP)
Ms. Not minutes. Milliseconds.
ActuallyFullOfShit@reddit
Honestly he's just very green. You already told him the truth about his use of time, and he wasn't receptive. He'll learn through experience, especially if he starts missing deadlines. Id recommend reporting to your mutual manager who could effect forceful feedback if needed.
Embarrassed_Quit_450@reddit
Teach him proper optimization and profiling.
MordecaiKravitz@reddit
There are basically 1 of 3 things someone will need when being mentored;
A direct answer.
Simple guidance to reach the answer on their own.
Hands on guidance to be provided context and deeper knowledge/perspective.
When presented with a similar case, I interpreted this as someone trying to do their best work, and might be trying to demonstrate (not only to the company, but to themself), that they're worthy. I would approach them with option 3, and start an honest conversation about always trying to work on the most impactful and valuable thing you can be. This is what moves everyone forward, and should be your focus. This work should not be discouraged, but if it relies on someone else showing the same diligence, then it's a fix in anticipation of what the codebase could be, and should be weighed as such.
I would also emphasise that it's a small win, and that I'm happy they did it.
FunkybunchesOO@reddit
Is a repeatable function if he makes the change? If you can use it elsewhere in the future it's a good change.
jl2352@reddit
First there is a bunch of positive leadership style things. For example having goals about what the team is trying to achieve, and what value they are trying to deliver. Having clear backlog refinements or sprint plans, which has clear prioritisation (and why). It also helps a lot to add a prioritisation system to tickets (this ticket is a P2 and so should be done before a P3).
It could also be something else as I think you get the idea.
Now that shouldn’t be you laying down the law. It should be you trying to build and guide them towards that. Ideally working with them, so they can be a part of building it and run it when you’re not there.
All said and done … then you lay down the law. If you’ve done prioritisation and he’s off working on random shit, you are justified in asking why are they working on that. Drop it. This is because you’ve worked, and made it clear, you want the team to have a healthy system for this stuff. He is ignoring it.
^ All of that is the long version of what I advise. Sometimes engineers get bees in their bonnet about ugly code that just doesn’t matter (including myself on occasion).
Another thing that I have seen help is to have 10% time. There he is free to optimise the string formatting in the product then (as long as it meets your standards of course). In my case lots of engineers used it to fix low level technical debt that annoyed them personally.
_totallyProfessional@reddit
It is a mark of a senior engineer to be able to realize the business value of work. Knowing when to spend time on something and when to write a jira ticket for a more junior engineer to take as a growth opportunity.
This person sounds fairly new to the industry and working on things like this are often the type of contribution you can expect and still appreciate.
It can be valuable for him to do this work to learn patterns and develop, but at the same time take some time to talk/mentor him about the time/value to the business.
Now you sound more senior. This is really an opportunity for you to grow. Software isn’t just about software.
travishummel@reddit
I was so happy when I moved into a more senior role and I had respect for my decision making. Approved an O(n) solution when optimal was log(n), but n maxed out at 5.
When I was a junior eng, I had this horrible dude review all my code and push back if it wasn’t supremely optimal.
Sulleyy@reddit
Software development is all about finding good enough solutions. If everyone optimizes everything, nothing gets done
jmking@reddit
Bro is trying to turn an eye dropper into a syringe.
Does the syringe hold more liquid? Totally.
Was that a worthwhile upgrade? Depends.
What's the impact? Well, the house is on fire. Trying to put it out with a syringe isn't going to do any better than the eye dropper. So no - that was a waste of time.
This is a classic example of getting caught up in the micro without the perspective of the macro. It's an easy mistake to make because from a relative perspective, the syringe can be quantitatively measured as a 500% improvement.
mpanase@reddit
"you are a junior, stop doing that"
"if you want to debate me, that's awesome. Here is a very nice book explaining it. Read it when you arrive home"
Dependent-Net6461@reddit
Fire him
Awric@reddit
If he’s a junior, I think it’s fine to let him explore and get a little creative. It’s important to give engineers that freedom. You’re probably right, but you don’t want to be too prescriptive. “Don’t do X. Why? Because I said so!”
Instead, prove to him why it isn’t worth it — or even better, give him a chance to prove you wrong. Gather performance metrics / establish a baseline and measure the improvement.
severoon@reddit
It's hard to make any judgment based on what you've described, but in general…
Readability (usually) trumps all. Code is read much more than it's written, so it's almost always a net gain if you spend time making code easier to read and reason about. In fact, it's frequently the case that making something perform less optimally in exchange for a simpler, more understandable approach is a good idea.
Remove speed bumps. As coders we know all about yak shaving, but there's a mental equivalent. Imagine understanding code as merging onto a highway and blasting along to your destination at 80 mph. Except, as soon as you get on, there's a small thing in the road. You slow down and, oh it's nothing, you speed back up. Then there's a pothole. Then there's unclear lane markings that cause people to overlap into where you think your lane is. Etc, etc. Instead of getting your destination at 80 mph, you end up with an average speed of 35 mph.
It turns out that removing all of these little pain points, en masse, is a much bigger deal than it may seem at first. When simple things are done simply and complicated things are done clearly and well as a matter of course, the average speed stays near optimal in the understanding phase. In the implementation phase, you often find yourself feeling like you're being dragged down with all of the unit tests you have to write and instrumentation you have to install, etc, etc, but the truth is without those things, you will end up going to work feeling like you had a very productive day because all of these new and exciting things are happening (due to bugs), but when you step back you realize all you're doing all day long is holding the line. If production isn't nice and boring for exceedingly long stretches of time, that's a red flag that your org is dedicating a lot of time that could be devoted to running fast and preventing problems (by writing tests).
Job satisfaction. Some amount of autonomy and freedom over your time is necessary to feel like you're able to deliver something you're proud of. If you want people to be happy and passionate about their work, you cannot micromanage them. It's perfectly fine to give your opinion of this or that task, but make sure it's clear that for such a low stakes thing as two hours, even if it doesn't tick any of the above boxes (which it probably does) the ultimate choice is up to them and you won't have anything more to say about it.
One of the best things I can say to anyone mentoring or managing other SWEs is this: Judge them by the amount and quality of their output over months, not days, and definitely not hours. The best and most productive coders I've ever worked with often look like they're just doing little dribs and drabs of work, it's only when you step back and look at the big picture over a significant amount of time that you can tell if their approach is effective or not. If you see someone not being effective on that time scale, then I would still focus on things applicable to that window of time and not pester them over a few hours here or there.
Additional-Map-6256@reddit
This is why I like people with real world experience vs academic experience. I'd recommend telling him to think about the business impact, because your company cares more about making money than perfect code. He should consider how long that tiny performance increase will take to pay for 2 hours of salary, if it does indeed save any money at all. My guess is that the code will be refactored or sunsetted before it is worth even 1% of the development cost
illogicalhawk@reddit
I'm curious what he means by "bloated", because that tends to refer to how things are written and organized rather than how performant they are, and if anything I find that these types of micro optimizations tend to result in bloated or unmaintainable code.
There should be a good reason for doing something like that, and "because we can" doesn't make it a compelling use of time.
Damaniel2@reddit
It's all about perspective. Point out that optimizations are good, but that if he's going to make them that he should consider the scale. If you spend 2 hours to fix something that saves 10ms, then you're wasting effort unless you can save that 10ms more than 720,000 times. If you're saving 10ms tens of thousands of times a day, every single day for years on end, then spending a couple hours to make things more efficient is possibly worth considering. If you're only saving 10ms a few times a day, you'll never make that time up.
I understand the satisfaction that comes from making something more efficient, but in cases like this you're almost always better off spending your time doing something else. Understanding these things come with time and experience, but pointing him in the right direction will hopefully get him to start thinking about the bigger picture of 'effort expended' versus 'time saved'.
DrFloyd5@reddit
When is the right time to micro optimize for a beginner? Never.
When is the right time to micro optimize for an expert? Later. Maybe.
When is the right time to macro optimize? Before you even begin coding.
Konomitsu@reddit
Is there an issue with his throughput or is he constantly not delivering? Not really seeing an issue here. If anything, you should also join in with the optimizations. Do an audit of your systems performance, identify the processes that take up the most time and focus optimization efforts there. I wish I had more developers under me that were conscious about Big O, Big Theta. Time and clyomatic complexity is something i feel most dev's don't care about enough before "memory" or "compute" is cheap. This thinking will get you in trouble when you have the need to scale.
Great_Distance_9050@reddit
As a Staff Eng I see this all the time, sometimes you just need to leave people to their own devices so they can learn first hand that the optimization doesn't actually matter. It's great that you offered them advice, but it's up to them if they can learn from it or not. You as well should work on letting go because it also doesn't matter if they focus on it or not you're both wasting mind power on something that doesn't matter.
PoopsCodeAllTheTime@reddit
Just tell him that it would matter in case the scale was upwards of thousands or of strings, because latency*iterations=impact, this basically solves it in his head too
MrJakk@reddit
Are you able to profile the install somehow? A tool that lets you see what parts are taking longer or shorter.
Once you have that it may be easier to show perspective. 10ms is nothing in the grand scheme of things. If you want to be efficient, this thing over here takes a whole second.
Did he task himself with the job of making it faster or was this an optimization he’s doing while implementing another feature?
Bakirelived@reddit
Print out this table https://xkcd.com/1205/
titogruul@reddit
[ Removed by Reddit ]
slowfly1st@reddit
An argument of 'ownership' or 'economics'? 2 hours for 10 ms. 8 Hours for 40ms. 365 days = 14 seconds out of an hour saved. If it were his company, would he hire an engineer, and let him work a year, just to shave off <0.1% of install time?
littlbrown@reddit
You haven't met my customers
Triabolical_@reddit
"Our policy is that we only do optimizations that show that the code is slow for a scenario we care about..."
breefield@reddit
I find the "golden triangle" is useful for these kind of prioritization exercises. If your company's priority is shipping at the moment, communicate that schedule is top priority and not quality.
If cost is actually top priority and his optimization could be communicated in terms of that—let him pull the thread himself and realize the marginal cost savings are so minuscule in comparison to the cost to employee him, that you'll be better of scaling compute/memory as needed.
armostallion2@reddit
I commented on this comic above, in response to another post. I don't like the comic, I don't think it conveys the point well, and it's difficult to understand quickly, at least it was for me. I'm not sure it'll make an impact on Mr. Efficiency coder guy.
breefield@reddit
One must read the title in it's entirety to understand the scale: `(Across Five Years)`
armostallion2@reddit
also, I edited my original response above with an update. Please consider it.
armostallion2@reddit
correct, and I caught that after trying to make heads and tails of it for a while. I don't like the comic, even after understanding how to read the table and successfully computing the sentence that describes the values.
WeekendCautious3377@reddit
The problem is not the time it takes to write it the first time. The problem is the time it takes in perpetuity to understand and maintain this code across teams that will inherit this long after he's gone
dbxp@reddit
I would ask him to look at the telemetry and follow the data to where the performance bottlenecks are.
JuanChainz@reddit
Teach them to focus that energy where it counts. Start by teaching them proper ways to measure and understand where the true bottlenecks might be and how to identify them. Teach them that patience here is actually key because premature optimizations really don’t benefit anyone. What if the time they spent improving that one scenario could have translated into a much larger time saving for the same cost. Without measuring these things and understanding the pain points, it doesn’t matter if they saved 10ms or an hour, what actually did they impact? In some cases, efficiency does matter more to the level that they are describing, especially if it translates directly to money saved for the company, but teach them to express it that way and to start reframing how they view their time and energy as an investment. What provides the most ROI.
It’ll be both a great learning experience and arguably critical for proper career growth and visibility.
jswitzer@reddit
This. Prove to me via profiling and metrics that expensive optimizations are worth it before you do it.
AHappySnowman@reddit
Is he even saving 10ms?
Code efficiency doesn’t always come in the ability for it to be execute the fastest. Developers ability to read, and thus maintaining is also something that needs to be efficient.
armostallion2@reddit
I think this is the correct answer. Readability over cleverness, every time, when all else (extra super duper efficiency) is inconsequential.
chrismo80@reddit
The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time
mercival@reddit
"How do I tell him that being memory efficient, while good practice, isn't always the priority, especially with dealing with small amounts of data?"
By ensuring they work on what they're delegated to work on by your team lead instead of going down rabbit holes.
By also ensuring your team-lead doesn't give them leeway to work on things like this as a learning opportunity - juniors interesting and learning and working on things like this is often mid-term better than just giving them other things to work on.
What would they have actually done to add value immediately in 2 hours to offset it?
birdparty44@reddit
All projects require documentation that establishes code style, architectural patterns, and who has the final say.
Then you can always refer to product docs about “how we work”, and if he doesn’t listen, you get the lead to overrule and get this person in line.
nickisfractured@reddit
Ask him to name 10 other places in the installer where you’d save more than 10 ms. Then after he tells you tell him this isn’t priority even if we were to be working on addressing inefficiency vs productivity
Basic-Magazine-9832@reddit
if you are trying to control 2 fuckign hours of a junior you are a micromanager and YOU ARE THE PROBLEM.