1. Home
  2. Explore
  3. Computer Science
  4. Language Design Principles

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Language Design Principles

Language Design, Notation, and Domain-Specific Languages

Choosing a Programming Language

The appropriate programming language depends on the task, not simply on the language’s general popularity or computational power.

A task such as searching a large dataset for volcanic eruptions above a certain magnitude could be implemented in many languages, including C, AWK, a shell language, or BASIC. However, the best choice depends on what matters most:

  • Programmer efficiency: How quickly and accurately can the programmer express the solution?

  • Machine efficiency: How quickly and economically does the resulting program execute?

  • Robustness: How well does the program handle malformed, unusually long, or unexpected input?

  • Notation: How naturally does the language express the concepts involved in the task?

  • Portability and maintainability: How easily can the program be moved, understood, modified, and preserved?

C Versus AWK for Data Processing

A small data-processing program written in C may require significant effort because the programmer must manage many low-level details:

  • Remembering library function interfaces and argument orders.

  • Handling input termination correctly.

  • Choosing the correct format specifiers for different data types.

  • Managing string tokenization.

  • Dealing explicitly with malformed or excessively long input.

  • Writing code for tasks that the language does not automate.

A comparable AWK program can often be written in seconds because AWK directly supports:

  • Line-oriented input processing.

  • Automatic splitting of records into fields.

  • Pattern matching.

  • Regular expressions.

  • Numeric and textual values.

  • Associative arrays.

  • Automatic iteration over input.

For a program that runs only once or a few times, execution speed is often irrelevant. A program that takes a fraction of a second to run does not benefit significantly from being optimized if the programmer spends twenty minutes writing it instead of two seconds.

For short-lived data-processing tasks, programmer efficiency can matter much more than machine efficiency.

Machine efficiency becomes crucial when a program:

  • Runs continuously.

  • Processes enormous quantities of data.

  • Serves millions of users.

  • Performs computationally intensive operations.

  • Has strict memory, latency, or energy constraints.

A search engine, for example, cannot reasonably be implemented in AWK merely because AWK is convenient for small text-processing jobs. Large-scale systems require languages and implementation techniques that provide much greater execution efficiency.

The central lesson is that language selection involves trade-offs. A language that is excellent for one domain may be inappropriate for another.


Programming Languages and the Tower of Babel

The large number of programming languages can be compared metaphorically with the biblical Tower of Babel. In the story, people who once shared a common language are given many different languages and become separated. Programming languages have likewise multiplied dramatically.

Even by the early 1960s, only a few years after the first stored-program computers, there were already many programming languages. Languages such as FORTRAN, LISP, SIMULA, and BASIC survived in various forms, while many others disappeared.

The growth in the number of languages reflects several factors:

  • Different machines have different capabilities.

  • Different communities have different needs.

  • Different domains require different notations.

  • Researchers explore alternative programming models.

  • New languages attempt to solve weaknesses in older ones.

  • Hardware improvements make previously impractical approaches feasible.

The existence of many languages is not necessarily a problem. A language becomes valuable when it provides a notation and set of abstractions that make an important class of tasks easier.


A Broad History of Programming Languages

The historical development of programming languages can be divided into broad, overlapping periods. The boundaries are approximate rather than strict.

Machine Code: The 1940s

Early computers were programmed directly in absolute machine code. Programmers entered binary instructions using:

  • Switches on a control panel.

  • Paper tape.

  • Other hardware-specific input mechanisms.

This required detailed knowledge of the machine’s instruction set, memory layout, and binary representation. Programs were difficult to write, difficult to inspect, and completely tied to a particular computer.

Assembly Languages: The 1950s

Assembly languages automated some of the clerical work involved in machine-code programming. An assembler could:

  • Translate symbolic operation names into machine opcodes.

  • Convert symbolic addresses into actual memory locations.

  • Handle machine-specific instruction formats.

  • Reduce the need to write raw bit patterns.

Assembly language remained closely connected to the hardware, but it made programming substantially more manageable.

High-Level Languages: The Late 1950s and 1960s

The development of high-level languages was one of the most important advances in software. These languages raised the level of discourse above individual machine architectures and allowed programmers to express solutions in terms closer to human problem-solving.

Examples included:

  • FORTRAN: Engineering and scientific computation.

  • COBOL: Business data processing.

  • BASIC: Teaching and introductory programming.

High-level languages provided two major benefits:

  1. Broader access to programming: A programmer no longer needed to master the assembly language of a specific machine.

  2. Portability: A program could be written once in a high-level language and translated for different machines.

