Theory and applications of first-order methods for convex optimization with function constraints