According to quoteinvestigator.com there is no consensus on who wrote the above saying: Among many guesses include: Edmund Burke, Victor Hugo, George Bernard Shaw, Benjamin Disraeli, and Winston Churchill…
However, it seems likely that Edmund Burke is the author. This is evidenced by an original comment made by a jurist named Anselme Polycarpe Batbie in a book published in 1875 where he attributes the saying to Edmund Burke.
Varied versions of the saying include the following:
If you’re not a socialist before you’re twenty-five, you have no heart; if you are a socialist after twenty-five, you have no head.
If you aren’t a liberal when you’re young, you have no heart, but if you aren’t a middle-aged conservative, you have no head.
Fred Shapiro the author of the “Yale Book of Quotations” says at
“But I was delighted to find that John Adams had expressed a similar idea well before Guizot entered adulthood. Thomas Jefferson preserved this quip, writing in a 1799 journal that Adams had said: “A boy of 15 who is not a democrat is good for nothing, and he is no better who is a democrat at 20.”.”