This separation between the problem description and the hardware implementation was a major step toward portable software.

System Programming Languages: The 1970s

Early high-level languages were often designed for particular application domains. During the 1970s, languages were needed for lower-level but still highly complex software, including:

  • Compilers.

  • Assemblers.

  • Loaders.

  • Text editors.

  • Operating systems.

  • Other central computing components.

C became the major surviving language of this period. It provided enough abstraction to support large software systems while retaining close control over memory and machine-level behavior.

C’s importance came from its ability to implement core system software without requiring programmers to write everything in assembly language.

Structure and Object-Oriented Programming: The 1980s

As computers became more powerful, programs grew larger. Larger programs became harder to understand and maintain. Languages therefore began adding features intended to preserve intellectual control over program structure.

This development contributed to the rise of object-oriented programming, with C++ as a dominant example.

Object-oriented approaches helped programmers organize large systems through concepts such as:

  • Encapsulation.

  • Data structures associated with operations.

  • Reusable components.

  • Hierarchical relationships.

  • Modular program organization.

Strong Typing, Portability, and Interpreted Execution: The 1990s

Languages such as Java emphasized:

  • Strong typing.

  • Portability.

  • Execution through an interpreter or virtual machine.

  • Reduced dependence on a particular hardware architecture.

As hardware became faster and memory became more abundant, it became acceptable to sacrifice some raw execution speed in exchange for:

  • Easier programming.

  • Greater portability.

  • A more controlled execution environment.

  • Fewer machine-specific concerns.

The historical pattern shows that language design responds not only to programming needs but also to changes in hardware capability.

Later Developments

The direction of language design in later decades is less predictable. Modern mainstream languages attempt to support a wide range of tasks reasonably well, while newer languages continue to explore:

  • Safety.

  • Concurrency.

  • Portability.

  • Simpler syntax.

  • Better abstraction.

  • More reliable memory management.

  • Specialized domains.


Major Streams of Language Development

Programming languages can be grouped into several broad streams.

Mainstream General-Purpose Languages

General-purpose languages attempt to support many different categories of programming, including:

  • Application development.

  • Systems programming.

  • Web software.

  • Data processing.

  • User interfaces.

  • Scientific and commercial computation.

They are powerful and flexible, but they are often large and complex because they must cover a wide range of needs.

Scripting Languages

Scripting languages form a parallel stream of development. Early examples include SNOBOL and operating-system command languages. AWK emerged in the late 1970s, followed by languages such as Perl, Python, Ruby, PHP, and JavaScript.

JavaScript became especially important because of its role in web browsers.

Characteristics of Scripting Languages

A scripting language commonly has the following properties:

  • Text as a fundamental data type: Text manipulation is natural rather than an afterthought.

  • Regular expressions: Pattern matching is often built into the language or provided as a central library.

  • Associative arrays: Key-value data structures are commonly available.

  • Flexible typing: Values can often be used as strings or numbers without extensive type declarations.

  • Interpretation: Programs are frequently executed by an interpreter, trading some speed for flexibility and portability.

In a language such as C, text processing is possible but usually requires explicit manipulation of arrays, character pointers, and library functions. In scripting languages, text is treated as a central object of computation.

Type systems in scripting languages are usually less formal than those found in languages such as SML, OCaml, or Haskell. Type inference and strict compile-time guarantees may be reduced or absent because the language prioritizes convenience and rapid development.

Functional Programming Languages

Functional programming languages include LISP, Haskell, and OCaml. They have historically been less common in general commercial programming than mainstream imperative languages.

However, functional programming research has influenced nearly every major programming language. Ideas that originated or were extensively developed in functional languages include:

  • Recursion.

  • Garbage collection.

  • Type inference.

  • Functions as first-class values.

  • Higher-order functions.

  • Declarative programming techniques.

A programming concept does not need to dominate industry directly in order to influence mainstream practice. Functional languages have served as important laboratories for language design.

Domain-Specific Languages

A domain-specific language, or DSL, is designed for a relatively narrow area of activity rather than for general-purpose programming.

Examples include:

  • Regular expressions for pattern matching.

  • Shell languages for operating-system command composition.

  • AWK for structured text processing.

  • SQL for database querying.

  • R for statistics.

  • AMPL for mathematical optimization.

  • Document-preparation languages.

  • Languages for drawing diagrams or generating tables.

A DSL may not be Turing complete. That means it may not be capable of simulating every possible computation. This limitation can be beneficial because it allows the language to remain smaller, clearer, and more focused.

