q2K BHP
Black History Portal
THE BHP WIRE —
HIDDEN TRUTHS
What's New!
THE JOURNEY THROUGH TIME

Explore Black History

Explore the people, places, events, achievements, struggles and stories that shaped our journey.

✊🏾

Civil Rights

Movements, leaders, victories and the continuing fight for equality.

⚙️

Black Inventors

Innovation, patents, science, technology and world-changing contributions.

🏆

Sports

Pioneers, champions, Negro Leagues, records, activism and excellence.

♟️

People

Meet the people whose lives, choices and achievements shaped the journey.

📍

Places

Black towns, communities, institutions and places where history happened.

📜

Events

Moments that changed communities, movements, institutions and the nation.

Enter a person, place, event, or topic.
MY'STORY

The MOVE Fire

This is a personal recollection on the Move fire on May 13, 1985 Philadelphia police fired thousands of rounds at the MOVE house, city officials approved dropping an explosive device on the roof, the resulting fire was allowed to burn, 11 people—including five children—died, and 61 homes were destroyed. Philadelphia City Council later called it a “brutal attack carried out by the City of Philadelphia on its own citizens” and acknowledged that no individual faced criminal consequences for the bombing. One timeline correction worth preserving for the BHP record: the major previous MOVE-police confrontation was August 8, 1978, about seven years before the bombing, not a year or two earlier. Officer James Ramp was killed, other police and firefighters were wounded, nine MOVE members were later convicted, and television cameras recorded police beating Delbert Africa during his arrest. The 1985 MOVE Commission later specifically criticized city planners for failing to adequately use lessons from that 1978 confrontation. And that actually strengthens the point you’re making: 1985 did not happen without precedent or institutional memory. There had already been a deadly confrontation with MOVE, years of conflict, negotiations and police involvement before Osage Avenue.

MORE →
BLACK FACTS
The Truths They Never Taught You...

Shirley Chisholm — Unbought and Unbossed

In 1968 Shirley Chisholm became the first Black woman elected to the United States Congress. In 1972 she launched a campaign for the Democratic presidential nomination, breaking another political barrier.

MORE →
BHP gathered finds from its connected research sources. Showing the 4 strongest Black History matches.
← BACK TO RESULTS
Wikipedia

Interpreter (computing)

W3sDesign Interpreter Design Pattern UML

In computing, an interpreter is software that executes source code without first compiling it to machine code. An interpreted runtime environment differs from one that processes CPU-native executable code which requires translating source code before executing it. An interpreter may translate the source code to an intermediate format, such as bytecode. A hybrid environment may translate the bytecode to machine code via just-in-time compilation, as in the case of .NET and Java, instead of interpreting the bytecode directly.

Before the widespread adoption of interpreters, the execution of computer programs often relied on compilers, which translate and compile source code into machine code. Early runtime environments for Lisp and BASIC could parse source code directly. Thereafter, runtime environments were developed for languages (such as Perl, Raku, Python, MATLAB, and Ruby), which translated source code into an intermediate format before executing to enhance runtime performance.

Code that runs in an interpreter can be run on any platform that has a compatible interpreter. The same code can be distributed to any such platform, instead of an executable having to be built for each platform. Although each programming language is usually associated with a particular runtime environment, a language can be used in different environments. Interpreters have been constructed for languages traditionally associated with compilation, such as ALGOL, Fortran, COBOL, C and C++.

History

[edit | edit source]

In the early days of computing, compilers were more commonly found and used than interpreters because hardware at that time could not support both the interpreter and interpreted code and the typical batch environment of the time limited the advantages of interpretation.[1]

Interpreters were used as early as 1952 to ease programming within the limitations of computers at the time (e.g. a shortage of program storage space, or no native support for floating point numbers). Interpreters were also used to translate between low-level machine languages, allowing code to be written for machines that were still under construction and tested on computers that already existed.[2] The first interpreted high-level language was Lisp. Lisp was first implemented by Steve Russell on an IBM 704 computer. Russell had read John McCarthy's paper, "Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I", and realized (to McCarthy's surprise) that the Lisp eval function could be implemented in machine code.[3] The result was a working Lisp interpreter which could be used to run Lisp programs, or more properly, "evaluate Lisp expressions".

