I have heard of some compilers that convert code in one high level language to another
e.g Shedskin that converts python code to optimized C++.
I was wondering why would one ever try to do that. Why not directly write in the desired language itself?
The only reason I could think of was may be compiled languages like C/C++ are better than interpreted ones performance-wise.
Any more insights are welcome.
Well if you think about it, any compiler converts to another language: machine code.
If you go with that argument, anything other than assembly is pointless. (Actually assembly would be too. Real men type hex opcodes by hand.)
You would use one language to convert to another if you want to write from a higher level perspective or if you are more comfortable in one language than another.
For example, would you rather write and debug a few hundred lines of network code in one language or use 5-10 lines in another language?
It is often handy to convert one part of a codebase into a different language if you want to reuse that code in another project.
For example, say you had a python application which used some handy utility functions. Later, you're writing a C++ application, and need that same functionality.
You have two options - either use some form of bridge to call the python code from C++ (which can be clunky at times, although it is possible), or rewrite the routine in C++. Translation tools can simplify the second option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With