Most developers do not write software that is going to last decades. Eventually, every code needs to be rewritten.

It doesn’t matter what the reasons could be.

A new preferred tech stack, API, changed user requirements, deprecation, redundancy or self-reflection could be one of them.

For example, let’s imagine a team built a software piece that was in Java. Then after some time, new hires are being made. Then let’s say the majority of the team now are Go (Golang) experts. The team is probably going to rewrite that Java code cause that is the preference.

(Ignoring the fact why you would hire Go experts when your software is built on Java)

Another example could be new APIs that are getting released. Usually, the old ones will get deprecated eventually. Meaning you need to rewrite old code to make use of the new ones. For example, iOS releases. After some time, developers need to support the new versions and stop supporting the old ones.

These are some examples of why the code needs to be rewritten eventually.

But the most important reason is the fact that you have grown.

You don’t wake up one day and know everything about writing software.

You get experience over-time, learn new things, and solve new problems every day. While you gain all this, you will realize that your old code can be rewritten. Either more elegantly, maintainable, readable, secure, simple, compact, or in general better.

That is just the nature of writing software (and even outside). It can always be better.

Rewriting code is a normal activity for developers.

Don’t stray away from it.