首页 > 编程知识 正文

编程语言之间的相互转换,只有两种编程语言

时间:2023-05-04 11:19:30 阅读:205306 作者:4415

两种编程语言转换

Editor’s Note: Learning multiple languages is key to anyone’s success as a programmer. Dr. Russel Winder gained experience with learning and teaching multiple languages first as Professor of Computing Science and head of the department of computer science at zxdz’s College London, then later working at various startups. Now retired, he continues to share his passion for learning programming languages, and here shares how learning multiple languages and paradigms can change your approach to programming for the better.We’d love to know your thoughts on this piece from 97 Things Every Programmer Should Know.

编者注: 学习多种语言是任何人成功成为程序员的关键。 Russel Winder博士首先担任计算科学教授和伦敦国王学院计算机科学系主任,在学习和教授多种语言方面积累了经验,随后又在多家初创公司工作。 现在退休了,他继续分享他对学习编程语言的热情,并在这里分享了学习多种语言和范式如何使您的编程方法变得更好的方法。我们很乐意从 每个程序员应该做的97件事中 了解您对这一部分的想法 知道了 。

程序设计心理学 (The Psychology of Programming)

People have known for a long time now that programming expertise is related directly to the number of different programming paradigms that a programmer is comfortable with — that is, not that he just knows about or knows a bit of, but that he can genuinely program with.

人们很久以来就已经知道编程专业知识与程序员可以适应的不同编程范式的数量直接相关,也就是说,不是他只是知道或不知道一点,而是他可以真正地使用。

Every programmer starts with one programming language. That language has a dominating effect on the way that programmer thinks about software. No matter how many years of experience the programmer gets using that language, if she stays with that language, she will know only that language. A one-language programmer is constrained in her thinking by that language.

每个程序员都从一种编程语言开始。 该语言在程序员思考软件的方式上起着主要作用。 不管程序员使用该语言有多少年的经验,如果她坚持使用该语言,那么她只会知道该语言。 一种语言的程序员在该语言中受到了限制。

A programmer who learns a second language will be challenged, especially if that language has a different computational model than the first. C, Pascal, Fortran — all have the same fundamental computational model. Switching from Fortran to C introduces a few, but not many, challenges. Moving from C or Fortran to C++ or Ada introduces fundamental challenges in the way programs behave. Moving from C++ to Haskell is a significant change and hence a significant challenge. Moving from C to Prolog is a very definite challenge.

学习第二语言的程序员将面临挑战,尤其是如果该语言与第一语言具有不同的计算模型时。 C,Pascal和Fortran都具有相同的基本计算模型。 从Fortran切换到C带来了一些但不是很多挑战。 从C或Fortran迁移到C ++或Ada带来了程序行为方面的根本挑战。 从C ++迁移到Haskell是一个重大的变化,因此是一个巨大的挑战。 从C转移到Prolog是一个非常明确的挑战。

We can enumerate a number of paradigms of computation: procedural, object-oriented, functional, logic, dataflow, etc. Moving among these paradigms creates the greatest challenges.

我们可以列举许多计算范例:过程,面向对象,功能,逻辑,数据流等。在这些范例之间移动会带来最大的挑战。

Why are these challenges good? That has to do with the way we think about the implementation of algorithms and the idioms and patterns of implementation that apply. In particular, cross-fertilization is at the core of expertise. Idioms for problem solutions that apply in one language may not be possible in another language. Trying to port the idioms from one language to another teaches us about both languages and about the problem being solved.

为什么这些挑战很好? 这与我们思考算法的实现方式以及适用的实现方式和模式有关。 特别是,交叉施肥是专业知识的核心。 可能无法使用另一种语言来提供适用于一种语言的问题解决方案的成语。 尝试将习惯用语从一种语言移植到另一种语言,可以使我们了解两种语言以及要解决的问题。

