Ada has the best modularity of all the programming languages I have used.
It was designed for building large real-world applications and separates specification from implementation by using separately compilable specification and body files:
https://learn.adacore.com/courses/intro-to-ada/chapters/modu...
This allows the interface between modules to be defined concretely without relying on the implementations.