当前的功能反应编程实现的现状是什么? [英] What's the status of current Functional Reactive Programming implementations?

查看:119
本文介绍了当前的功能反应编程实现的现状是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Haskell中可视化一些简单的自动物理系统(如摆锤,机器人手臂等)。
通常这些系统可以用等式来描述,如



df / dt = c * f(t)+ u(t) / code>



其中 u(t)表示某种智能控制。这些系统看起来非常适合功能反应编程范例。



所以我拿到了Paul Hudak的书Haskell表达学派,
和发现域名特定语言功能动画语言(功能动画语言)实际上对于我的简单玩具系统来说非常好用(尽管一些功能,特别是集成似乎是有点太懒了,有效地使用,但很容易解决)。



我的问题是,更成熟,最新,维护良好的性能 - 可以选择更先进的,甚至是实际的应用程序吗?



这个维基页面列出了Haskell的几个选项,但我不清楚以下方面:


  1. 反应性,Conal Eliott的项目是(据我所知)这个程序的发明者之一看起来有点陈旧。我喜欢他的代码,但也许我应该尝试其他更新的替代方案?在语法/性能/运行时稳定性方面,它们之间的主要区别是什么?


  2. 引用调查,第6节...FRP实现仍然不够有效或足够可预测在需要延迟保证的域中有效使用性能... 。由于FRP已经存在了15年以上,所以调查结果表明了一些有趣的可能的优化,我觉得这个性能问题可能是非常有用的,甚至至少在本质上难以解决一些年。这是真的吗?


  3. 同一作者在他的blog 。 FRP中的问题是独一无二的,还是以纯粹的非严格语言进行编程时通常都会遇到的问题?你有没有发现只要太难以稳定基于FRP的系统,如果不是很好,那么这个系统是否仍然是一个研究项目?


  4. 像工厂工程师,机器人工程师,财务工程师等人员是否真的使用它们(适合自己需要的语言)?


虽然我个人更喜欢Haskell实现,但我可以接受其他建议。例如,使用Erlang实现将是非常有趣的 - 那么拥有智能的,自适应的自学习服务器进程将变得非常容易!

解决方案

现在主要有两个实用的Haskell库,用于功能反应式编程。两者都由单身人士维护,但也正在接收其他Haskell程序员的代码捐款:




  • Netwire 侧重于效率,灵活性和可预测性。它具有自己的事件范例,可用于传统FRP不起作用的领域,包括网络服务和复杂模拟。风格:适用和/或箭头。初始作者和维护者:ErtugrulSöylemez(这是我)。


  • 反应香蕉建立在传统的FRP范式上。虽然使用它实际上也是经典FRP研究的基础。它的主要重点是用户界面,并有一个现成的wx界面。风格:适用。初始作者和维护者:Heinrich Apfelmus。




您应该尝试这两者,但根据您的应用程序,您可能会找到一个或另一个更好的适合。



对于游戏,网络,机器人控制和模拟,您将发现Netwire是有用的。它为这些应用程序提供了现成的线,包括各种有用的差异,积分和许多功能,用于透明事件处理。有关教程,请访问我链接的页面上的 Control.Wire 模块的文档。



对于图形用户界面目前你最好的选择是反应香蕉。它已经有一个wx接口(作为一个单独的库反应式 - 香蕉-wx),而海因里奇在这个上下文中介绍了很多关于FRP的代码示例。



回答你的其他问题:FRP不适合您需要实时可预测性的场景。这主要是由于Haskell,但不幸的是,FRP很难在较低级别的语言中实现。一旦Haskell本身变得实时准备,FRP也会到达。概念性Netwire已经准备好了实时应用程序。



时间泄漏不再是真正的问题,因为它们在很大程度上与monadic框架有关。实际的FRP实现根本不提供一个monadic接口。 Yampa已经开始了,Netwire和反应式香蕉都建立在这一点上。



