Jump to content

Programming language design and implementation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Spacebyte (talk | contribs) at 01:01, 3 March 2023 (Spacebyte moved page Draft:Creation of a Programming Language to Creation of a Programming Language: I believe that issues have been fixed enough to be moved to the mainspace once again.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, Creation of a Programming Language is typically done by creating an implementation called either an interpreter or compiler. Interpreters are designed to read programs, usually in some variation of a text format, and preforms actions based on what it reads, whereas compilers convert code to lower level, and more readable formats. [1]

Design

In programming language design, there are a wide variety of factors to consider. It may be necessary to consider whether your programming language will perform better interpreted, or compiled, if your language should be dynamically or statically typed, if inheritance will be in your language, and the general syntax of the language.[2] Many factors involved with the design of a language can be decided on by the goals behind the language. It's important to consider the target audience of a language, its unique features and its purpose.[3] It is good practice to look at what existing languages lack, or make difficult, to make sure your language serves a purpose. [3]

Implementation

Interpreters

An interpreter is a program that reads a program, typically as text, [3] as seen in languages like Python. Interpreters read code, and produces the result directly.[4] Interpreters typically read code line by line, and parses it to convert and execute the code as operations and actions.[5]

Compilers

Compilers are programs that read programs, also usually as some form of text, and converts the code into lower level machine code or operations[3]. Compiled languages converted to machine code, tend to be a lot faster, as lower level operations are easier to run, and outcomes can be predicted and compiled ahead of time. [5]

Process

Processes of making a programming language may differ from developer to developer, however, here is a general process.

  • Design: Consider design aspects such as types, syntax, semantics, and library usage to develop your language.[6]
  • Consideration: Consider how a language will be written. Languages like Python interpret code at runtime, whereas language like C++ follow an approach of basing it's compiler off of C (programming language)'s compiler.[7]
  • Create an implementation: Write an interpreter or compiler. Compilers will convert to other formats, usually ending up as low-level as assembly, even down to binary.[8]
  • Improve your implementation: Implementations should be improved upon. Expand your programming language, try to aim to have enough functionality to bootstrap, where a programming language is capable of writing an implementation of itself.
  • Bootstrapping: If using a compiler, you may use the process of bootstrapping, where you rewrite the programming language in itself.[9] This is good for bug checking, and proving its capability.[10] Bootstrapping also comes with the benefit of only needing to program the language in itself from there-on.

References

  1. ^ Friedman, Daniel. "Essentials of Programming Languages" (PDF). Retrieved 2 March 2023.
  2. ^ "Programming Languages and Learning". Washington EDU. University of Washington. Retrieved 2 March 2023.
  3. ^ a b c d "How are Programming Languages created". GoNoCode. GoNoCode. 8 December 2021. Retrieved 2 March 2023.
  4. ^ Diver, Laurence. "Published on Dec 07, 2021 Interpreting the Rule(s) of Code: Performance, Performativity, and Production". MIT. MIT.
  5. ^ a b Rathi, Mukul. "How I wrote my own "proper" programming language". mukulrathi. Retrieved 2 March 2023.
  6. ^ Chouchanian, Vic. "Programming Languages". California State University Northridge. Retrieved 2 March 2023.
  7. ^ Stroustrup, Bjarne. "A History of C ++ : 1979− 1991" (PDF). Archived (PDF) from the original on 2 February 2019. Retrieved 18 July 2013.
  8. ^ Ferguson, Andrew. "A History of Computer Programming Languages". Brown University. Retrieved 2 March 2023.
  9. ^ Glück, Robert (2012). "Bootstrapping compiler generators from partial evaluators". In Clarke, Edmund; Virbitskaite, Irina; Voronkov, Andrei (eds.). Perspectives of Systems Informatics: 8th International Andrei Ershov Memorial Conference, PSI 2011, Novosibirsk, Russia, June 27 – July 1, 2011, Revised Selected Papers. Lecture Notes in Computer Science. Vol. 7162. Springer. pp. 125–141. doi:10.1007/978-3-642-29709-0_13. Getting started presents the chicken-and-egg problem familiar from compiler construction: one needs a compiler to bootstrap a compiler, and bootstrapping compiler generators is no exception.
  10. ^ "Installing GCC: Building". GNU Project - Free Software Foundation (FSF).