Redesigning spectroscopic sensors with programmable photonic circuits