News for hackers. Stuff that matters.
Re:Abstract Syntax Tree for Patching Code and Assessing Code... by erezsh on Monday June 07, 2021 @04:55AM (#27420450)
> 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!

Re:Abstract Syntax Tree for Patching Code and Assessing Code... by 1337shadow on Monday June 07, 2021 @07:31AM (#27421306)
Interesting! can you link your repo please? Life without webpack has been only pure joy TBH ;)
Re:Abstract Syntax Tree for Patching Code and Assessing Code... by erezsh on Monday June 07, 2021 @11:13AM (#27423523)
Sorry, no repo yet.
Re:Abstract Syntax Tree for Patching Code and Assessing Code... by acka on Monday June 07, 2021 @09:07AM (#27422090)
Please 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.
Re:Abstract Syntax Tree for Patching Code and Assessing Code... by erezsh on Monday June 07, 2021 @10:52AM (#27423297)
> 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.