The development of editing interpreters was influenced by the need for interactive computing. In the 1960s, the introduction of time-sharing systems allowed multiple users to access a computer simultaneously, and editing interpreters became essential for managing and modifying code in real-time. The first editing interpreters were likely developed for mainframe computers, where they were used to create and modify programs on the fly. One of the earliest examples of an editing interpreter is the EDT (Editor and Debugger for the TECO) system, which was developed in the late 1960s for the PDP-1 computer. EDT allowed users to edit and debug programs using a combination of commands and macros, paving the way for modern text editors and interactive development environments.[citation needed ]

Notable uses for interpreters include:

Commands and scripts
Interpreters are frequently used to execute commands and scripts
Virtualization
An interpreter acts as a virtual machine to execute machine code for a hardware architecture different from the one running the interpreter.
Emulation
An interpreter (virtual machine) can emulate another computer system in order to run code written for that system.
Sandboxing
While some types of sandboxes rely on operating system protections, an interpreter (virtual machine) can offer additional control such as blocking code that violates security rules.[citation needed ]
Self-modifying code
Self-modifying code can be implemented in an interpreted language. This relates to the origins of interpretation in Lisp and artificial intelligence research.[citation needed ]

Efficiency

[edit | edit source]

Interpretive overhead is the runtime cost of executing code via an interpreter instead of as native (compiled) code. Interpreting is slower because the interpreter executes multiple machine-code instructions for the equivalent functionality in the native code. In particular, access to variables is slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time.[4] But faster development (due to factors such as shorter edit-build-run cycle) can outweigh the value of faster execution speed—especially when prototyping and testing when the edit-build-run cycle is frequent.[4][5]

An interpreter may generate an intermediate representation (IR) of the program from source code in order to achieve goals such as fast runtime performance. A compiler may also generate an IR, but the compiler generates machine code for later execution whereas the interpreter prepares to execute the program. These differing goals lead to differing IR design. Many BASIC interpreters replace keywords with single byte tokens which can be used to find the instruction in a jump table.[4] A few interpreters, such as the PBASIC interpreter, achieve even higher levels of program compaction by using a bit-oriented rather than a byte-oriented program memory structure, where commands tokens occupy perhaps 5 bits, nominally "16-bit" constants are stored in a variable-length code requiring 3, 6, 10, or 18 bits, and address operands include a "bit offset". Many BASIC interpreters can store and read back their own tokenized internal representation.

There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems (such as some Lisps) allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed.[6]

Implementation

[edit | edit source]

Since the early stages of interpreting and compiling are similar, an interpreter might use the same lexical analyzer and parser as a compiler and then interpret the resulting abstract syntax tree.

Example

[edit | edit source]

An expression interpreter written in C++.

import std;

using std::runtime_error;
using std::unique_ptr;
using std::variant;

// data types for abstract syntax tree
enum class Kind: char { 
    VAR, 
    CONST, 
    SUM, 
    DIFF, 
    MULT, 
    DIV, 
    PLUS, 
    MINUS, 
    NOT 
};

// forward declaration
class Node;

class Variable { 
public:
    int* memory; 
};

class Constant {
public:
    int value; 
};

class UnaryOperation {
public:
    unique_ptr<Node> right; 
};

class BinaryOperation { 
public:
    unique_ptr<Node> left;
    unique_ptr<Node> right;
};

using Expression = variant<Variable, Constant, BinaryOperation, UnaryOperation>;

class Node {
public:
    Kind kind;
    Expression e;
};

