Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ZioCain26675yI tend to make the most efficient code all the time, I'm still trying to make stuff run smoothly in every occasion, my websites get awesome score on page speed.
But when I have to run stuff in the backend, OMG, I put so much shit in there... -
ddephor44465yReal world problems are not that elementary that you could put them in a simple O-notation.
You have dependencies, sequential processes, parallel workloads, etc.
And there are also just the practical things like tools that run once a day or once a week where no one ever cares if that thing runs 2 seconds or 2 minutes.
Also, most use cases do not process the content of a Google Data Center, so O(n) and O(n²), maybe even O(2^n) doesn't make a big difference. -
When i started to work as dev i was always trying to make efficient code. But now... man. If it runs i'm satisfied. It depends on the project and the environment too.
-
Yeah if I have stuff where complexity applies, I don't over-optimise early on, but I will still choose a decent base algo so that this won't become a bottleneck later. It's way too often that shit has to handle much more data than the devs had anticipated.
I even avoid stcrcat() in loops on the same string because that's a hidden n^2. Instead, I use a custom strcpy that returns a pointer to the end of the string.
Or, last month when I used qsort and bsearch to get to n*log(n) where the naive implementation would have has n^2. -
Mb3leb21495y@Fast-Nop that's the correct way but don't you think that this structure might take more time to find a solution where O complexity is N
-
@Mba3gar you just can't always reac O(n). But at least, you should avoid O(n^2) or worse.
I once had a thing at work where shit was done in PHP on XML on the server, and it worked with a few dozen items, but for several thousand ones, it failed after 1.5 hours. So I rewrite that shit properly and in C, then it took 7 seconds. Prime example where the original devs should have given more thought.
Here is the rant: https://devrant.com/rants/1993396/...
Related Rants
Do you all look for code complexity O(n) while coding? Or you make sure that your code runs and never look back what's happening ?
Because as per code review no one looks for code complexity and that's so sad
rant
complexity
code
o(n)