为什么 smalltalk 不是函数式编程语言? [英] Why is smalltalk not a functional programming language?

查看:27
本文介绍了为什么 smalltalk 不是函数式编程语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着对函数式编程语言的重新兴趣,我看到 Smalltalk 和 FPL 之间的一些相似之处,即闭包(Smalltalk 中的 BlockClosures) 然而,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?

需要什么来考虑它?

推荐答案

使用面向对象范式编程是通过将问题域实体识别和建模为对象来创建程序,然后让它们彼此协作以解决每个问题实例.使用函数范式编程是将问题建模为数学问题,并创建一个数学函数(通过组合其他函数),为每个问题实例计算问题解决方案.

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 在大多数情况下可以表达使用面向对象编程范式创建的所有解决方案,但它不能原始地表达使用函数式编程范式创建的许多解决方案.这就是为什么我不认为它是 FPL.尽管原始上无法表达 FPL 可以表达的所有解决方案,但 Smalltalk 具有极强的可扩展性,您可以将其扩展为能够表达 FPL 可以表达的所有解决方案.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