我知道现在没有使用FRP的商业或其他大型项目。图书馆已经准备好了,但我认为人们还没有。


I'm trying to visualize some simple automatic physical systems (such things as pendulum, robot arms,etc.) in Haskell. Often those systems can be described by equations like

df/dt = c*f(t) + u(t)

where u(t) represents some kind of 'intelligent control'. Those systems look to fit very nicely in the Functional Reactive Programming paradigm.

So I grabbed the book "The Haskell School of Expression" by Paul Hudak, and found that the domain specific language "FAL" (for Functional Animation Language) presented there actually works quite pleasently for my simple toy systems (although some functions, notably integrate, seemed to be a bit too lazy for an efficient use, but easily fixable).

My question is, what's the more mature, up-to-date, well-maintained, performance-tuned alternative for more advanced, or even practical applications today?

This wiki page lists several options for Haskell, but I'm not clear about the following respects:

  1. The status of "reactive", the project from Conal Eliott who is (as I understand it) one of the inventers of this programming paradigm, looks a bit stale. I love his code, but maybe I should try other more up-to-date alternatives? What's the primary difference between them, in terms of syntax/performance/runtime-stability?

  2. To quote from a survey in 2011, Section 6, "... FRP implementations are still not efficient enough or predictable enough in performance to be used effectively in domains which require latency guarantees ...". Alghough the survey suggests some interesting possible optimizations, given the fact that FRP is there for more than 15 years, I get the impression that this performance problem might be something very or even inherently difficult to solve at least within a few years. Is this true?

  3. The same author of the survey talks about "time leaks" in his blog. Is the problem unique to FRP, or something we are generally having when programming in a pure, non-strict language? Have you ever found it just too difficult to stabilize an FRP-based system over time, if not performant enough?

  4. Is this still a research level project? Are the people like plant engineers, robotics engineers, financial engineers, etc. actually using them (in whaterver language that suits their needs)?

Although I personally prefer a Haskell implementation, I'm open to other suggestions. For example, it would be particularly fun to have an Erlang implementation --- it would then be very easy to have an intelligent, adaptive, self-learning server process!

解决方案

Right now there are mainly two practical Haskell libraries out there for functional reactive programming. Both are maintained by single persons, but are receiving code contributions from other Haskell programmers as well:

  • Netwire focusses on efficiency, flexibility and predictability. It has its own event paradigm and can be used in areas where traditional FRP does not work, including network services and complex simulations. Style: applicative and/or arrowized. Initial author and maintainer: Ertugrul Söylemez (this is me).

  • reactive-banana builds on the traditional FRP paradigm. While it is practical to use it also serves as ground for classic FRP research. Its main focus is on user interfaces and there is a ready-made interface to wx. Style: applicative. Initial author and maintainer: Heinrich Apfelmus.

You should try both of them, but depending on your application you will likely find one or the other to be a better fit.

For games, networking, robot control and simulations you will find Netwire to be useful. It comes with ready-made wires for those applications, including various useful differentials, integrals and lots of functionality for transparent event handling. For a tutorial visit the documentation of the Control.Wire module on the page I linked.

For graphical user interfaces currently your best choice is reactive-banana. It already has a wx interface (as a separate library reactive-banana-wx) and Heinrich blogs a lot about FRP in this context including code samples.

To answer your other questions: FRP isn't suitable in scenarios where you need real-time predictability. This is largely due to Haskell, but unfortunately FRP is difficult to realize in lower level languages. As soon as Haskell itself becomes real-time-ready, FRP will get there, too. Conceptually Netwire is ready for real-time applications.

Time leaks aren't really a problem anymore, because they are largely related to the monadic framework. Practical FRP implementations simply don't offer a monadic interface. Yampa has started this and Netwire and reactive-banana both build on that.

I know of no commercial or otherwise large scale projects using FRP right now. The libraries are ready, but I think the people aren't – yet.

这篇关于当前的功能反应编程实现的现状是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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