A DSL is still a language when it has:

  • A formal or rigorously defined grammar.

  • Defined meanings for its expressions.

  • Rules for valid composition.

  • A specific domain of interpretation.

A small language designed for one important task may be more useful than a large language designed to do everything.


Why Domain-Specific Languages Are Attractive

Creating a new general-purpose language comparable to C++ is extremely difficult. Such a language requires:

  • A large and consistent design.

  • A complete implementation.

  • Extensive libraries.

  • Documentation.

  • Tooling.

  • Performance engineering.

  • Compatibility management.

  • A large user community.

By contrast, a small DSL can be created by an individual or small team in a relatively short time. Its design can focus on one problem and provide notation that matches that problem closely.

A useful starting point for language design is therefore:

  1. Identify a recurring problem.

  2. Determine which concepts appear repeatedly in solutions.

  3. Design notation that expresses those concepts directly.

  4. Automate the repetitive work.

  5. Keep the language small enough to understand and maintain.

Examples include:

  • A pattern-matching language.

  • A document-formatting language.

  • A diagram-description language.

  • A statistical modeling language.

  • A database-query language.


Notation and How Languages Shape Thought

Notation is one of the most important aspects of language design. A suitable notation can make a problem feel simple, while a poor notation can make a simple task tedious and error-prone.

The idea that language influences thought is associated with Benjamin Whorf in the context of natural languages. In programming, this principle can be even more direct: artificial languages determine how programmers describe operations to computers and which abstractions are easy to express.

A language’s notation can:

  • Highlight important relationships.

  • Hide irrelevant implementation details.

  • Encourage certain ways of structuring a solution.

  • Make common operations concise.

  • Make unusual or dangerous operations difficult.

  • Influence the programmer’s mental model of the problem.

Alan Perlis expressed a related principle: a programming language should change the way programmers think about a problem. If a language offers no new or useful way of seeing the domain, creating it may not be worthwhile.

A successful language does more than provide new syntax; it provides a useful way of thinking.


AWK: A Language for Structured Text Processing

Origins and Purpose

AWK arose from experience with Unix shell programming. The shell was effective for composing commands but was not especially convenient for numerical processing or structured data manipulation.

AWK’s design combined three interests:

  • Regular expressions, associated particularly with Al Aho.

  • Database-style data processing, associated with Peter Weinberger.

  • A practical programming language for short programs, associated with Brian Kernighan.

The goal was to create a language for problems that seemed as though they should require only one or two lines of code.

Typical AWK tasks include:

  • Selecting records that meet a condition.

  • Transforming selected data.

  • Summarizing collections of records.

  • Generating reports.

  • Extracting particular fields from lines of text.


The Pattern–Action Model

The central notation of AWK is the pattern–action pair:

  • A pattern identifies records of interest.

  • An action specifies what to do when the pattern matches.

Conceptually, AWK repeatedly performs the following process:

  1. Read an input record.

  2. Test the record against each pattern.

  3. Execute the associated action for every matching pattern.

  4. Continue until all input has been processed.

A pattern can be:

  • A regular expression.

  • A numerical comparison.

  • A condition involving one or more fields.

  • A more complicated Boolean expression.

For example, a condition such as $3 > 6 selects records whose third field is greater than 666.

The pattern–action model appears in many other tools:

  • Grep: The pattern is a regular expression; the action is printing matching lines.

  • Sed: Patterns identify text locations; actions perform editing commands.

  • Lex: Patterns describe lexical forms; actions produce tokens or other results.

  • YACC: Grammar patterns and rules determine parser actions.

  • Functional pattern matching: Patterns determine which computation applies to a value.

The model is powerful because it corresponds to a common way of reasoning: “When this kind of thing appears, perform this operation.”


Automation in AWK

AWK automates repetitive operations that would otherwise require boilerplate code.

Its implicit structure can be understood as three nested loops:

  1. Iterate over input files.

  2. Iterate over lines within each file.

  3. Iterate over patterns and execute actions for matching lines.

The programmer does not normally write these loops explicitly.

AWK also automates:

  • Reading input.

  • Splitting input into records.

  • Splitting each record into fields.

  • Accessing fields by position.

  • Handling variables without explicit type declarations.

  • Performing operations according to whether values behave as numbers or strings.

  • Maintaining common built-in values and counters.

This automation allows the program to remain focused on the task rather than on the mechanics of processing input.

Flexible Variables

AWK variables can contain either strings or numbers. The programmer does not need to declare a fixed type or initialize every variable explicitly.

The language attempts to interpret a value appropriately:

  • As a number during arithmetic.

  • As text during string operations.

  • According to the context in which it is used.

