At that size/portability, there's really only one serious contender on the market today.
The FxTec Pro 1 is the first proper android phone with a slide-out keyboard since the Motorola Photon Q in 2012
, and it's also probably the best sliding keyboard I've ever used, I could quite comfortably use it for quickly writing small programs as OP describes.https://www.fxtec.com/product/fxtec-pro1/
Discounting Blackberries, with their locked down bootloaders and weird android emulation layers.