Kontentke ótiw

Sawatlı programmalastırıw

Wikipedia — erkin enciklopediya
Fayl:Literate Programming book cover.jpg
Donald Knuttıń «Sawatlı Programmalastırıw» kitabı sawatlı programmalastırıw boyınsha tiykarǵı kitap bolıp tabıladı.

Sawatlı programmalastırıw (LP) — bul 1984-jılı Donald Knutt tárepinen usınılǵan programmalastırıw paradigması bolıp, onda kompyuter programması onıń qalay isleytuǵının tábiyiy tilde, mısalı, inglis tilinde túsindiriw retinde beriledi, bul makroslar menen dástúrli derek kodı bólimleri menen aralastırılǵan (jaylastırılǵan), sonnan kompilyaciyalanatuǵın derek kodı payda etiliwi múmkin. Bul usıl ilimiy esaplawlarda hám maǵlıwmat iliminde qaytalanatuǵın izertlewler hám ashıq kiriw maqsetleri ushın úziliksiz qollanıladı. Sawatlı programmalastırıw quralların búgingi kúnde millionlaǵan baǵdarlamashılar paydalanadı.

Donald Knutt tárepinen oylap tabılǵan sawatlı programmalastırıw paradigması kompyuter programmaların kompilyator tárepinen belgilengen usılda hám tártipte jazıwdan bas tartıwdı bildiredi hám onıń ornına baǵdarlamashılarǵa óz oylarınıń logikası hám aǵımı talap etetuǵın tártipte programmalar islep shıǵıw ushın makroslar beredi[1]. Sawatlı programmalar logikanıń kóbirek tábiyiy tildegi bayanlaması retinde jazıladı, onda makroslar abstrakciyalardı hám dástúrli derek kodın jasırıw ushın paydalanıladı, kóbirek esse tekstine uqsas.

Sawatlı programmalastırıw quralları derek faylınan eki kórinis alıw ushın qollanıladı: birewi kompilyator yamasa interpretator ushın túsinikli bolǵan, «shatastırılǵan» kod hám ekinshisi formatlanǵan hújjet retinde kóriw ushın, ol sawatlı derekten «toqılǵan» delinedi.[5] Sawatlı programmalastırıw qurallarınıń birinshi áwladı kompyuter tiline tán bolǵan bolsa, keyingileri tilden ǵárezsiz hám jeke programmalastırıw tillerinen tıs bar.

Tariyxı hám filosofiyası

Sawatlı programmalastırıw birinshi ret 1984-jılı Donald Knutt tárepinen usınıldı, ol onı adamlar ushın sáykes ádebiyat bolatuǵın programmalar jaratıw ushın jobalastırǵan edi. Ol onı Stenford universitetinde algoritmler hám cifrlı tipografiya boyınsha izertlewleriniń bir bólimi retinde ámelge asırdı. Implementaciya «WEB» dep ataldı, sebebi ol onıń ele de esaplawǵa qollanılmaǵan az sanlı úsh háripli inglis sózleriniń biri ekenine isengen edi[2]. Degen menen, ol ápiwayı materiallardan náziklik penen biriktirilgen programmalıq támiynattıń quramalı tábiyatına uqsaydı. Sawatlı programmalastırıw ámeliyatı 2010-jıllarda, ásirese maǵlıwmatlar iliminde, esaplaw dápterlerin paydalanıw menen áhmiyetli qayta tikleniwdi kórdi.

Koncepciya

Sawatlı programmalastırıw — bul programma logikasın adam tilinde, qosılǵan (ápiwayı belgilew menen ajıratılǵan) kod bólimleri hám makroslar menen jazıp shıǵıw. Sawatlı derek faylındaǵı makroslar — bul programmalastırıw máselesin sheshiw waqtında jaratılǵan adam abstrakciyaların táriyipleytuǵın, kod bólimlerin yamasa tómen dárejeli makroslardı jasırıp turatuǵın adam tilindegi atamaǵa uqsas yamasa túsindiriwshi sóz dizbekleri. Bul makroslar ádette kompyuter ilimin oqıtıwda qollanılatuǵın psevdokodtaǵı algoritmlerge uqsas. Bul qálegen túsindiriwshi sóz dizbekleri baǵdarlamashı tárepinen jedel jaratılǵan anıq jańa operatorlarǵa aylanadı, tiykarındaǵı programmalastırıw tiliniń ústinde metatil quraydı.

