What programs? This is the question.
If you want to run the latest version of Adobe CS/CC/etc for 5 years, upgrading every year (or maintaining a subscription) - you're talking about the 2017/18 edition - who knows, it might require a minimum of 32gb ram + 4gb of vram. In which case the rMBP won't cut it but a 'maxed out' iMac should.
If you want to work with the current version of FCPX/CS6 etc... you'll find the rMBP and iMac both perform very similarly. For everyday use the rMBP will respond faster. They both have similar CPU capabilities, but only when the rMBP is hitting it's turbo mhz. The iMac can sustain higher speeds - arguably only noticeable for tasks like transcoding/rendering large video files, batch processing images etc.
Some people wonder why photo/video pro's still use 2009 MacPros (for example) and don't buy new - they're future proofed - 64gb ram expansion, GPUs blah blah blah. A 2009 4 core CPU might not chew through data anywhere near as fast as a rMBP, but a 2010 12 core will spank it, and neither will hit bottle necks as easily - workhorses.
Think of the iMac as further towards this end of the scale, spec to last (user upgradable ram).
Think of the rMBP as a the closest you can get with batteries + retina/faster response/shorter shelf life.
in summary, I would guess (this ain't science)...
For 3 years (roughly), the rMBP can do anything the iMac can do, not quite as fast for long periods, is safe, and is portable. The iMac has you covered for the full 5 years (probably), is like a rMBP on steroids, but you can't use it on the train.