5 is appropriate for Lego, but in my experience from volunteering at a teach-kids-to-code club, is almost always to young for programming. If only because they can't read yet, but also their eye for detail (I have seen two 7-year olds spend 10 minutes and still not see the difference between "Step();" and "Step()" when these two lines were right below each other).