Constrained Counting and Sampling: Bridging the Gap Between Theory and Practice