Given a executable file (Windows, Linux or Mac OS X) of an application, is there a way to figure out the programming language that was used to write that application?
-
Possible duplicate - http://stackoverflow.com/questions/1704202/determine-source-language-from-a-binary/1704449#1704449. In most instances there will be 'distinctive' features, but it won't be trivial - e.g. there isn't a standard metadata header stamped with language, compiler, version etc. – StuartLC Sep 16 '11 at 06:08
3 Answers
In the general case, I would think not. In a specific case, however, it might be possible.

- 3,172
- 18
- 27
-
You can give a unqualified **no** to the _general_ case because I can design two simple languages right now and make compilers for each that generate the exact same executables for "similar" programs in each language. – Ray Toal Sep 16 '11 at 06:06
Highly unlikely unless there is some specific metadata associated with it or some language specific feature associated with that exe. Executables are (usually) code compiled for a specific platform or intermediate code that will be just-in-time compiled for a specific language. In the case of JITed code you might be able to determine if its .NET or some other language that produces an intermediate code but for the most part this is a fairly difficult and unreasonable task. I could be wrong but from my understanding this isn't possible.

- 12,451
- 19
- 58
- 82
I might as well throw in a late answer.
Even if a compiler for a given programming language decides to throw out some metadata such as symbols in a data section with a message like "Compiled from Joe's C compiler version 4.1.104" nothing -- nothing at all stops me from writing a Go compiler that writes the same message into the same location in the data section to trick unsuspecting people looking at the executable.
Not to mention there are an infinite number of compilers that can be written for any given language.
And suppose we look at an executable containing just a few bytes.... say nothing more than incrementing a register. Hundreds of different languages admit compilers that in theory could optimize down to a metadata-free, single section executable.
The answer is simply no.
TL;DR: You can always spoof.

- 86,166
- 18
- 182
- 232