KTUGFaq
KTUG FAQ
Far duller than a serpent's tooth it is to spend a quiet youth.
FrontPage › LiterateProgramming
À§ ÄÚµå´Â KnuthÀÇ Àú¼ Literate Programming ÀÇ Ç¥Áö¿¡ ³ª¿ÍÀÖ´Â ÄÚµåÀÔ´Ï´Ù.
[ÆíÁý]
1 ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö À̶õ? ¶
¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö(literate programming)Àº ÇÁ·Î±×·¡¹Ö ¹æ¹ý·ÐÀÇ ÇÑ °¡Áö·Î, ÇÁ·Î±×·¡¹ÖÀ» ÇÒ ¶§ ÄÄÇ»ÅÍ·Î ÄÄÆÄÀÏ °¡´ÉÇÑ Äڵ带 ¸¸µå´Â °Íº¸´Ù »ç¶÷ÀÌ ÀÌÇØÇϱ⠽¬¿î Äڵ带 ¸¸µå´Â °Í¿¡ ÁßÁ¡À» µÎ´Â ¹æ¹ýÀÌ´Ù. Áï, »ç¶÷ÀÌ º¸°í ÀÌÇØÇÒ ¼ö ÀÖµµ·Ï ¹®¼¸¦ ¸¸µéµíÀÌ ÇÁ·Î±×·¡¹ÖÀ» ÇÏ´Â °ÍÀÌ ¸ñÀûÀÌ´Ù. '¸¶Ä¡ ¹®ÇÐÀÛÇ°À» Àд °Íó·³ ÇÁ·Î±×·¡¹ÖÀ» ÀÐÀ» ¼ö ÀÖµµ·Ï ¸¸µå´Â °Í'ÀÌ ¸ñÇ¥À̹ǷΠ'¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö'À̶ó´Â À̸§À» Áö¾ú´Ù. (Ãâó: ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö-À§Å°¹é°ú)
[ÆíÁý]
1.1 ±â¿ø ¹× ¼Ò°³ ¶
¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀº ¿ì¸®¿¡°Ô TeXÀÇ ÀúÀÚ·Î ¾Ë·ÁÁø Knuth°¡ ¸¸µé¾î³½ ÇÁ·Î±×·¡¹ÖÀÇ »õ·Î¿î Æз¯´ÙÀÓÀÔ´Ï´Ù. Knuth°¡ ÀÌ¿¡ ´ëÇÑ °³³äÀ» ±¸Ã¼ÈÇϱ⠽ÃÀÛÇÑ °ÍÀÌ 1980³â´ë ÃʹÝÀ̴ϱî 2006³â ÇöÀç·Î½á´Â '»õ·Î¿î'À̶õ ´Ü¾î°¡ Á» ¹«»öÇØ Áý´Ï´Ù. ÇÏÁö¸¸ ÇöÀç±îÁöµµ ±×¸® ³Î¸® ÀÌ¿ëµÇ°í ÀÖÁö´Â ¾ÊÀ¸µí ½Í½À´Ï´Ù.
Àü»êÇп¡´Â Àü»êÇÐÀÇ ³ëº§»óÀ̶ó ºÒ¸®´Â Æ©¸µ»ó(A. M. Turing Award) ÀÌ ÀÖ½À´Ï´Ù. 1974³â Æ©¸µ»ó ¼ö»óÀÚ´Â ¾Ë°í¸®ÁòÀÇ ºÐ¼®°ú ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÇ µðÀÚÀÎ ±×¸®°í, The art of computer programming À̶ó´Â Àú¼·Î ±× ºÐ¾ß¿¡ ¸¹Àº °øÇåÀ» ÇÑ Knuth ¿´½À´Ï´Ù.
°ü·Ê(?)·Î½á ±× ÇØ Æ©¸µ»óÀ» ¹ÞÀº »ç¶÷Àº ACM Turing Award Lecture¶ó´Â À̸§À¸·Î °ÀǸ¦ ÇÏ°Ô µÇ¾î Àִµ¥, 1974³â ±× °ÀÇÀÇ Á¦¸ñÀº Computer Programming as an Art(»õ·Î¿î ÷ºÎ "knuth-turingaward.pdf)¿´½À´Ï´Ù"ÆÄÀÏ ¾÷·Îµå. Knuth´Â ¿©±â¼ ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¹ÖÀ» ´Ü¼øÇÑ ±â¼úÀÌ ¾Æ´Ñ À½¾Ç, ¹Ì¼ú, ¹®Çаú °°Àº Á¾·ùÀÇ ÇϳªÀÇ ¿¹¼ú È°µ¿À̶ó°í °Á¶ÇÏ°í ÀÖ½À´Ï´Ù. ±×¸®°í °á·ÐºÎ¿¡´Â ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¸Ó ÀÚ½ÅÀÌ ¿¹¼ú°¡¶ó´Â ÀνÄÀ» °¡Áö°í ÇÁ·Î±×·¡¹Ö ÀÛ¾÷¿¡ ÀÓÇϸé, ÇÁ·Î±×·¡¹ÖÀÌ ´õ¿í Áñ°Ì°í, ±× °á°ú ¶ÇÇÑ ´õ¿í ÁÁÀ» °ÍÀ̶ó°í ¸»ÇÕ´Ï´Ù.
To summarize: We have seen that computer programming is an art, because it applies accumulated knowledge to the world, because it requires skill and ingenuity, and especially because it produces objects of beauty. A programmer who subconsciously views himself as an artist will enjoy what he does and will do it better. Therefore we can be glad that people who lecture at computer conferences speak about the state of the Art.
¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀº ÀÌ·¸°Ô ½ÃÀÛÇß³ªº¾´Ï´Ù. ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¹ÖÀ» ¿¹¼ú·Î º¸´Â ´ë°¡·Î ºÎÅÍ ¸»ÀÔ´Ï´Ù. À§ÀÇ °ÀǸ¦ ½ÃÀÛÀ¸·Î ´«¿¡ º¸ÀÌ´Â º»°ÝÀûÀÎ ¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀÇ ½ÃÀÛ ¶ÇÇÑ KnuthÀÇ ³í¹® Literate Programming (knuthweb.pdf (257.24 KB) ) ¿¡¼ ½ÃÀÛÇÕ´Ï´Ù. ÀÌ ³í¹®¿¡¼ Knuth´Â ´õÀÌ»ó ÄÄÇ»Å͸¦ À§ÇØ ÇÁ·Î±×·¡¹ÖÀ» ÇÏ´Â ½Ã´ë´Â Áö³µ´Ù°í ¸»ÇÕ´Ï´Ù. »ç¶÷À» À§ÇÑ ÇÁ·Î±×·¡¹ÖÀ» ÇÏÀÚ°í ÇÕ´Ï´Ù. ¹°·Ð ÇÁ·Î±×·¡¹ÖÀ̶ó´Â °ÍÀÌ ÄÄÇ»ÅÍ¿¡ ÀÏÀ» ½ÃÅ°±â À§ÇÑ ¸í·ÉµéÀÇ ÁýÇÕÀÌÁö¸¸, ÀÌ°Í¿¡ ¿¬¿¬ÇÏ¿© ³Ê¹« ÄÄÇ»ÅÍ¿¡¸¸ ÃÊÁ¡À» ¸ÂÃßÁö ¸»°í, »ç¶÷µé¿¡°Ô ´«À» µ¹¸®ÀÚ´Â °ÍÀÌÁö¿ä. ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¹ÖÀÇ ¸£³×»ó½º ½Ã´ë°¡ ¿Â °ÍÀÌÁö¿ä.
ÀÌ ³í¹®¿¡¼ ¿ª½Ã ÀÏ°üµÇ°Ô ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¹ÖÀ» ¹®ÇÐ ÀÛÇ°(works of literature) À¸·Î °£ÁÖÇÏ°í, Àç¹ÌÀÖ´Â ¸»ÀÎ Literate Programming À̶õ ¸»À»¸¸µé¾î ³Â½À´Ï´Ù. Knuth´Â ¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀ» ´Ü¼øÇÑ ¸»À峿¡ ±×Ä¡´Â °ÍÀ» ½È¾îÇؼ WEBÀ̶ó´Â ½Ã½ºÅÛÀ» ¸¸µé¾î ³Â½À´Ï´Ù. TeXÀÌ WEB ½Ã½ºÅÛÀ¸·Î ¸¸µé¾îÁ³´Ù´Â °ÍÀº Àß ¾Ë·ÁÁø »ç½ÇÀÌÁö¿ä.
I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature. Hence, my title: Literate Programming.
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
ÄÄÇ»ÅÍ ÇÁ·Î±×·¡¹ÖÀ» º»°ÝÀûÀ¸·Î ÀÍÈ÷°íÀÚ ÇÏ´Â »ç¶÷µéÀº ¹Ýµå½Ã ÀоîºÁ¾ß ÇÑ´Ù°í ÇÕ´Ï´Ù. TeX¿¡ Àͼ÷ÇØÁö¸é Çѹø µµÀüÇØ º¸°íÀÚ ÇÕ´Ï´Ù.
% weave tex.web <-- tex.web ÆÄÀÏ¿¡¼ tex.tex ÆÄÀÏÀ» ¾ò½À´Ï´Ù. % tex tex.tex <-- texÀÌ ¼¼¹øÀ̳ª ¾²¿´³×¿ä. % dvipdfmx tex.dviÀ§Ã³·³ ÇÏ¿© ¸¸µé¾î Áø Ã¥ÀÌ ¹Ù·Î KnuthÀÇ Àú¼ Computers & Typesetting ½Ã¸®ÁîÀÇ Volume BÀÎ TeX: The Program ÀÔ´Ï´Ù.
[ÆíÁý]
1.2 KnuthÀÇ ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö °ÀÇ ¶
Knuth´Â 1987³â 10~12¿ù¿¡ ½ºÅÄÆ÷µå´ëÇп¡¼ Mathematical WritingÀ̶õ Á¦¸ñÀ¸·Î °ÀǸ¦ ÇÏ¿´½À´Ï´Ù. ±× Áß ÀϺΰ¡ ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö¿¡ °üÇÑ ³»¿ëÀÔ´Ï´Ù. ¿µ¾î°¡ ª¾Æ¼ ´Ù ¾Ë¾ÆµèÁö´Â ¸øÇϴµ¥, ÇÑ°¡Áö ´ÙÇàÀÎ Á¡Àº °ÀÇ Á¦¸ñ°ú µ¿ÀÏÇÑ Mathematical Writing À̶õ Ã¥ÀÌ Àִµ¥, ±× Ã¥Àº ÀÌ °ÀǸ¦ ¼ö°ÇÑ Çлýµé°ú Knuth°¡ ¸¸µç Ã¥À¸·Î "°ÀÇ ³ëÆ®"ÀûÀÎ ¼º°ÝÀÌ Â£½À´Ï´Ù. ÀÌ¿¡ ±× Ã¥¿¡¼ ÇØ´ç °ÀÇ ºÎºÐÀ» ¿Ã¸³´Ï´Ù. µ¿¿µ»ó ½Ãû¿¡ ¸¹Àº µµ¿òÀÌ µÇ¸®¶ó º¾´Ï´Ù.
- Presenting algorithm (°ÀÇ ¿ä¾àº»: pa.pdf (36.34 KB) )
- Literate Programming(1) (°ÀÇ ¿ä¾àº»: lp1.pdf (43.49 KB) )
- Literate Programming(2) (°ÀÇ ¿ä¾àº»: lp2.pdf (39.55 KB) )
[ÆíÁý]
1.3 KnuthÀÇ ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö¿¡ ´ëÇÑ ¾ÖÁ¤ ¶
TUGboat Volume 26 (2005), No.3¿¡ Interview with Donald E. Knuth¶ó´Â Á¦¸ñÀ¸·Î KnuthÀÇ ÀÎÅÍºä ±â»ç°¡ ½Ç·È½À´Ï´Ù. ÀÌ ±â»ç¿¡¼ TeXÀ» ¸¸µé±â À§Çؼ ¾î¶² ÅøÀ» »ç¿ëÇߴ°¡¶ó´Â Áú¹®¿¡´ëÇÑ ±×ÀÇ ´ë´ä¿¡¼ KnuthÀÇ ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö¿¡ ´ëÇÑ »ç¶ûÀ» ¿³º¼ ¼ö ÀÖ´Â ºÎºÐÀÌ Àֱ⿡ ¿Å°Ü º¾´Ï´Ù.
"The tools I used were home grown and became known as Literate Programming. I am enormously biased about Literate Programming, which is surely the greatest thing since sliced bread. I continue to use it to write programs almost every day, and it helps me get efficient, robust, maintainable code much more successfully than any other way I know. Of course, I realize that other people might find other approaches more to their liking; but wow, I love the tools I¡¯ve got now. I couldn¡¯t have written difficult programs like the MMIX meta-simulator at all if I hadn¡¯t had Literate Programming; the task would have been too difficult."
[ÆíÁý]
1.4 ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö °ü·Ã ±Û ¶
- fine_art_programming.pdf (54.54 KB) : Free Software Magazine Issue 6¿¡ ½Ç¸° ±Û·Î½á, Free software¿Í ¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀÇ ¹Ì·¡¿¡ ´ëÇÑ ±ÛÀÔ´Ï´Ù. Àо ¸¸ÇÕ´Ï´Ù. (Âü°í·Î ÀúÀÚ Matt BartonÀº St. Cloud State University in MinnesotaÀÇ ¿µ¹®ÇÐ ±³¼ö¶ó°í ÇÕ´Ï´Ù.)
[ÆíÁý]
2 ¹®ÇÐÀû ÇÁ·Î±×·¡¹Ö ½Ã½ºÅÛ ¶
¹®ÇÐÀû ÇÁ·Î±×·¡¹ÖÀº ÇÁ·Î±×·¥ ¼Ò½º¿Í ±×¿¡ ´ëÇÑ ¹®¼È ÀÛ¾÷À» µ¿½Ã¿¡ ÇÏ´Â °ÍÀÌ´Ù. µû¶ó¼ ¹®ÇÐÀû ÇÁ·Î±×·¥ÀÇ ¼Ò½º´Â Å©°Ô ÇÁ·Î±×·¡¹Ö ºÎºÐ°ú ¹®¼È ºÎºÐÀ¸·Î ³ª´µ¾îÁø´Ù. ÇÁ·Î±×·¡¹Ö ºÎºÐÀº ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡ µû¶ó ´Ù¸£Áö¸¸, ¹®¼È ºÎºÐÀº ±âº»ÀûÀ¸·Î LaTeX ȤÀº plain TeXÀ» ÀÌ¿ëÇÑ´Ù. µû¶ó¼ ¹®¼È ºÎºÐ¿¡ ¾î¶² TeXÀ» »ç¿ëÇÏ´À³Ä¿¡ µû¶ó ³ª´· ¼ö ÀÖ°Ú´Ù.
[ÆíÁý]
2.1.1 noweb À» ÀÌ¿ëÇÏ´Â ¹æ¹ý ¶
noweb Àº LaTeX À» ÀÌ¿ëÇÒ ¼ö ÀÖµµ·Ï, ¶Ç ¿©·¯°¡Áö ÇÁ·Î±×·¡¹Ö ¾ð¾î¸¦ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï º¯°æÇÑ, WEB ÀÌ´Ù. ½ÇÁ¦·Î LaTeX À» »ç¿ëÇϱâ À§Çؼ´Â noweb À» »ç¿ëÇÏ´Â °ÍÀÌ Á¤´äÀ̶ó°í º¼ ¼ö ÀÖ´Ù.
- ÀåÁ¡ : ½ºÅ¸ÀÏ ÆÄÀϸ¸À» Á¦°øÇÔÀ¸·Î¼ ±âÁ¸ÀÇ Å¬·¡½ºµé°ú È¥¿ëÇÏ¿© »ç¿ëÇÏ´Â °ÍÀÌ °¡´ÉÇÏ´Ù. ¿©·¯°¡Áö ÇÁ·Î±×·¡¹Ö ¾ð¾î¸¦ Á¦°øÇÑ´Ù.
- ´ÜÁ¡ : nawk µî ´Ù¸¥ À¯Æ¿¸®Æ¼¸¦ »ç¿ëÇÏ¿© ¼Ò½º¸¦ ÄÄÆÄÀÏ ÇÏ°Ô µÇ¹Ç·Î Á÷°üÀûÀÌÁö ¾ÊÀº ¼³Ä¡°úÁ¤ÀÌ ÇÊ¿äÇÏ´Ù. ±âÁ¸ÀÇ CWEB ¾ð¾î¿Í´Â Á¶±Ý ´Ù¸£´Ù.
[ÆíÁý]
2.1.2 CWEB À» ÀÌ¿ëÇÏ´Â ¹æ¹ý ¶
CWEBÀ¸·Î ÀÛ¼ºµÈ w ÆÄÀÏÀ» ±â¹ÝÀ¸·Î ÇÑ´Ù. cweb.cls ¶ó°í Çϴ Ŭ·¡½º ÆÄÀÏÀÌ ÀÖÀ¸¹Ç·Î À̸¦ ÀÌ¿ëÇÏ°Ô µÈ´Ù.
- ÀåÁ¡ : ±âÁ¸ÀÇ w ÆÄÀϵéÀ» ¸î°¡Áö º¯°æÇÔÀ¸·Î¼ LaTeX »ó¿¡¼ »ç¿ëÀÌ °¡´ÉÇÏ´Ù.
- ´ÜÁ¡ : Ŭ·¡½º ÆÄÀϸ¸À» Á¦°øÇÔÀ¸·Î¼ º»°ÝÀûÀÎ È®ÀåÀÌ °ÅÀÇ ºÒ°¡´É ÇÏ´Ù. ¿¹¸¦ µé¾î¼ ¸Þ¸ð¾Æ¿Í °°ÀÌ »ç¿ëÇϱâ À§Çؼ´Â Ŭ·¡½º ÆÄÀÏÀÎ cweb.cls ¸¦ .sty ÆÄÀÏ·Î º¯°æÇØ¾ß Çϴµ¥, ÀÌ ³ë·ÂÀº °ÅÀÇ ¹«ÀÇ¹Ì ÇÏ´Ù°í »ý°¢ÀÌ µÈ´Ù.