Optimization over Nonnegative and Convex Polynomials With and Without Semidefinite Programming