This flexibility is particularly useful in data-processing scripts, where input often combines text and numeric fields.


Associative Arrays

An associative array stores values indexed by keys rather than by consecutive numerical positions. It is often called a map or dictionary in other languages.

For example, instead of storing values under indexes such as 111, 222, and 333, an associative array can store:

  • A total under the key “pizza.”

  • A total under the key “beer.”

  • A count under the key “geology.”

  • A result under a particular name or identifier.

Associative arrays are especially useful for:

  • Counting occurrences.

  • Grouping records.

  • Summing values by category.

  • Building symbol tables.

  • Representing sparse data.

  • Relating names to values.

Example: Summing Categories

Suppose each input record contains:

  • A category in the first field.

  • A cost in the second field.

The program can add the second field to the associative-array element corresponding to the first field. At the end, it can print the accumulated total for each category.

An action with no pattern is applied to every input line. Thus, the language automatically performs the repeated accumulation over the entire input.

The broader lesson is that associative arrays provide a general-purpose mechanism for handling aggregates of related data.

For many data-processing tasks, an associative array is the most directly useful data structure because it combines lookup, grouping, counting, and accumulation.


AWK and the Principle of Familiarity

AWK’s action language resembles C. This was a deliberate design choice: programmers already familiar with C could recognize much of the syntax immediately.

A useful language-design principle follows:

Build on familiar ideas when existing conventions are already effective.

A new language does not need to invent a completely unfamiliar syntax to be innovative. It can instead combine:

  • Familiar surface notation.

  • A specialized data model.

  • Automated control flow.

  • Domain-specific operations.

This combination reduces the learning barrier while still providing a new way to solve problems.


Lessons from AWK and Language Use

Useful Languages Will Be Used in Unexpected Ways

If a language is useful, users will apply it beyond the tasks its designers originally intended.

AWK was designed for one-line and two-line programs, but users have written:

  • Large AWK applications.

  • Programs thousands of lines long.

  • Programs that generate AWK code.

  • Symbol-table systems.

  • Teaching examples.

  • Unusual or deliberately obscure programs.

This is not necessarily a design failure. It demonstrates that users will extend a language when its abstractions are convenient.

However, a language may become awkward when it is used far beyond its intended scale. A tool optimized for concise data processing may not be the best choice for a very large software system.

Machine-Generated Input Is Different

Programs are often tested using input written by humans. Human-generated input tends to be:

  • Limited in volume.

  • Relatively structured.

  • Influenced by expectations about what the program can handle.

  • Less likely to contain extreme combinations.

Machine-generated input is different:

  • It can be extremely large.

  • It can be generated tirelessly.

  • It can contain deeply nested structures.

  • It can produce unusual names and combinations.

  • It can expose assumptions that human users rarely trigger.

Therefore, machine-generated input is an especially effective stress test.

An early C++ compiler illustrates this principle. It generated C source code containing:

  • Very deeply nested expressions.

  • Many levels of parentheses.

  • Unusually similar identifiers.

  • Structures that were difficult for human readers to understand.

Although such output was inscrutable to people, it was valuable for exposing weaknesses in C compilers.

Generated input tests the limits of a language implementation more aggressively than ordinary human-written input.

Real Use Reveals Design Mistakes

A language can seem coherent during design and still contain flaws that become obvious only after users adopt it.

Real users reveal:

  • Ambiguous features.

  • Missing operations.

  • Poor defaults.

  • Inconsistent syntax.

  • Unexpected interactions.

  • Performance problems.

  • Maintenance difficulties.

A language’s design continues to be tested after implementation because actual usage reveals requirements that designers could not fully predict.

Stability Versus Improvement

Language designers face a persistent tension:

  • Fixing mistakes and adding useful features improves the language.

  • Frequent changes make existing programs stop working.

  • Stability allows users to learn and maintain the language.

  • Growth can make a language larger, more complex, and less coherent.

A language that changes rapidly may frustrate users whose existing programs no longer compile or behave as expected. A language that never changes may become obsolete or fail to address important needs.

The design challenge is to improve the language without destroying its conceptual stability.

Avoiding Untried Ideas

A principle associated with Tony Hoare advises against placing untested ideas into a language. This does not mean that new ideas should never be explored. Rather, experimental concepts should ideally be tested independently before being made part of a widely used language.

A language feature can have long-term consequences because:

  • Syntax becomes difficult to remove.

  • Users build code around it.

  • Libraries depend on it.

  • Later features must remain compatible with it.

  • A flawed abstraction can affect the entire language.


