I wrote code for a little over 20 years, starting when I was 30-something. Then I got caught in a layoff in the double-whammie of the dotcom bubble bursting and 9/11; by the time people were hiring again, my resume had gone completely stale and I was in my mid-50s. Even taking some retooling classes, i couldn't find anyone who would hire me. I ended up retiring out of a retail job that barely paid the bills. Now I'm living on savings and Social Security; fortunately, the savings survived all of the turmoil, so it's enough.
I know I did some things wrong (didn't take XXX classes, spent too much time on YYY job boards, didn't get to the ZZZ networking sessions, ...) while looking for another job; that's not the point. If someone offered me a job coding, I'd probably take it, enjoy it, and do it well, but I've given up hope finding it for myself; the repeated "Sorry, we're not interested -- Next!" just got too painful to endure, so I quit trying.
So, why am I grumping about and not adding anything to the conversation? Partly to get it off my chest, and partly to make this one point: The older you get, the harder it is to find someone who will hire you. I don't know why that is, or even if it's true for everyone, but it certainly was for me. If you're over 30, keep an eye on what's happening around you. If it looks like things are going south, jump ship while you still can. It's a lot easier to get a new job if you look while you're still in the old one.