Rethinking MBP. I now have a 27" iMac. Looking at the 21"
You'll need to up-spec a 21.5-inch iMac quite a bit. RAM is not designed to be user-upgradable in that model so you must order it with the RAM you'l need down the road--16GB min in my opinion. Think of it as your "forever RAM."
We see a huge number of complaints here of slow 21.5-inch iMacs and most of those are due to the bottleneck their badly under-powered mechanical hard drives create. Apple has been installing slow, 3GBps 5400RM drives in 21.5 iMacs with a fast 6GBps drive bus since 2011. I'm not comfortable with the Fusion drives so consider the factory SSD. I did for my most recent iMac and the steep cost has been worth every penny.
I would also avoid the base model. Go for the 4K with discreet graphics instead of integrated graphics. Buy as much processor as you can afford.