AMPL: A Domain-Specific Language for Optimization

Linear Programming

AMPL is designed for describing mathematical optimization problems.

In a basic linear-programming problem, the goal is to choose values for variables that:

  1. Satisfy a collection of constraints.

  2. Minimize or maximize an objective function.

A general form is:

minimize or maximize f(x1,x2,…,xn)\text{minimize or maximize } f(x_1,x_2,\ldots,x_n)minimize or maximize f(x1​,x2​,…,xn​)

subject to constraints such as:

ai1x1+ai2x2+⋯+ainxn≤bia_{i1}x_1+a_{i2}x_2+\cdots+a_{in}x_n \leq b_iai1​x1​+ai2​x2​+⋯+ain​xn​≤bi​

When both the objective and constraints are linear, the problem is a linear program.

Related optimization classes include:

  • Integer programming: Some or all variables must have integer values.

  • Quadratic programming: The objective or constraints contain quadratic expressions.

  • Nonlinear programming: More general nonlinear relationships are allowed.

  • Stochastic programming: The model incorporates uncertainty or random outcomes.

Before modeling languages such as AMPL, optimization problems were often specified by:

  • A matrix generator that produced a large coefficient matrix.

  • GAMS, an older and less convenient language modeled on FORTRAN.

These approaches made it difficult to express the mathematical structure of a problem clearly.


AMPL’s Algebraic Notation

AMPL allows a person familiar with mathematics to describe an optimization model using notation close to ordinary algebra.

An AMPL model generally contains:

  • Sets: Collections such as foods or nutrients.

  • Parameters: Known values such as prices or nutrient requirements.

  • Indexed parameters: Tables containing values associated with combinations of indexes.

  • Variables: Quantities to be determined.

  • Objectives: Quantities to minimize or maximize.

  • Constraints: Conditions that must be satisfied.

The model is separate from the data. This means one model can be reused for many specific instances of a problem.

For example, one diet model can be applied to:

  • Feeding university students.

  • Planning meals for hospitals.

  • Supplying food in institutions.

  • Designing a restaurant menu.

  • Managing large-scale food procurement.

Only the data changes; the mathematical structure remains the same.


The Diet Problem

The classic diet problem asks how to feed a population at minimum cost while satisfying nutritional requirements.

The model may contain:

  • A set of available foods.

  • A set of required nutrients.

  • The amount of each nutrient in each food.

  • The cost of each food package.

  • Minimum nutrient requirements.

  • Maximum nutrient limits.

  • The number of packages of each food to purchase.

The objective can be represented as:

minimize ∑j∈foodscjxj\text{minimize } \sum_{j \in \text{foods}} c_j x_jminimize ∑j∈foods​cj​xj​

where:

  • cjc_jcj​ is the cost of one package of food jjj.

  • xjx_jxj​ is the number of packages of food jjj purchased.

For each nutrient iii, the model can impose a lower bound:

∑j∈foodsaijxj≥Li\sum_{j \in \text{foods}} a_{ij}x_j \geq L_i∑j∈foods​aij​xj​≥Li​

and an upper bound:

∑j∈foodsaijxj≤Ui\sum_{j \in \text{foods}} a_{ij}x_j \leq U_i∑j∈foods​aij​xj​≤Ui​

where:

  • aija_{ij}aij​ is the amount of nutrient iii in food jjj.

  • LiL_iLi​ is the minimum acceptable amount of nutrient iii.

  • UiU_iUi​ is the maximum acceptable amount.

The language expresses these relationships through sets and indexing rather than requiring the programmer to construct every matrix element manually.


Declarative Modeling

AMPL’s core modeling language is declarative. It states:

  • What the variables represent.

  • What the objective is.

  • Which constraints must hold.

  • How values are related.

It does not specify the algorithm used to solve the problem.

The model is translated into a large, usually sparse matrix and passed to an optimization solver. The solver computes a solution and sends the results back in terms of the original model.

This separation is valuable because:

  • The same model can use different solvers.

  • The model remains close to the mathematics.

  • The optimization algorithm can improve independently.

  • The user does not need to implement simplex, branch-and-bound, or other algorithms.

  • Results can be displayed using the original names and relationships.

Industrial linear-programming models may contain thousands of rows and columns while having a density far below 1%1\%1%. Such matrices are large but sparse, meaning that most possible coefficient positions contain zero.


AMPL’s Three Language Components

AMPL effectively contains several related languages.

Modeling Language

The modeling language describes:

  • Sets.

  • Parameters.

  • Variables.

  • Objectives.

  • Constraints.

  • Indexing relationships.

