KTUGFaq

KTUG FAQ

LiterateProgramming (rev. 1.51)

α:
йȣ:
You recoil from the crude; you tend naturally toward the exquisite.
FrontPage › LiterateProgramming

1 α׷ ̶?
1.1 Ұ
1.2 Knuth α׷
1.3 Knuth α׷ֿ
1.4 α׷
1.5 α׷ Ʈ
2 α׷ ý
2.1 LaTeX ̿ α׷
2.1.1 noweb ̿ϴ
2.1.2 CWEB ̿ϴ
2.1.3 Ÿ ڷ
2.2 PlainTeX ̿ α׷
[]

1 α׷ ̶?

α׷(literate programming) α׷ , α׷ ǻͷ ڵ带 ͺ ϱ ڵ带 Ϳ δ ̴. , ֵ α׷ ϴ ̴. 'ġ ǰ д ó α׷ ֵ ' ǥ̹Ƿ ' α׷'̶ ̸ .
[]

1.1 Ұ

α׷(Literate programming) 츮 TeX ڷ ˷ Knuth  α׷ ο зԴϴ. Knuth ̿ üȭϱ 1980 ʹ̴ϱ 2006 ν 'ο'̶ ܾ ϴ. ׸ θ ̿ǰ ͽϴ.

п 뺧̶ Ҹ Ʃ(A. M. Turing Award: http://awards.acm.org/turing/) ֽϴ. 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.

  • WEB ۼ TeX ҽ: http://ftp.ktug.or.kr/tex-archive/systems/knuth/tex/tex.web
    ǻ α׷ ϴ ݵ о Ѵٰ մϴ. TeX ͼ ѹ մϴ.
  • ִ Ͽ: pdf  ϴ. tex.web ٿð,
    % weave tex.web      <-- tex.web Ͽ tex.tex  ϴ.
    % tex tex.tex      <-- tex ̳ ׿. :)    ص  ƽø Ͻϴ.
    % dvipdfmx tex.dvi
    
    ó Ͽ å ٷ Knuth Computers & Typesetting ø Volume B TeX: The Program Դϴ. Volume D METAFONT: The Program http://ftp.ktug.or.kr/tex-archive/systems/knuth/mf/mf.web ٿż pdf ø ˴ϴ. Ͻ ̴ϴ.

  • []

    1.2 Knuth α׷

    Knuth 1987 10~12 п Mathematical Writing̶ Ǹ Ͽϴ. Ϻΰ α׷ֿ Դϴ.  ªƼ ˾Ƶ ϴµ, Ѱ Mathematical Writing ̶ å ִµ, å Ǹ л Knuth å " Ʈ" £ϴ. ̿ å ش κ øϴ. û Ǹ ϴ.
    []

    2 CWEB Ұ

    $$\hbox{CWEB}=\hbox{C programming language}+\hbox{\TeX}$$

    from KTUGContrib:3195 (by )

    α׷ ý Ǵ Ƹ CWEB Դϴ. α׷ ý ⺻ Ǿ ǻα׷ Ǵµ, CWEB Ǵ Ǿ TeX Ǵ C ýԴϴ. CWEB Ǵ ý̶ ؼ ̻ ϳ ?

    CWEB TeX α׷ µ WEB ýۺ ýԴϴ.WEB TeX Pacal α׷ ̷ִµ, C Pascalٴ (?) α׷ ̱ ̶ϴ. Ʒ ÷ CWEB ޴ cwebman.tex ʹݺ α׷ְ CWEB Դϴ. ޴ Ĺݺδ ǻ α׷ֿ õ κ̶ ߽ϴ.

    @korean_cwebman.pdf (139.65 KB)

    CWEB ý α׷ ý۵ մϴ. http://www.literateprogramming.com Ʈ 湮 ø, ſ پ ý۵ ֽϴ. Ʈ Knuth Ұ ſ Ǹ ƮԴϴ.
    []

    3 Microsoft Visual C++ CWEB α׷ ϱ

    CWEB α׷ ۾ (?) ࿡ ̷ Խϴ (ϰų ų). ð 帧 ̻ Ÿϰ ִ ࿡ ۾ Ȳ Ǿϴ. ȯ IDE ϰ ȯ ü ̹ Դϴ. ̿ cweb α׷ ۾ ȭ 帧 ߾ IDE ǥ̶ ִ Microsoft Visual C++ ҽϴ.

    @cwebmsvc.pdf (92.58 KB)

    Ͽ Visual C++ cweb α׷ ϱ , cweb ִ ˴ϴ.

    []

    4 CWEB

    $$\hbox{cweb}=\hbox{ctangle}+\hbox{cweave}$$
    • Ȯڰ .w ؽƮ , foo.w ̶ ϴ. foo.w web Ȥ cweb ε, α׷ ҽ ׿ شϴ ťƮ ÿ ִ Դϴ. cweb α׷ Ҷ, ó α׷ְ ťƮ ÿ ؾ մϴ.
    • Ʒ ɾ cweb foo.wκ α׷ ҽ foo.c(Ȥ foo.cpp) ϴ.
    % ctangle foo
    
    • ctangle foo.c gcc C Ϸ ̿ؼ ϴ.
    • ɾδ foo.w TeX foo.tex ϴ.
    % cweave foo
    
    • cweave foo.tex PlainTeX ̿Ͽ foo.dvi ϴ.
    % tex foo
    
    Ǵ, pdf ʺ ϰ ôٸ, Ͻø ˴ϴ.
    % tex "\let\pdf+ \input foo"
    
    ׸ Ÿ ϴ.

    cweave.jpg

    []

    5 CWEB

    C α׷ ؾ , CWEB α׷ ϰ ִµ, CWEB α׷ ֽϴ. ðڴٸ, Knuth ð? Knuth ǿ ̷ Ѵٳ׿. "CWEB programming is such fun!"
    []

    6 CWEB ý ѱȭ



    []

    7 CWEB ġ ѱ

    : Hangul-ucs ̿Ͽ ucsplain.tex ϴ 쿡 شϴ ̰, HLaTeX ̿Ͽ, htex.tex Ͻô ̶, Դϴ.

    UTF-8ε ѱ ϴ cweb ҽ .w Ϸκ ctangle cweave ɾ ̿ؼ C α׷ .c ϰ TeX .tex ٺ, Է ʹ ٴ ޽ ɴϴ. ̴ ɾ óϱ ؼ (char 迭) ְ, Ÿ buffer_end ۾Ƽ ޽Դϴ. Ÿ buffer_end ũָ ߻ ʴ ޽Դϴ. ĺ ѹڰ 1Ʈ̱ ׷ ޽ ϴ. 쵵 ʹ ϸ ׷ ޽ .

    ( utf-8 ϴ.) utf-8 ڸ 1Ʈ ִ 4Ʈ ǥѴٰ ϴ. utf-8 ۼ ҽ 츦 ؼ buffer_end ִ 4谡 ǰϸ ˴ϴ.

    ctangle cweave ȭ ¿ κ̳ κ common.w ִµ, buffer_end ٷ Ͽ ֽϴ.

    common.w Ϻ
    @d buf_size 100 /* for \.{CWEAVE} and \.{CTANGLE} */
    @d longest_name 1000
    @d long_buf_size (buf_size+longest_name) /* for \.{CWEAVE} */
    ...
    @<Definitions...@>=
    char buffer[long_buf_size]; /* where each line of input goes */
    char *buffer_end=buffer+buf_size-2; /* end of |buffer| */
    ...
    
    buf_size ִ 4 ũϴ, ƴϸ, buffer_end ϴ κп buf_size ſ long_buf_size ϸ ˴ϴ.

    cweb ġҶ, ι° ؼ ġؼ, utf-8 Ҷ ctangle̳ cweave մϴ. ̰ utf-8 ٺ ذå, ӽù 𸣰,  ޽ ֽϴ.

    cweb α׷ ҽ ĥ , ش ҽ ġ ùٸ ƴմϴ. cweb ̷ 츦 ؼ Ȯڰ .ch change մϴ. ó common.w , comm-utf8.ch  common.c ,
    ctangle common.w comm-utf8.ch
    
    ϸ ˴ϴ. comm-utf8.ch 
    @x
    char *buffer_end=buffer+buf_size-2; /* end of |buffer| */
    @y
    char *buffer_end=buffer+long_buf_size-2; /* end of |buffer| */
    @z
    
    Ͻø ˴ϴ. (.ch cweb cwebman.pdf ø ֽϴ.) е 帰 common.w Ͻô Ƽ ̳ 帳ϴ. ϼŵ ũ ϴ. ٸ ƴ϶ .

    ^
    Valid XHTML 1.0! Valid CSS! powered by MoniWiki
    last modified 2006-07-17 12:03:48
    Processing time 0.2152 sec