What is Real?
Because Real is only in definition to an interpreter.
Is Mandarin any more or less real than English?
- Certainly Mandarin is not particularly useful to an English speaker
- similarly English is so much nonsense to a Mandarin speaker
- unless they speak both.
So Real isn't even the question. Lets rephrase it:
Why is Pseudo Code used instead of a Formal Language?
A simple VENN Diagram can highlight the problem easily. The set of all humans that are English And Mandarin Speakers is the subset of English Or Mandarin Speakers. Because it takes effort to obtain proficiency in any language the intersection is generally much smaller than the union.
The textbook on programming can presume that you understand at least one natural language, the language the textbook is written in. Its generally safe to presume this, as otherwise a different more legible textbook would have been selected. After all learning one language is difficult enough - two is harder.
This gives the first reason for using a pseudo code. It maximises the audience that could easily read the book. This is done by following established language conventions already found in the natural language. Say recipes from cooking, mathematical formulas, etc... Any gap can be bridged by a quick natural language explanation, or failing that a final recourse to our visual system with pictures.
As for why the common language could not be the programming language. I leave to you to consider how much Mandarin (or any language you do not already speak) you have learned by reading a book about programming written with examples given in a familiar programming language.
What A textbook Achieves
As for the second reason, consider what a textbook must achieve:
- explain why they would bother to learn an alien language instead of just using their natural language.
- explain an alien language to the reader such that they might be able to speak it themselves.
Most of the book has to convince you as to why you would want to learn and use this alien language, or any similar language. This means discussing the essence of programming itself.
- How do you identify a problem
- How do you break a problem apart
- How do you architect the data
- How do you architect the processes
- How do you manage the dependencies
- How do you identify faults
- and more
Most of this has nothing to do with the machines themselves, its mostly a discussion on how meat-ware should operate in order to bring about a program. That's pretty complex because it has to show why we would link our human space goals, to program space problems and strive to solve them.
Describing a Program
The second textbook achievement is describing a Language. Now most programming languages can be described with a Grammar and a few semantic rules. On the shallow end are languages like JSON which can be defined fairly completely within three or so pages. More complex languages need a larger specification, but for the most part do not need a total understanding in order to be useful. What these descriptions are however are Pseudo Code. They specify the formal language in terms of a natural language. The difference is that these pseudo codes are specified in advance.
Now given that even Formal Languages are themselves (Executable) Pseudo Codes, the question is what is most important when describing an algorithm? The next-larger context.
- The algorithm has a Goal that is reasonable in that context,
- that context has some constraints,
- and the algorithm is a description of how those constraints can be handled while achieving the goal.
At no point is the language that the algorithm is written in important. If anything only a few key operations are critical for the algorithms success. So the question then becomes:
- is it better to describe a meat-ware program capable of interpreting the full specification of a Formal Language like C++/C#/Python/etc... in order to understand the algorithm
- or just Define the 4 or so primitives required to understand the algorithm.
Given that learning a language is Hard, and the reader must have learned/learn a language in order to understand the algorithm, as the writer of a textbook what should you ask of the reader?