需要学习的是编程,而不是编程语言(译)

信息来源:阮一峰每周分享

文章来源:Learning programming is different from learning a programming language


Learning programming is different from learning a programming language

We are all programmers, and we are all learners. It's surprising to see how many people(learners) who are bashing their head against the walls thinking they are learning to programme.

我们是程序员,但同时我们也是学员。令人惊讶的是许多钻进死胡同的人(学员)以为他们正在学习编程。

You might be learning a programming language instead of programming itself

你可能在在学习编程语言而非编程本身

Don't feel surprised to know that computer science does not study computers. Instead, it's the study of automated problem solving using. Problem-solving is computer science, not programming. That's why many computer science students seem not to understand why they learn algorithm or mathematics.

计算机科学不用来研究计算机,知道这个后不要感觉惊讶。相反,计算机科学是用来研究如何使用自动化解决问题的。计算机科学是为了解决问题的,而不是编程。这也就是许多计算机科学的学生对他们要学习算法和数学感到不解的原因。

If you have been to a computer science class before, you won't be surprised by what I am saying here. Because you would have noticed that programming has few to do with programming languages. Ask yourself why the pseudo code is so common in those classes.

如果你之前上过计算机科学的相关课程,你就会对我现在所说的话不会感到惊奇。因为你已经注意到编程其实和编程语言没有太大关系。不信你问一下自己为什么伪代码在课堂中使用得如此广泛。

But, most self-thought programmers always fall into the trap. We learn programming language for decades before we realize what exactly we've got to do: programming. I myself have been a victim.

不过,大多数自己思考问题的程序员都会掉入这种陷阱,我们学了数十年编程语言后才明白我们最应该学的是什么:是编程而不是编程语言,我自己也是这些观念的受害者。

I took more than a decade learning bit by bit various programming languages. The more I learn, the harder it is to build something simple. I have had that sensation of not finding the right tool. But, the issue is that I forgot to look for the right job to do instead of the right tool when I don't even know the job to do.

我花了十多年一点一点地学习了各种编程语言,学的语言越多,越难以构建一些简单的程序,我当时觉得是自己没有找到合适的工具。但问题是,当我甚至不知道要做的工作时,我忘了去寻找合适工作,而是专注于合适的工具。

And the strange things with programming languages is that they always evolve. Programming languages change almost every single day. It's very hard to follow up. And most good programs use only a little part of a programming language.

另外,与编程语言相关的奇怪问题也是不断发展变化着的,编程语言几乎每一天都在变化,你很难时刻跟进,而且许多编程高手也仅仅只是用了编程语言的一小部分特性。

The problem with learning programming languages first is like learning how to use a carpenter saw, a hammer, and all sort of cutting machines before learning carpentry. Carpentry requires attention: ideas, analysis of feasibility, measurements, tests, customer behavior. The boss carpenter will be more interested in those things than the hammer and nails. During his scientific study of the job, he would also take time to check the quality of the nails, colorants, woods, etc.

学习编程语言时遇到的第一个问题就像木匠在学习木工之前要学习如何使用木工据、锤子和各种切割机。木工需要重视:创意、可行性分析、测量、测试、顾客行为喜好。老木匠比较重视的是上面提到的这些,而不是锤子或者钉子,在他们进行专业学习期间,他们也会花时间检查一下钉子、着色剂、木材等工具的质量。

What is the difference between learning programming and learning a programming language?

学习编程和学习一门编程语言究竟有什么不同?

To program is setting a system free to operate by giving it instructions only once. We do that every day in everything. We teach our kids, our soldiers, our customers. We give them or we receive instructions to be free/independent to live in a given way. Your parent doesn't need to follow you and instruct you on every move you make in your life. They would have already programmed you in many aspects of life.

编程是通过给予仅有的一次指令来让系统自己运行起来,我们每个人每天都在做这样的的事情。我们教育孩子,训练士兵,与顾客交流,我们给予他们一些指令信息同时也受到一些来自他们的指令信息来自由或独立地生活在特定的环境中。你的父母不需要一直跟着指导你人生中的每一步该怎么走,他们已经在你生活的各个方面对你产生了类似于向你发送“指令信息”的影响。

