4 ms·
> Python to JavaScript That's cool. I'm working on something very similar, with the goal of generating idiomatic Javascript, which seems to be a goal for your
by erezsh 5y ago
> Python to JavaScript
That's cool. I'm working on something very similar, with the goal of generating idiomatic Javascript, which seems to be a goal for your code as well.
I did make a few different choices.
- Instead of worrying about formatting and indent, I just output whatever I feel like, and run Prettier afterwards. That way I don't have to worry about whitespace, indents, or superfluous parenthesis.
- I integrated it with type analysis, so that operators like `+=` will produce different code for each type (ints vs lists, for example).
- I also include the comments from the python source in the target javascript
But these things aside, I can see a lot of similarities!
- 1337shadow 5y agoInteresting! can you link your repo please? Life without webpack has been only pure joy TBH ;)
- erezsh 5y agoSorry, no repo yet.
- acka 5y agoPlease do realize that if your project ever ends up under source code management, reading diffs and merging changes may cause headaches for anyone who wishes to contribute to your code. SCM and liberal use of code reformatting tools usually don't mix well, unless you're very careful while configuring them.
- erezsh 5y ago> SCM and liberal use of code reformatting tools usually don't mix well Care to elaborate about that? It seems to me like the resulting code will be very consistent, and only change when I either improve the transpiler, or when Prettier issue an update to their formatting. But that's unlikely, and anyway I can just use a fixed version.