Question about running "executables" without source code

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Messages
3,372
Reaction score
465
I have a simple question I guess, basically by how classes etc are formed. In general a class in C++ has some categories such as private, public and protected, which okay everyone knows/can find what they are meant for. E.g. a private member will not be accessible outside the class member functions. My question is then, is it possible to completely hide it from the user then? Or even hide the whole class if you don't want them to "play around" with it?
As an example, my question is related to the intermediate step between having a source code which runs and produces executables from the programmer, and the application which is publicly distributed. When I install a game X, I am unable to see the code which actually built it and runs behind the scene [except maybe for if I am a cheater or something]. what happened to it? In the past I had tried sending to a friend just the executable of a fun project I made [with python in that case], but she was unable to run it without the code- however I didn't want to send the code which would need more stuff from her side to run [e.g. download the necessary interpreter, modules etc] but also because it would make the project easy to change by the user.
 
Physics news on Phys.org
ChrisVer said:
I have a simple question I guess, basically by how classes etc are formed. In general a class in C++ has some categories such as private, public and protected, which okay everyone knows/can find what they are meant for. E.g. a private member will not be accessible outside the class member functions. My question is then, is it possible to completely hide it from the user then? Or even hide the whole class if you don't want them to "play around" with it?
These are high level constructs. It is possible to reverse engineer some things, like figuring out algorithms, by looking at executables, but I would be very surprised if someone could recover object-oriented constructs.

ChrisVer said:
As an example, my question is related to the intermediate step between having a source code which runs and produces executables from the programmer, and the application which is publicly distributed. When I install a game X, I am unable to see the code which actually built it and runs behind the scene [except maybe for if I am a cheater or something]. what happened to it?
The code was transformed into a binary executable, which involved a compiler going many times through some high-level code and mangling it into a series of assembly language instructions, including some optimization. One can disassemble the binary to get back assembly code, but figuring out what it is doing is going to be hard.

ChrisVer said:
In the past I had tried sending to a friend just the executable of a fun project I made [with python in that case], but she was unable to run it without the code- however I didn't want to send the code which would need more stuff from her side to run [e.g. download the necessary interpreter, modules etc] but also because it would make the project easy to change by the user.
Python is not really a compiled language, isn't it? Also, compiled programs may rely on outside code found in libraries. Make an executable doesn't necessarily mean making something that is stand-alone.
 
  • Like
Likes   Reactions: QuantumQuest
That's what a library is. You know how if you want to talk to a database, you #include <mysql.h>, but if you look at mysql.h, it's just a list of functions with no actual code? That's because that's the public interface for what is behind the scenes a very complicated piece of software. That's because you also have to link mysql.lib. This .lib file (can also be .dll, .so, .a) is a precompiled library. It means the original source was compiled with a public interface, and you can use it as though it were just more code.