Over the past decades, researchers proposed numerous approaches to visualize source code. A popular one is CodeCity , an interactive 3D software visualization representing software system as cities: buildings represent classes (or files) and districts represent packages (or folders). Building dimensions represent values of software metrics, such as number of methods or lines of code. There are many implementations of CodeCity , the vast majority of them running on-screen. Recently, some implementations using virtual reality (VR) have appeared, but the usefulness of CodeCity in VR is still to be proven. Our comparative study aims to answer the question “Is VR well suited for CodeCity , compared to the traditional on-screen implementation?” We performed two experiments with our web-based implementation of CodeCity , which can be used on-screen or in immersive VR. First, we conducted a controlled experiment involving 24 participants from academia and industry. Taking advantage of the obtained feedback, we improved our approach and conducted a second controlled experiment with 26 new participants. Our results show that people using the VR version performed the assigned tasks in much less time, while maintaining a comparable level of correctness. VR is at least equally well-suited as on-screen for visualizing CodeCity , and likely better. • CodeCity in VR is comparable to CodeCity on-screen, with respect to the accuracy of results, and much better with respect to efficiency. • Virtual Reality users are considerably faster than on-screen users across program comprehension tasks using CodeCity. • Virtual Reality immersion could play a pivotal role when carrying out program comprehension tasks in a 3D environment. • BabiaXR offers a web-based version of CodeCity that is able to use in any modern browser, including the browser for the VR glasses with the VR interaction by default.