You are on page 1of 7

Influences on Language Design

 There are several factors influence the basic design of programming languages. The most
important of these are computer architecture and programming design methodologies.

Computer Architecture

 The fundamental design of languages has been greatly influenced by computer architecture.
design.
 Most of the popular languages of the past 50 years have been designed around the prevalent
computer architecture, called the von Neumann architecture, after one of its originators,
John von Neumann (pronounced “vonNoyman”).
 These languages are called imperative languages.
 In a von Neumann computer, both data and programs are stored in the same memory.
 The central processing unit (CPU), which executes instructions, is separate from the memory.
 Therefore, instructions and data must be transmitted, or piped, from memory to the CPU.
 Results of operations in the CPU must be moved back to memory.
 The overall structure of a von Neumann computer is shown in Figure 1.1.

 Because of the von Neumann architecture, the central features of imperative


languages are variables, which model the memory cells; assignment statements,
which are based on the piping operation; and the iterative form of repetition, which
is the most efficient way to implement repetition on this architecture.
 Operands in expressions are piped from memory to the CPU, and the result of
evaluating the expression is piped back to the memory cell represented by the left side
of the assignment.
 The execution of a machine code program on a von Neumann architecture computer
occurs in a process called the fetch-execute cycle.
 Programs reside in memory but are executed in the CPU.
 Each instruction to be executed must be moved from memory to the processor.
 \
 The address of the next instruction to be executed is maintained in a register called
the program counter.

The fetch-execute cycle can be simply described by the following algorithm:

initialize the program counter


repeat forever
fetch the instruction pointed to by the program counter
increment the program counter to point at the next instruction
decode the instruction
execute the instruction
end repeat

 The “decode the instruction” step in the algorithm means the instruction is examined to
determine what action it specifies.
 Program execution terminates when a stop instruction is encountered
 Control transfers from the operating system to a user program for its execution and then back to
the operating system when the user program execution is complete.

Functional Languages:

 There's another type of language called functional languages, where the main way of doing
things is by applying functions to inputs.

 In functional languages, you don't use variables like you do in imperative languages, and you
don't need to give the computer step-by-step instructions.

 Some computer scientists think functional languages are great because they have benefits
like simplicity and clarity.

 However, because current computers are built on the von Neumann architecture, which
is better suited for imperative languages; functional languages aren't as efficient on them.

 Even if functional languages were as efficient as imperative ones, some people might still
prefer imperative languages because they feel more natural to use.
Programming Design Methodologies

1. Evolution of Software Development Methodologies:

 In the late 1960s and early 1970s, there was a big shift in how people thought about creating
software.

 This was partly because computers became cheaper, so the biggest cost was no longer
buying the hardware, but paying programmers to write the software.

 Also, the problems computers were solving became bigger and more complicated, like
controlling entire factories or managing worldwide airline reservations.

2. Top-Down Design and Stepwise Refinement:

 These were new ways of planning and organizing how software was built.

 Instead of just writing code as they went along, programmers started with a big picture plan
and then broke it down into smaller, more manageable parts.

 This made it easier to work on complex projects and find and fix problems.

3. Data-Oriented Program Design:

 In the late 1970s, a new approach called data-oriented design became popular.

 This method focused more on organizing and managing the data that programs use, rather
than just the steps they follow.

 It emphasized creating abstract data types, which are like templates for storing and working
with different kinds of information.

 The first language to provide even limited support for data abstraction was SIMULA 67

4. Object-Oriented Design:

 This is an even newer way of thinking about software, which started in the early 1980s.

 Object-oriented design builds on data-oriented design, but also adds concepts like
inheritance and dynamic method binding.

 Inheritance allows programmers to reuse existing code more easily, which can make
development faster and more efficient.
 Object-oriented programming developed along with a language that supported its concepts:
Smalltalk (Goldberg and Robson, 1989).

 Smalltalk never became as widely used as many other languages, support for object-oriented
programming is now part of most popular imperative languages, including Ada 95 (ARM,
1995), Java, C++, and C#.

5. Language Support:

 As these new methodologies emerged, programming languages had to evolve to support


them.

 Object-oriented concepts became especially popular and are now included in many widely-
used programming languages like Java, C++, and Python.

 Even functional and logic programming languages have adopted object-oriented features.

6. Procedure-Oriented Programming:

 This is a simpler approach to programming where the focus is more on the sequence of
steps to be followed rather than on the data being processed.

 While data-oriented methods are now more common, procedure-oriented programming hasn't
disappeared.

Finally, the way we create software has evolved over time, with new methodologies and
programming paradigms emerging to tackle increasingly complex problems. This evolution has
led to the development of new language features and constructs to support these methodologies.

Language Categories

Language Categories: Programming languages are often grouped into four main categories:
imperative, functional, logic, and object-oriented.

1. Object-Oriented Languages and Imperative Languages: Languages that support object-


