Is there any meaning or grammatical difference between the following sentences? -Flying is safer than driving. -Flying is safer than to drive.Are both patterns true?
I can see your confusion. In terms of meaning, they both convey the same point. However, I would say that the second sentence is wrong. I say this, because there is a lack of consistency. Because you use "flying," it should be balanced by "driving." If you used "to fly", then you could use "to drive." So, here is the sentence with "to fly."
"To fly is safer than to drive."
In short, be consistent. If you want to use the gerund, then use the gerund. If you want to use the infinitive, use the infinitive.
I don't see a difference in the meaning of the two sentences, but there is a clear grammatical difference.
The first sentence "Flying is safer than driving" uses two gerunds (the "-ing" words in this sentence that are acting like nouns) whereas the second sentence has only one gerund and ends in an infinitive phrase ("to drive").
I much prefer the first sentence over the second because the first has good parallelism and the second does not. See the link below for information on parallel constructions.