Just my opinion - and it depends on one’s needs, location & whatnot - but I find a natural gas-fueled tankless water-heater to be waay more efficient, economical while having much better delivery than an electric tank water heater.
My experience with a gas tankless water heater is from my parents’ house in Oregon. When I grew up in their house, it had an electric tank water heater - then later - in the early 90s a combination solar-electric dual tank water heater (the water was preheated by a roof mounted array.) The solar unit lasted about 7 years then they went back to an electric tank system.
The solar was great and with the solar power & tax credits broke even - or it would have except for the downtime due to maintenance and other crap.
The last few years they’ve had a natural gas on demand tankless water heater that is low maintenance, more efficient, & delivers all the hot water you want - all day, all night.
A former house of mine back east had a tanked natural gas water heater that was better than electric tanked - almost as efficient as the tankless natural gas. It seems that on demand (tankless) hot water - electric, gas or whatever is um…better than the tank-based ones.
My experience was with both tanked & tankless systems were central systems. It’s my understanding that distributed systems - a heater for each bathroom, kitchen & etcetera - tanked or non - gas or electric - is even better.