本文介绍了函数式反应式编程语言的规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在某个时候创建​​一个功能性反应式框架.我已经阅读了很多关于它的内容并看到了一些示例,但我想清楚地了解这个框架必须做什么才能被视为 FRP 扩展/dsl.我并不真正关心实施问题或细节等,而是更关心在完美世界情况下需要什么.

I am looking at messing around with creating a functional reactive framework at some point. I have read quite a lot about it and seen a few examples but I wanted to get a clear idea of what this framework would HAVE to do to be considered an FRP extension/dsl. I'm not really concerned with implementation problems or specifics etc but more as to what would be desired in a perfect world situation.

理想的函数式反应式编程语言的关键操作和品质是什么?

What would be the key operations and qualities of an ideal functional reactive programming language?

推荐答案

我很高兴您首先询问规范而不是实现.关于 FRP 是什么,有很多想法.从 90 年代初开始(当我在 Sun Microsystems 和 Microsoft Research 从事交互式图形工作时),它一直是关于两个属性 (a) 外延性和 (b) 时间连续性.许多人放弃了这两个属性,并用各种实现概念来识别 FRP,在我看来,所有这些都离题了.为了减少混淆,我希望看到函数式反应式编程"这个术语.取而代之的是更准确的 &描述性的指示性、连续时间编程"(DCTP),正如 Jake McArthur 在去年的一次对话中所建议的那样.

I'm glad you're starting by asking about a specification rather than implementation first.There are a lot of ideas floating around about what FRP is.From the very start in the early 90's (when I was working in interactive graphics at Sun Microsystems and then Microsoft Research), it has been about two properties (a) denotative and (b) temporally continuous.Many folks drop both of these properties and identify FRP with various implementation notions, all of which are beside the point in my perspective.To reduce confusion, I would like to see the term "functional reactive programming" replaced by the more accurate & descriptive "denotative, continuous-time programming" (DCTP), as suggested by Jake McArthur in a conversation last year.

外延"是指建立在精确、简单、独立于实现的组合语义上,它准确地指定了每种类型和构建块的含义.然后,语义的组合性质决定了构建块的所有类型正确组合的含义.对我来说,外延是心脏和函数式编程的本质,是实现精确 &易于处理的推理,因此是正确性、推导和优化的基础.彼得兰丁推荐外延"作为对模糊术语功能性"的实质性替代以及一种将深入/真正的函数式编程与仅具有函数式外观的符号区分开来的方法.请参阅此评论Landin 引用和论文参考.

By "denotative", I mean founded on a precise, simple, implementation-independent, compositional semantics that exactly specifies the meaning of each type and building block.The compositional nature of the semantics then determines the meaning of all type-correct combinations of the building blocks.For me, denotative is the heart & essence of functional programming, and is what enables precise & tractable reasoning and thus a foundation for correctness, derivation, and optimization.Peter Landin recommended "denotative" as a substantive replacement to the fuzzier term "functional" and a way to distinguish deeply/genuinely functional programming from merely functional-looking notations.See this comment for some Landin quotes and a paper reference.

关于连续时间,看帖子为什么要编程连续时间? 以及我在本页上 AshleyF 的回答中的引述.我很惊讶 &考虑到计算机的离散性,连续时间的想法在某种程度上是不自然的或不可能实现的.这种思路让我觉得很奇怪,尤其是当来自 Haskellers 时,有以下几个原因:

About continuous time, see the post Why program with continuous time? and my quote in AshleyF's answer on this page.I'm surprised over & over by hearing the claim that the idea of continuous time is somehow unnatural or impossible to implement, considering the discrete nature of computers.This line of thinking strikes me as bizarre, especially when coming from Haskellers, for a few reasons:

  • 使用lazy 函数式语言,我们可以在有限 机器上随意使用无限 数据进行编程.结果我们得到了可爱的模块化,如 John Hughes 的经典论文 为什么函数式编程很重要.
  • 在连续空间中有很多编程的例子,例如矢量图形,还有Pan.
  • 我喜欢我的程序反映我如何思考问题空间而不是执行程序的机器,我倾向于期望其他高级语言程序员也有这种偏好.(当编程语言的程序需要关注不相关的内容时,它就是低级语言."- Alan Perlis)
  • Using lazy functional languages, we casually program with infinite data on finite machines. We get lovely modularity as a result, as illustrated in John Hughes's classic paper Why Functional Programming Matters.
  • There are many examples of programming in continuous space, for instance, vector graphics, but also things like Pan.
  • I like my programs to reflect how I think about the problem space rather than the machine that executes the programs, and I tend to expect other high-level language programmers to share that preference.("A programming language is low level when its programs require attention to the irrelevant." - Alan Perlis)

自从 TBAGActiveVRML(第一个 DCTP/FRP 系统)和后来的 弗兰.正确实施很容易.论文连续建模动画的功能实现.有效地实现连续时间(并且仍然正确!)是另一回事,尤其是避免重新计算不变的值.(参见论文推拉函数式反应式编程.)

I've been making libraries for programming with continuous time since TBAG and ActiveVRML (the first DCTP/FRP system) and later Fran.It's easy to implement correctly.A few different approaches are described in the paper Functional Implementations of Continuous Modeled Animation.Implementing continuous time efficiently (and still correctly!) is another matter, especially avoidance of recomputing unchanging values.(See the paper Push-pull functional reactive programming.)

相关备注见我对Reactive 和 Functional-Reactive 编程之间的区别什么是(函数式)反应式编程? 更新:有关为什么连续时间很重要的更多信息,请参阅这些注释.更新:另见,我 2015 年的演讲 FRP 的本质和起源(以及与之相关的相关演讲).

For related remarks, please see my answer to The difference between Reactive and Functional-Reactive programming and to What is (functional) reactive programming? Update: For more on why continuous time matters, see these notes. Update: See also, my 2015 talk The essence and origins of FRP (and the related talks linked there).

祝您探索顺利,如果您有任何问题,请告诉我.我的联系信息位于我的主页.

Good luck with your exploration, and please let me know if you have any questions.My contact info is on my home page.

这篇关于函数式反应式编程语言的规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 13:38
查看更多