[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

[Advertise on 4chan]


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1629793923131.png (23 KB, 554x554)
23 KB
23 KB PNG
>be me
>senior cares more about readability, I care more about performance
>we have arguments each day on how we should do some basic stuff like string concatenation
>i tell him that the way he wants it will create 2 additional strings
>he says it's easier to read

Who's wrong here bros?
>>
Cool blog, how do I unsubscribe?
>>
File: bury.gif (1.46 MB, 200x100)
1.46 MB
1.46 MB GIF
You. He just wants to be able to make sense of your shit codebase once he fires you and replaces you with an indian.
>>
>>84463885
It depends, how much time are you actually saving with your way?
>>
We are not in the 90's we have powerful computers now.

You VILL stop optimizing
You VILL stop caring about efficiency
You VILL waste 500MB for hello world
You VILL get in the cagie
>>
you
readability>performance
within reasonable limits ofc
>>
If you are doing general webshit then readability > performance in most cases. You are wrong and immature unless this is some low level code or hyper-optimized insanely high traffic application and you are constrained by your infra (which in that case, spend your time fixing infra instead).

Arguing about the way he does string concatenation is retarded. Find a style guide that everyone on the team agrees to, and adhere to it.

For example:
https://google.github.io/styleguide/jsguide.html
>>
>>84463885

If more than 3 people will read your code, you always prefer readability
>unless the code is hot garbage and renders a dropdown for 30 sec
Your "smart" solution will be thrown away as soon as someone more senior spends more than 5 minutes deciphering it and saying fuck it, I'm not gonna answer questions about this for the next 10 years.
>>
>>84463995
>>84463978
>>84463974
its literally not that much different
my way is:
var variable = new string($"{var18} blabla");
his way is:
var variable = var18 + "blabla";

Is the first case really that much harder to read?
>>
>>84464020
ask me how I know you're an intern
>>
Performance is hard to measure. Even profiling yields vastly different results based on the execution environment.
You can get some pointers like big O notation, but don't misunderstand what it is: the rate of growth based on input size. Consider a two sum problem with a small input: the O(n) hashmap version will be vastly slower than the O(n^2) one because hashmap operations are much slower than array access.
Then a lot of software these days is IO bound and this is what most of us work on(inb4 I'm HFT genius making 1 mil/year).
Unless you're a CS God, I'd be very pragmatic about optimization and favor readability.
>>
>be me
>senior cares more about readablility, I care more about perfomance
>tell him okay let's care more about readibility then
>finish job
>go home
>working on personal project
>caring more about performance than readibility

is literally that easy. Who fucking cares about the end result in your job if none pay you attention.
>>
>>84464070
what do you mean i don't get a say in how my seniors should think (i definitely know better, trust me)
>>
>>84464020
Definitely not worth it, unless you spend a LOT of runtime in this code.

This is how you optimize:
1) big O within code where a lot of runtime is spent
2) powergap
3) If you had to ask, you're not qualified - always go for readability so that when someone who actually is qualified comes to fix your shit code, he doesn't have to spend unnecessary time trying to figure out what the fuck you were trying to do
>>
>>84464070
BUT IVE PUT MY HEART AND SOUL INTO MEGAGLOMO CORPS ACCOUNTING SUITE, I CANT BETRAY MY PRINCIPLES FOR THE MAN /G/
>>
>>84463885
>be a nigger
>argue with people who know more than you
>accomplish jack shit
>be white/european
>listen to people who know more than you
>get shit done
>>
Readability first you frogposting nigger.
Performance is good and all but it won't do you any good in the long run if your codebase is full of unreadable "performant" shit.
>>
>>84463885
>wasting hours with discussing to save 0.00000001 second
What do you think?
>>
>>84464020
IT'S NOT BETTER PERFORMANT IN ANY WAY christ get a gf nigger
>>
>>84463885
Please quit and never work in development again. Please and thank you.
>>
>>84464070
This
>>
>>84463885
>she
>>
>>84463885

make a loop, run both variants n million times and compare and post benchmarch results here
>>
>>84463885
Keep a fork of your version. If it isn't significantly faster shut the fuck up and do it the readable way
>>
Wow, so many racists on here. All reported to FBI
>>
OP's ego is bigger than the amount of trannies that kill themselves.
>>
people who refuse to work with how the rest of the codebase is designed are 100x more harmful than some shitty code, just do your job and stop making everybody else's life miserable for no meaningful reason.
>>
You're a greentext frogposter who called us bros so that should tell you all you need to know.
>>
File: 1637862256835.jpg (27 KB, 400x388)
27 KB
27 KB JPG
>>84463885
I make my code readable and then my PRs get shit on because I didn't use a bunch of unreadable one liner garbage
>>
>>84463885
are you processing terabytes of strings a second or either way box it runs on will have 99% idle?
>>
You're a subordinate. You do what you're told to do. End of.
>>
>>84463885
You

always code for readibility/maintainability and once a working product is out code for speed at problem spots.
>>
>>84464020
OP you can't seriously be having arguments over this shit.
Have you even profiled the software to make sure it's worth writing this confusing garbage? Is this even faster? Just do what you're fucking told if you have to ask.
>>
>>84463885
Readability always wins.
If performance becomes an issue, you can go in later and improve things, because its "Readable".
>>
>>84464020
To the people in this thread, would OP's way really be so bad to senior devs if he just left a comment for it? */ concatenate string with blabla using $ operator, equivalent to var18 + "blabla". I get that its a retarded hill to die on but I'm not sure why you need a single line to be expressly readable, at least one so simple.
>>
>>84464020
Those do two different things. Proof that /g/ is nocode since they don't point out the obvious.
>>
>>84464020
one, yours is doing formatting and allocating a new string
two, his is omitting the formatting and allocating a new string implicitly
>>
>>84463885
faggot
>>
>>84463885
Depends how many times the code is executed.

If you're concatenating strings billions of times you should consider performance.
If you're just outputting a concatenated string to the user performance won't even be noticeable in any way.

Usually a small portion of the codebase is responsible for the vast majority of performance.
Best to limit performance efforts to that and keep all the rest simple and easy to maintain.



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.