How to show a menu item for anonymous users only? I want to show a "Join Now" tab on the main menu for anonymous users only. 

In the past I used Menu per Role module which does exactly that.

Since it's only one tab I would rather use 5 or 10 lines of code. Which hook should I use and what are the functions to check the current user role and add a menu item (or hide it for logged in users)?
I think the simplest way would be to override the access callback for the path that your menu link will be pointing to. You can do this in a custom module with hook_menu_alter(), and use user_is_anonymous() as the callback function:

function MYMODULE_menu_alter(&amp;$items) {
  $items['path/to/page']['access callback'] = 'user_is_anonymous';
}


If you add a menu link for this path, Drupal's menu system will respect the access callback, and the link won't be shown to anyone who's logged in.

Using this method will also make sure that logged in users can't access the page directly, which is probably a good thing.