Installing a bathroom vent with a permit is wise and for your safety. There are pros and cons to the fan exhausted out the wall or roof away from neighbors.
The city building department requires a permit for the electrical circuit for the fan. Only a licensed electrician can pull a permit for you unless you pull a homeowners permit. Whenever you are in doubt, call the city building department. They are eager to answer your questions and are there to help protect you and your home.
They may also want a permit for the roof vent (if you go that route), because a permit for roof construction may be required.
Now, where to vent the fan?
1. Through the roof is good because warm moist air rises. Bad if it discharges into the attic and not directly outside. Warm air in the attic promotes ice dams and moisture causes mold. Use a quality roof vent to prevent cold air from back flowing down into the bathroom. Another tip is to use insulated duct when venting up through an attic because moisture can condensate in single walled pipe and run back to the fan causing a drip.
2. Venting through the sidewall is good because a fan can move more air through a shorter distance. Mount the fan high on the wall to capture the most steam. Then direct the air down a foot or so then out through the wall. Venting down and out the wall decreases the potential of cold air leaking back into the bathroom because cold air does not flow up very well.
3. Do you have an overhang (soffit) around your house? Is it large enough to install a four-inch vent? If you have enough overhang to install a vent and not have it directly over a window you could get the best of both worlds. The fan could be mounted in the ceiling and the exhaust hose could be insulated between the ceiling joists. A vent in the overhang discharging down will reduce the airflow back into the bathroom.
When you look at exhaust fans consider airflow, noise and possibly lights or heaters. You will find that fans with more airflow make more noise. Quieter fans cost more money, but considering the cost of labor, it is worth the money spent. Once a fan is installed, you will live with this decision for a long time.