<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[The Osmosian Order of Plain English Programmers Welcomes You]]></provider_name><provider_url><![CDATA[http://osmosianplainenglishprogramming.blog]]></provider_url><author_name><![CDATA[gerryrzeppa]]></author_name><author_url><![CDATA[https://osmosianplainenglishprogramming.blog/author/gerryrzeppa/]]></author_url><title><![CDATA[Plain English Programming]]></title><type><![CDATA[link]]></type><html><![CDATA[<header class="entry-header">
<h1 class="entry-title"></h1>
</header>
<div class="entry-content">
<p>Having programmed for many years in many languages, I often find myself thinking in English pseudo-code, then I translate my thoughts into whatever artificial syntax I’m working with at the time. So one day I thought, “Why not simply code at a natural language level and skip the translation step?” My elder son (also a programmer) and I talked it over, and we decided to test the theory. Specifically, we wanted to know:</p>
<p>1. Is it easier to program when you don’t have to translate your natural-language thoughts into an alternate syntax?</p>
<p>2. Can natural languages be parsed in a relatively “sloppy” manner (as humans apparently parse them) and still provide a stable enough environment for productive programming?</p>
<p>3. Can low-level programs (like compilers) be conveniently and efficiently written in high level languages (like English)?</p>
<p>And so we set about developing a Plain English compiler (in Plain English) in the interest of answering those questions. And we are happy to report that we can now answer each of those three questions, from direct experience, with a resounding, “Yes!”</p>
<p><strong>The Theory</strong></p>
<p>Our parser operates, we believe, something like the parsing centers in the human brain. Consider, for example, a father saying to his baby son…</p>
<p><span style="color:#00ccff;">“Want to suck on this bottle, little guy?”</span></p>
<p>…and the kid hears…</p>
<p><span style="color:#00ccff;">“blah, blah, SUCK, blah, blah, BOTTLE, blah, blah.”</span></p>
<p>…but he properly responds because he’s got a “picture” of a bottle in the right side of his head connected to the word “bottle” on the left side, and a pre-existing “skill” near the back of his neck connected to the term “suck.” In other words, the kid matches what he can with the pictures (types) and skills (routines) he’s accumulated, and simply disregards the rest. Our compiler does very much the same thing, with new pictures (types) and skills (routines) being defined — not by us, but — by the programmer, as he writes new application code.</p>
<p><strong>The Practice</strong></p>
<p>A typical type definition looks like this:</p>
<p><span style="color:#00ccff;">A polygon is a thing with some vertices.</span></p>
<p>Internally, the name “polygon” is now associated with a dynamically-allocated structure that contains a doubly-linked list of vertices. “Vertex” is defined elsewhere (before or after this definition) in a similar fashion; the plural is automatically understood.</p>
<p>A typical routine looks like this:</p>
<p><span style="color:#00ccff;">To append an x coord and a y coord to a polygon:</span><br />
<span style="color:#00ccff;"> Create a vertex given the x and the y.</span><br />
<span style="color:#00ccff;"> Append the vertex to the polygon’s vertices.</span></p>
<p>Note that formal names (proper nouns) are not required for parameters and variables. This, we believe, is a major insight. A real-world chair or table is never (in normal conversation) called “c” or “myTable” — we refer to such things simply as “the chair” or “the table”. Likewise here: “the vertex” and “the polygon” are the most natural names for these variables.</p>
<p>Note also that spaces are allowed in routine and variable names (like “x coord”). It’s surprising that all languages don’t support this feature; this is the 21st century, after all. Note also that “nicknames” are also allowed (such as “x” for “x coord”). And that possessives (“polygon’s vertices”) are used in a very natural way to reference fields within records.</p>
<p>Note, as well, that the word “given” could have been “using” or “with” or any other equivalent since our sloppy parsing focuses on the pictures (types) and skills (routines) needed for understanding, and ignores, as much as possible, the rest.</p>
<p><strong>Like a Math Book</strong></p>
<p>At the lowest level, things look like this:</p>
<p><span style="color:#00ccff;">To add a number to another number:</span><br />
<span style="color:#00ccff;"> Intel $8B85080000008B008B9D0C0000000103.</span></p>
<p>Note that in this case we have both the highest and lowest of languages — English and machine code (in hexadecimal) — in a single sentence. The insight here is that a program should be written primarily in a natural language, with snippets of code in more appropriate syntax as (and only as) required. Like a typical math book: mostly natural language with formula snippets interspersed.</p>
<p>We hope someday the technology will be extended, at the high end, to include Plain Spanish, and Plain French, and Plain German, etc; and at the the low end to include “snippet parsers” for the most useful, domain-specific languages. Español Llano, thanks to our helper Pablo in Argentina, is now up and running.</p>
<p><strong>An Objection Answered</strong></p>
<p>Now perhaps you’re thinking natural language programming is a silly idea. But have you considered the fact that <em>most </em>of the code in <em>most</em> programs does simple stuff like “move this over there” and “show that on the screen” — things that can be most conveniently and most naturally expressed in a natural language? Let’s consider an example we can examine in detail:</p>
<p>Our compiler — a sophisticated Plain-English-to-Executable-Machine-Code translator — has 3,050 imperative sentences in it.</p>
<p>1,306 of those (about 42%) are conditional statements, and at least half of those are trivial things like these:</p>
<p><span style="color:#00ccff;">If the item is not found, break.</span><br />
<span style="color:#00ccff;"> If the compiler&#8217;s abort flag is set, exit.</span></p>
<p>The remainder of those conditional statements are slightly more complex, but all of them fit on a single line (with our font, in our editor). Here are a couple of the longer ones:</p>
<p><span style="color:#00ccff;">If the length is 4, attach $FF32 to the fragment&#8217;s code; exit.</span><br />
<span style="color:#00ccff;"> If the rider&#8217;s token is any numeric literal, compile the literal given the rider; exit.</span></p>
<p>Of the remaining sentences:</p>
<p>272 (about 9%) are simple assignment statements:</p>
<p><span style="color:#00ccff;">Put the type name into the field&#8217;s type name.</span></p>
<p>202 (about 7%) are just the infrastructure for various loops:</p>
<p><span style="color:#00ccff;">Loop.</span><br />
<span style="color:#00ccff;"> Get a field from the type&#8217;s fields.</span><br />
<span style="color:#00ccff;"> [ other stuff here]</span><br />
<span style="color:#00ccff;"> Repeat.</span></p>
<p>183 (6%) simply add something to the end of this or that list, like so:</p>
<p><span style="color:#00ccff;">Add the field to the type&#8217;s fields.</span></p>
<p>164 (about 5%) are trivial statements used to return boolean results, start and stop various timers, show the program’s current status, and write interesting things to the compiler’s output listing.</p>
<p><span style="color:#00ccff;">Say no.</span><br />
<span style="color:#00ccff;"> Say yes.</span><br />
<span style="color:#00ccff;"> Set the variable&#8217;s compiled flag.</span><br />
<span style="color:#00ccff;"> Start the compiler&#8217;s timer.</span><br />
<span style="color:#00ccff;"> Stop the compiler&#8217;s timer.</span><br />
<span style="color:#00ccff;"> Show status &#8220;Compiling&#8230;&#8221;.</span><br />
<span style="color:#00ccff;"> List the globals in the compiler&#8217;s listing.</span></p>
<p>119 (about 4%) advance the focus in the source code, sentences like:</p>
<p><span style="color:#00ccff;">Bump the rider.</span><br />
<span style="color:#00ccff;"> Move the rider (code rules).</span></p>
<p>92 (about 3%) are used to create, destroy and keep internal indexes up to date, sentences like:</p>
<p><span style="color:#00ccff;">Create the type index using 7919 for the bucket count.</span><br />
<span style="color:#00ccff;"> Index the type given the type&#8217;s name.</span><br />
<span style="color:#00ccff;"> Destroy the type index.</span></p>
<p><span style="color:#000000;">58 (about 2%) are used to find things in various lists:</span></p>
<p><span style="color:#00ccff;">Find a variable given the name.</span></p>
<p><span style="color:#000000;">37 (about 1%) are calls to various conversion routines:</span></p>
<p><span style="color:#00ccff;">Convert the rider&#8217;s token to a ratio.</span></p>
<p>31 (about 1%) are used to generate actual machine code (plus those that appear in conditional statements, as above):</p>
<p><span style="color:#00ccff;">Attach $E8 and the address to the fragment.</span></p>
<p>And that accounts for 80% of the code in our compiler.</p>
<p>Only 57 of the remaining sentences (less than 2% of the whole) are mathematical in nature, a line here and there like these:</p>
<p><span style="color:#00ccff;">Add 4 to the routine&#8217;s parameter size.</span><br />
<span style="color:#00ccff;"> Subtract the length from the local&#8217;s offset.</span><br />
<span style="color:#00ccff;"> Multiply the type&#8217;s scale by the base type&#8217;s scale.</span><br />
<span style="color:#00ccff;"> Calculate the length of the field&#8217;s type.</span><br />
<span style="color:#00ccff;"> Round the address up to the nearest multiple of 4096.</span></p>
<p>And the rest are not formulaic at all. Stuff like:</p>
<p><span style="color:#00ccff;">Copy the field into another field.</span><br />
<span style="color:#00ccff;"> Append the fragment to the current routine&#8217;s fragments.</span><br />
<span style="color:#00ccff;"> Abort with &#8220;I was hoping for a definition but all I found was &#8216;&#8221; then the token.</span><br />
<span style="color:#00ccff;"> Initialize the compiler.</span><br />
<span style="color:#00ccff;"> Remove any trailing backslashes from the path name.</span><br />
<span style="color:#00ccff;"> Reduce the monikette&#8217;s type to a type for utility use.</span><br />
<span style="color:#00ccff;"> Eliminate duplicate nicknames from the type&#8217;s fields.</span><br />
<span style="color:#00ccff;"> Prepend &#8220;original &#8221; to the term&#8217;s name.</span><br />
<span style="color:#00ccff;"> Extend the name with the rider&#8217;s token.</span><br />
<span style="color:#00ccff;"> Unquote the other string.</span><br />
<span style="color:#00ccff;"> Read the source file&#8217;s path into the source file&#8217;s buffer.</span><br />
<span style="color:#00ccff;"> Generate the literal&#8217;s name.</span><br />
<span style="color:#00ccff;"> Extract a file name from the compiler&#8217;s abort path.</span><br />
<span style="color:#00ccff;"> Write the compiler&#8217;s exe to the compiler&#8217;s exe path.</span><br />
<span style="color:#00ccff;"> Swap the monikettes with the other monikettes.</span><br />
<span style="color:#00ccff;"> Skip any leading noise in the substring.</span><br />
<span style="color:#00ccff;"> Scrub the utility index.</span><br />
<span style="color:#00ccff;"> Fill the compiler&#8217;s exe with the null byte given the compiler&#8217;s exe size.</span><br />
<span style="color:#00ccff;"> Position the rider&#8217;s token on the rider&#8217;s source.</span><br />
<span style="color:#00ccff;"> Pluralize the type&#8217;s plural name.</span><br />
<span style="color:#00ccff;"> Link.</span><br />
<span style="color:#00ccff;"> Finalize the compiler.</span><br />
<span style="color:#00ccff;"> Check for invalid optional info on the type.</span></p>
<p>And that’s why we say that <em>most </em>of what <em>most </em>programs do is easy stuff, stuff that can be conveniently expressed in a natural language. And that, in turn, is why we like programming in Plain English: the thoughts in our heads are typed in as Plain English “pseudo code” and, with a tweak here and there, that pseudo code actually compiles and runs. And is self-documenting, to boot.</p>
<p><strong>Another Objection Answered</strong></p>
<p>You may be thinking that natural language is just too verbose for programming. But is it really that bad? Let’s consider a couple of examples. In a traditional programming langauge, we might draw a box using a statement like this:</p>
<pre><code>substring.draw ( box, color, source.text.font, source.text.alignment ) ;</code></pre>
<p>Which is 10 words and 11 punctuation marks: 21 total elements.</p>
<p>The Plain English equivalent would be:</p>
<p><span style="color:#00ccff;">Draw the substring in the box with the color and the source&#8217;s text&#8217;s font and alignment.</span></p>
<p>Which is 16 words and 3 punctuation marks: 19 total elements.</p>
<p>Admittedly, the Plain English version requires a few more easy-to-type alphabetic characters (it’s difficult to say exactly how many since traditional coders put spaces in different places); but that’s a small price to pay for not having to learn (or think in) an artificial syntax.</p>
<p>Here’s another example:</p>
<pre><code>if ( ! source.colorized ( ) ) color = black ;</code></pre>
<p>Which is 5 words and 8 punctuation marks: 13 total elements.</p>
<p>Compared with the Plain English:</p>
<p><span style="color:#00ccff;">If the source is not colorized, put black into the color.</span></p>
<p>Which is 11 words and 2 punctuation marks: 13 total elements.</p>
<p>Again, it’s mostly a matter of whether you like to type words or (specialized) punctuation. And whether you like to think in two different syntactical and grammatical forms simultaneously. And whether you want your code to be self-documenting. And whether you want code that’s friendly for beginners. And whether you want to code in a language (like English) that will still be in common use 100 years from now. Personally, we think you may have lost some <em>human </em>perspective if you’ve come to think that “(!source.colorized())” is a good way of saying anything!</p>
<p><strong>The Prototype</strong></p>
<p>If you’re interested, you can download the whole shebang here:</p>
<p><a href="http://www.osmosian.com/cal-4700.zip" target="_blank" rel="noopener noreferrer">www.osmosian.com/cal-4700.zip</a></p>
<p>It’s a small Windows program, less than a megabyte in size. But it’s a complete development environment, including a unique interface, a simplified file manager, an elegant text editor, a handy hexadecimal dumper, a native-code-generating compiler/linker, and even a wysiwyg page layout facility (that we used to produce the documentation). It is written entirely in Plain English. The source code (about 25,000 sentences) is included in the download. No installation is necessary; just unzip. Start with the “instructions.pdf” in the “documentation” directory and before you go ten pages you won’t just be writing “Hello, World!” to the screen, you’ll be re-compiling the entire thing in itself (in less than three seconds on a bottom-of-the-line machine from Walmart).</p>
<p>Thanks for your time and interest.</p>
<p><img loading="lazy" class="alignnone size-full wp-image-286820" src="https://cdncontribute.geeksforgeeks.org/wp-content/uploads/me-pixels-2.png" alt="" width="115" height="115" /><br />
Gerry Rzeppa<br />
Grand Negus of the Osmosian Order of Plain English Programmers</p>
<p><img loading="lazy" class="alignnone size-full wp-image-286818" src="https://cdncontribute.geeksforgeeks.org/wp-content/uploads/dan-pixels-1.png" alt="" width="115" height="115" /><br />
Dan Rzeppa<br />
Prime Assembler of the Osmosian Order of Plain English Programmers</p>
</div>
]]></html><thumbnail_url><![CDATA[https://i0.wp.com/cdncontribute.geeksforgeeks.org/wp-content/uploads/me-pixels-2.png?fit=440%2C330&ssl=1]]></thumbnail_url><thumbnail_width><![CDATA[115]]></thumbnail_width><thumbnail_height><![CDATA[115]]></thumbnail_height></oembed>