- #1
elcaro
- 128
- 30
- TL;DR Summary
- Most programming languages and environments store program source as text in source (and accompanying) files. But a program can be seen as a collection of relations between different objects, and thus these relations could also be stored in a data base. For example: every Variable has a relation to a Type, every function call implies a relation between caller and callee, etc. Has there ever been an attempt to store program source in the form of relations into a database?
Almost all (compiled or interpreted) programming langues store the program source in the form of a series of bytes (using an encoding like ASCII or UTF-8) into a text file, enforcing the grammer of the programming language using a parser (as part of the compilation process or interpretation of the source text).
But intrinsically a program can also be seen as a collection of relations between different objects, which can be stored as tuples in a relational database system.
For example:
No programming language or environment (perhaps with the exception of a language/programming environment like smalltalk) however stores these relations as such, most languages store it as text in a source file.
The advantages of storing program source as relations in a database are multiple, like for instance:
But intrinsically a program can also be seen as a collection of relations between different objects, which can be stored as tuples in a relational database system.
For example:
- A program Variable needs to have a definition, which creates both a relation between the variable and a type, and also a location within another object (for example a function and/or module) in which the definition takes place.
- A function call creates a relation between the calling function or module and a called function, a relation between its return value and a type, and a relation between the function and the object or module in which it was defined.
No programming language or environment (perhaps with the exception of a language/programming environment like smalltalk) however stores these relations as such, most languages store it as text in a source file.
The advantages of storing program source as relations in a database are multiple, like for instance:
- One can enforce strong typing rules for all objects.
- One can produce many usefull insights into the program source, like dependencies between objects (what function gets called by what function, what modules or objects use what variables, etc.).
- Compilation could be done piece wise (per object) as part of the editing proces (saving the object also pre-compiles it, and shows the errors encountered during compilation if any - source is stored anyway).
- Each variable or object name needs to be stored only once, and renaming objects would only take place at one point. Optionally, each programmer could name objects in their native language and script.
- The program itself can be stored in the form of an abstract syntax tree, simplyfying the process of creating object code and executable generation.
- Refactoring a program, or moving functions between modules, and retaining all dependency relations (like header files), could be done much simpler and less error prone then in a textual environment.
- Build/make information can be easily extracted from the relations already stored in the database, using the dependency relations already stored.
- Optionally also the versioning system itself could be implemented as part of the programming development system, also storing version information as relations into a database.
- For compatibility with the usual work environment and programming development tools, easy import and export functionality could be provided for such a programming development environment.