i have task in `Codewars` : and i found tow same w...
# getting-started
h
i have task in
Codewars
: and i found tow same ways with little diff so i need help : how can know what is the beast code ? any tool to do that ? what easy way and good performance ? Is the
build time completed
when run app , can relies on it or no
v
There exists no "best code". If you mean "most performant" code, then don't even try to do that, or you need to right away write assemble instead of a higher level language. Also it usually is not worth it. 80 % of the lifetime of a program is spent in 20 % of its code and there is not much point in optimizing the other 80 %. Generally: 1. make your code work like you intend it to (optimally with tests, will give confidence for later steps) 2. make your code nice by refactoring (for example moving things into methods, renaming, whatever, so that the code is better readable and maintainable, remember, the code is much more often read than written, so you should write code for readers) 3. make your code fast, but only where you actually measured a problem. There is not much point in making some part of the code as performant as possible while loosing readability if the code is run once an hour, but it might be worth to squeeze every bit of performance out of a code line that is executed once every 100 ms.
🌹 1
m
@Vampire I'd like to add on to your statement that one thing is very important to work out: Big O @hisham bin awiad make sure to check your code complexity
🌹 1
v
But mainly under point 3. 🙂 Of course it makes always sense to use the right collection type for the usage, so a bit high-level optimization right away is ok. But there are people out there that compare generated bytecodes of syntax variants to find out which code construct they should use and similar. o_O