I'm sure the phone is powerful enough to compile, I just can't imagine trying to actually do it. Further, I suspect you are somewhat forgetting that this is really a phone, an appliance, and not really a computer, even though it has one inside of it - just like a microwave.
Can you write scripts like that on anything? A script that "knows" the state of another app? ( a real question, not a troll. ) It sounds like you want something similar to Applescript, which allows you to write a script which actually launches whatever apps, invokes the methods exposed by the app via the script library, and then does something else, no?
If so, I think the reason Apple excludes such a thing is twofold: one, sandboxing and security is difficult with such a beast, and two, .0001% of their customer base wants such a thing. Heck, it's almost dead on the Mac. It would be pretty awesome, though!
As for ethics, they haven't excluded this because they secretly have a heart of cold iron and a desire to hurt, they've done it just because it isn't desired sufficiently.