Are books necessary to become great at writing code or Codecademy and platforms providing challenges will be enough?
It depends on what you mean by the question.
Are they strictly necessary? Probably not. But you’d need an equal investment into finding and organizing a bunch of material that you can access while learning.
It also depends on what you mean by great at writing code. For a lot of domains of programming, it’s hard for me to see where I would have (efficiently) picked up certain concepts or ideas without looking at some of the books I’ve read. Also, one can read the best books and go to the best classes, but the work of translating that into a tangible skill is another thing altogether.
Tl;dr: sure it’s possible in theory, but I would ask myself what I would gain by not looking at books. If access or price is an issue, a lot of libraries offer access to useful material.