In which programming language (not using the garbage collector) can you generate a method code, save it and use it at the next program start?
What methods are there at all?
In which programming language (not using the garbage collector) can you generate a method code, save it and use it at the next program start?
What methods are there at all?
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
It is possible in many, different only the level of service provided to you by the compiler / standard library. If you can generate a data file, then you can generate an executable module.
For example, in .NET you can compile the source of the .NET class into an assembly , since the compiler is part of the .NET framework. After successful compilation, you can immediately connect the assembly through Assembly.Load.
Java has a similar opportunity.
With other languages ​​that do not contain a compiler in the runtime library, you will have to independently generate the executable module in the format of your OS. This task is feasible, because compilers are usually written in the target language. Another question is whether you want to take on this rather time-consuming task.
PS: .NET is not executed by the virtual machine, it has a JIT compiler.
eval
. Although eval
is not a feature of "interpreted" languages. - VladDThe question is some muddy. In the statement of the author, almost any programming language falls under this definition. Any PL in one way or another uses bytecode (object code) that can be used the next time it is run. Even SQL has the concept of a precompiled query, I will generally keep silent about all sorts of different interpreters - of which there are countless numbers - there, too, there is a concept of some kind of bytecode, which can be saved and run as needed. Az sinner is also the author of one scripting tongue (still used in the depths of one very big office) - so I know what I'm talking about.
The author is so cunning.
In which programming language ( not using a virtual machine ) can you generate a method code, save it and use it at the next program start?
If we can generate the code and save it, then it needs to be done so that you can easily download it back. Load binary code? It is not comfortable.
If you want such flexibility, then in any case you will have to use some kind of bytecode. Or download directly as the source code.
By topic: Common Lisp comes to mind.
LoadLibrary
+ GetProcAddress
(Windows native), Assembly.Load
+ Assembly.GetTypes
(.NET) - what could be simpler? - VladDdlopen
+ dlsym
and a few verbose tricks for Java . - VladDMore detailed information is needed about the specific application, the environment in which it is planned to be launched, and the requirements of the TOR, otherwise the only answer is to use the make command to start the application, rebuilding it from C ++ source codes (the only mainstream language is OOP and without garbage collection).
In fact, it’s quite a solution - zaphaet all of your proprieritarny commercially significant code in a binary library without source code, and drag the modified part in the source code, and compile it into an executable file when you start the application.
Otherwise, you can dummy to create another supercompiler for the metaprogramming language 8-)
Source: https://ru.stackoverflow.com/questions/168017/
All Articles
eval
can be used, but they all have virtual machines. But, for some reason, I suspect that the author does not want to write a compiler. Therefore, I ask - why do you need it, what goal (code generation is clearly not an end in itself) do you want to receive? Perhaps here it is not necessary ... - drdaeman Nov.