// interpreter procedure
[[nodiscard]]
int executeIntExpression(const Node& n) {
    int leftValue;
    int rightValue;
    switch (n->kind) {
        case Kind::VAR:
            return std::get<Variable>(n.e).memory;
        case Kind::CONST:
            return std::get<Constant>(n.e).value;
        case Kind::SUM:
        case Kind::DIFF:
        case Kind::MULT:
        case Kind::DIV:
            const BinaryOperation& bin = std::get<BinaryOperation>(n.e);
            leftValue = executeIntExpression(bin.left.get());
            rightValue = executeIntExpression(bin.right.get());
            switch (n.kind) {
                case Kind::SUM: 
                    return leftValue + rightValue;
                case Kind::DIFF: 
                    return leftValue - rightValue;
                case Kind::MULT: 
                    return leftValue * rightValue;
                case Kind::DIV: 
                    if (rightValue == 0) {
                        throw runtime_error("Division by zero");
                    }
                    return leftValue / rightValue;
            }
        case Kind::PLUS: 
        case Kind::MINUS: 
        case Kind::NOT:
            const UnaryOperation& un = std::get<UnaryOperation>(n.e);
            rightValue = executeIntExpression(un.right.get());
            switch (n.kind) {
                case Kind::PLUS:
                    return +rightValue;
                case Kind::MINUS:
                    return -rightValue;
                case Kind::NOT: 
                    return !rightValue;
            }
        default: 
            std::unreachable();
    }
}

Just-in-time compilation

[edit | edit source]

Just-in-time (JIT) compilation is the process of converting an intermediate format (i.e. bytecode) to native code at runtime. As this results in native code execution, it is a method of avoiding the runtime cost of using an interpreter while maintaining some of the benefits that led to the development of interpreters.

Variations

[edit | edit source]
Control table interpreter
Logic is specified as data formatted as a table.
Bytecode interpreter
Some interpreters process bytecode which is an intermediate format of logic compiled from a high-level language. For example, Emacs Lisp is compiled to bytecode which is interpreted by an interpreter. One might say that this compiled code is machine code for a virtual machine – implemented by the interpreter. Such an interpreter is sometimes called a compreter.[7][8]
Threaded code interpreter
A threaded code interpreter is similar to bytecode interpreter but instead of bytes, uses pointers. Each instruction is a word that points to a function or an instruction sequence, possibly followed by a parameter. The threaded code interpreter either loops fetching instructions and calling the functions they point to, or fetches the first instruction and jumps to it, and every instruction sequence ends with a fetch and jump to the next instruction. One example of threaded code is the Forth code used in Open Firmware systems. The source language is compiled into "F code" (a bytecode), which is then interpreted by a virtual machine.[citation needed ]
Abstract syntax tree interpreter
An abstract syntax tree interpreter transforms source code into an abstract syntax tree (AST), then interprets it directly, or uses it to generate native code via JIT compilation.[9] In this approach, each sentence needs to be parsed just once. As an advantage over bytecode, AST keeps the global program structure and relations between statements (which is lost in a bytecode representation), and when compressed provides a more compact representation.[10] Thus, using AST has been proposed as a better intermediate format than bytecode. However, for interpreters, AST results in more overhead than a bytecode interpreter, because of nodes related to syntax performing no useful work, of a less sequential representation (requiring traversal of more pointers) and of overhead visiting the tree.[11]
Template interpreter
Rather than implement the execution of code by virtue of a large switch statement containing every possible bytecode, while operating on a software stack or a tree walk, a template interpreter maintains a large array of bytecode (or any efficient intermediate representation) mapped directly to corresponding native machine instructions that can be executed on the host hardware as key value pairs (or in more efficient designs, direct addresses to the native instructions),[12][13] known as a "Template". When the particular code segment is executed the interpreter simply loads or jumps to the opcode mapping in the template and directly runs it on the hardware.[14][15] Due to its design, the template interpreter very strongly resembles a JIT compiler rather than a traditional interpreter, however it is technically not a JIT due to the fact that it merely translates code from the language into native calls one opcode at a time rather than creating optimized sequences of CPU executable instructions from the entire code segment. Due to the interpreter's simple design of simply passing calls directly to the hardware rather than implementing them directly, it is much faster than every other type, even bytecode interpreters, and to an extent less prone to bugs, but as a tradeoff is more difficult to maintain due to the interpreter having to support translation to multiple different architectures instead of a platform independent virtual machine/stack. To date, the only template interpreter implementations of widely known languages to exist are the interpreter within Java's official reference implementation, the Sun HotSpot Java Virtual Machine,[12] and the Ignition Interpreter in the Google V8 JavaScript execution engine.
Microcode
Microcode provides an abstraction layer as a hardware interpreter that implements machine code in a lower-level machine code.[16] It separates the high-level machine instructions from the underlying electronics so that the high-level instructions can be designed and altered more freely. It also facilitates providing complex multi-step instructions, while reducing the complexity of computer circuits.

