Ted Chiang said this quote
“ The ray of light has to know where it will ultimately end up before it can choose the direction to begin moving inFermat's principle sounds weird because it describes light's behavior in goal-oriented terms. It sounds like a commandment to a light beam: Thou shalt minimize or maximize the time taken to reach thy destination. ”