Though he's my favorite fantasy author, I don't think Tolkien was an optimist. One of the main themes running through his work is that things don't get better, they get worse. It's just a matter of how much worse.
True, at the end of LotR you have Aragorn assuming the throne of Gondor and forming the house of Telcontar (wow - I really out-geeked myself with that), and you have Sam and Rosie breeding a small herd of hobbits, which seems all well and good until you look at the big picture - the loss of the elves and wizards.
Essentially, Tolkien's view of the world was of an entropic spiral, where everything slowly and inexorably worsens. We assume evil never wins, but at the end of the day, good is left with a rather dull, grey world.
Just as the world worsens, victories lessen. In the War of Wrath, you got the Valar riding in to whup on Melko/Melkor and take him out of the picture permanently. The Last Alliance also wins, but does not dispatch Sauron. By the time you get to the end of the Third Age, things have gotten even worse, which brings us to a central element of LotR. Frodo doesn't win; he loses.
Sure, the ring goes into the fire, but no element or agent of good puts it there. By this point in Middle-Earth history, good no longer has the strength to defeat evil. Evil (in the form of Gollum and his greed) has to defeat itself (Sauron).
In the end, I'd have to give Howard's work the edge in optimism, though barely. Howard's world has an endless cycle of primitives rising to barbarians rising to civilization - then being destroyed from within or without and starting all over again. In Tolkien, on the other hand, things just get steadily more drab. We'll never return to the 'days that were' - they are gone forever.
Lovecraft, of course, gets my vote for most pessimistic. After all, how can you beat a worldview that offers nothing but a nihilistic abyss of alien malevolence and madness?
