Bonds are not supposed to be punishment, although they are sadly often used that way by some misguided judges. They are supposed to be a financial guarantee to make sure you return to court and that you are not a danger to the community while out awaiting trial. Bonds require the payment of money, but can also include other conditions like a "no contact order" or random drug screens, to use just a couple of examples. If you are arrested on a judge's warrant, there will already be a pre-set bond.
If you arrested by a police officer who thinks you committed a crime, there are often pre-set bonds for common offenses, like DUI, Petit Theft or Possession of Marijuana, for instance. You can pay the amount of the bond, at the jail and you will be released and stay out of jail unless you are later sentenced by the Court to jail time. If you miss a court date or pick up new charges while you are out on the bond, it can be revoked (kept by the county) and you can be placed back in jail with a new, higher bond to pay. If you cannot afford to pay the whole bond, you can contact a bail bondsman.
A bondsman is licensed to guarantee your return to court, with a promise that he will pay your bond to the county if you do not appear (run away) for an extended period of time. For his trouble the bondsman get's 10% of the total cost of the bond, from you. You do not get this money back when the case is over. That bondsman has now made an investment in you and will want to make sure you stay out of trouble and don't miss a court date. Many will require you to check in with them or let them know if you are travelling. However, if you pay the whole bond yourself, you get it all back. If the bond is too high for you to afford, even with a bail bondsman, you will get to see a judge the next day and ask for a lower bond.
This is generally called a "first appearance." It will usually not be handled by the judge who will later be assigned your case. The first appearance judge will examine your prior record, ties to the community and the nature of the charges. He will also listen to what you have to say. However, do not admit any involvement in the offense. Your comments are admissible at trial. Only talk about the reasons you need a lower bond, such as bills, income, children and other family issues. If the first appearance judge does not give you a makeable bond, you will have to apply (through your lawyer) for a lower bond, to the actual trial judge. It may take a week or two to get that hearing (in some cases longer).
There are also other ways to get out. Sometimes first appearance courts release people without the necessity of a bond (an ROR) if they have good records and the charges are minor. A judge can also find that the charges are not supported by probable cause (a standard lower than beyond a reasonable doubt this is the standard necessary to simply make a legal arrest) and release you, pending trial. Finally, the State has a 30 day deadline to file charges. If the State is unable to do so, and you are still in jail; your lawyer can start demanding your release on the 33rd and then 40th day.
You cannot be held beyond 40 days without charges being filed (this rarely happens). Additionally, if the State waits more than 21 days to file charges, but then you are still held, you are entitled to an adversarial probable cause hearing. This hearing is a mini trial in which the State must prove to the Court that there is probable cause that you committed the offense, with actual witnesses/evidence; rather than the simple flimsy police report used to establish probable cause at the first appearance hearing. All defendants are entitled to some kind of bond (although it may be a very high one in some circusmtances) except in cases in which there is an allegation of violation of probation or there is an allegation of a very serious offense like murder and the evidence appears, initially, so strong that the "proof is evident and the presumption is great."