IS IT PRAISEWORTHY TO FAST?
Gemara
(Shmuel): One who fasts is called a sinner.
He holds like the following Tana:
(Beraisa - R. Elazar Hakapar b'Ribi) Question: "V'Chiper Alav me'Asher Chota Al ha'Nefesh" - concerning which soul did the Nazir sin?
Answer: He pained his own soul by denying himself wine; for this he is called a sinner. All the more so, it is a sin to (fast and) deny oneself everything!
(R. Elazar): One who fasts is called Kadosh.
A Nazir pained himself only from one thing, and he is called Kadosh - "Kadosh Yihyeh Gadel Pera Se'ar Rosho". All the more so, one who fasts and pains himself from everything is called Kadosh!
Shmuel explains that "Kadosh" refers to Gadel Pera (his hair), not to the Nazir. R. Elazar explains that "Chota Al ha'Nefesh" refers to becoming Tamei through a Mes.
Contradiction: Elsewhere, R. Elazar expounded that one should consider that his innards are Kodesh (and he may not weaken them) from "B'Kirbecha Kadosh v'Lo Avo b'Ir"!
Resolution: If one can bear the fast he is praiseworthy. If not, he sins.
(Reish Lakish): He is called Kadosh - "Gomel Nafsho Ish Chased v'Ocher She'ero Achzari".
(Rav Sheshes): If a Talmid fasts, a dog should eat his food (i.e. he will not be rewarded, like one who fasts because he has no food).
(R. Yirmeyah bar Aba citing Reish Lakish): A Talmid may not fast, because this decreases his work (Torah) for Shomayim.
Bava Kama 91a (Mishnah - R. Akiva): A person may not injure himself.
Contradiction (Beraisa) Suggestion: Perhaps one who swore to harm himself and did not do so is exempt!
Rejection: "(If one swore) to harm or to benefit..." - just like the benefit discussed is optional (not a Mitzvah), also the harm. This includes one who swore to harm himself (he is liable if he does not do so).
Answer #1 (Shmuel): The Beraisa discusses an oath to fast.
Objection (Beraisa): What is the case of (swearing to) harm others? 'I will hit Ploni, I will bruise his brain'.
Answer #2: Tana'im argue about this. R. Elazar Hakapar forbids a person to damage himself.
Rishonim
Rashi (Ta'anis 11b DH Nikra): Reish Lakish says that one who fasts and can bear it is called Ish Chased". If he weakens himself he is called Achzari.
Tosfos (11b DH Gomel): Reish Lakish says that one who does not fast is called Ish Chased".
Rambam (Hilchos De'os 3:1): Since Ta'avah is so bad, one might think that he should go to the other extreme and not eat meat and wine, get married, or have a nice house and clothing, rather, he should wear sackcloth or hard wool, like Edomite priests. This is a bad way. It is forbidden, and one who does so is called a sinner. A Nazir who denies himself wine needs atonement. All the more so, one who denies himself everything needs atonement! Therefore, Chachamim commanded to refrain only from what the Torah forbids, and not to add Isurim through vows and oaths. This includes fasting constantly. Chachamim forbade tormenting the body through fasting. Shlomo commanded "Al Tehi Tzadik Harbe v'Al Tischakem Yoser Lamah Tishomem".
Question: In Ta'anis, Shmuel says that one who fasts sins. In Bava Kama he permits this!
Answer #1 (Tosfos Ta'anis 11a DH Omar): One who fasts sins, but the fast is a greater Mitzvah. This is like one who fasts on Shabbos due to a dream. It atones for him, but he must fast again during the week to atone for fasting on Shabbos.
Shitah Mekubetzes (Nedarim 10a DH Lo): Likewise, even though the reward for a weekday fast is greater than the punishment, one must atone for the fast. Even though a Nazir abstains from wine for 30 days, fasting one day is more painful, therefore it is a Kal va'Chomer.
Rebuttal and Answer #2 (Gvuras Ari Ta'anis 11a DH Omar and DH Ela): If the reward outweighs the punishment it is totally permitted, just like an Aseh is Docheh a Lo Sa'aseh because an Aseh is stronger! Shmuel merely explained the Beraisa; perhaps he himself disagrees. Also, he did not say that one may fast, only that such an oath takes effect.
Ran (Shevu'os 11a DH Gemara): Even though we expound (Bava Kama 91b) that one may not harm himself, since it is not explicit in the Torah, a Shevu'ah takes effect on it.
Answer #3 (Lechem Mishneh): Shmuel forbids to fast mid'Rabanan. Even though an oath takes effect on an Isur mid'Rabanan, the Beraisa connotes that the Tana permits harming oneself even mid'Rabanan. Shmuel established the Beraisa to discuss fasting. This is not like R. Elazar Hakapar, rather, like R. Elazar who argues with him. However, all agree to the law of the Beraisa, that the oath takes effect.
Pri Chodosh (brought in Likutim in Frankel Rambam): If one sinned it is proper to fast according to his ability. R. Shimon and R. Yehoshua fasted until their teeth went black to atone for statements not befitting the honor of R. Akiva and Beis Shamai, respectively.
Kovetz (in Likutim in Frankel Rambam): The Gemara concludes that Shmuel and R. Elazar do not argue. R. Elazar discusses one who can bear the fast, and Shmuel discusses one who cannot. This is why the Rambam forbids fasting constantly and tormenting the body through fasting.
Ra'avad (Ba'alei ha'Nefesh Sha'ar ha'Kedushah DH v'Ani p.176): One should not fast to afflict himself, lest he get weak and be Batel from Torah and Tefilah and err in Halachah. Torah is acquired only through Simchah. If one sees that his nature requires him to fast one or two days a week he should do so and he is called Kadosh, as long as it does not cause Bitul from Torah and Mitzvos.
Shitah Mekubetzes (Nedarim 10a DH Mikan): It is Asur to fast out of anger, to pain oneself. Surely it is permitted for the sake of complete Teshuvah to subdue the Yetzer ha'Ra, like the Gemara says 'Here (it is permitted) when he needs...' (our text says 'd'Matzi Letze'urei' (he can pain himself); the Shitah's text reads 'd'Tzarich Lei').
Aruch l'Ner (Rosh Hashanah 9a DH Kol): If one benefits from this world more than the Torah allows, he sins against his Neshamah. Likewise, if he does not give to his body the food and drink it requires, he sins against his body - "me'Asher Chota Al ha'Nefesh". The command to eat on Erev Yom Kipur and fast on Yom Kipur are to atone for "Nafshoseichem" (plural, as opposed to Nafshechem), these two parts of the soul.
Poskim
Shulchan Aruch (OC 571:1): If one fasts and he can bear the fast he is called Kadosh. If not, e.g. he is not healthy and strong, he is called a sinner.
Magen Avraham (1): Fasting atones for sins. We do not discuss one who has known sins, for in this case even a Chacham should fast, even if he cannot bear it. However, if he is occupied solely with Torah he should not fast so much; rather, he should learn more. The Ra'avad says that if one could fast once a week, but instead just eats meagerly like (other) people, he will not be punished. It is a great affliction to cease eating while one has appetite.
Mishnah Berurah (2): The best affliction is a Ta'anis Dibur (to speak only Torah and Tefilah). It does not harm the body or Neshamah.
Bi'ur Halachah (DH Talmid): Even for known sins a Chacham should not cause Bitul from his learning through fasting. The SHLaH says that one day a week he should isolate himself from people, cling his thoughts to Hash-m and speak to him like a slave to his Master or son to his father. The Chayei Adam says that he should repent with a full heart and cry from depth of his heart and learn more than he used to, for Torah is a Mikveh Taharah. He should refrain from indulgences and eat only to sustain the body. The confession and crying are primary.
Kaf ha'Chayim (2): One who fasts is called Kadosh. He is like an angel. He shows humility, for haughtiness come from eating much.
Kaf ha'Chayim (3): One must be careful to avoid anger when fasting. There is a tendency to get angry when hungry. If this occurs, it is better not to fast - "Hen l'Rav u'Matzah Tatzumu"?! (Yeshayahu 58:4)
Kaf ha'Chayim (4): Sefer Chasidim forbids afflicting oneself through fasting if he is needed by the Tzibur, e.g. he teaches the Rabim. This does not refer to teaching Torah, for even one who learns by himself may not fast.
Note: The Kaf ha'Chayim himself (8) brings opinions that even a Chacham should fast for known sins. Perhaps Sefer Chasidim forbids this for teachers!
Kaf ha'Chayim (5,6): If he cannot bear it he is a sinner, for it is a Mitzvah to make one's body healthy, and fasting is not a Mitzvah. If one should fast for sins but cannot, he can give Tzedakah instead (like the Rema 568:2).
Kaf ha'Chayim (9): Even if one can bear the fast, it is good only if he is very careful (even) about things that people treat lightly, e.g. Tefilah, Berachos, speaking in the Beis ha'Keneses, secular talk on Shabbos, looking at what is not his, sitting with scoffers, theft, Chilul Hash-m, Lashon ha'Ra, and pride.
Shulchan Aruch (2): A Talmid Chacham may not fast, because this decreases his work for Shomayim. However, if the Tzibur is fasting he fasts with them to avoid separating from the Tzibur. One who teaches children is like a Chacham.
Source Beis Yosef (DH ha'Yoshev): SMaG and SMaK say that when the Tzibur is in pain, a Chacham should join them. Teaching children is the greatest work of Shomayim. The world stands on the Divrei Torah of children.
Source (Gra DH d'Ha): The first fasts for lack of rain are for Chachamim (Ta'anis 10a).
Magen Avraham (2): One who is occupied solely with Torah is a Chacham regarding this law even nowadays.
Magen Avraham (3): If a teacher of children fasts, he diminishes the work of Shomayim and also steals from the Rabim. Even one hired for an individual may not fast.