且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

榆树中是否存在并行性?

更新时间:2022-05-28 03:15:54

简短答案

否,目前不行.但是下一个版本(0.15)将提供处理Elm内部效果的新方法,因此您将需要减少使用ports + JavaScript代码.因此,在下一个版本中,很有可能会在Elm内部产生工人.

Short answer

No, not currently. But the next release (0.15) release will have new ways to handle effects inside Elm so you will need to use ports + JavaScript code less. So there may well be a way to spawn workers inside Elm in the next version.

如果您喜欢冒险,请尝试阅读在Elm上发表的论文(或更长的原始论点)显示, Elm使用的FRP的原始样式非常适合用于细粒度的并发.还有一个async构造,有可能使程序的一部分以更粗糙的方式单独运行.操作系统级别的线程(例如JS Webworkers)和并行性可能会对此提供支持.

If you're feeling adventurous, try reading the published paper on Elm (or the longer original thesis), which shows that the original flavour of FRP that Elm uses is well suited for fine-grained concurrency. There is also an async construct which can potentially make part of the program run separately in a more coarse-grained manner. That might be support with OS-level threads (like JS Webworkers) and parallelism.

以前有对Webworkers进行的早期实验.社区内对并发肯定有兴趣,但是JavaScript并没有提供任何出色的并发选择.

There have been earlier experiments with Webworkers. There is certainly an interest in concurrency within the community, but JavaScript doesn't offer (m)any great options for concurrency.

有关本文的阅读提示,请访问来自榆树的地雷-讨论邮件列表:

For reading tips on the paper, here's post of mine from the elm-discuss mailing list:

如果您想了解更多有关信号和选择加入异步的信息,建议您在Elm上尝试Evan的PLDI论文.从简介(1)到构建GUI(4)进行阅读.您可以跳过类型系统(3.2)和功能评估(3.3.1),这可以节省您一些时间.构建GUI(4)前后,大多数都是您已经知道的东西.图8可能是async关键字功能的***概述(请注意,当前的Elm编译器未实现async关键字).

If you want to know more about signals and opt-in async, I suggest you try Evan's PLDI paper on Elm. Read from the introduction (1) up to building GUIs (4). You can skip the type system (3.2) and functional evaluation (3.3.1), that may save you some time. Most in and after building GUIs (4) is probably stuff you know already. Figure 8 is probably the best overview of what the async keyword does (note that the async keyword is not implemented in the current Elm compiler).