What is dynamic code and static code?

Asked

Viewed 721 times

10

Recently in a conversation with friends came the term dynamic code and static code. With this came a certain discussion. Some said that dynamic code is related to scaffolding, others with code analysis. Others say it is the simple fact that the system generates the code for you.

But in fact, what is dynamic code and static code? Some or all of these descriptions are correct?

  • 3

    It depends on the context. In the current form, I find it difficult to give an adequate answer.

  • @bigown These terms do not have a standard "meaning", or global, so to speak?

  • I don’t know. And it seems that each of the two are being used "in this conversation" for things so different that already shows this. It seems they are not being used one as opposed to the other. The obvious Google search shows that this has to do with code analysis in both cases, but this is a Google glitch. The word "analysis" makes all the difference in context.

  • @bigown So these definitions are not wrong? Of course, depending on the context.

  • 1

    Depending on the context anything is right :) For me static code is the one that is all generated at development time and dynamic code is the one that is generated at runtime. By generation, you can understand how to adapt too.

  • Thanks @bigown. Already helped me. I’ll let the question press to see if anyone else has any opinions. But if you want, you can vote to close, I really agree with you that it’s a little wide, but there’s no way to express myself better about it, unfortunately.

  • I consider dynamic code something changeable without code rewriting. Ex.: A code that supports parameterization is dynamic. If it employs constants, it is static. But it goes from case to case.

Show 2 more comments

1 answer

16


Code analysis is something that looks different from what is being treated. There is static analysis (a compiler-like tool does this in source code) and dynamic analysis that tracks actual code execution.

Static code, in a given context, is a term that has little use. It indicates that the code was generated manually or automatically (in scaffolding, for example) at development time.

Dynamic code is one that is generated at runtime. This requires that the language and environment where it runs allow this to occur. It has several techniques to accomplish this. Some safer, others dangerous. Eventually we can say that the simple injection of code can be a dynamism. But I don’t know if it can be applied here if the code was previously generated.

Maybe you’re talking about self modifying code.

In other contexts, it can mean something else.

  • self modifying code is a "term" I didn’t know. I found the explanation interesting. + 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.