programming language theory - LeFreq/Singularity GitHub Wiki

Programming Language Design

If we're making the perfect operating system, we need the perfect programming language. The perfect programming language is inobtrusive, so that what you're trying to accomplish is evident. Forth offers some good tips in syntax: use symbols instead of keywords to differentiate variables from functional language elements.

XXXthis text out-of-date, see prime language discussion.

Language should have automatic construct to send items to "standard error" and "keyboard in".

How does programming language theory evolve? The theory of languages is like the development of raw substrate of the cosmos and the nature of difference into:

  1. number and symbol,
  2. arithmetic and logic,
  3. functions (to module-files and program sets), data structures,
  4. objects, containers for objects,
  5. object architecture GOOP
  6. modular and file-divisions of process flow
  7. unknown levels beyond
Starting with symbols. Like a building, symbols perform functions: a door, a window, ventilation duct. These are architecturally significant. You don't go allowing these symbols anywhere just because you want to get from one place to another (like Perl). No you're the architect: you're designing the building (the software) for a purpose, that may not be completely known to the general user, who just wants to get from their desk to the copier.

If we're going to create the perfect language, then we might as well consider symbols instead of keywords for reasons which follow. There are very few language constructs needed to make Turing Complete language. As this is so, then we can create the ultimate language convergence by making keywords into symbols; saving typing and putting user-programmer names FIRST, instead of the language.

Once the basic language structure is perfected, then user-programmers need only to learn how to make the perfect NAME for all of their routines. Names might be UPPER-CASEed upon definition, but then lower-cased in nearly every other use, and Capitalized on meta-typing.

There are just a few constructs necessary to handle every programming need, including readability, scalability, efficiency, expressivity. These could theoretically be designated by symbols rather than keywords and be better expressed as punctuation to the language. Like four codons of biology, they revolve around the Rule of Four. They are related to the four OS design quadrants (listed at the front of each list, both as a micro-design issue and a macro issue):

Four +/- 1 constructs necessary for Turing completeness(?)

  • variable assignments: =
  • arithmetic operators: + - \ *
  • while loop, possibly with an initialization list of temporary variables
  • conditional: ? true_response / false_response
  • user i/o: get ?input1, input2 and report output!s.
  • +1: Named subroutines with parameters (up to 4 + 1): :
  • -1: hardware input (serial lines, network, keyboard) KEYB_IN >>>> KeyboardBuffer, output (display, audio) points: AudioStream >>>> SPEAKER_OUT
Formatting:
  • " " (CR) between method definitions
  • "," between separate items for input, containers, output
  • Capitals on objects (where you can pass data into and out) to distinguish from procedures or functions
  • Docstrings: if the user doesn't supply a one-line docstring, an error or warning will occur on run.
Four + 1 constructs necerssary for scalable architecture:
  • Storage: containers holding arbitrary numbers of named items: ordered <,>, unordered {,}, immutable ordered? (,), mutable memory-static containers [,]
  • Processing: objects (data+code): & (on prior line with one-liner docstring)
  • Communications: doctests """ and message-based architecture of communicating between objects >> << (a registration object might be running on one machine sending >> nodename.data to another machine running a database object that checks all objects, etc....)
  • System i/o: import objects in a different branch of the namespace +/dir/objectgroup
  • Interpreter environment to maintain and set security: (SET commands on RUN, MSG, SET etc.)
For loop is an anonymous function taking three parameters, the last of which should be considered a lambda function: a pointer to an arbitrary function “object” for making arbitrary, generalized, looping constructs. In other words, for is not a keyword anymore. Initialization lists can be comma-separated, arbitrarily long list of variables which will be thrown away after the condition is met.

Compilers only really need to do these minimal tasks and then can translate any language into them, but this OS won't need compilers -- it's all done by the kernel, effectively, JIT.

We shall call this language: Prime. In theory, there is one and only one perfect language for any given computational architecture (like single-processor, von Neumann machines or a 16 processor hypercube). Even down to the single-character symbol. Which character(s) encodes the function or keyword best? These architecture engender whole different paradigms of computing -- a new arena for computer science that will have to be discovered.

What are the mechanical engineering equivalents to these constructs, such that any machine can be built with a few basic primitives and abstractions?

⚠️ **GitHub.com Fallback** ⚠️