Why are interpreters used?

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1912 Views - Last Post: 18 January 2019 - 08:32 AM

#16 Nwb   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 11-November 18

Re: Why are interpreters used?

Posted 14 January 2019 - 10:34 PM

Quote

the linker will optimize the code

Skydiver, so the linker links when the user runs the installer/program. So it links only once?

How do I also make a linker for my applications like this?

This post has been edited by Nwb: 14 January 2019 - 10:35 PM

Was This Post Helpful? 0
  • +
  • -

#17 Nwb   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 11-November 18

Re: Why are interpreters used?

Posted 14 January 2019 - 10:52 PM

Can you link compiled files with interpreted files? How?
Say you want the best out of both.

One more question: Since Python just bundles the interpreter and source code when it makes an executable file, it can be decompiled.
https://stackoverflo...piled-by-py2exe

So doesn't mean that you shouldn't use Python to program distributed files that aren't supposed to be looked into?

Can we say the same for all JIT?

This post has been edited by Nwb: 14 January 2019 - 10:58 PM

Was This Post Helpful? 0
  • +
  • -

#18 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1641
  • View blog
  • Posts: 8,506
  • Joined: 07-September 06

Re: Why are interpreters used?

Posted 15 January 2019 - 07:26 AM

Quote

Can you link compiled files with interpreted files? How?


The simple answer here is "yes", however it does normally require that the side you want to use the linked stuff with is set up to work with it. For instance, you can write python and PHP modules in C, link them using python's (or PHP's, respectively) libraries, put them in a place that the language knows to look, and start using the highly optimized assembly in the scripting language.

One the other side of that coin, C and C++ allow you to add scripting languages to your applications and export symbols to them, if you compile in the scripting language and tell the compiler what functions you want the scripting language to be able to access. LUA is a common example of a C/C++ scripting language used for mods and plugins in a lot of games.
Was This Post Helpful? 0
  • +
  • -

#19 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7141
  • View blog
  • Posts: 24,251
  • Joined: 05-May 12

Re: Why are interpreters used?

Posted 15 January 2019 - 08:58 AM

View PostNwb, on 15 January 2019 - 12:34 AM, said:

Skydiver, so the linker links when the user runs the installer/program. So it links only once?

No. It's linked before release. Basically the process looks like this:
Compile --> Link --> Run scenarios to be optimized --> Link again --> Release to production.

View PostNwb, on 15 January 2019 - 12:34 AM, said:

How do I also make a linker for my applications like this?

See post #15.
Was This Post Helpful? 0
  • +
  • -

#20 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2754
  • View blog
  • Posts: 4,414
  • Joined: 21-June 11

Re: Why are interpreters used?

Posted 15 January 2019 - 09:48 AM

View PostNwb, on 15 January 2019 - 06:34 AM, said:

How do I also make a linker for my applications like this?


If you mean "How do I use the linker to perform optimizations like this", Skydiver's link answers that. If you mean "How do I program my own linker", you should probably look in a compiler construction textbook (though you should first make sure that it even covers linking - not all do) and then into the source code of a real linker. I'm not sure you actually want to do that though.

View PostNwb, on 15 January 2019 - 06:52 AM, said:

Can you link compiled files with interpreted files? How?


No. Linking is the process of turning (possibly multiple) object files into a final executable or library file. When using an interpreter, there's no such thing as object files when using an interpreter and you can't link source code. You can link against the interpreter itself (or rather its library version, which many interpreters have) and then use that to load and run the source code (which you can even embed into your executable) at runtime, but I wouldn't call that linking against the source file. And in the context of this discussion, it should be pointed out that doing so will in absolutely no way perform link-time optimizations on your interpreted code.

Quote

One more question: Since Python just bundles the interpreter and source code when it makes an executable file


Python (as in the official Python interpreter) doesn't create executable files. Py2exe (which is an independent tool, not part of the official Python distribution) does what you describe (or actually, it probably bundles the interpreter with .pyc files, not the original source code).

Quote

it can be decompiled.


Everything can be decompiled (though the decompiled code won't necessarily be readable - especially when using an obfuscator).

Quote

So doesn't mean that you shouldn't use Python to program distributed files that aren't supposed to be looked into?


There's probably obfuscators for Python if that's a legimate concern for your use.
Was This Post Helpful? 0
  • +
  • -

#21 Nwb   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 11-November 18

Re: Why are interpreters used?

Posted 17 January 2019 - 09:20 AM

Is obfuscation a thing at assembly level?
Was This Post Helpful? 0
  • +
  • -

#22 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7141
  • View blog
  • Posts: 24,251
  • Joined: 05-May 12

Re: Why are interpreters used?

Posted 17 January 2019 - 12:34 PM

Yes. Before Microsoft bought Skype, part of Skype's defense in depth was also obfuscating their code all the way down to the assembly level by having multiple code paths interleaved with essentially complex do nothing paths or paths that do a round about trip to nowhere. Also if you look at some of the anti-piracy approaches on the Commodore 64, the 6502 assembly of the actual game would have red herring code mixed in. Basically, a decompiler needed to be really smart to follow all the code paths and tease out the real relevant code from the noise.
Was This Post Helpful? 1
  • +
  • -

#23 Nwb   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 98
  • Joined: 11-November 18

Re: Why are interpreters used?

Posted 18 January 2019 - 04:59 AM

Is there no way other than obfuscation that you can use to preserve your code?
Encrypting somehow?

It wouldn't make sense to obfuscate C++ right.. the compiler will just undo all the obfuscation thanks to its optimizing.. Then what do you do?

I'm just curious not planning to do any obfuscation or anything.

Is it easy to decompile? When you decompile do you get the entire assembly code?
Was This Post Helpful? 0
  • +
  • -

#24 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15363
  • View blog
  • Posts: 61,613
  • Joined: 12-June 08

Re: Why are interpreters used?

Posted 18 January 2019 - 08:32 AM

Yes, encryption can be used to a degree but at some one point the system needs to decrypt that code and there is a vulnerability.

Yes you can obfuscate c++ code on build. "c++ obfuscator"

Easy to decompile? Depends, as mentioned by skydiver.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2