A defendant may be granted an "O.R." release (a release on their own recognizance). That means that they are released without having to post bail in any amount on their written promise to appear in court when ordered.
This is usually the case for misdemeanors unless a person has warrants, a prior record or other holds on them (immigration hold, probation violation allegation, etc.).
This can happen in a felony case as well. Your attorney may be able to negotiate a release without bail if the jail personnel or judge are convinced the person is not a danger, not a flight risk and will appear in court. Hiring an attorney is a good step towards showing you're taking the case seriously and will appear when ordered.
Posting cash bail
You can post the entire amount of the bail with the jail. The benefit to posting a cash bail is that when the case is concluded and the bail exonerated, you get every penny back. As long as the defendant makes all their court appearances and doesn't violate any terms of their release to jeopardize your bond, you'll get the money back at the end of the case. Of course, not everybody walks around with that kind of cash, so most people have to go through a bail bond company.
Using a bail bond company
Bail companies are regulated by the insurance department and in essence, you're buying an insurance policy when you arrange a bail bond. You pay a premium (anywhere from 7 to 10 percent of the bail amount) and they put up the bail with the court. If you make all your court appearances and don't violate the terms of your release, when the case is over, the bail company gets all their money back. The amount you paid the bail company is NOT returned to you, however. That's the price of their services and posting the bail on your behalf. Yes, it can be expensive, but it beats sitting in jail.
Your attorney will have a good working relationship with a bail bonds agent they know and trust. Often, a reduced rate will be offered to defendants who have retained an attorney.