Lazy interworking of compiled and interpreted code for sandboxing and distributed systems

Camil Staps, John H. G. van Groningen, M. J. Plasmeijer
{"title":"Lazy interworking of compiled and interpreted code for sandboxing and distributed systems","authors":"Camil Staps, John H. G. van Groningen, M. J. Plasmeijer","doi":"10.1145/3412932.3412941","DOIUrl":null,"url":null,"abstract":"More and more applications rely on the safe execution of code unknown at compile-time, for example in the implementation of web browsers and plugin systems. Furthermore, these applications usually require some form of communication between the added code and its embedder, and hence a communication channel must be set up in which values are serialized and deserialized. This paper shows that in a functional programming language we can solve these two problems at once, if we realize that the execution of extra code is nothing more than the deserialization of a value which happens to be a function. To demonstrate this, we describe the implementation of a serialization library for the language Clean, which internally uses an interpreter to evaluate added code in a separate, sandboxed environment. Remarkable is that despite the conceptual asymmetry between \"host\" and \"interpreter\", lazy interworking must be implemented in a highly symmetric fashion, much akin to distributed systems. The library interworks on a low level with the native Clean program, but has been implemented without any changes to the native runtime system. It can therefore easily be ported to other programming languages. We can use the same technique in the context of the web, where we want to be able to share possibly lazy values between a server and a client. In this case the interpreter runs in WebAssembly in the browser and communicates seamlessly with the server, written in Clean. We use this in the iTasks web framework to handle communication and offload computations to the client to reduce stress on the server-side. Previously, this framework cross-compiled the Clean source code to JavaScript and used JSON for communication. The interpreter has a more predictable and better performance, and integration is much simpler because it interworks on a lower level with the web server.","PeriodicalId":235054,"journal":{"name":"Proceedings of the 31st Symposium on Implementation and Application of Functional Languages","volume":"29 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2019-09-25","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 31st Symposium on Implementation and Application of Functional Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3412932.3412941","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

More and more applications rely on the safe execution of code unknown at compile-time, for example in the implementation of web browsers and plugin systems. Furthermore, these applications usually require some form of communication between the added code and its embedder, and hence a communication channel must be set up in which values are serialized and deserialized. This paper shows that in a functional programming language we can solve these two problems at once, if we realize that the execution of extra code is nothing more than the deserialization of a value which happens to be a function. To demonstrate this, we describe the implementation of a serialization library for the language Clean, which internally uses an interpreter to evaluate added code in a separate, sandboxed environment. Remarkable is that despite the conceptual asymmetry between "host" and "interpreter", lazy interworking must be implemented in a highly symmetric fashion, much akin to distributed systems. The library interworks on a low level with the native Clean program, but has been implemented without any changes to the native runtime system. It can therefore easily be ported to other programming languages. We can use the same technique in the context of the web, where we want to be able to share possibly lazy values between a server and a client. In this case the interpreter runs in WebAssembly in the browser and communicates seamlessly with the server, written in Clean. We use this in the iTasks web framework to handle communication and offload computations to the client to reduce stress on the server-side. Previously, this framework cross-compiled the Clean source code to JavaScript and used JSON for communication. The interpreter has a more predictable and better performance, and integration is much simpler because it interworks on a lower level with the web server.
沙盒和分布式系统中编译和解释代码的惰性交互
越来越多的应用程序依赖于编译时未知代码的安全执行,例如web浏览器和插件系统的实现。此外,这些应用程序通常需要在添加的代码和它的嵌入器之间进行某种形式的通信,因此必须建立一个通信通道,在其中对值进行序列化和反序列化。本文表明,在函数式编程语言中,如果我们意识到额外代码的执行只不过是对碰巧是函数的值的反序列化,我们可以立即解决这两个问题。为了演示这一点,我们描述了Clean语言的序列化库的实现,它在内部使用解释器在单独的沙盒环境中评估添加的代码。值得注意的是,尽管“主机”和“解释器”在概念上是不对称的,但惰性交互必须以高度对称的方式实现,这与分布式系统非常相似。该库与本机Clean程序在较低的级别上进行交互,但在实现时没有对本机运行时系统进行任何更改。因此,它可以很容易地移植到其他编程语言。我们可以在web环境中使用相同的技术,我们希望能够在服务器和客户端之间共享可能的延迟值。在这种情况下,解释器在浏览器中的WebAssembly中运行,并与用Clean编写的服务器无缝通信。我们在iTasks web框架中使用它来处理通信和卸载计算到客户端,以减少对服务器端的压力。在此之前,该框架将Clean源代码交叉编译为JavaScript,并使用JSON进行通信。解释器具有更可预测和更好的性能,并且集成要简单得多,因为它与web服务器在较低的级别上进行交互。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信