Don't forget inflation.
With a Roth 401k (or IRA), you don't pay any taxes on inflationary or real gains. You pay taxes at the beginning and then no more taxes (unless you invest money after you distributed from it).
With a regular, taxable investment account (not a 401k or IRA), you pay taxes on the initial amount. And then you pay taxes on the gains, both inflationary and real. So you effectively pay taxes on the inflated principal twice. Once at initial earning and once when it shows up as inflationary gains. I'll give an example later.
With a traditional 401k (or IRA), you pay no taxes on the initial amount. You pay taxes on the distributed amount. That includes taxes on gains, but it only taxes them once, not twice. All the taxes are paid at distribution time.
Here's a semirealistic example. This is not a real example with real numbers, but the numbers shouldn't be ridiculously off. They could happen. I'm going to ignore variation and pretend that all the numbers will be the same each year so as to simplify the math.
So you pay a 25% marginal tax rate and want to invest $12,000 plus any tax savings.
Roth: $12,000 principal
Traditional IRA (Trad): $16,000 principal with $4000 in tax savings
Taxable Investment Account (TIA): $12,000 principal
Let's assume that you make an 8% rate of return and inflation is 3%. Both numbers are possible, although higher and lower numbers have occurred in the past. That gives you returns of $960 for the Roth and TIA cases and a return of $1280 for the Trad case. Pay no annual taxes on the Roth or Trad cases. Pay 25% marginal tax on the TIA case, that's $240.
Balances after one year:
Roth: $12,960
Trad: $17,280
TIA: $12,720
Inflation decreases the value of the Roth and TIA cases by $360 in the Roth and TIA cases. And by $480 in the Trad case.
Ten years of inflationary gains (cumulative):
Roth: $5354
Trad: $7138
TIA: $4872
Net buildup (including inflationary gains):
Roth: $25,907
Trad: $34,543
TIA: $23,168
Real value (minus inflation to maintain spending power):
Roth: $20,554
Trad: $27,405
TIA: $18,109
Now take out $3000 per year, after taxes. That's $3000 in the the Roth and TIA cases, as you already paid the taxes. In the Trad case, that's $4000 because you have to pay 25% tax which will cost $1000.
Do that for five years and the new balances are
Roth: $9931
Trad: $13,241
TIA: $5973
The TIA will run out in the 8th year. The Roth and Trad will both run out in the 9th year.
So to summarize. The Traditional IRA initially grows the most. The TIA grows the least. The TIA is tax-advantaged over the Traditional IRA at that point, but it still runs out first. The Roth IRA grows about the same as the Traditional after taxes are included.
Note that I left out the matching contribution from a 401k. That would help both those options. I assumed that the marginal tax rate would be 25% on the Traditional IRA distributions. It might be only 15%, which would increase the advantage of the Traditional IRA. I assumed that the 15% rate on capital returns would still be true for the entire period. If that is increased, the TIA option gets a lot worse.
Inflation could be higher or lower. As stated earlier, the TIA account is hit the worst by inflation.