How to hide published content to anonymous user programmatically? I have created a new content type programmatically and I would like to set permission so that anonymous users do not see this content when it is published.

How can I do this?
By default, Drupals permission system does not support specific view permissions by content types. You will need a module for that. Have a look at Controlling Access to Content Overview. In Drupal 6 projects I have used Taxonomy access control lite quite offen.