[go: nahoru, domu]

Jump to content

Non-structured programming: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Clarified opening definition: the key definition of structured versus unstructured is structured control flow, not procedures or objects. Added citation.
change paradigms template to navbox (see Template talk:Programming paradigms#too long)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''Non-structured programming''' is the historically earliest [[programming paradigm]] capable of creating [[Turing-complete]] algorithms{{Citation needed|reason=The [[lambda calculus]] is as old as Turing machines themselves.|date=October 2019}}. It is often contrasted with the [[structured programming]] paradigm, in particular with the use of unstructured control flow using [[goto]] statements or equivalent. The distinction was particularly stressed by the publication of the influential "[[Go To Statement Considered Harmful]]" open letter in 1968 by Dutch computer scientist [[Edsger W. Dijkstra]], who coined the term "structured programming".{{sfn|Dijkstra|1968|ps=, "The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress. ... The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program."}}
{{Programming paradigms}}
'''Non-structured programming''' is the historically earliest [[programming paradigm]] capable of creating [[Turing-complete]] algorithms. It is often contrasted with the [[structured programming]] paradigm, in particular with unstructured control flow using goto statements or equivalent. The distinction was particularly stressed by the publication of the influential "[[Go To Statement Considered Harmful]]" open letter in 1968 by Dutch computer scientist [[Edsger W. Dijkstra]], who coined the term "structured programming".{{sfn|Dijkstra|1968|ps=, "The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress. ... The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program."}}


Unstructured programming has been heavily criticized for producing hardly readable [[spaghetti code|("spaghetti") code]].
Unstructured programming has been heavily criticized for producing hardly-readable [[spaghetti code|("spaghetti") code]] and is sometimes considered a bad approach for creating major projects. However, it has been praised for the freedom it offers to programmers and has been compared to how [[Wolfgang Amadeus Mozart|Mozart]] wrote music.<ref>[http://eric.ed.gov/ERICWebPortal/custom/portlets/recordDetails/detailmini.jsp?_nfpb=true&_&ERICExtSearch_SearchValue_0=ED280737&ERICExtSearch_SearchType_0=no&accno=ED280737 William W. Cobern. A positive albeit ambiguous case for BASIC programming in secondary science teaching.]</ref>


There are both high- and low-level [[programming language]]s that use non-structured programming. Some languages commonly cited as being non-structured include [[JOSS]], [[FOCAL (programming language)|FOCAL]], [[TELCOMP]], [[assembly language]]s, [[MS-DOS]] [[batch file]]s, and early versions of [[BASIC]], [[Fortran]], [[COBOL]], and [[MUMPS]].
There are both high- and low-level [[programming language]]s that use non-structured programming. Some languages commonly cited as being non-structured include [[JOSS]], [[FOCAL (programming language)|FOCAL]], [[TELCOMP]], [[assembly language]]s, [[MS-DOS]] [[batch file]]s, and early versions of [[BASIC]], [[Fortran]], [[COBOL]], and [[MUMPS]].
Line 9: Line 8:


=== Basic concepts ===
=== Basic concepts ===
A program in a non-structured language usually consists of sequentially ordered commands, or statements, usually one in each line. The lines are usually numbered or may have labels: this allows the flow of execution to jump to any line in the program.
A program in a non-structured language uses unstructured jumps to labels or instruction addresses. The lines are usually numbered or may have labels: this allows the flow of execution to jump to any line in the program. This is in contrast to [[structured programming]] which uses sequential constructs of statements, selection (if/then/else) and repetition (while and for).

Non-structured programming introduces basic [[control flow]] concepts such as loops, branches and jumps. Although there is no concept of [[Subroutine|procedures]] in the non-structured paradigm{{Citation needed|date=January 2010}}<!-- totally inconsistent with the rest of the sentence -->, subroutines are allowed. Unlike a procedure, a subroutine may have several entry and exit points, and a direct jump into or out of subroutine is (theoretically) allowed. This flexibility allows realization of [[coroutine]]s.

There is no concept of locally [[Scope (computer science)|scoped]] variables in non-structured programming (although for assembly programs, [[general purpose registers]] may serve the same purpose after saving on entry), but labels and variables can have a limited area of effect (for example, a group of lines). This means there is no (automatic) context refresh when calling a subroutine, so all variables might retain their values from the previous call. This makes general [[Recursion (computer science)|recursion]] difficult, but some cases of recursion—where no subroutine state values are needed after the recursive call—are possible if variables dedicated to the recursive subroutine are explicitly cleared (or re-initialized to their original value) on entry to the subroutine. The depth of nesting also may be limited to one or two levels.

=== Data types ===
Non-structured languages allow only basic data types, such as numbers, strings and arrays {{Citation needed|reason= January 2010|date=January 2010}} (numbered sets of variables of the same type). The introduction of arrays into non-structured languages was a notable step forward, making stream data processing possible despite the lack of structured data types{{Citation needed|reason= January 2010|date=January 2010}}<!-- Please explain what restricted arrays from non structured programming if you can ??? -->.


==References==
==References==
Line 22: Line 14:


== Further reading ==
== Further reading ==
*{{cite journal|last=Cobb|first=Gary W.|year=1978|title=A measurement of structure for unstructured programming languages|journal=[[Association for Computing Machinery|ACM]] [[SIGSOFT]] Software Engineering Notes|volume=3|issue=5|pages=140–147|issn=0163-5948|doi=10.1145/953579.811114}}
*{{cite journal|last=Cobb|first=Gary W.|year=1978|title=A measurement of structure for unstructured programming languages|journal=ACM SIGSOFT Software Engineering Notes|volume=3|issue=5|pages=140–147|issn=0163-5948|doi=10.1145/953579.811114|doi-access=free}}


==External links==
==External links==
{{Wikibooks|Computer Programming|Control}}
{{Wikibooks|Computer Programming|Control}}
* [http://code.google.com/p/bpstruct/ BPStruct] - A tool to structure concurrent systems (programs, process models)
* [http://code.google.com/p/bpstruct/ BPStruct] - A tool to structure concurrent systems (programs, process models)

{{Programming paradigms navbox}}


[[Category:Programming paradigms]]
[[Category:Programming paradigms]]

Latest revision as of 23:04, 1 February 2024

Non-structured programming is the historically earliest programming paradigm capable of creating Turing-complete algorithms[citation needed]. It is often contrasted with the structured programming paradigm, in particular with the use of unstructured control flow using goto statements or equivalent. The distinction was particularly stressed by the publication of the influential "Go To Statement Considered Harmful" open letter in 1968 by Dutch computer scientist Edsger W. Dijkstra, who coined the term "structured programming".[1]

Unstructured programming has been heavily criticized for producing hardly readable ("spaghetti") code.

There are both high- and low-level programming languages that use non-structured programming. Some languages commonly cited as being non-structured include JOSS, FOCAL, TELCOMP, assembly languages, MS-DOS batch files, and early versions of BASIC, Fortran, COBOL, and MUMPS.

Features and typical concepts[edit]

Basic concepts[edit]

A program in a non-structured language uses unstructured jumps to labels or instruction addresses. The lines are usually numbered or may have labels: this allows the flow of execution to jump to any line in the program. This is in contrast to structured programming which uses sequential constructs of statements, selection (if/then/else) and repetition (while and for).

References[edit]

  1. ^ Dijkstra 1968, "The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress. ... The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program."

Further reading[edit]

  • Cobb, Gary W. (1978). "A measurement of structure for unstructured programming languages". ACM SIGSOFT Software Engineering Notes. 3 (5): 140–147. doi:10.1145/953579.811114. ISSN 0163-5948.

External links[edit]

  • BPStruct - A tool to structure concurrent systems (programs, process models)