Abstract: Hierarchical modeling has become ubiquitous in statistics, while MCMC has become the default approach to fitting such models. At the same time, the literature has seen an explosion in techniques (MCMC-based and otherwise) for fitting, assessing, and comparing models. Various software packages allow flexible specification of hierarchical models and provide algorithms such as specific types of MCMC, particle filter, Laplace approximation, or others. However, many new and old algorithms remain inaccessible for practical use without re-writing them for each model. Moreover, having different packages for different algorithms makes it difficult to combine methods or try different methods on the same problem. I will present the NIMBLE package (r-nimble.org) as a solution to these challenges that allows flexible programming of algorithms with access to the model structure declared by BUGS code. Once specialized to a model, algorithm functions can be processed into C++, compiled, and interfaced with R. I will give an overview of the use of NIMBLE and how it works “under the hood”. I’ll illustrate how to program algorithms using the example of our sequential Monte Carlo algorithms. Finally, I will present an example of NIMBLE in action on an application in paleoenvironmental reconstruction, in which we are inferring forest biomass for the past few thousand years based on pollen deposited in lake sediments.