I bought the 718 as a 55th birthday present to myself and it fulfilled a lifelong dream for me. It was also the first ever new car I'd owned. I ran a second car beside it, I do around 12,000 pa on a work commute so was not putting that mileage on a Porsche. The car was sold as we were looking at purchasing property abroad, however we have postponed that for the time being.
I loved it, but it was only getting used for one trip out of each cycle of four for work, picking up my fiancée, odd trip to shops and an odd drive for pleasure. My fiancée is happy enough being in the car whilst I'm "making good progress" if it's on a straight, but not at all in the twisties and that is where the 718 excelled. Also, as a biker of 41 years (currently a BMW S1000R Sport) it is the bike I use for pleasure if solo.
So, along with looking at property, part of the reason for selling was that it was out of warranty in June and would have been due a major service next June and between them that was over £2,000 just to keep the car another year, before actual running costs and it was very hard to justify that for the use it was getting.
To answer your question though, sorry for the long winded intro, I will give my opinion on the two cars.
Looks, Porsche edges it for me, pic of my old 718 below.
Handling. Absolutely no contest, Porsche hands down.
Servicing/maintenance/parts. BMW is definitely cheaper, from what I've seen so far 4 years with the Z4 for servicing is a third of the cost.
Running costs. Same for both on VED/Insurance. Z4 will give me high 40's, at motorway speeds on the work commute, 718 high 30's.
Performance, not really fair to compare, 718 lighter and more hp.
Cabin/comfort. Z4 by a country mile. Cabin is more spacious/luxurious, seats are more comfortable, dash is better as is info screen and media.
Kudos factor, hate to be a snob but liked saying when asked, that I had a Porsche.
In summary, having owned both, they are very different cars imo. The M40i would be a better comparison. For me I now have a car that is a more relaxed, refined place to cruise, has more tech goodies in the cabin, costs me less in servicing, repairs, parts and petrol but still has more than enough power for the road.
Other two benefits are my Fiancée Lynn is more relaxed in the car and, because I'm hoping to retire in 2 years, I get to drive it every day.
The Z4 is far better suited to us than the 718 and I'm enjoying having the use of it every day.
Take some time to think of what you want your Z4 for, a 20i may well be perfectly suitable, after test driving one I could happily have lived with it for what I need in a car.
You mentioned the M40i, more power, different engine, higher servicing/running costs. May be perfect for you, depends on what you want from the car, how you intend to use it etc.
Hope this helped lol, this was my 718.
E4E293F9-AB6D-456A-9E87-ACC5156FBCE7_1_105_c.jpeg