Cross-fertilization in the use of programming languages has huge effects. Perhaps the most obvious is the increased and increasing use of declarative modes of expression in systems implemented in imperative languages. Anyone versed in functional programming can easily apply a declarative approach even when using a language such as C. Using declarative approaches generally leads to shorter and more comprehensible programs. C++, for instance, certainly takes this on board with its wholehearted support for generic programming, which almost necessitates a declarative mode of expression.

在编程语言中使用交叉施肥会产生巨大的影响。 也许最明显的是在以命令式语言实现的系统中越来越多地使用声明式表达方式。 精通函数式编程的任何人都可以轻松地使用声明性方法,即使在使用诸如C之类的语言时也是如此。使用声明性方法通常会导致程序更短,更易于理解。 例如,C ++无疑会以其对泛型编程的全力支持来支持这一点,这几乎需要一种声明式的表达方式。

The consequence of all this is that it behooves every programmer to be well skilled in programming in at least two different paradigms, and ideally at least the aforementioned five. Programmers should always be interested in learning new languages, preferably from an unfamiliar paradigm. Even if their day job always uses the same programming language, the increased sophistication of use of that language when a person can cross-fertilize from other paradigms should not be underestimated. Employers should take this into account and allow room in their training budget for employees to learn languages that are not currently being used, as a way of increasing the sophistication of the languages that are being used.

所有这一切的结果是,每个程序员都应该在至少两个不同的范例中,最好在至少上述五个范例中,熟练地进行编程。 程序员应该始终对学习新语言感兴趣,最好是从陌生的范例中学习。 即使他们的日常工作总是使用相同的编程语言,当一个人可以从其他范式中相互取长补短时,使用该语言的复杂性也不应被低估。 雇主应考虑到这一点,并在培训预算中留出空间供员工学习当前不使用的语言,以增加使用的语言的复杂性。

Although it’s a start, a one-week training course is not sufficient to learn a new language: it generally takes a good few months of use, even if part-time, to gain a proper working knowledge of a language. It is the idioms of use, not just the syntax and computational model, that are the important factors.

尽管这是一个开始,但是为期一周的培训课程不足以学习新的语言:通常,即使是兼职,也要花几个月的时间才能获得正确的语言工作知识。 重要的因素是使用习惯,而不仅仅是语法和计算模型。

学得更快。 深入挖掘。 看得更远。 (Learn faster. Dig deeper. See farther.)

Join the O’Reilly online learning platform. Get a free trial today and find answers on the 壮观的柠檬, or master something new and useful.

加入O'Reilly在线学习平台。 立即获得免费试用版,即时找到答案,或者掌握一些新的有用的知识。

Learn more

学到更多

Dr. Russel Winder was first a theoretical high energy particle physicist and then retrained himself as a Unix systems programmer. This led to him becoming a computer science academic (University College London, then zxdz’s College London) interested in programming; programming languages, tools, and environments; concurrency; parallelism; build; human–computer interaction; and sociotechnical systems. Having been Professor of Computing Science and head of the department of computer science at zxdz’s College London, he left academia to dabble with start-ups as CTO or CEO. After this he was an independent consultant, analyst, author, trainer, and expert witness for a decade before retiring in 2016. He is still very interested in programming; programming languages, tools, and environments; concurrency; parallelism; and build — it keeps him active during retirement.

Russel Winder博士最初是理论上的高能粒子物理学家,然后接受了Unix系统程序员的重新培训。 这导致他成为对编程感兴趣的计算机科学学者(伦敦大学学院,然后是伦敦国王学院)。 编程语言,工具和环境; 并发 并行性 建立; 人机交互; 和社会技术系统。 他曾是伦敦国王学院计算机科学系教授和计算机科学系系主任,他离开学术界开始涉足新兴企业担任CTO或CEO。 此后,他担任独立顾问,分析家,作家,培训师和专家见证达十年之久,直到2016年退休。 编程语言,工具和环境; 并发 并行性 和成长-使他在退休期间保持活跃。

翻译自: https://medium.com/oreillymedia/know-well-more-than-two-programming-languages-65a40464c848

两种编程语言转换

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。