See also

[edit | edit source]

References

[edit | edit source]
  1. ^ "Why was the first compiler written before the first interpreter?". Ars Technica. 8 November 2014. Retrieved 9 November 2014.
  2. ^ Bennett, J. M.; Prinz, D. G.; Woods, M. L. (1952). "Interpretative sub-routines". Proceedings of the ACM National Conference, Toronto.
  3. ^ According to what reported by Paul Graham in Hackers & Painters, p. 185, McCarthy said: "Steve Russell said, look, why don't I program this eval..., and I said to him, ho, ho, you're confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bug, and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today..."
  4. ^ a b c This article is based on material taken from Interpreter at the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
  5. ^ "Compilers vs. interpreters: explanation and differences". IONOS Digital Guide. Retrieved 2022-09-16.
  6. ^ Nanz, Sebastian; Furia, Carlo A. (May 2015). "A Comparative Study of Programming Languages in Rosetta Code". 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering. pp. 778–788. arXiv:1409.0252. doi:10.1109/icse.2015.90. ISBN 978-1-4799-1934-5.
  7. ^ Kühnel, Claus (1987) [1986]. "4. Kleincomputer - Eigenschaften und Möglichkeiten" [4. Microcomputer - Properties and possibilities]. In Erlekampf, Rainer; Mönk, Hans-Joachim (eds.). Mikroelektronik in der Amateurpraxis [Micro-electronics for the practical amateur] (in German) (3 ed.). Berlin: Militärverlag der Deutschen Demokratischen Republik [de], Leipzig. p. 222. ISBN 3-327-00357-2. 7469332.
  8. ^ Heyne, R. (1984). "Basic-Compreter für U880" [BASIC compreter for U880 (Z80)]. radio-fernsehn-elektronik [de] (in German). 1984 (3): 150–152.
  9. ^ AST intermediate representations, Lambda the Ultimate forum
  10. ^ Kistler, Thomas; Franz, Michael (February 1999). "A Tree-Based Alternative to Java Byte-Codes" (PDF). International Journal of Parallel Programming. 27 (1): 21–33. doi:10.1023/A:1018740018601. ISSN 0885-7458. S2CID 14330985. Retrieved 2020-12-20.
  11. ^ Surfin' Safari - Blog Archive » Announcing SquirrelFish. Webkit.org (2008-06-02). Retrieved on 2013-08-10.
  12. ^ a b "openjdk/jdk". GitHub. 18 November 2021.
  13. ^ "HotSpot Runtime Overview". Openjdk.java.net. Retrieved 2022-08-06.
  14. ^ "Demystifying the JVM: JVM Variants, Cppinterpreter and TemplateInterpreter". metebalci.com.
  15. ^ "JVM template interpreter". ProgrammerSought.
  16. ^ Kent, Allen; Williams, James G. (April 5, 1993). Encyclopedia of Computer Science and Technology: Volume 28 - Supplement 13. New York: Marcel Dekker, Inc. ISBN 0-8247-2281-7. Retrieved Jan 17, 2016.

Sources

[edit | edit source]
[edit | edit source]

Source: Wikipedia. Article content is retrieved live through the MediaWiki API.

Wikipedia

Interpreter (computing)

In computing, an interpreter is software that executes source code without first compiling it to machine code. An interpreted runtime environment differs from one that processes CPU-native executable code which requires translating source code before executing it. An interpreter may translate the source code to an intermediate format, such as bytecode. A hybrid environment may translate the bytecode to machine code via just-in-time compilation, as in the case of .NET and Java, instead of interpreting the bytecode directly. Before the widespread adoption of interpreters, the execution of computer programs often relied on compilers, which translate and compile source code into machine code. Early runtime environments for Lisp and BASIC could parse source code directly. Thereafter, runtime environments were developed for languages (such as Perl, Raku, Python, MATLAB, and Ruby), which translated source code into an intermediate format before executing to enhance runtime performance. Code that runs in an interpreter can be run on any platform that has a compatible interpreter. The same code can be distributed to any such platform, instead of an executable having to be built for each platform. Although each programming language is usually associated with a particular runtime environment, a language can be used in different environments. Interpreters have been constructed for languages traditionally associated with compilation, such as ALGOL, Fortran, COBOL, C and C++.

