Doug Slater 10月02日
初学者编程教学:函数式vs命令式
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

对于初学者,函数式编程和命令式编程的教学顺序取决于学习者的背景。教学应从学习者熟悉的知识点出发,逐步引入新概念。例如,从简单的数量认知(如数点)开始,再引入算术。MIT的SICP课程侧重函数式编程,但并非适合所有人。学习者可能更习惯从底层硬件(如晶体管)理解编程,或从数学函数概念入手。最佳方法是早期接触多种编程范式,并以学习者已有的知识为基础进行教学,培养多层次的抽象思维能力。

📚教学应从学习者熟悉的知识点出发,逐步引入新概念,例如从简单的数量认知到算术,帮助学习者建立知识联系。

🔄MIT的SICP课程侧重函数式编程,但并非适合所有人,部分学习者可能需要从底层硬件(如晶体管)或数学函数概念入手才能更好地理解。

🌐最佳方法是早期接触多种编程范式,并以学习者已有的知识为基础进行教学,培养多层次的抽象思维能力,适应不同学习风格。

🔗函数式编程和命令式编程的教学顺序取决于学习者的背景,教学应灵活调整,确保学习者感到舒适和 grounded。

🧠学习者需要意识到不同编程范式之间的联系,例如函数式编程中的monads最终也是内存中的 bits,命令式编程中的寄存器分配虽重要但并非核心。

In the alum chat for Mirdin, someone posted the following question, "Would it be better to start teaching beginners functional or imperative programming first?"

Pretending for a second that FP and IP are the only choices (they're not), an answer depends on where your beginner comes from.

A meta-pedagogical (teaching about teaching) answer acknowledges that learning starts in a place the learner feels grounded and connects them from there to new knowledge. For example, subitizing is an innate ability. A developmentally normal child can instantly know how many objects are presented, for values up to about 5.

Image: How many dots are there? You just subitized.

From there, you can teach a 5-year-old arithmetic, for example to add, by having them subitize groups of objects alongside numerals and the math symbol +. This connects their innate notion of quantity to the abstract notion of numbers.

The MIT book and course SICP is a masterpiece in programming pedagogy, and it falls heavily on the FP side. Watch Professor Sussman absolutely rip apart side effects in lecture 5A. But not everybody "gets" this approach easily. Even Hal acknowledges in this Corecursive interview that the FP approach didn't work for everyone:

In the very beginning days, we would teach a sort of short courses for MIT faculty and some of the electrical engineers would just get stuck. "You haven’t showed us how the transistors work". ...People think different ways. Some people have to be grounded on where they’re comfortable and for some people, well, it really is transistors.

Contrast that to somebody who knows what a function is, in the math sense. The machinery of a transistor, of gates, sources, drains, and TTL will be an irritating detail, like multiplying matrices by hand.

So in the dichotomy between introducing FP and IP first, the answer might depend on where the learner is coming from. I learned IP and OOP first because that's what material was available. I was first exposed to FP in college in the form of Scheme. It was disorienting. I couldn't count all the parentheses, let alone grok tail recursion. I wish it could have been presented to me grounded in terms of what I was already comfortable with, for example high school algebra.

I say, introduce multiple programming paradigms early, and ground it in what the learner knows. A fundamental programming skill is to think at multiple levels of abstraction. The Haskell programmer needs to be aware that even monads at some point are just bits in a memory hierarchy, just as it's important for an assembly programmer to know that while register allocation is critical to performance, registers are not really what the program is about.

To close, let's ground this discussion in something we all know. To design a cathedral, the architect needs to know what bricks will be used. To build a cathedral, the bricklayer needs to envision the noble end to which each brick is set down.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

编程教学 函数式编程 命令式编程 初学者 教学范式
相关文章