TITLE: What is the exact statement of "there are 27 lines on a cubic"?
QUESTION [21 upvotes]: I think there was a theorem, like 

every cubic hypersurface in $\mathbb P^3$ has 27 lines on it. 

What is the exact statement and details?

REPLY [7 votes]: There is a nice recent proof in a paper by Galkin and Shinder. These authors prove a relation in the Grothendieck of varieties involving the classes of a smooth cubic hypersurface, its variety of lines, and its symmetric square. The proof of this formula is based on the following elementary geometric principle: take a point on a cubic hypersurface and a line passing through that point; either the line is contained in the hypersurface, or it cuts the hypersurface in three points, the given one and a pair of points. (They prove a similar formula in the singular case, as well.)
Given the classical computations of the Euler-Poincaré characteristic/Hodge-Deligne polynomial of a hypersurface, and of its symmetric square, this gives a formula for the Hodge-Deligne polynomial of the variety of lines of the given cubic hypersurface. 
In the case of a surface, one gets exactly 27: there are 27 lines on a smooth cubic surface.