How to control the display's backlight in the sketch?

You always need a current limiting device when using an LED and a resistor is the simplest one you can have. Anyone who tells you different is wrong.

I was going to say the same thing but then I figured that someone would point out the exception, which would be if one happened to be using a current limiting supply. Even then the resistor wouldn't hurt anything.

I agree - you should always use a current limiting resistor.

Don