It's not even about punishment. Calling it discrimination is like saying that hiring based on years of experience discriminates against younger people. It's the wrong point at which to solve the problem.
We know that taking a year off impacts employment prospects. If we want to compensate for it, what should we do?
The implied solution is to force employers to hire less experienced workers. But that has all kinds of known problems. The quality of their work will be lower. It creates an incentive for businesses to cheat and benefits the ones that do. The cost is not uniformly distributed, which creates risk and surprise for smaller businesses that may not be able to absorb the sudden cost.
What problem are we trying to solve here? We want to encourage parenting and help parents, so do that. Have a social insurance program for parental leave equivalent to unemployment insurance. Have a generous tax deduction for dependent children that compensates for the resulting lower salary. Do things, in general, that spreads the risk across all taxpayers rather than creating asymmetric costs for the employers who happen to employ parents, so that we avoid giving employers a perverse incentive to find ways to offset the cost.
It's not a problem if you make $5000/year less in salary if you also pay $5000/year less in taxes. Or $10,000/year less in taxes.
There is some nuance. For example, a $5k tax credit might help me level the playing field today, but that $5k difference still exists for social security calculation.
Sure, so identify the problems and fix them. The way social security works is illogical. It's supposed to be a safety net, so why do we pay in proportion to past income rather than giving everyone the same amount? Do the affluent somehow need a larger safety net? If anything they should be expected to have more of their own savings.