GopherCon Europe 2020: André Eriksson - Automatically Translating Python Source to Idiomatic Go Code

preview_player
Показать описание
About the talk:
Manually converting source code in one language to another is laborious. Existing approaches, often dubbed “transpilers” the JavaScript community, are insufficient for this purpose as they (1) produce code intended for machines, not humans; (2) work in the direction of going from stronger type systems to equivalent or weaker type systems.

This talk presents an approach that addresses both of these concerns. I will present how we successfully converted a project of several thousand lines of dynamically typed Python code into human-readable, fully typed, idiomatic Go source code. The program is built entirely in Go and consists of a Python parser, a static analyzer that does full-program analysis to understand what type(s) each Python object may be, and an output stage that converts this representation into idiomatic Go code.

The talk will show the audience how the program works and how to overcome the challenges of going from dynamically typed Python source code to fully typed Go source code. It will give the audience a better understanding of parsing source code into ASTs, how to analyze them and rewrite them to perform modifications, and lastly how to use Go’s excellent source code formatting to output properly formatted Go source code at the end.

About the speaker:

#gopherconEU
Рекомендации по теме
Комментарии
Автор

Very impressive. Thank you so much. I will be testing this for some of my one off jobs translation.

danielsmeyer
Автор

is this py2go tool available somewhere so I can play with it?
Can it support python3 also?
Thanks for the talk!

mateuszm
welcome to shbcf.ru