Optimization over Nonnegative and Convex Polynomials with and without Semidefinite Programming