MORE →
No preview image
Wikipedia

ASSIST (computing)

ASSIST (the Assembler System for Student Instruction and Systems Teaching) is an IBM System/370-compatible assembler and interpreter developed in the early 1970s at Penn State University by Graham Campbell and John Mashey along with student assistants. In the late 1960s, computer science education expanded rapidly and university computer centers were faced with a large growth in usage by students, whose needs sometimes differed from professionals in batch processing environments. They needed to run short programs on decks of Punched cards with fast turnaround (minutes, not overnight) as their programs more often included syntax errors. Once they compiled, they would often fault quickly, so optimization and flexibility were far less important than low overhead. WATFIV was a successful pioneering effort to build a FORTRAN compiler tuned for student use. Universities began running it in a dedicated "fast-batch" memory partition with a small run-time limit, such as 5 seconds on an IBM System/360 Model 67). The low limit enabled fast turnaround and avoided waste of time by programs stuck in infinite loops. WATFIV's success helped inspire development of ASSIST, PL/C and other student-oriented programs that fit the "fast-batch" model that became widely used among universities. ASSIST was enhanced and promoted by others, such as Northern Illinois University's Wilson Singletary & Ross Overbeek and University of Tennessee's Charles Hughes and Charles Pfleeger who reported in 1978 that ASSIST was being used in 200+ universities. In the 1980s, NIU did a new implementation on IBM PCs, ASSIST/I (Interactive), used by computer scientist John Ehrman to teach a "boot camp" course in assembly programming at SHARE (computing) meetings, at least through 2011, but perhaps for several years after. On March 1, 1998, Penn State declared that ASSIST was no longer copyrighted and that the program was freely available as per the last release notes. The original ASSIST code seems to still get some use, as seen in 2017 demonstration video assembling its source and running it in MVS 3.8 emulation on a laptop. IBM System/360 and /370 computers used 24-bit addressing and ignored the high-order 8 bits. Assembly programmers of the era, including those who wrote ASSIST, often saved precious memory by using the high-order 8 bits for flags, which required a compatibility mode when IBM introduced 31-bit and then 64-bit addressing.

MORE →
No preview image
Wikipedia

Translator (computing)

A translator or programming language processor is a computer program that translates one computer language into another computer language. It is a generic term that can refer to a compiler, assembler, or interpreter. These include translations between high-level and human-readable computer languages such as C++ and Java, intermediate-level languages such as Java bytecode, low-level languages such as the assembly language and machine code, and between similar levels of language on different computing platforms, as well as from any of these to any other of these. The term is also used for translators between software implementations and hardware/ASIC microchip implementations of the same program, and from software descriptions of a microchip to the logic gates needed to build it.

MORE →
No preview image
Wikipedia

Shebang (Unix)

In computing, a shebang is the character sequence #!, consisting of the characters number sign (also known as hash or octothorpe) and exclamation mark (also known as bang), at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling. When a text file with a shebang is used as if it were an executable in a Unix-like operating system, the program loader mechanism parses the rest of the file's initial line as an interpreter directive. The loader executes the specified interpreter program, passing to it as an argument the path that was initially used when attempting to run the script, so that the program may use the file as input data. For example, if a script is named with the path path/to/script, and it starts with the line #!/bin/sh, then the program loader is instructed to run the program /bin/sh, passing path/to/script as the first argument. The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose.

MORE →
TOPIC OF THE DAY

Greenwood / Black Wall Street

Before the 1921 destruction of Tulsa’s Greenwood District, Black residents had created a remarkable center of business and community life. The district included stores, professional offices, entertainment venues and homes owned by Black citizens. Understanding Greenwood means learning what was built—not only what was burned.

MORE →
TRIVIA QUESTION OF THE DAY

What prosperous Tulsa district became widely known as “Black Wall Street”?

The Greenwood District.