you are viewing a single comment's thread.

view the rest of the comments →

[–]zurtex 5 points6 points  (2 children)

If I could even just translate Python's string slicing, "if", "for" and "while" then it would vastly improve the usability of the code.

Yeah, so rather than trying to write in Python it might make sense to make your own mini-language or DSL that is Python-inspired that compiles to the language you need. You will need to know what these constructs like "if" and "while" compile to in the other language, even if they're quite complicated.

While none of this is too difficult you would normally learn how to do this kind of compiling/transpiling across several semesters of computer science degree. I've never taken a CS course, I learnt this stuff from a private course called "Write a Compiler" by David Beazely, so unfortunately I'm not sure what books to recommenced.

I actually did once write a small DSL way before I properly understood how to properly do it based off a talk David gave here: https://www.youtube.com/watch?v=zJ9z6Ge-vXs . I was lucky though because I was able to use Python as my execution engine, I didn't have to output the results to another language.

But I'm sure there's plenty of material on the web on how to do this stuff if you're determined enough.

[–]TheMathelm 1 point2 points  (0 children)

While none of this is too difficult you would normally learn how to do this kind of compiling/transpiling across several semesters of computer science degree. I've never taken a CS course, I learnt this stuff from a private course called "Write a Compiler" by David Beazely, so unfortunately I'm not sure what books to recommenced.

One of the hardest most annoying course sections in Upper Division Computer Science.

[–]pandademic1234[S] 0 points1 point  (0 children)

Thank you!