In this talk I will review a novel algorithm (the LLR method) for computing the density of states in gauge theories. Density of states is a complementary approach to Monte Carlo calculation in case where rare configurations play a non secondary role. Typical example of such cases is the evaluation of the free energy and the associated thermodynamical quantities of a system, or the study of a near first order phase transition. As an application, I will discuss Compact U(1) Lattice Gauge Theory, for which using our algorithm highly accurate results are obtained in the pseudo-critical region on lattice sizes that are out of reach with importance sampling techniques. I will also discuss an attempt to apply the LLR method to theories at finite density affected by the notorious sign problem, reducing a high-dimensional oscillating integral to a one-dimensional one. I will present our findings for the study of the relativistic Bose gas.