Runnable pseudocode?

I am trying to determine the state of the art for the following idea:

1) user types in some code in a language called (insert_name_here);

2) the user selects the target language from the list of known output candidates (javascript, ruby, perl, python);

3) the processor translates insert_name_here into executable code in the target language;

4) the processor then runs the code using the appropriate system call based on the selected language

The reason this happens is because there is a predefined mapping between all language constructs from insert_name_here to all supported target languages.

( Disclaimer: This clearly does not create โ€œelegantโ€ code that is well adapted to the target language. It simply performs a rudimentary translation that can be run. Quick and dirty implementation of algorithms in several different languages โ€‹โ€‹for those cases when they do not want to reinvent the wheel , but for any reason they are required to work with a specific language for a specific project.)

Does it already exist?

+3
source share
5 answers

There are converters available for different languages. The problem you are facing is with the libraries. Although matching between language formulations can be simple, finding comparisons between library functions will be very difficult.

I'm not sure how useful this type of code generator is. Why would you write something in one language and then immediately convert it to something else? I see the rationale for fourth-generation languages โ€‹โ€‹that convert diagrams or models into code, but I really don't see the point in your efforts.

+2
source

The .NET CLR is designed in such a way that C ++. Net, C # .Net, and VB.Net are all compiled into the same machine language, and you can "decompile" this CLI back into any of these languages.

So, yes, I would say that it already exists, although not in the way you describe.

+4
source

Yes, a program that converts a program from one view to another exists. It was called a "compiler."

And as for your question, is it always possible: while your target language is no less powerful than the source, then it is possible. So, if your target language is Turing-complete, then this is always possible, because there cannot be a language that is more powerful than a language full of Turing.

However, there does not have to be a 1: 1 mute display.

For example: the Microsoft Volta compiler, which compiles the CIL bytecode into JavaScript source code, has a problem: .NET has threads, JavaScript doesn't. But you can implement streams with continuations. Well, JavaScript also has no continuations, but you can implement continuations with exceptions. Thus, Volta converts CIL to CPS, and then implements CPS with exceptions. (Newer versions of JavaScript have half-cores in the form of generators that can also be used, but Volta is designed to work with a wide range of JavaScript versions, including, obviously, JScript in Internet Explorer.)

+3
source

This seems a little strange. If you use the term โ€œprior artโ€ in its most common form, you are discussing a potentially patentable idea. If this is the case, you have:

1 / I published the idea, starting the hours of working with the patent - I suppose, possibly, incorrectly, that you are in the USA. Other jurisdictions may have different rules.

2 / I told your idea to the whole planet, which means that it is almost useless to try and patent it if you do not act very quickly.

If you do not think about patenting this and simply used the term โ€œstate of the artโ€ in the sense of lay people, I apologize. I work for a company that takes patents very seriously and has carefully studied us what we are allowed to do with the information before applying.

Having said that patentable ideas should be new, useful and non-obvious. I would think that your idea would not go through the third of them, since you are describing a language translator that would have prior art from several pascal-to-c and fortran-to-c converters.

One glimmer of hope is your idea's ability to generate one of several output languages โ€‹โ€‹(which are not executed by p2c and f2c), but I think that even this will be covered by similar cross-compilers (for example, gcc), which turn the source into one of many different languages objects.

IBM has a product called Visual Age Generator in which you encode one (proprietary) language and convert to COBOL / C / Java / others to work on different target platforms from PC to large System z honing systems, so there is your first problem ( thinking about patenting the idea that IBM, the largest in the world, is already using).

+2
source

Tons of them. p2c, f2c, and the original implementation of s C ++ and Objective-C hit me immediately. Other than that, it's hard to tell what you're describing from any compiler, especially for us old guys whose compilers generated ASM code for intermediate representation anyway.

+2
source

All Articles