Why are the fangs of the cobra shorter than those of the viper?

In case you did not know, cobras have short fangs. Unlike vipers, these snakes cannot fold their fangs out of the way when they are not being used. If the fangs were too long, a cobra would injure itself when it closed its mouth. That only thing would only happen in cartoons.