Most schools and educational websites will teach a programming language's syntax. They could add some design patterns(while you ignore what exactly design is), a few arithmetic calculations, how variables are declared and how to use them, the data types and how to declare/create them.

多数学校和在线教育网站会教一些编程语言的语法知识,他们还可以增加一些设计模式(而设计模式到底是什么正是你所忽略的)、一些算术计算、变量应该怎么声明和使用、数据类型以及数据类型的声明和创建。

This does not teach you reasoning. With such method, you will discover reasoning methods, but later. It will make you feel like you wasted or it took a lot of time to learn to program.

这不是在教你推理,而是有了上面的这些方法,你会自己发现推理方法,但是是在很久以后的事了。这会让你觉得你为了学习编程花费太多时间啦。

We solve problems with programming and programming languages are tools which help us do that.

我们通过编程解决一些问题,而编程语言就是我们解决问题的工具。

They are like tool boxes. We call them frameworks. They help you organize your thoughts.

编程语言就像是工具箱,我们称之为框架,框架可以帮助你整理和组织思路。

If you are learning to programme and you can't still plan and code a real application, it means you are learning more about the programming language than programming.

如果你正在学习编程并且你还不会规划和编码一个实际的应用,这意味着你更多的是在学习编程语言而不是编程本身。

How many time do we meet people(learners) who still wonder how to create a program. To a programmer, a program is a problem to solve. He solves it with critical analysis, before even involving any programming language. When you solve any problem, it can be coded in any programming language. Let's take the case of the square. To square something, we times it by itself. We could have it implemented in various languages like:

有多少次我们遇到那些想知道如果创建一个程序的初学者?对程序员来说,编程就是解决问题,在引入任何编程语言之前已经通过辨证分析解决掉了问题。当你解决了一个问题,你可以用任何编程语言来实现它。我们以求平方值为例,求某个数的平方,我们用它自身来乘以自身,我们可以通过多种编程语言实现它,比如=:

In C
function square(int * x) {
    return x * x;
}

In PHP
function square ($x){
    return $x * $x;
}

In Javascript
function square(x){
    return x * x
}

In Scheme (a Lisp dialect)
(define (square x) (* x x))

You can notice that only the syntax matters in the implementations. The solution is the same. And this is one of the main reasons why you can almost use any programming language at which you are more comfortable to build any type of software.

你应该能注意到在实现过程中只有语法是不同的,解决问题的方法都是一样的。这就是你几何可以使用任意一种你用起来觉得舒服的编程语言来构建任意你想构建的软件程序。

It's easier to discover a language through programming

通过编程更容易探究一门语言

The issue generally is the human language. The human language is fraught with limitation and errors. It's impossible to use to instruct machines since they can't feel.

人类的语言充满限制和错误,不可能用于控制机器运作因为机器根本理解不了。

When learning to programme, you would learn a new jargon and new tools to help you write your logic in a manner that computers or other programmers could understand and agree on.

学习编程时,你会学习使用一些行话和新的工具来帮助你以一种计算机和其他编程人员可以理解和赞成的方式编写逻辑代码。

Usually, you would start from a simple and human-language-like symbolic called pseudo code. It's a good transition tool from human language to computer programming language. That is usually done to prevent you from wasting time on the language. That way you have full focus on reasoning. Through that, you will discover core parts that make up a good programming tool(language). You understand what exactly is needed. You understand the core goals of a programming language. With that, you learn it without realizing when you did it.

通常,你会以一种简单的、人性化的伪代码开始学习编程,这是一种很好的用于从人类语言到计算机编程语言过渡的工具。这通常会防止你在语言上浪费太多时间,让你完全专注于推理。通过上述方式,你就可以发现一个编程工具或编程语言最核心的组成部分,你就会明白什么是真正需要学习的,明白一个编程语言最核心的目标是什么。通过上面讲的,你就会在无意识的情况下学习到了编程。


2018.11.16 北京 晴 无霾

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 162,050评论 4 370
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,538评论 1 306
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 111,673评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,622评论 0 218
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,047评论 3 295
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,974评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,129评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,893评论 0 209
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,654评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,828评论 2 254
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,297评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,619评论 3 262
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,326评论 3 243
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,176评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,975评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,118评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,909评论 2 278

推荐阅读更多精彩内容