为什么smalltalk不是一种功能性编程语言? [英] Why is smalltalk not a functional programming language?
问题描述
需要考虑的是什么?
面向对象模式编程通过识别问题域实体并将其模型化为对象来创建程序,然后使它们之间协作解决每个问题实例。
使用功能范例进行编程是将问题建模为数学问题,并为每个问题实例创建一个数学函数(通过组合其他函数)来计算问题解决方案。
在我看来,函数式编程语言是一种为使用函数式编程范式解决的问题提供解决方案的语言,该语言可以完全按照它的想法来表达该解决方案。如果您需要转换解决方案的某些部分,以适应语言所能表达的内容,那么它并不完全支持您以前认为解决方案的范例。
Smalltalk在大多数情况下可以表达所有使用面向对象编程范例创建的解决方案,但它不能原始地表达使用函数式编程范例创建的大量解决方案。这就是为什么我不认为它是FPL。
尽管不能够表达FPL可以提供的每个解决方案,但Smalltalk是极其可扩展的,您可以将其扩展为能够表达FPL可以提供的所有解决方案。
With the renewed interest in functional programming languages, I've seen some similitudes between Smalltalk and FPL, namely closures ( BlockClosures in Smalltalk ) Yet, Smalltalk is not a FPL?
What would be needed to consider it as such?
Programming with the Object Oriented paradigm is creating a program by identifying and modeling the Problem Domain Entities as objects, and then make them collaborate between themselves to solve each problem instance. Programming with the Functional paradigm is modeling the problem as a mathematical problem, and creating a mathematical function (by composing other functions) that for each problem instance, computes the problem solution.
In my opinion, a functional programming language is a language that given a solution for a problem solved using the functional programming paradigm, the language can express that solution exactly as it was thought. If you need to "transform" some part of your solution so it fits in what the language can express, then it doesn't fully support the paradigm you used to think the solution.
Smalltalk can express in most cases all the solutions created using the Object Oriented Programming paradigm, but it cannot expresss primitively a lot of solutions created using the Functional Programming paradigm. That's why I don't consider it a FPL. Despite not primitively be able to express every solution that a FPL can, Smalltalk is extremelly extensible, and you can extend it to be able to express all the solutions a FPL can.
这篇关于为什么smalltalk不是一种功能性编程语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!