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 assembly, script and/or languages:

    Had every Athenian citizen been a Socrates, every Athenian assembly would still have been a mob.
    James Madison (1751–1836)

    I long to create something
    that can’t be used to keep us passive:
    I want to write
    a script about plumbing, how every pipe
    is joined
    to every other.
    Adrienne Rich (b. 1929)

    It is time for dead languages to be quiet.
    Natalie Clifford Barney (1876–1972)