Data Specification Language

The data language supplies the values for a particular problem instance. It may define:

  • Food names.

  • Nutrient names.

  • Prices.

  • Nutrient quantities.

  • Requirements.

  • Upper and lower limits.

The data can often be entered in table-like forms.

Command Language

A command or shell-level language controls execution. It can specify:

  • Which model to load.

  • Which data to load.

  • Which solver to use.

  • Which calculations to perform.

  • Which results to display.

  • How results should be formatted.

This separation between model, data, and execution makes the overall system flexible.


Integer Constraints

A continuous linear-programming model may produce fractional solutions. For example, an optimal result might require purchasing 462346\frac{2}{3}4632​ packages of a food, which is not practical if food can only be purchased in whole packages.

The model can be changed to an integer program by declaring the relevant variables to be integers. Conceptually, this requires only a small modification to the model.

The underlying mathematical problem becomes substantially harder. Integer linear programming is computationally difficult and is associated with NP-complete or NP-hard computational challenges, depending on the precise formulation and decision version.

The important language-design benefit is that the model changes only slightly while the solver handles the much more difficult computational method.

A good modeling language lets users change the mathematical problem without rewriting the entire implementation.


AMPL’s Evolution and Conceptual Integrity

AMPL began as a purely declarative language: users described a model and asked a solver to process it.

Users later needed more computational control, so features associated with general-purpose programming were added, including:

  • Loops.

  • Conditional statements.

  • Function calls.

  • Additional control mechanisms.

These additions made AMPL more expressive, but they also made its syntax less uniform.

This illustrates the principle of conceptual integrity: a language is easier to understand when its features fit together according to a small number of consistent ideas. Adding features one at a time can gradually weaken that consistency.

A language may begin with a clean design and later become irregular because:

  • New requirements emerge.

  • Existing users demand more power.

  • Backward compatibility prevents redesign.

  • Features are added by different designers.

  • The original domain expands.


Document-Preparation Languages

EQN and Mathematical Typesetting

EQN was designed to express mathematical formulas for typesetting systems that did not originally provide good support for mathematics.

Its central insight was that mathematical notation is often spoken aloud in a structured way. For example, a mathematician might say:

  • “x sub i equals pi.”

  • “a over b.”

  • “sum from i equals one to n.”

This spoken mathematical structure can be translated into a textual language that produces formatted mathematical expressions.

EQN therefore used a notation based on the way mathematics is verbally described rather than on the detailed commands needed to position symbols manually.

Benefits of EQN’s Notation

EQN’s notation was simpler than later, more powerful systems such as TeX because it did less. That simplicity made it accessible:

  • Typists without mathematical backgrounds could learn it quickly.

  • Standard mathematical documents could be produced after limited training.

  • Users could gradually teach themselves more complex constructions.

  • The notation focused on mathematical relationships rather than formatting mechanics.

This demonstrates that a language can be successful by offering the right level of abstraction, even if a more powerful language exists.

Pipelines and Resource Constraints

EQN was developed when computers had extremely limited memory. Early Unix machines had only about 646464 kilobytes of memory.

Because individual programs had to remain small, it was impractical to place all document-processing features into one large program. Unix pipelines provided an alternative:

  1. One program processed mathematical notation.

  2. Its output was passed to another program.

  3. The second program processed ordinary text.

  4. Additional tools handled tables or other document features.

This modular structure allowed each program to have a focused purpose and its own suitable notation.

Resource limitations therefore encouraged an architecture that later proved powerful and flexible.

Influence on TeX

TeX’s mathematical typesetting system was influenced by the same broad idea: mathematical expressions should be entered in a notation that is reasonably natural to write.

TeX expanded the approach substantially, providing:

  • More powerful constructions.

  • More robust processing.

  • Higher-quality output.

  • Greater control over layout and typography.

The underlying principle of expressing mathematical structure textually remained similar.


Pic and Textual Drawing

Pic was designed to describe line drawings using text. It could create diagrams such as:

  • Flowcharts.

  • Organization charts.

  • Simple technical diagrams.

  • Block diagrams.

  • Curves and sampled waveforms.

Instead of drawing with a mouse, the user described the intended objects and relationships in a textual language. Pic then translated the description into commands for a typesetting system such as Troff.

A simple diagram could be described in terms such as:

  1. Input.

  2. Process.

  3. Output.

The system handled much of the positioning and sizing automatically.

Advantages of Textual Descriptions

