Actually, a lot of the lag comes from apps needing to talk to servers far away. If the data center is on the other side of the country, that signal delay adds up fast. It's a physical limit, not just bad code.
Read an article about how some big companies are building more local data centers to cut down on that exact delay. They said even a few hundred miles can make a noticeable difference for things like live video or games. It's wild that light speed is still too slow sometimes... makes you realize how much we're asking these systems to do. Really shows it's a whole infrastructure problem, not just the app on your phone.