Yeah, currently popular languages don't have any separation, internal isolation, any way to limit or monitor authority (and use of that authority) to access and use resources at all. Programs and any part of them usually have full
ambient authority, meaning they can just name and use resources (importing libraries by name, opening any files by stating file paths, ...) without restrictions.
Instead, (parts of) programs should be restrictable to pure computation by denying any external resource access by default, unless explicitly granted or approved more (to the minimum they need, following the principle of least authority).
See: https://en.wikipedia.org/wiki/E_(programming_language) or any of the languages listed here: https://en.wikipedia.org/wiki/Object-capability_model#Langua...
Having a microkernel OS isn't really sufficient if you want to "hollow out the attack surface" well, because many programs (including imported libraries) consist of hundreds of thousands of lines of code made by hundreds or thousands of people (and now also AI). So programs should be internally compartmentalizable as well. Only this, imported libraries being able to sandbox their imported libraries and so on recursively truly reduces the possible effects of vulnerabilities to a minimum.
And only programming languages (or virtual machines i guess) can achieve these types of guarantees in a platform independent way.