Textual descriptions of diagrams offer several benefits:

  • They are reproducible.

  • They can be stored with source code.

  • They can be modified systematically.

  • Similar diagrams can be generated automatically.

  • Relationships between elements can be expressed directly.

  • Changes can be made without redrawing the entire figure.

A textual representation is particularly powerful when a diagram is derived from another diagram.

For example, a waveform can be described once. A second version that marks every fourth sampling point can be generated by adding a condition to the description. If the waveform’s frequency or shape changes, both versions can be regenerated easily.

An artistically drawn version would require manual editing and careful alignment. A textual description preserves the underlying structure, so related figures remain consistent.

Generated Graphics

Graphs are a specialized class of pictures. This led to the idea of creating a graph-description language that would:

  1. Read numerical data.

  2. Convert the data into Pic instructions.

  3. Pass the Pic output to Troff.

  4. Produce a formatted graph.

This is an example of machine-generated input being used productively. One language can generate programs or descriptions for another language.

The technique can be extended recursively: a tool can generate input for a drawing language, which generates input for a typesetting language.


Why Languages Succeed

A language’s success depends on more than technical elegance. Several factors interact.

1. Useful Notation

The most important factor is whether the notation makes an important task easier.

A successful language:

  • Matches the way users think about the problem.

  • Expresses common operations directly.

  • Eliminates repetitive boilerplate.

  • Makes simple tasks remain simple.

  • Provides abstractions that are useful at the appropriate scale.

A language with beautiful implementation technology but poor notation may fail because users cannot express their work conveniently.

2. Cultural Compatibility

A language is culturally compatible when it resembles the conventions users already know.

Languages based on C syntax benefited from familiarity. Examples include:

  • C++.

  • Java.

  • JavaScript.

  • AWK.

  • Perl, to some extent.

These languages changed or extended C-like syntax but retained enough familiar structure that existing programmers could approach them without starting from nothing.

Cultural compatibility does not require copying another language exactly. It means that the new language fits users’ expectations sufficiently well to reduce the initial learning barrier.

3. Environmental Compatibility

A language must also fit into the surrounding technical environment.

Environmental compatibility may include:

  • Operating-system support.

  • Existing libraries.

  • Compatible data formats.

  • Familiar development tools.

  • Existing source-code conventions.

  • Ability to interoperate with established languages.

  • Compatibility with an installed hardware platform.

C++ benefited from fitting naturally into the C and Unix ecosystem:

  • C and C++ source code looked related.

  • C libraries could be used.

  • Existing Unix systems supported it.

  • Organizations did not need to abandon their existing infrastructure.

By contrast, a language may fail if using it requires users to adopt an entirely new ecosystem, even if the language itself is technically strong.

4. Open Source and Community Investment

Open-source availability can help a language grow because:

  • Users can obtain it without paying licensing fees.

  • Developers can inspect and modify the implementation.

  • Contributors can improve the language and its tools.

  • Organizations can invest in the ecosystem with less risk.

  • The language is less dependent on a single vendor.

Proprietary languages can still succeed, especially when they solve a valuable specialized problem. However, they may face difficulty if a free and well-supported alternative appears.

A company built around proprietary software may instead consider:

  • Consulting services.

  • Paid extensions.

  • Enterprise support.

  • Freemium models.

  • Free basic functionality with paid advanced features.

Consulting can sustain an open-source project, but it is harder to scale because consulting is labor-intensive and resembles a retail service. Software licensing is more like a wholesale operation: one product can be sold repeatedly without requiring proportional increases in staff.

5. Competition

A language’s competitors may be weak, poorly timed, or unsuitable for the same environment.

C succeeded partly because competing options were not strong replacements for system programming:

  • Pascal had useful features but was not well suited to low-level systems work.

  • BCPL was elegant but lacked a type system and did not match machine architectures as effectively.

JavaScript outperformed Java in browser scripting partly because it was easier to distribute source code to browsers. Java generally required compiled code and a more elaborate execution model, while JavaScript fit the browser environment more directly.

6. Timing and Luck

Technical quality is not the only determinant of success. A language may benefit from being associated with an important technological wave.

C gained repeated advantages from appearing at the right times:

  • Minicomputers.

  • Workstations.

  • Personal computers.

  • Embedded systems.

Objective-C experienced a similar element of luck. It was adopted by NeXT, later became important in Apple’s software ecosystem, and was used for Mac and iOS development. Its success depended partly on being in the right place at the right time.

A language may therefore succeed because it combines:

  • Adequate technical quality.

  • A useful domain.

  • A compatible ecosystem.

  • Strong distribution.

  • Favorable historical timing.


Why Languages Fail or Fail to Thrive

