我正在寻找最酷的事情,你可以在几行简单的代码。我相信你可以用Haskell用15行写一个Mandelbrot集,但是很难理解。

我的目标是启发学生编程很酷。

我们知道编程很酷,因为你可以创造任何你想象到的东西——它是最终的创意出口。我想激励这些初学者,让他们尽可能多地克服早期学习的困难。

Now, my reasons are selfish. I'm teaching an Intro to Computing course to a group of 60 half-engineering, half business majors; all freshmen. They are the students who came from underprivileged High schools. From my past experience, the group is generally split as follows: a few rock-stars, some who try very hard and kind of get it, the few who try very hard and barely get it, and the few who don't care. I want to reach as many of these groups as effectively as I can. Here's an example of how I'd use a computer program to teach:

Here's an example of what I'm looking for: a 1-line VBS script to get your computer to talk to you: CreateObject("sapi.spvoice").Speak InputBox("Enter your text","Talk it") I could use this to demonstrate order of operations. I'd show the code, let them play with it, then explain that There's a lot going on in that line, but the computer can make sense of it, because it knows the rules. Then I'd show them something like this: 4(5*5) / 10 + 9(.25 + .75) And you can see that first I need to do is (5*5). Then I can multiply for 4. And now I've created the Object. Dividing by 10 is the same as calling Speak - I can't Speak before I have an object, and I can't divide before I have 100. Then on the other side I first create an InputBox with some instructions for how to display it. When I hit enter on the input box it evaluates or "returns" whatever I entered. (Hint: 'oooooo' makes a funny sound) So when I say Speak, the right side is what to Speak. And I get that from the InputBox. So when you do several things on a line, like: x = 14 + y; You need to be aware of the order of things. First we add 14 and y. Then we put the result (what it evaluates to, or returns) into x.

这就是我的目标,有一堆很酷的例子来演示,并在他们玩得开心的时候教他们。我在我室友身上尝试了这个例子,虽然我可能不会把它作为第一课,但她喜欢它,并学到了一些东西。

一些很酷的数学程序,可以做出漂亮的图形或容易理解的形状,这是很好的想法,我将研究这些。这里有一些复杂的actionscript示例,但这有点太高级了,我不能教flash。你还有什么其他的想法吗?


当前回答

我给有学习障碍的11-12岁学生上过课。我们使用Hypercard,他们发现他们可以记录物体(图像,盒子等)的位置,因为他们移动它,并播放它(动画)。虽然这不是编码,但他们想做的是:删除其中一个动作,而不重新记录它。我告诉他们,他们必须去查看代码并修改它。

你可以看出谁有计算机/编程的诀窍,当他们更喜欢用代码来做的时候,因为他们有更多的控制权。

在Excel中做一个复杂的宏,然后学习代码在做什么,这可能是通往VBA的门户。

根据年龄群体或兴趣水平的不同,直接进入代码可能很难,但最终是重要的。

其他回答

我记得我发现简单的循环很神奇。每次我学习一门新语言,我通常会把这样的东西放在一起:

<?php
$numberOfBottles = 99;
print("<h1>$numberOfBottles Bottles of Beer on the Wall</h1>");
print("$numberOfBottles bottles of beer on the wall,<br />");
print("$numberOfBottles bottles of beer!<br />");
print("Take one down, pass it around,<br />");
for($numberOfBottles--; $numberOfBottles>1; $numberOfBottles--)
{
    print("$numberOfBottles bottles of beer on the wall!<br />");
    print("<br />");
    print("$numberOfBottles  bottles of beer on the wall,<br />");
    print("$numberOfBottles  bottles of beer!<br />");
    print("Take one down, pass it around,<br />");
}
print("One last bottle of beer on the wall!");
?>

也许一些while或foreach循环的变化也会很容易。

和大多数其他评论者一样,我开始写代码是为了解决数学问题(或者为我所设计的糟糕游戏创造图像,如《夺宝奇兵大战僵尸》)。

真正让我开始学习数学和编程的是基于文本,选择自己的冒险风格的游戏……转向更多基于图像的游戏。我一开始是给图纸上色和绘制像素,直到我接触到几何……发现了如何用方程来画曲线、直线、方框等。

我的观点是,我可以真正进入处理(http://processing.org/),其中典型的程序看起来像这样:

void setup() 
{
  size(200, 200); 
  noStroke();
  rectMode(CENTER);
}

void draw() 
{   
  background(51); 
  fill(255, 204);
  rect(mouseX, height/2, mouseY/2+10, mouseY/2+10);
  fill(255, 204);
  int inverseX = width-mouseX;
  int inverseY = height-mouseY;
  rect(inverseX, height/2, (inverseY/2)+10, (inverseY/2)+10);
}

对我来说,这就是未来的“Logo”。

这里有一些简单的“hello world”示例,可以让人们快速地绘制和更改代码,并看到事情是如何崩溃的,以及会产生哪些奇怪的“意外”……一直到更高级的交互和分形创造……

首先,为了在最短的时间内获得最大的关注,你需要使用高级语言。 可能你会想要显示3D。

我会选择Opengl——我首先展示一个3d电脑游戏中的短场景,然后解释,这是通过将大程序划分为小部分来完成的,然后向他们展示小部分的样子。 比如nehe.gamedev.net上的第05课,或者更高级的课程。 这很令人印象深刻,也不太复杂。

此外,你可能想检查Alice,它包含3d,被设计用来教学。

当我第一次写这个的时候。

10 PRINT "What is your name?"
20 INPUT A$
30 PRINT "Hello " A$
40 GOTO 30

它把人们都惊呆了!电脑记住了他们的名字!

编辑:只是补充一下。如果你能说服一个新程序员,这是他们能做的最酷的事情,他们就会成为优秀的程序员。现在,您几乎可以用一行代码来运行别人编写的库。就我个人而言,这样做绝对不会让我感到满足,也看不到教它有什么好处。

你可能会考虑像Robocode这样的东西,其中大量的代码被抽象出来,你基本上只是告诉机器人做什么。一个简单的10行函数可以让机器人做很多事情,并且有一个非常直观和易于遵循的结果。

也许Robocode本身并不适合这项任务,但这种东西是一种将编写的代码与计算机上的可视操作联系起来的好方法,而且当你需要给出示例时,它很有趣。

public class MyFirstJuniorRobot extends JuniorRobot {
 public void run() {
  setColors(green, black, blue);
  // Seesaw forever
  while (true) {
   ahead(100); // Move ahead 100
   turnGunRight(360); // Spin gun around
   back(100); // Move back 100
   turnGunRight(360); // Spin gun around
  }
 }
 public void onScannedRobot() {
  turnGunTo(scannedAngle);
  fire(1);
 }
 public void onHitByBullet() {
  turnAheadLeft(100, 90 - hitByBulletBearing);
 }
}