Which approach is better?
In that book the author encourages the reader to write a neural network library from scratch, to gain an understanding of the principles of deep learning. Tensorflow is a mature deep learning library that can be used in production, and can make use of high performance computing resources like GPUs and TPUs. The code in the book is better for learning and Tensorflow is better for training models for real world applications.