A straight line can be differentiated. Consider the line y=1. This is a horizontal line with constant gradient of 0. The derivative is a function of the gradient at any point on the curve- hence the derivative of a straight line y=k for some constant k is dy/dx=0.
Even other lines, like y=x has a constant gradient of 1, hence dy/dx=1 etc etc.
For curves, you need more than just this constant gradient because the gradient changes- hence the idea behind first principles differentiation