Is running Linux through a VM as fast as running it natively on MacBook?
If you do not need real performance, you should run a VM. It's MUCH easier to install and the support with mac is better. For instance, you won't have any problem with your trackpad under a VM. 
However, if you need some huge performances or direct hardware access, you should run linux natively, if you want to run Kali Linux and do some pen testing, using a VM would be a pain because it would slow down a lot cryptography and access to the wifi drivers for exemple. 

So for what you want to do, I suggest you to install a nice linux distribution on a VM, for instance a Debian based linux like Ubuntu. If you can afford a paid VM software like VMWare it would be much smoother and better integrated with your Mac, but for your purpose, I think VirtualBox would do the job !