oriented programming (like Java and C++) are typically considered extensions of imperative
languages rather than forming a separate category. Although object-oriented programming is
different from the procedural style used in imperative languages, the changes needed to support it are
not extensive. For example, the basic syntax (like expressions, assignment statements, and control
statements) in C and Java are quite similar, but the features like arrays and subprograms can be
different.

3. Visual Languages: Visual languages, like those in the .NET framework, are a subset of
imperative languages. These languages allow developers to create code segments visually, often
through drag-and-drop interfaces. They're sometimes referred to as fourth-generation languages, and
they're commonly used for quickly building graphical user interfaces for programs.

4. Scripting Languages: Scripting languages (like Perl, JavaScript, and Ruby) are also treated
as separate category. However, these languages are essentially imperative languages, despite their
focus on partial or full interpretation rather than compilation.

5. Logic Programming Languages:

 Logic programming languages, like Prolog, operate differently from imperative and
functional languages.
 In imperative languages, programmers specify the exact steps an algorithm should take,
while in logic programming languages, rules are specified without a particular order,
and the system decides how to execute them to achieve the desired result.

6. Markup/Programming Hybrid Languages:

 Markup languages are not programming languages.


 For instance, HTML, the most widely used markup language, is used to specify the layout of
information in Web documents.
 However, some programming capability has crept into some extensions to HTML and XML.
Among these are the Java Server Pages Standard Tag Library ( JSTL) and eXtensible
Stylesheet Language Transformations (XSLT).
 These languages, like Java Server Pages (JSP) and XML, mix markup languages (like
HTML) with programming capabilities.
 However, they're not complete programming languages like those in the other categories
mentioned.

7.Special-Purpose Languages:

 There are many languages designed for specific tasks, like generating business reports or
instructing machine tools.
 These range from Report Program Generator (RPG), which is used to produce business
reports; to Automatically Programmed Tools (APT), which is used for instructing
programmable machine tools; to General Purpose Simulation System(GPSS), which is used
for systems simulation.

Language Design Trade-Offs

1. Conflicting Criteria in Language Design: When designing programming languages, there are
many factors to consider, but often these factors conflict with each other. For example, two
important criteria are reliability (how trustworthy the code is) and execution cost (how quickly the
code runs). There may be conflicts between these requirements.

 Example with Java and C: Java, for instance, requires that all references to array
elements be checked to make sure they're within legal ranges. This makes Java programs
more reliable because it catches errors, but it also makes them slower to execute compared
to similar programs written in C, which doesn't have this requirement.
 This requirement in Java adds to the reliability of Java programs because it catches errors
like accessing out-of-bounds array elements, preventing unexpected behavior or crashes at
runtime. However, it also adds to the cost of execution because Java needs to perform these
checks every time an array element is accessed, potentially slowing down the program. So,
Java prioritizes reliability over execution efficiency.

public class Main {


public static void main(String[] args) {
// Creating an array with 5 elements
int[] numbers = {1, 2, 3, 4, 5};

// Trying to access an element outside the bounds of the array


int index = 10;
int value = numbers[index]; // This will cause an
ArrayIndexOutOfBoundsException
}
}

3. Example with APL: Another example is APL, which is known for its powerful array operators.
While this makes APL programs very concise and easy to write for tasks involving arrays, it also
makes them very difficult to read because of the large number of symbols and complex expressions.
So, APL prioritizes writability (ease of writing) over readability (ease of understanding).

example in APL that calculates the sum of elements in an array:

+/ 1 2 3 4 5

4. Trade-offs in Language Design:

 The conflict between factors like writability and reliability is common in language
design.
 For instance, C++ allows for flexible manipulation of pointers, which can lead to efficient
code but also raises reliability concerns.
 In contrast, Java avoids pointers altogether to prioritize reliability over flexibility.
 In C++, pointers are powerful tools that allow programmers to directly manipulate memory
addresses, providing flexibility in how data is accessed and managed.
 However, this flexibility comes with a trade-off in reliability.
 Mishandling pointers can lead to bugs such as memory leaks, dangling pointers, or accessing
invalid memory locations, which can cause unpredictable behavior or crashes in a program.
 While C++ provides the flexibility to manipulate pointers in this way, it also requires careful
management of memory to ensure reliability.

In contrast, Java does not include pointers as part of its language design. Instead, Java uses
references, which are safer alternatives to pointers. Java's memory management is automatic
through garbage collection, which helps to mitigate common reliability issues associated with
manual memory management in languages like C++.

In Java, the language abstracts away the complexities of memory management and pointer
manipulation, prioritizing reliability by reducing the risk of common pointer-related issues seen in
languages like C++.

5. Compromises in Language Design: Designing a programming language involves making many


compromises and trade-offs between different features and goals. There's often no perfect solution,
so designers have to weigh the pros and cons of each choice carefully.

You might also like