Kompilyaciyalanatuǵın derek kodın bir buyrıq penen («shatastırıw»), al hújjetti ekinshi buyrıq penen («toqıw») payda etiw ushın qálegen ierarxiyalardı yamasa, durısıraq aytqanda, «makroslardıń óz-ara baylanıslı 'torların'»[3] almastırıw ushın preprocessor qollanıladı. Preprocessor sonıń menen birge makroslardıń mazmunın jazıp shıǵarıwǵa hám sawatlı programma derek faylınıń tekstiniń qálegen jerinde aldınnan jaratılǵan makroslarǵa qosıwǵa imkaniyat beredi, solay etip dástúrli programmalastırıw tilleri tárepinen qoyılǵan sheklewlerdi yadta saqlaw zárúrliginen yamasa oylaw aǵımın úziwden qutqaradı.

Artıqmashılıqları

Knuttıń aytıwınsha,[4][5] sawatlı programmalastırıw joqarı sapalı programmalar beredi, sebebi ol baǵdarlamashılardı programmanıń tiykarındaǵı oylardı anıq aytıwǵa májbúrleydi, bul jaman oylanǵan dizayn sheshimlerin ayqınıraq etedi. Knutt sonıń menen birge sawatlı programmalastırıwdıń qosımsha emes, al programmanıń jaratılıwı waqtında biriniń oyların bayanlaw processinde tábiyiy túrde ósetuǵın birinshi dárejeli hújjetlestiriw sistemasın usınatuǵının da aytadı[6]. Nátiyjesindegi hújjetlestiriw avtorǵa óziniń oylaw processlerin hár qanday keyingi waqıtta qayta baslawǵa imkaniyat beredi hám basqa baǵdarlamashılarǵa programmanıń qurılısın ańsat túsinip alıwǵa múmkinshilik beredi. Bul dástúrli hújjetlestiriwden ayırmashılıq etedi, onda baǵdarlamashıǵa kompilyator tárepinen belgilengen tártipke boysınatuǵın derek kodı usınıladı hám ol programmanıń tiykarındaǵı oylaw processin kodtan hám onıń menen baylanıslı kommentariyalardan sheshiw kerek boladı. Sawatlı programmalastırıwdıń metatil imkaniyatları sonıń menen birge oylawdı ańsatlastıradı, kodtıń joqarıdan «qustıń ushıw» kórinisin beredi hám aqıldıń tabıslı saqlap hám qayta isley alatuǵın túsinikler sanın arttıradı dep aytıladı. Koncepciyanıń úlken kólemdegi programmalastırıwǵa, yaǵnıy kommerciyalıq dárejedegi programmalarǵa qollanılıwı TeX kodınıń sawatlı programma retindegi basılımı menen dálillengen.

Knutt sonıń menen birge sawatlı programmalastırıwdıń programmalıq támiynattı bir neshe ortalıqlarǵa ańsat portlawǵa alıp keliwi múmkin ekenin de aytadı hám hátte TeX-tiń implementaciyasın mısal retinde keltiredi[7].

Hújjetlestiriw generaciyası menen salıstırıw

Sawatlı programmalastırıw kóbinese[8] derek kodı hám kommentariyaları bar ulıwma fayldan payda bolǵan formatlanǵan hújjetlestiriwge ǵana silteme beredi dep qáte túsiniledi — bul durıs túrde hújjetlestiriw generaciyası dep ataladı — yamasa kod penen birge berilgen úlken kólemli kommentariyalarǵa. Bul sawatlı programmalastırıwdıń kerisinshe: jaqsı hújjetlestirilgen kod yamasa kodtan alınǵan hújjetlestiriw kodtıń strukturasına boysınadı, bunda hújjetlestiriw kodqa jaylastırılǵan; al sawatlı programmalastırıwda kod hújjetlestiriwge jaylastırılǵan, bunda kod hújjetlestiriwdiń strukturasına boysınadı.

Bul qáte túsinik Perl Plain Old Documentation yamasa Java Javadoc sistemaları sıyaqlı kommentariya alıw qurallarınıń «sawatlı programmalastırıw quralları» ekenligi haqqındaǵı pikirlerge alıp keldi. Degen menen, bul qurallar tábiyiy til makrosları sistemasınıń artında jasırınǵan «abstrakt koncepciyalar torın» ámelge asırmaǵanlıqtan yamasa derek kodınıń tártibin mashina tárepinen belgilengen izbe-izlikten adam aqılına qolaylı bir tártipke ózgertiw imkaniyatın bermegenlikten, olar Knutt tárepinen jobalanǵan mániste durıs mánide sawatlı programmalastırıw quralları dep atawǵa bolmaydı[9].

