Add the sugar, cornstarch, milk, and salt to a double boiler (or a heatproof bowl set over a saucepan) placed over medium heat.
½ cup granulated sugar, ⅓ cup cornstarch, 2½ cups whole milk, ½ teaspoon kosher salt
Whisk frequently until the mixture begins to thicken, about 10-15 minutes.
Place the egg yolks in a separate bowl.
3 egg yolks
Add about ½ cup of the thickened milk mixture to the egg yolks and whisk to temper the eggs.
Add the tempered eggs to the milk mixture and continue to whisk until thickened, about 3-5 minutes. It may look slightly thinner than pudding at this point, but it will thicken further in the refrigerator. (See notes for further explanation).
Remove from the heat then whisk in the vanilla extract, butter, and food coloring (if using) until the butter has melted.