Assembly e linguaggi algoritmici (come C, Algol, ecc.) [duplicato]

1

Solitamente, i documenti informatici descrivono algoritmi in pseudolinguaggio simile ad Algol, simile a Pascal o addirittura C / C ++.

Ma Donald Knuth usa il proprio linguaggio assembly (MMIX).

Esistono algoritmi noti non indicibili in un linguaggio simile ad Algol ma espressi in codice assembly non strutturato? Come le coroutine, forse?

    
posta Dennis Yurichev 09.11.2014 - 23:22
fonte

1 risposta

4

Credo che Knuth stesso fornisca una risposta in "The Art of Computer Programming".

Dice:

High level languages are inadequate for discussing important low-level details such as coroutine linkage, random number generation, multi-precision arithmetic, and many problems involving the efficient usage of memory.

Ma la decisione di utilizzare un linguaggio orientato alla macchina è probabilmente dovuta al fatto che:

New algebraic languages go in and out of fashion every five years or so, while I am trying to emphasize concepts that are timeless.

(Prefazione al TAOCP vol. 1)

Moreover, if I did use a high-level language, what language should it be? In the 1960s I would probably have chosen Algol W; in the 1970s, I would then have had to rewrite my books using Pascal; in the 1980s, I would surely have changed everything to C; in the 1990s, I would have had to switch to C++ and then probably to Java. In the 2000s, yet another language will no doubt be de rigueur. I cannot afford the time to rewrite my books as languages go in and out of fashion; languages aren't the point of my books, the point is rather what you can do in your favorite language. My books focus on timeless truths.


Expressing basic methods like algorithms for sorting and searching in machine language makes it possible to carry out meaningful studies of the effects of cache and RAM size and other hardware characteristics (memory speed, pipelining, multiple issue, lookaside buffers, the size of cache blocks, etc.) when comparing different schemes.

Infatti poiché '60 c'erano le notazioni appropriate per le coroutine in lingue simili ad ALGOL:

...coroutine linkage had already been noted briefly as a "programming tip" in an early UNIVAC publication [...] A suitable notation for coroutines in ALGOL-like languages was introduced in Dahl and Nygaard's SIMULA I [...] and several excellent examples of coroutines (including replicated coroutines) appear in the book Structured Programming [by Dahl, Dijkstra, and Hoare].

(TAOCP vol. 1, pp 229-230)

Per non parlare della routine ad alta precisione / precisione multipla in FORTRAN / ALGOL:

Extended precision subroutines for use in FORTRAN programs were described by B.I. Blum (1965) [...] and for use in ALGOL by M. Tienari and V.Suokonautio [...] Arithmetic on integers with unlimited precision, making use of linked memory allocation techniques, was elegantly introduced by G.E. Collins [...]

(TAOCP vol.2, pg 279)

Stessa cosa per la generazione di numeri casuali: ci sono esempi in C (TAOCP vol. 2, pp 185-188) ed esercizi in altri linguaggi di alto livello (ad es. [EX10] pg 193).

    
risposta data 10.11.2014 - 11:00
fonte

Leggi altre domande sui tag