One of the major strategic rules of chess is "Keep your King safe!". It is precisely due to this rule that a very common pin from many openings which start with 1. e4 e5 is especially dangerous. For example this one:
We've all had a similar experience during our chess beginnings. The result of the pin is very painful for Black. Due to the unavoidable capture of the Nf6, Black's kingside structure is going to be ruined. But what should you do if your Knight is pinned--how can you break the pin? One common way to do it is to push the 'h' and 'g' pawns (h3 followed by g4 for White and h6 followed by g5 for Black). Most inexperienced chess players do exactly that and as a result their King gets exposed. Talk about a medicine being worse than the illness. The next classical game is a good example of what happens in this case:
Chess coaches (me included!) warn their students about the consequences of such a weakening of your own kingside. But let's see what hapenned in another classical game:
And one more classical game:
But wait, there is more!
So, what's going on here? Did Capablanca refute the rule of keeping the King safe, or are these games a major exception? Or maybe it is the situation described by the Latin phrase: "Quod licet Iovi, non licet bovi" ? Actually, the explanation is very simple. In all of Capablanca's games his King was very safe and by pushing the 'g' pawn in front of his King he achieved a big strategical advantage in all of his games. In two of them his opponent's Bishop was entombed and in the game against Marshall it was actually a signal for an attack against his opponent's King. So, the g2-g4 move is not better or worse than any other chess move, but if played in a wrong situation, then the consequences of your mistake will be magnified by the weakness of your King.
My advice is: playable, but proceed with extreme caution!