4 ms·
How did you do this? “semi-automatically translated it to C++” Or is that part of why you said you needed to write an essay.
by jbritton 6y ago
How did you do this?
“semi-automatically translated it to C++”
Or is that part of why you said you needed to write an essay.
- chubot 6y agoYeah at some point I should write a blog post, but here is a pretty good condensed summary of it: https://old.reddit.com/r/ProgrammingLanguages/comments/jb5i5m/help_i_keep_stealing_features_from_elixir_because/g8urxou/ https://old.reddit.com/r/ProgrammingLanguages/comments/jb5i5... The mycpp tool I wrote can be thought of as a cross between this old "Shed Skin" project, and mypyc: https://www.oilshell.org/cross-ref.html#mycpp https://www.oilshell.org/cross-ref.html#mycpp I kept extensive notes on the process on Zulip, list of threads ehre: http://www.oilshell.org/blog/2020/03/recap.html#mycpp-the-good-the-bad-and-the-ugly http://www.oilshell.org/blog/2020/03/recap.html#mycpp-the-go... Really short summary: I used the MyPy front end, and basically printed its AST as C++. This involves a bunch of hacks, but it works. The following conditions helped a lot: - I control all the code in Oil, so I can statically type all of it, which involves both annotations and occasional patches. A shell doesn't have many Python library dependencies; i.e. it doesn't depend on BeautifulSoup or something like that. It's basically all string and data structure manipulation, with a few sys calls. - Oil has extensive tests. I run the same tests against the translated and compiled C++, which flushes out bugs in the translator. (Something like 915 out of 1700 tests pass now, so the translation process isn't done.) - I also used unit tests to generate some of the type annotations with pyannotate. There is still some translation left to do if anyone is interested in helping. You will probably learn something about both Python and C++!