Jumıs barısı

Sawatlı programmalastırıwdı ámelge asırıw eki basqıshtan ibarat:

  1. Toqıw: programma hám onıń qollap-quwatlawı haqqında tolıq hújjet payda etiw.
  2. Shatastırıw: mashina orınlay alatuǵın kod dúziw

Toqıw hám shatastırıw bir-birine sáykes keliwi ushın bir derekte orınlanadı.

Derekler

  1. I had the feeling that top-down and bottom-up were opposing methodologies: one more suitable for program exposition and the other more suitable for program creation. But after gaining experience with WEB, I have come to realize that there is no need to choose once and for all between top-down and bottom-up, because a program is best thought of as a web instead of a tree. A hierarchical structure is present, but the most important thing about a program is its structural relationships. A complex piece of software consists of simple parts and simple relations between those parts; the programmer's task is to state those parts and those relationships, in whatever order is best for human comprehension not in some rigidly determined order like top-down or bottom-up.
    Donald E. Knuth, Literate ProgrammingÚlgi:Ref label
  2. «Literate Programming». Archive.ComputerHistory.org. Qaraldı: 3-iyun 2019-jıl.
  3. WEB's macros are allowed to have at most one parameter. Again, I did this in the interests of simplicity, because I noticed that most applications of multiple parameters could in fact be reduced to the one-parameter case. For example, suppose that you want to define something like [example elided] .... In other words, the name of one macro can usefully be a parameter to another macro.
    Donald E. Knuth, Literate ProgrammingÚlgi:Ref label
  4. Knuth. «Interview with Donald Knuth» (25-aprel 2008-jıl). — „Yet to me, literate programming is certainly the most important thing that came out of the TeX project. Not only has it enabled me to write and maintain programs faster and more reliably than ever before, and been one of my greatest sources of joy since the 1980s, it has actually been indispensable at times. Some of my major programs, such as the MMIX meta-simulator, could not have been written with any other methodology that I've ever heard of. The complexity was simply too daunting for my limited brain to handle; without literate programming, the whole enterprise would have flopped miserably. ... Literate programming is what you need to rise above the ordinary level of achievement.“. Qaraldı: 4-yanvar 2009-jıl.
  5. Another surprising thing that I learned while using WEB was that traditional programming languages had been causing me to write inferior programs, although I hadn't realized what I was doing. My original idea was that WEB would be merely a tool for documentation, but I actually found that my WEB programs were better than the programs I had been writing in other languages.
    Donald E. Knuth, Literate ProgrammingÚlgi:Ref label
  6. Thus the WEB language allows a person to express programs in a "stream of consciousness" order. TANGLE is able to scramble everything up into the arrangement that a PASCAL compiler demands. This feature of WEB is perhaps its greatest asset; it makes a WEB-written program much more readable than the same program written purely in PASCAL, even if the latter program is well commented. And the fact that there's no need to be hung up on the question of top-down versus bottom-up, since a programmer can now view a large program as a web, to be explored in a psychologically correct order is perhaps the greatest lesson I have learned from my recent experiences.
    Donald E. Knuth, Literate ProgrammingÚlgi:Ref label
  7. «"Oral History of Donald Knuth"- an Interview with Ed Feigenbaum». Archive.ComputerHistory.org. Qaraldı: 7-dekabr 2018-jıl.
  8. Dominus. «POD is not Literate Programming». Perl.com (20-mart 2000-jıl). 2-yanvar 2009-jılda túp nusqadan arxivlendi.
  9. I chose the name WEB partly because it was one of the few three-letter words of English that hadn't already been applied to computers. But as time went on, I've become extremely pleased with the name, because I think that a complex piece of software is, indeed, best regarded as a web that has been delicately pieced together from simple materials. We understand a complicated system by understanding its simple parts, and by understanding the simple relations between those parts and their immediate neighbors. If we express a program as a web of ideas, we can emphasize its structural properties in a natural and satisfying way.
    Donald E. Knuth, Literate ProgrammingÚlgi:Ref label