未加星标

pygo: Interpreters in Go and for Go

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

View the slides

Go is a great general purpose programming language and it is thus no surprise it can be a great fit for science work. Indeed, Go provides an efficient and quick edit/compile/run development cycle, while being also reasonably fast at runtime. The Gonum community[1] already provides a set of robust scientific libraries. Thanks to its static binaries, Go is easy to deploy on various hardware (laptop, desktop, clusters, …): this is also facilitated by its simple cross-compilation mechanism. Last but not least, Go is a simple language that scientists can quickly learn and become proficient, if not master. But Go could be an even better fit for all kind of exploratory work, such as data analysis, if it had an interactive interpreter, also known as a Read-Eval-Print Loop (a REPL).

Of course, there are already many Go interpreters and REPLs: github.com/motemen/gore github.com/sbinet/go-eval golang.org/x/tools/ssa/interp ...

Unfortunately, none of them provide an interactive interpreter with support for the full Go language. The github.com/go-interpreter organization is a nascent community effort to address this issue to design, implement and provide an interactive interpreter, for the full Go language (and implemented in Go.) This is still early days and development process is still at the design phase [2].

What can you do when you have next to no expertise in designing and building REPLs? When you need to assemble an interpreter from its core components? When you don’t know what are these components? When you need to decide between using a virtual machine to interpret a Go program or whether to directly interpret the AST? Should you use a stack-based or a register-based VM? What opcodes should your VM use? etc…

To help navigate through this flock of existential questions, it is best to have a kind of skeleton which can be iterated over, experimenting with various approaches. For this talk, I started with the blueprint from the “Architecture of Open Source Applications” book [3]: the nice article “A python Interpreter Written in Python” by Allison Kaptur [4]. “pygo” is the translation of this article into a Go space: “pygo” is a toy virtual machine interpreter for CPython-3, written in Go. Like in the AOSA article, “pygo” uses the “python3” interpreter to compile python source code into bytecode. This bytecode is then fed to the “pygo” VM that will read, decode and interpret instructions from the bytecode. The full code of “pygo” [5] is available at: github.com/sbinet/pygo There are still many more issues to address and implement (functions, frames, blocks, closures, classes, …) to, finally, provide a REPL. It is still very much a work in progress.

Thanks!

[1]: https://github.com/gonum [2]: https://github.com/gonum/proposal/issues/1 [3]: http://aosabook.org [4]: http://www.aosabook.org/en/500L/a-python-interpreter-written-in-python.html [5]: https://github.com/sbinet/pygo

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

主题: Python
分页:12
转载请注明
本文标题:pygo: Interpreters in Go and for Go
本站链接:http://www.codesec.net/view/522817.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(34)