Spaghetti Code - Assembly and Script Languages

Assembly and Script Languages

When using the many forms of assembly language (and also the underlying machine code) the danger of writing spaghetti code is especially great. This is because they are low-level programming languages where equivalents for structured control flow statements such as for loops and while loops exist, but are often poorly understood by inexperienced programmers. Many scripting languages have the same deficiencies: this applies to the batch scripting language of DOS and DCL on VMS.

Nonetheless, adopting the same discipline as in structured programming can greatly improve the readability and maintainability of such code. This may take the form of conventions limiting the use of goto to correspond to the standard structures, or use of a set of assembler macros for if and loop constructs. Most assembly languages also provide a function stack, and function call mechanisms which can be used to gain the advantages of procedural programming. Macros can again be used to support a standardized form of parameter passing, to avoid ad hoc global variables and the action at a distance anti-pattern.

Programs written in higher-level languages with high-level constructs such as for loops (as in the second example above) are often compiled into assembly or machine code. When this process occurs, the high-level constructs are translated into low-level "spaghetti code" which may resemble the first example above in terms of control flow. But because compilers must be faithful to high-level constructs in the source code, the problems that plague relatively unstructured languages like BASIC do not haunt higher-level languages. It does, however, mean that debugging even mildly optimized code with a source-level debugger can be surprisingly confusing.

Read more about this topic:  Spaghetti Code

Famous quotes containing the words languages, assembly and/or script:

    Science and technology multiply around us. To an increasing extent they dictate the languages in which we speak and think. Either we use those languages, or we remain mute.
    —J.G. (James Graham)

    Our assembly being now formed not by ourselves but by the goodwill and sprightly imagination of our readers, we have nothing to do but to draw up the curtain ... and to discover our chief personage on the stage.
    Sarah Fielding (1710–1768)

    Genghis Khan, in his usual jodhpurs accessorized with whip, straddled a canvas chair and gloated upon the fairyland he had built. Journalists, photographers, secretaries, sycophants, script girls, and set dressers milled and stirred around him, activity ... irresistibly reminiscent of the movement of maggots upon rotting meat.
    Angela Carter (1940–1992)