I am so sorry to hear that Freddy. I would think it's illegal. Have you considered talking to an employment law adviser? On the basis of age alone, they can't tell you that you're too old for the job. If you weren't performing well, that's another issue, but not necessarily related to age. Younger people can have those issues too. There are plenty of older people in engineering, software development, etc. It's terrible people have these cognitive biases. Similarly, although not in employment, it was once inferred to me that my brain is slower, as I am older. I know, despite my age, I have good brain function and memory. I believe it is discrimination what you are experiencing. What's the point doing a job you aren't interested in, just because of your age! I would definitely seek legal advice.