There is a video/workbook series on prayer by Phillip Yancey (which I highly recommend) (and based on one of his books) that talks about how we should pray openly about all things.
It even says that we should tell God when we are frustrated with God himself. After all, (a) God wants to be part of our lives, (b) God already knows what we're going through and (c) if we reach out to him, he may answer our prayers or comfort us to reaffirm that he is our God.
All very valid and very useful points.
To illustrate this, he uses the illustration from Habakkuk. In chapter 1, Habakkuk prays to God:
Habakkuk 1:2 (NIV)
How long, LORD, must I call for help,
but you do not listen?
Or cry out to you, “Violence!”
but you do not save?
God seems to respond favorably to this prayer:
Habakkuk 1:5 (NIV)
Look at the nations and watch—
and be utterly amazed.
For I am going to do something in your days
that you would not believe,
even if you were told.
There's another example of this type of prayer (praying a complaint about God) in Jeremiah 12.
However, if we look at the book of Job, we see God respond unfavorably to Job's complaining. Job goes on for 37 chapters to complain while his friends chide him for brining it on himself (when really, as we see in Job 1, God allowed Satan to do this to Job unprovoked).
Finally, in Job 38, God answers:
Job 38:1-3 (NIV)
1 Then the LORD spoke to Job out of the storm. He said:2 “Who is this that obscures my plans
with words without knowledge?
3 Brace yourself like a man;
I will question you,
and you shall answer me.
God goes on for four more chapters to rebuke Job to show how powerless and foolish Job is.
My question (finally):
How can we reconcile God's angry response to Job's complaining with God's favorable response to Habakkuk and Jeremiah's complaining? What did Job do that was so wrong to bring on God's anger (in his response)?
Furthermore, how should we pray to avoid committing the sin that Job committed (in order to avoid God's wrath)? I'm seeking the Protestant viewpoint, excluding the doctrine of reciting prayers. This is more a question regarding open-ended prayer. (see doctrine of prayer)