Here's the thing, it's about your value proposition (what are you offering).

All things equal, how many days can you work without sleep? How much do you need to get paid to do the job?

Age is just a coincidental number that correlates (doesn't cause) to number being able to program for days on end without suffering increasing consequences, and getting a programming job for $15 / hr not being suitable to handle a mortgage, truck payment, kids braces, and the things that come with the higher age number.

So, if you are starting out at 40 and someone is competing for a beginner job at 18, they are going to be the obvious choice because 1) they are typically more of an open book, and 2) you can pay them $15 / hr to get the same work that you would need to charge $40/hr to do.

That being said. The other side of it is if you have been programming since you were 7 and are now 42 with 20 solid years of professional experience competing with Joe Youngster who wrote his first line of code last year and has been to a programming boot camp.

Part of the issues are that you still have the stigma of 1) not being able to sacrifice time/sleep for code, 2) are more expensive.

Both of which are accurate.

However, if you are competing for a job that an 18 year old qualifies for after 20 years of experience, something is amiss.

I've seen this MANY times and am guilty of it myself, where a person will spend years spinning their wheels and not actually increasing their skills. It happens to a lot of people. You could get the same year of experience 20 times over (there was a good article written about that, good read, don't have the link handy). So "20 years of experience" boils down to 1 year of experience that you have practiced 20 times over.

After 20 years, younger programmers should not be able to compete with you. Not because they can't write code as well as you. It has nothing to do with that.

But the experience should have taught you and made second-nature all the design patterns, all the best practices, all the security tricks, all the devops.

An 18 yo can code, but they can't build a palace out of code yet (and if they can, they are typically swept up quickly). It takes years to go from knowing how to lay a brick to how to design a brick building to never crumble even if someone is beating it with a fallen tree.

While age descrimination exists (the concept of a senior developer is iffy sometimes), and I experienced it for the first time last year when someone said "no thanks" and hung up when they asked how any years experience I have; it doesn't exist when you are actually shooting for jobs that require 20 legitimate years of experience.

Some programmers settle back knowing they could code the world, but don't actually do it. Or code something twice as fast. Or 5 times as solid. Or with 567% less bugs.

What makes the 20 year experience you better than the 19 year experience you?

If you cannot sell that one year of difference, then it's not age discrimination, it's skill discrimination.

And to answer your actual questions.... :-D

What is your stack: After 21 years, I've work in .Net/Java/Node.js/LAMP(erl&HP) stacks plus tinkered with others. Now I do application security.

How have you gotten around age discrimination: When I've been discriminated against, I feel like I dodged a bullet, because who would want to work with / for someone that judges the content of a book by the wear of the spine?

How do you suss out whether a company is right for you? I focus on team and personal questions when I interview a company. What's the team culture, do they support members teaching each other, do they foster speaking at conferences, etc. The more information flow between developers and the industry the better, generally. That indicates a supportive culture rather than a competitive culture. Ask to speak to people you will be working with. "Their references".

I ask personal questions of interviewers. What is their next skill they are going to work on? What was the last issue they tackled that really taught them something new? Do they seem themselves with this company in 10 years? What was the last conference they attended? Was that on their own time? When was the last time they had an opportunity to speak at a conference?

Don't worry about getting into personal questions relating to their job.

I've found that tells me more (not necessarily their answers, but also how they answer) about the culture than the standard shpiels.

It's ALL about culture. A crap boss and crap co-workers will never be made for with good pay or high-skills in the long run.