In this talk, we will discuss the problem of automatically constructing computer programs from input-output examples, especially when the target language is domain-specific and defined using a context-free grammar. I will introduce a theoretical framework called distribution-based search, discuss its challenges, and present several search strategies based on learning the weights of a probabilistic context-free grammar (PCFG) and then using this PCFG to enumerate the most promising candidate programs efficiently. The presentation will be based on the following paper published at AAAI'2022: https://arxiv.org/abs/2110.12485 Joint work with Nathanaël Fijalkow, Théo Matricon, Kevin Ellis, Pierre Ohlmann, Akarsh Potta