Ask coding questions

← Back to all posts
Python3 To C++ Compiler (Prototype)
TurtleAndrew (211)

I spent a few hours working on a basic compiler that converts python3 code (one of the easier languages to learn) to c++ (one of the harder languages to learn). This would let you write code in python3 but still have the speed of c++. This prototype is far from good and needs hours of work. I was wondering if i could get help (as in a group of people to help me develop it) making it sence python3 is very different from c++ and will need tons of work to get properly and consistently converting. I want this to be very easy to use so all you have to do is run the program with the file's title and have it convert it to runable c++ code with no editing of the converted file required. I also want to have the converted c++ code maintain formating so anyone wanting to switch for python3 to c++ (on a project) can easily convert the code and use the converted code. There's also many features i want that i have know idea on how to add such as converting the code under imports that are used to c++. You will need to know python3 sorta well and some c++. If anyone wants to help me develop this then comment bellow and I'll set up a multiplayer replit for it. I'm looking for 3-6 people to help out and more would always be appreciated.

When you run the program, it prints the output (the c++ code which is runable). The code that is being converted can be found under the "python3_to_c.Cpy" file. The converter its self can be found under the "python3_to_c.py" file. The outputed c++ file can be found under the "python3_to_c.cpp" file. You can change the code under the "python3_to_c.Cpy" file and when run the output will be different. Note that it is very basic and dosent support many python3 syntaxes.

Comments
hotnewtop
BananaJellyfish (210)

I know a lot of python, but no c++. Im planning on learning it but i may take a while since i have very little time. Im also unsure as to whether python3 is the python i know.

BananaJellyfish (210)

@BananaJellyfish actually, it is python3 i know. Also, im sure c++ isn't too different from python and js

TurtleAndrew (211)

@BananaJellyfish It is and isn't similar (c++). The basic structure is essentially the same but once you get into classes (like objects), it becomes quite different.

BananaJellyfish (210)

Yeah, i might have a problem with things like that. Edit: i just looked at the code and it seems pretty similar to js, which i'm learning right now @TurtleAndrew

BananaJellyfish (210)

Wait, which language will you make this in? @TurtleAndrew

TurtleAndrew (211)

@BananaJellyfish Im making the compiler in python3 and the output is c++

TurtleAndrew (211)

@TurtleAndrew Also, i was talking on discord with my friends, we then started to spam eachother (for fun), now i have made a spam bot (that i made in python3) so i can spam them without putting in any effort.

BananaJellyfish (210)

@TurtleAndrew so how is it going to work? It'll take all your python3 code and turn it into c++? So all your if statekents and things will be changed? Surely that would be a lot of work, considering the amount of functions in python3

TurtleAndrew (211)

@BananaJellyfish Ya, you give it the python3 file/files and it returns a c++ file/files. There are a lot of functions but the hard part is classes I'm thinking (their very different compared to python3).

BananaJellyfish (210)

@TurtleAndrew yeah ok i probably won't be much help though given my lack of c++ knowledge

TurtleAndrew (211)

@BananaJellyfish Don't worry to much about the project. Your the only one who's offered so the team is super small and therefore idk if its even going to be possible within the short amount of time i will have to work on it each day (about 1-2 hours). if i can get more help then it will definitely be more likely.

BananaJellyfish (210)

Yeah hopefully more people will join

notGilbert (121)

that sounds like a challenge (many, many differences and abstraction between the languages)

TurtleAndrew (211)

@notGilbert definitely. It's possible though.