There is longstanding tradition to hoisting any flag at sea. Understanding all the flag flying customs on the water can be a daunting task. These few quick pointers should keep you in safe water when in port.
The most basic, a national flag hoisted on a boat is refered to as an ensign. This flag should be given the prominent position over any other flags or pennants that might also be flown. Positions of prominence include a "pigstick" lashed to the highest mast to give it the pinnacle elevation. Even better is from the gaff extending from the main mast. Sometimes a sailing vessel will sew the ensign to the leech of the sail (trailing edge). A pleasureboat may choose to set the flag from the stern for convenience. In this case, the ensign extends over the stern via a short pole in a socket. Any other flags, such as club burgees should be flown at a subordinate position to a national flag. Lastly, the ensign should be flown only during daylight hours. Naval custom is to hoist the flag at sunrise and take in at sunset accompanied by the report of a cannon.
The emphasis on flag customs developed out of necessity. Before communications over airwaves, mariners used signal flags to relate critical information between ships at sea. A quarantine flag would warn other ships of a plague ridden ship that wasn't safe to board. Alphabet flags were designated for each letter and numeral flags likewise. A navy would develop it's own unique signal flags and pennants in a book for confidential communications. It was precise signal flag communication that allowed Admiral Nelson to fool and bait the French Navy into battle at Trafalgar, which as we know changed the outcome of world events and turned the tide on the Napoleonic empire. Signalmen had a full set of signals in a flag bag by a halliard. Ships strewn to the visible limits of the horizon relayed maneuvering signals for the ambush. Today, this archaic language for most is the stuff of yacht clubs and tall ship parades. Yet, the International Code of Signals is still used widely by merchant mariners and navies. Signal flags perpetuate in navigation regulations today. Take for instance the November Charlie flag for distress or the Alpha flag for diver down. Many governments still require flying the quarantine and customs flag when a foreign ship first arrives in port. The US Navy uses alphabet flags, numeral pennants and special flags to communicate during periods of radio silence. So don't dismiss the old salt who tends to strict adherence to tradition. These seemingly silly customs of today are the thread that connects us to long purposeful naval histories of yore.