Disappearing Domains

A language may be technically successful but later lose its ecological niche.

EQN, Pic, Grap, and related Troff tools were useful when Troff-based document production was common. As TeX, LaTeX, and other systems became dominant, the environment that supported those tools shrank.

The tools did not necessarily become useless overnight. Rather:

  • Fewer people needed them.

  • Their surrounding infrastructure became less common.

  • Alternative systems absorbed some of their ideas.

  • Their user communities declined.

Many languages do not disappear completely; they simply fail to thrive.

Excessive Size and Complexity

Languages may fail because they become too:

  • Large.

  • Complicated.

  • Slow to implement.

  • Difficult to learn.

  • Late to market.

  • Inconsistent.

Algol-68 and PL/1 are examples of languages often associated with excessive ambition and complexity.

C++ illustrates a related risk. Its large installed base makes disappearance unlikely, but its complexity raises questions about whether it has become too difficult for ordinary programmers to master fully.

Being Too Late

A language can miss its opportunity by arriving after the surrounding ecosystem has moved on.

Perl 6 illustrates the danger of excessive delay. If a promised successor takes too long to appear, users may adopt other tools, and the original language may lose momentum.

Timing matters because languages compete not only on features but also on:

  • Availability.

  • Tool support.

  • Community size.

  • Existing code.

  • Educational adoption.

  • Industrial investment.

Excessive Ideology

A language may embody a design philosophy so strongly that it becomes difficult for many users to adopt.

Some functional languages require highly abstract or mathematically rigorous ways of thinking. Such approaches can be powerful, but they may not match how all programmers naturally reason about problems.

A language can therefore fail to spread widely if its core ideology demands too much conceptual change without providing enough practical benefit for its intended audience.

Loss of an Embedded Base

Even a flawed or overly complex language may survive because many existing programs depend on it.

An established codebase creates inertia:

  • Rewriting software is expensive.

  • Existing programmers have accumulated expertise.

  • Tools and libraries depend on the language.

  • Organizations are reluctant to risk migration.

  • New software may need to interoperate with old software.

This explains why languages can remain important even after better-designed alternatives appear.


General Principles for Language Designers

The examples of AWK, AMPL, EQN, Pic, C, C++, JavaScript, and other languages support several broad principles.

Match the Language to the Task

A general-purpose language is not automatically the best tool. A small DSL may be superior when:

  • The domain is narrow.

  • The same structures recur frequently.

  • Users have specialized knowledge.

  • The language can automate repetitive processing.

  • The notation can closely match the domain.

Automate Repetition

If the language knows that every input file should be read line by line, users should not have to write those loops repeatedly.

Automation should target:

  • Boilerplate control flow.

  • Common data transformations.

  • Routine input processing.

  • Standard conversions.

  • Repeated formatting.

  • Domain-specific calculations.

Preserve Conceptual Integrity

A language should have a coherent set of central ideas. Adding features should be done cautiously because each addition can:

  • Increase complexity.

  • Create irregular syntax.

  • Interact unexpectedly with existing features.

  • Make the language harder to teach.

  • Weaken the original design.

Prefer Small, Testable Innovations

New concepts should ideally be tested before being built into a major language. Small experimental languages and DSLs provide a safer environment for exploring:

  • New notation.

  • New type systems.

  • New control structures.

  • New abstraction mechanisms.

  • New programming models.

Expect Users to Extend the Language

Designers should assume that users will:

  • Apply the language to unanticipated tasks.

  • Generate programs in the language.

  • Combine it with other languages.

  • Use it at larger scales than intended.

  • Discover edge cases.

  • Demand new capabilities.

A language should be designed with enough flexibility to accommodate useful extension without losing its central identity.


Final Perspective

There remains substantial room for new programming languages. The most promising opportunities often lie not in replacing a massive general-purpose language but in creating a small language that solves a specific problem elegantly.

A practical strategy is:

  1. Choose a domain where people repeatedly perform similar tasks.

  2. Identify the concepts that dominate those tasks.

  3. Design notation that reflects those concepts.

  4. Automate routine work.

  5. Build on familiar cultural and technical conventions.

  6. Keep the language small enough to understand.

  7. Test it with real users and machine-generated input.

  8. Preserve stability while adding carefully chosen improvements.

The central lesson is that language design succeeds when the language makes an important problem easier to express and easier to think about. Small, focused languages such as regular expressions, AWK, AMPL, EQN, and Pic demonstrate that a carefully chosen notation can have a significant practical effect without attempting to become the next enormous general-purpose language.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent