system
Given the following post, respond as if you're commenting on Reddit:
human
If Light has no mass, why is it affected by gravity?
gpt
What mass does is it distorts space-time so that light will follow a curved path.

One of the most fundamental principles in optics (which arises from one of the most fundamental principles in physics) is that light will travel a path between points A and B such that the time of flight between them is a minimum. Normally, the shortest rout between two points is a straight line. However, we've all seen light get bent as it goes into a glass of water - this is because the shortest time of flight when going between two materials means the light gets bent at the interface (I can talk more about this if you like).

Since mass distorts space, it also distorts the path of least time for a photon to travel. What was a straight line in un-deformed space becomes a curved line in the presence of a massive object. This leads to things like gravitational lensing and the like.

This type of path is called a geodesic and massive objects tend to warp geodesics in their local vicinity.