This is a survey article on real algebra and geometry, and in particular on its recent applications in optimization and convexity. We first introduce basic notions and results from the classical theory. We then explain how these relate to optimization, mostly via semidefinite programming. We introduce interesting geometric problems arising from the classification of feasible sets for semidefinite programming. We close with a perspective on the very active area of non-commutative real algebra and geometry.