The requirement is not risk, but stakes.
Anecdotally, you will not get very good at programming if you only read textbooks and do puzzles, you will not get very good at performing with a musical instrument by only practicing in your room, and you will not get very good at a sport by only doing drills. You should do real programming projects, perform in front of people to feel out your nerves, and actually compete and try to win.
Your arguments and examples here really don't prove your point:
1. Learning by doing/fucking around in Java eclipse or something, doesn't necessitate there being any risks or penalties for failure, you don't have to do programming professionally to get better at it.
2. The only practical difference between performing in front of a audience and practicing in your room is whether or not you suffer from stage fright, whether or not people are looking at you has no bearing whatsoever on one's musical talents.
3. While it is true that drills alone are not enough to make you good at a sport, there is one thing that in combination with drills definitely is. That being practice matches, whose only practical difference between a real match is the lack of stakes involved.
Stakes and risks are not at all necessary to become good at a skill, you don't need to have been part of a deadly street brawl in order to get a black belt in Karate.
At most you could argue that stakes significantly speed up the learning process, but that does not mean that said learning process is all but impossible without them.
Like for instance, tests in education are exactly that TESTS meant to test whether or not you properly understand the curriculum, the only part they play in the actual learning process is in math tests where they technically double as math excercises.
A system that instead awards a bunch of bonus xp for live fire combat and other stakes heavy activity such as high level politics, would both be much more realistic, and far more likely to work as then the voters will seek out this activity at every turn, as opposed to only when the looming shadow of stagnacy xp penalties returns once more.