用画笔编程,而非铅笔。
Program with Paint Brushes, Not Pencils

原始链接: https://blog.pickcode.io/program-with-paint-brushes-not-pencils/

2022 年,作者创建了一个名为“PaintBrush”的 Python 类,旨在通过创意视觉项目引导高中生学习编程。尽管如今人工智能可以在几秒钟内生成此类代码,但作者认为这些课程依然至关重要。教育者不应将人工智能视为威胁,而应利用它快速构建各种全新的抽象工具(如音乐合成器或数据可视化工具),从而让学生保持创造力挑战。 其目标是将重心从容易诱发人工智能“走捷径”的枯燥重复性任务,转向能够让学生获得成就感与自我效能感的有意义项目。通过将高阶抽象作为创意表达的工具,教师可以激发学生的内在参与度,鼓励他们亲手编写代码——这并非因为他们缺乏人工智能助手,而是因为创作过程本身真实、具有表现力且充满乐趣。归根结底,利用大语言模型快速生成新工具,使教育者能够不断更新课程,从而确保每一位学生的学习体验都既有收获又独具个人色彩。

```Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 用画笔编程,而非铅笔 (pickcode.io) 5 分 | skadamat 发布于 2 小时前 | 隐藏 | 往期 | 收藏 | 1 条评论 | 帮助 Lerc 7 分钟前 [–] 我觉得这话有道理。我为 9 岁孩子准备的入门程序是: print("draw with the arrow keys"); var cx=320; var cy=240; function move() { if (keyIsDown(38)) cy-=1; if (keyIsDown(40)) cy+=1; if (keyIsDown(37)) cx-=1; if (keyIsDown(39)) cx+=1; } function draw() { fillCircle(cx,cy,6); } run(move,draw); 我想从那时起,我把 keyIsDown 改成了 keyHeldDown [配合 keyWentDown 使用] 作为补充。再加上 https://fingswotidun.com/code/index.php/Keycodes ,这就能实现一个“绘图画板”程序,并提供了足够的信息教他们如何将其转换为 WASD 操作,这似乎是 9 岁孩子的一种普遍冲动。 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

In 2022 while I was still teaching high school CS, I wrote a Python class called PaintBrush for my students to use. This took 20-30 minutes on a Sunday afternoon with my laptop and a cup of coffee. Today, that code could be written by Claude in 20-30 seconds.

In 2022, my goal was to get students motivated with a lesson where their code could do something visual and fun. Today, this sort of lesson serves that same purpose and can help serve another: motivating students to write code by hand when an LLM could easily do it for them.

Let’s get concrete and look at how the PaintBrush lesson worked.

import turtle
import random

class PaintBrush():
  def __init__(self):
    self.t = turtle.Turtle()
    self.t.color("black")
    self.t.width(3)
    self.t.speed(6)
    self.t.hideturtle()
    self.randomness = 0
    
  def line(self, x1, y1, x2, y2):
    self.t.penup()
    def get_delta():
      return random.randint(-self.randomness * 5, self.randomness * 5)
      
    self.t.goto(x1 + get_delta(), y1 + get_delta())
    self.t.pendown()
    
    self.t.goto(x2 + get_delta(), y2 + get_delta())

  def setrandomness(self, amount):
    self.randomness = amount

  def setcolor(self, color):
    self.t.color(color)

  def setwidth(self, width):
    self.t.width(width)

With this class, students could write code like:

from paint import PaintBrush

brush = PaintBrush()

# Draws the letter C
brush.setrandomness(0)
brush.setwidth(10)
brush.line(-50, 100, -100, 100)
brush.line(-100, 100, -100, 0)
brush.line(-100, 0, -50, 0)

A PaintBrush object works differently than the turtle class that is so familiar in the history of CS pedagogy, allowing students to draw lines between specific coordinates in the plane. The PaintBrush class is an abstraction for students. 

Here were the instructions I gave students after we reviewed the basics of the PaintBrush together:

In 2022, students wrote this code by hand, because there wasn’t another option. My hypothesis is that in 2026, students would be more likely to write code by hand for this lesson because of how easy it is to produce tangible results. 

If lessons are repetitive, tedious, or overly prescriptive, I wouldn’t blame a student for generating code with AI. “Write a loop to print a multiplication table” should yield different student engagement from “can you use a concept we know to make 1000 lines in your painting?”

The specifics of the PaintBrush lesson aren’t as important as the overall concept. Programming is a tool for creative expression, and high-level abstractions allow students to engage with programming in different ways. If print statements are pencils in art class, abstractions like PaintBrush are, well, paint brushes.

The PaintBrush here isn’t unique in being a “paint brush”. Turtle, processing, and pygame are all abstractions in this vein. However, any individual abstraction is not interesting to students for long. Your twelfth turtle drawing doesn’t “hit” with the same excitement as the first or second. 

Because of the speed with which teachers can generate new abstractions with LLMs, we aren’t stuck pulling just from the existing menu. We can write code that lets students easily make music, data visualizations, photo filters, games, videos, etc. 

With the right abstractions, I believe we can convince students to interact with the code itself without using AI as a shortcut. It doesn’t matter if an LLM could generate their code more quickly. Learning to program is about fostering a sense of self efficacy and pride in students as they create work that’s authentically theirs. We need every tool we can find to help students see that.

联系我们 contact @ memedata.com