📜  自然语言编程——教孩子

📅  最后修改于: 2021-10-22 02:52:29             🧑  作者: Mango

在 Osmosian Order of Plain English Programmers,我们采用不同的方法教孩子们如何编程。

界面

我们做的第一件事是消除所有不必要的和分散注意力的杂物。例如,这就是我们的全屏集成开发环境 (IDE) 的样子:

按字母顺序排列的菜单和顶部的状态消息字段、中间的工作区和底部的选项卡。没有窗口边框、小部件、图标、工具栏和调色板。因此,我们鼓励学生专注于前景中的内容,而不是背景(我们将其留在背景中它所属的地方)。哎呀!差点忘了。没有滚动条。曾经。鼠标右键用于移动内容——水平、垂直和/或对角线——并且增量查找工具用于在大文件中“跳跃”(可惜已故,伟大的杰夫拉斯金)。还可以直观地使用 Home、End、Page Up、Page Down 和箭头键来根据需要更改焦点。

文件系统使用完整路径名向程序员公开。这是给程序员的唯一视图:在“打开”和“另存为”对话框中没有图标,也没有替代视图(因为我们不使用或不需要对话框)。因此,学生们将了解在他们的程序中引用文件所需的确切语法,并且他们只需要在他们萌芽的大脑中维护一个文件系统的单一心理图像。

我们学生的申请也很整洁。当他们清除屏幕时,它会被擦除为黑色,从上到下和从一边到另一边。他们的应用程序是真实的本地程序,可以访问整个屏幕(和计算机),因此他们的梦想可以完全按照他们的想象实现。没有沙箱。

语言

我们方法的第二个区别是我们使用自然的英语句子进行编程。我们的“关键字”是冠词(如aanthesome )和介词(如inofwith等),而不是像 CONST 和 EVAL 和 INSTANCEOF 这样的晦涩词(从技术上讲,它们不是真正的词全部)。

我们还重点关注语义(说什么)而不是语法(如何说)。简单英语的例程通常有多个标题,因此可以通过多种方式调用它们。这个例程,例如……

To erase the screen;
To blank out the screen;
To wipe off the screen;
To clear the screen:
Unmask everything.
Draw the screen's box with the black color and the black color.
Refresh the screen.
Put the screen's box into the context's box.

……可以用四种不同的方式来称呼:

Erase the screen.
Blank out the screen.
Wipe off the screen.
Clear the screen.

熟悉学生通常说话方式的熟练教师通常会提供常用例程的预编码库,并带有“当地方言”标题。还鼓励学生通过向现有库添加头文件以及开发自己的库来教编译器像他们一样说话(和思考)。

深度

我们方法的第三个区别是,我们对新手和专家都使用相同的界面和语言。这一个给孩子们的系统,但它不仅仅是一个给孩子们的系统。我们自己使用这种界面和语言来方便有效地创建整个shebang:整洁的桌面、简化的文件管理器、优雅的文本编辑器、方便的十六进制转储器、生成本机代码的编译器/链接器以及用于文档和其他的所见即所得页面布局工具创意写作和绘画任务。所以当学生准备深入挖掘时,他可以简单地挖掘。他不必投资新铲子或寻找另一块土地。一切尽在一处,来自“Hello, World!”到机器码。

你好世界!

说到“Hello, World!”,这是我们经常用来说明序列、条件语句和循环的基本概念的一个版本。这是我们告诉学生输入的内容:

To run:
Start up.
Clear the screen.
Use medium letters. Use the fat pen.
Pick a really dark color.
Loop.
Start in the center of the screen.
Turn left 1/32 of the way.
Turn right. Move 2 inches. Turn left.
Write "HELLO WORLD".
Refresh the screen.
Lighten the current color about 20 percent.
Add 1 to a count. If the count is 32, break.
Repeat.
Wait for the escape key.
Shut down.

这就是他们在运行程序时在屏幕上看到的内容(使用运行命令,该命令位于“R”菜单下,方便直观):

沙漠景观

编程是一种文本式的左脑活动。但是当学生的大脑两边都参与时,他们的学习效果最好。因此,我们的大多数介绍性练习都会产生鼓舞人心的图形输出,以活跃大脑半球和连接它们的胼胝体。这是另一个示例程序:

To run:
Start up.
Draw a desert landscape.
Wait for the escape key.
Shut down.

To draw a desert landscape:
Clear the screen.
Draw the sky.
Draw the sun.
Draw the birds.
Draw the sand.
 
To draw the sky:
Use the lightest sky blue pen.
Imagine a line across the middle of the screen's box.
Loop.
Draw the line.
Refresh the screen.
Darken the current color about 3 percent.
Move the line up 1 pixel.
If the line is above the screen's box's top, break.
Repeat.
 
To draw the sun:
Pick a spot anywhere in the top middle 1/4 of the screen's box.
Make a dot between 1/4 inch and 1 inch wide.
Center the dot on the spot.
Draw the dot with the lightest yellow color.
 
To draw the birds:
Pick a spot in the screen's box about 1 inch above the middle.
Use the black pen.
Loop.
Move to the spot.
Face east.
Pick a width between 1/8 inch and 1/4 inch.
Draw a quarter circle given the width.
Turn around.
Draw another quarter circle given the width.
Move the spot about 1/2 inch in any direction.
Add 1 to a count. If the count is 3, break.
Repeat.
 
To draw the sand:
Use the lightest orange pen.
Imagine a line across the middle of the screen's box.
Loop.
Draw the line.
Refresh the screen.
Darken the current color about 3 percent.
Move the line down 1 pixel.
If the line is below the screen's box's bottom, break.
Repeat.

请注意矢量图形和海龟图形的无缝集成。这是程序产生的艺术品类型:

视错觉

视错觉总是有趣和鼓舞人心的。这是我个人的最爱之一:

To run:
Start up.
Draw the crooked line illusion.
Wait for the escape key.
Shut down.
 
To draw the crooked line illusion:
Clear the screen.
Use the fat pen.
Imagine a big box 4 inches smaller than the screen's box.
Imagine a line across the top of the big box.
Imagine a small box 1/2 inch by 1/2 inch.
Move the small box to the top left corner of the big box.
Loop.
Draw and fill the small box with the white color.
Move the small box right 1 inch.
Refresh the screen.
If the small box is still in the big box, repeat.
Move the small box close to the left side of the big box.
Draw the line with the red color.
Move the line down 1/2 inch.
Move the small box down 1/2 inch.
If the small box is still in the big box, repeat.
Draw the line with the red color.
Use medium letters.
Write "THE RED LINES ARE ALL STRAIGHT AND PARALLEL."
with the gold pen at the bottom of the screen's box.
Refresh the screen.

您将需要一个标尺来检查此结果:

结论

我们相信,未来的程序员会像我们今天“编程”Amazon Echo 或Apple Siri 或Google home 或Microsoft Cortana 一样对他的机器进行编程。例如,当我妻子说:

"Echo, set a timer for 12 minutes. Then play a song by the Beatles."

她正在用英语编写和执行一个简短的程序。现在,如果上面列出的设备本身是用英语编程的,那么我们真的走在正确的轨道上。我们的普通英语原型证明了这种方法的可行性。毕竟,如果我们能方便地用英文写出一个完整而高效的Compiler和IDE,为什么不做一个自动化助手呢?这是 21 世纪,我最后一次检查。为什么我们的用户程序员不应该用我们用来互相交谈的同一种语言与我们的机器交谈?