Come mouviciel e ha osservato Emilio Garavaglia , il concetto precede l'informatica. Tuttavia, la prima istanza di un ciclo software era il ciclo Ada Lovelace utilizzato per calcolare Numeri di Bernoulli , come descritto in Nota G della sua traduzione del Schizzo del motore analitico inventato da Charles Babbage , di L. F. Menabrea . Menabrea ha notato la capacità del loop del motore analitico:
This being understood, let us, at the beginning of the series of operations we wish to execute, place the needle C on the division 2, the needle B on the division 5, and the needle A on the division 9. Let us allow the hammer of the dial C to strike; it will strike twice, and at the same time the needle B will pass over two divisions. The latter will then indicate the number 7, which succeeds the number 5 in the column of first differences. If we now permit the hammer of the dial B to strike in its turn, it will strike seven times, during which the needle A will advance seven divisions; these added to the nine already marked by it will give the number 16, which is the square number consecutive to 9. If we now recommence these operations, beginning with the needle C, which is always to be left on the division 2, we shall perceive that by repeating them indefinitely, we may successively reproduce the series of whole square numbers by means of a very simple mechanism.
Il meccanismo di looping del motore analitico è ereditato direttamente da Joseph Marie Jacquard membro meccanico (1801), come osservato nel libro di memorie di Menabrea:
It will now be inquired how the machine can of itself, and without having recourse to the hand of man, assume the successive dispositions suited to the operations. The solution of this problem has been taken from Jacquard's apparatus, used for the manufacture of brocaded stuffs, in the following manner:—
Two species of threads are usually distinguished in woven stuffs; one is the warp or longitudinal thread, the other the woof or transverse thread, which is conveyed by the instrument called the shuttle, and which crosses the longitudinal thread or warp. When a brocaded stuff is required, it is necessary in turn to prevent certain threads from crossing the woof, and this according to a succession which is determined by the nature of the design that is to be reproduced. Formerly this process was lengthy and difficult, and it was requisite that the workman, by attending to the design which he was to copy, should himself regulate the movements the threads were to take. Thence arose the high price of this description of stuffs, especially if threads of various colours entered into the fabric. To simplify this manufacture, Jacquard devised the plan of connecting each group of threads that were to act together, with a distinct lever belonging exclusively to that group. All these levers terminate in rods, which are united together in one bundle, having usually the form of a parallelopiped with a rectangular base. The rods are cylindrical, and are separated from each other by small intervals. The process of raising the threads is thus resolved into that of moving these various lever-arms in the requisite order. To effect this, a rectangular sheet of pasteboard is taken, somewhat larger in size than a section of the bundle of lever-arms. If this sheet be applied to the base of the bundle, and an advancing motion be then communicated to the pasteboard, this latter will move with it all the rods of the bundle, and consequently the threads that are connected with each of them. But if the pasteboard, instead of being plain, were pierced with holes corresponding to the extremities of the levers which meet it, then, since each of the levers would pass through the pasteboard during the motion of the latter, they would all remain in their places. We thus see that it is easy so to determine the position of the holes in the pasteboard, that, at any given moment, there shall be a certain number of levers, and consequently of parcels of threads, raised, while the rest remain where they were. Supposing this process is successively repeated according to a law indicated by the pattern to be executed, we perceive that this pattern may be reproduced on the stuff. For this purpose we need merely compose a series of cards according to the law required, and arrange them in suitable order one after the other; then, by causing them to pass over a polygonal beam which is so connected as to turn a new face for every stroke of the shuttle, which face shall then be impelled parallelly to itself against the bundle of lever-arms, the operation of raising the threads will be regularly performed. Thus we see that brocaded tissues may be manufactured with a precision and rapidity formerly difficult to obtain.
Il telaio di Jacquard è un'applicazione molto precoce di un loop nel contesto di che ordina a una macchina di produrre un output ripetuto :
The idea behind the Jacquard-loom was a system of punch cards and hooks. The cards were made very thick and had rectangular holes punched in them. The hooks and needles used in weaving were guided by these holes in the cardboard. When the hooks came into contact with the card they were held stationary unless it encountered one of the punched holes. Then the hook was able to pass through the hole with a needle inserting another thread, thus forming the desired pattern. Intricate patterns were achieved by having many cards arranged one after the other and/or used repeatedly.
Il telaio di Jacquard è anche riconosciuto come una primissima forma di un programma memorizzato :
If the impetus behind much of the development of calculating machines discussed so far had arisen from numerical computation, the motivation that led to the earliest form of 'stored program' was to come from a very different source: the textile industry. We have seen earlier that one of the fundamental aspects of computational systems is the concept of representing information and, although we have not done so explicitly, the application of this idea can be discerned in all of the artefacts that we have examined up to now: in the development of written representations for numeric values and the mechanical parallels that sprung from these. Thus, the alignment of pebbles on an abacus frame, the juxtaposition of moving scales on a slide-rule, and the configuration of cogged gears on the devices of Schickard, Pascal and Leibniz, are all examples of representational techniques that seek to simplify the complex processes underlying arithmetic tasks. There are, however, categories of information, and representations thereof, other than number upon which computational processes can be performed. The weaving technology developed by Joseph-Marie Jacquard in 1801 illustrates one example of such a category.
Charles Babbage ha anche adattato la procedura di memorizzazione di Jacquard al Motore analitico , la presenza o l'assenza di una buca ha comunicato un semplice comando on-off sulla macchina:
The Analytical Engine has many essential features found in the modern digital computer. It was programmable using punched cards, an idea borrowed from the Jacquard loom used for weaving complex patterns in textiles. The Engine had a 'Store' where numbers and intermediate results could be held, and a separate 'Mill' where the arithmetic processing was performed. It had an internal repertoire of the four arithmetical functions and could perform direct multiplication and division. It was also capable of functions for which we have modern names: conditional branching, looping (iteration), microprogramming, parallel processing, iteration, latching, polling, and pulse-shaping, amongst others, though Babbage nowhere used these terms. It had a variety of outputs including hardcopy printout, punched cards, graph plotting and the automatic production of stereotypes - trays of soft material into which results were impressed that could be used as molds for making printing plates.
I rami condizionali del motore analitico combinati con i loop meccanici e la procedura di memorizzazione ispirati a Jacquard sono sorprendentemente simili (concettualmente) al tuo esempio, specialmente se aggiungiamo Stampante del robot nel mix, per le parti
print "..."; .
Ovviamente i loop meccanici precedono il telaio di Jacquard, il primo dispositivo conosciuto che funziona in un loop fashion essendo il meccanismo di Antikythera (100 AC), e se guardiamo ancora oltre nella storia (e avventuriamo orribilmente fuori tema) , meridiane sono probabilmente i meccanismi più antichi realizzati dall'uomo, in cui è evidente la comprensione dei loop, seguendo naturalmente il pattern ripetuto del sole e le orbite di altri corpi stellari.
Tuttavia penso che nel contesto dell'informatica (e non del calcolo o altro), il motore analitico e l'algoritmo di calcolo dei numeri di Bernoulli di Ada possano essere accreditati per introdurre loop, condividendo almeno parte del credito con il telaio di Jacquard, avendo adattato direttamente il concetto da esso.