> My advice to CS majors is that you need to make enough to retire by 35 as that's when you stand a good chance of being tossed on the trash heap.
I agree with this. CS is a GREAT career when you're in your mid 20's, making 6 figures with just a bachelors, while your cohorts are still taking on even more loans in graduate school or earning a fraction of your salary down in the bottom rungs of the corporate ladder.
The trick is to live as frugally as you can while making the big bucks throughout your 20s and early 30s, invest it, and plan to never touch it. With some market luck, you can pretty much guarantee a safe retirement by late 50's or early 60s, even if you decide (or are forced) to change careers to something less lucrative, and especially if (very likely) your salary won't grow much faster than inflation (and less than COL increases) once you're past 35. This is in contrast, BTW, to most other professionals like lawyers, doctors, academics, etc. who tend to earn more and more each year until mid 50's.
Because the reality is that most of us are not going to be the top 10% who will be courted by FAANGS well into our 40's, with offers of $500K plus equity, to lead projects.
Instead, you're going to hit a glass ceiling in your mid 30's and unless you move to management or start your own consultancy, you're going to be competing with 28 year olds who can write CRUD apps in the shiny new frameworks better than you at 2/3 the salary. Which is why many corporations don't really enjoy keeping on 40+ year old developers who expect to get 5% raises each year when they're not really worth more than the 27-33 year olds who have enough experience to crank out code that works well enough.