两句语法上都成立.动名词做表语表经常习惯性动作,to do不定式侧重表示具体的某一次.这里第二句更好,不定式作表语表目的.再给你个例句吧:
I like swimming.
I like to swim in such a hot day.