Plain English is an experimental programming language. It was developed to answer several questions about programming languages that we felt had not been adequately addressed elsewhere. A lively discussion of those questions can be found here:
http://forums.anandtech.com/showthread.php?t=2358744
Plain English was also developed as an ideal first language for new programmers: we thought, by eliminating (or at least minimizing) the "syntax barrier" present in other languages, we could get the student to focus on fundamental programming concepts instead of punctuation, etc. The purpose of this thread is to show how those fundamental concepts are realized in Plain English code. Let us begin.
Statements
Most programming languages consist of different kinds of "statements" that instruct the compiler (at compile-time) and/or the computer (at run-time) to do something. In Plain English, such statements are called sentences because they are, in fact, grammatically typical English-language sentences. Five kinds of sentences are used in Plain English code, as described below.
1. Type Definitions
Sentences defining types, in Plain English, always start with indefinite articles: specifically, A, AN, or SOME. For example:
A total is a number.
This sentence defines a new data type, called total, and specifies that it is a subset of the built-in type, number.
2. Global Variable Definitions
In Plain English, Global Variables are defined with sentences that start with the definite article, THE. Like so:
The grand total is a total.
The above sentence defines "grand total" as a variable of type "total" which is a sub-type of the built-in type "number". Note that spaces are allowed in names in Plain English; more on names in the next post.
3. Routine Headers
Routine headers, in Plain English, always start with the preposition TO and end with a colon. For example:
To triple a total:
This sentence begins the definition of a routine that will (presumably) triple any variable of type "total" that is passed to it.
4. Conditional Statements
Conditional sentences always begin with the word IF. Like this:
If the grand total is more than 100, beep.
As you can guess, this sentence, when executed, will cause the computer to make a beeping sound if the value of the grand total global variable is greater than a hundred.
5. Imperative Statements
Everything else is considered an imperative sentence in Plain English. For example:
Triple the grand total.
In fact, the "beep" in the conditional statement above is also an imperative sentence (technically, a clause -- a sentence within another sentence). There is a built-in imperative for exiting a routine (EXIT), and three built-in imperatives for the construction of various kinds of loops: one to mark the start of a loop (LOOP), another to break out of a loop (BREAK), and a third to repeat the loop, starting at the top (REPEAT). Here is a sample showing how these statements are typically used in actual practice; note that everything in square brackets is considered a comment:
To loop around:
[stuff we want to do before the loop]
Loop.
[stuff we always want to do in the loop]
If [we want to jump out of the loop], break.
If [we want to jump out of the whole routine], exit.
[stuff we may want to do in the loop]
Repeat.
[stuff we want to do after the loop]
Future versions of Plain English will undoubtedly include other kinds of loop constructs, such as "For each..." and "While...", etc. We've found with beginners, however, that this form is both easy to explain (as above) and easy to use (ie, the student doesn't have to decide what "kind" of loop to employ).
But enough for a first post. More to come. Stay tuned...
http://forums.anandtech.com/showthread.php?t=2358744
Plain English was also developed as an ideal first language for new programmers: we thought, by eliminating (or at least minimizing) the "syntax barrier" present in other languages, we could get the student to focus on fundamental programming concepts instead of punctuation, etc. The purpose of this thread is to show how those fundamental concepts are realized in Plain English code. Let us begin.
Statements
Most programming languages consist of different kinds of "statements" that instruct the compiler (at compile-time) and/or the computer (at run-time) to do something. In Plain English, such statements are called sentences because they are, in fact, grammatically typical English-language sentences. Five kinds of sentences are used in Plain English code, as described below.
1. Type Definitions
Sentences defining types, in Plain English, always start with indefinite articles: specifically, A, AN, or SOME. For example:
A total is a number.
This sentence defines a new data type, called total, and specifies that it is a subset of the built-in type, number.
2. Global Variable Definitions
In Plain English, Global Variables are defined with sentences that start with the definite article, THE. Like so:
The grand total is a total.
The above sentence defines "grand total" as a variable of type "total" which is a sub-type of the built-in type "number". Note that spaces are allowed in names in Plain English; more on names in the next post.
3. Routine Headers
Routine headers, in Plain English, always start with the preposition TO and end with a colon. For example:
To triple a total:
This sentence begins the definition of a routine that will (presumably) triple any variable of type "total" that is passed to it.
4. Conditional Statements
Conditional sentences always begin with the word IF. Like this:
If the grand total is more than 100, beep.
As you can guess, this sentence, when executed, will cause the computer to make a beeping sound if the value of the grand total global variable is greater than a hundred.
5. Imperative Statements
Everything else is considered an imperative sentence in Plain English. For example:
Triple the grand total.
In fact, the "beep" in the conditional statement above is also an imperative sentence (technically, a clause -- a sentence within another sentence). There is a built-in imperative for exiting a routine (EXIT), and three built-in imperatives for the construction of various kinds of loops: one to mark the start of a loop (LOOP), another to break out of a loop (BREAK), and a third to repeat the loop, starting at the top (REPEAT). Here is a sample showing how these statements are typically used in actual practice; note that everything in square brackets is considered a comment:
To loop around:
[stuff we want to do before the loop]
Loop.
[stuff we always want to do in the loop]
If [we want to jump out of the loop], break.
If [we want to jump out of the whole routine], exit.
[stuff we may want to do in the loop]
Repeat.
[stuff we want to do after the loop]
Future versions of Plain English will undoubtedly include other kinds of loop constructs, such as "For each..." and "While...", etc. We've found with beginners, however, that this form is both easy to explain (as above) and easy to use (ie, the student doesn't have to decide what "kind" of loop to employ).
But enough for a first post. More to come. Stay tuned...
Last edited: