2

Whether I'm using a freeware countdown timer, a utorrent client, video player, etc. is there an easy way to find out what programming language it is written in? Especially if it is one of the more mainstream programming languages such as C, C++, Java, Perl, Basic, etc.

I'm familiar with PHP and JavaScript for web use and have no trouble opening and editing those files, but now that I'm looking to pick up a non-web programming language, I would like to increase the scope of my skills a bit. I'm having a bit of difficulty finding out what language the various applications I personally use were written in. I would like to compare languages with real-life examples that I'm familiar with.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Simon Suh
  • 10,599
  • 25
  • 86
  • 110
  • 1
    You mean from the executable, not from the source code? – Tim Pietzcker Dec 23 '10 at 12:25
  • 1
    @Tim: is there an automatic tool which can tell the language from source code? – Vlad Dec 23 '10 at 12:34
  • @Vlad: See [this question](http://stackoverflow.com/questions/924929/parsing-source-code-unique-identifiers-for-different-languages). – Tim Pietzcker Dec 23 '10 at 12:37
  • 7
    May be, you could simply ask the developers of an application? – SK-logic Dec 23 '10 at 12:42
  • @Tim: the answer at that question is that there's no answer :-) Indeed, how would you distinguish between C and C++ if no classes are used? Also C# and Java can look very similar. – Vlad Dec 23 '10 at 12:55
  • Possible duplicate of [Find Programming Language Used](http://stackoverflow.com/questions/371460/find-programming-language-used) – Roland Dec 07 '16 at 14:05

2 Answers2

6

Examining the list of shared libraries (DLLs in Windows-speak) of a compiled program can give a clue, because typically each language has a specific distinctive library to provide the runtime environment.

For example, on my Linux PC, running the ldd command on an executable produced the following tell-tale output:

ldd *redacted*
    linux-gate.so.1 =>  (0x0042e000)
    libxerces-c.so.28 => /usr/local/lib/libxerces-c.so.28 (0x004b0000)
    *redacted*.so => not found
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x05f28000)
    libm.so.6 => /lib/libm.so.6 (0x00a61000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x05be0000)
    libc.so.6 => /lib/libc.so.6 (0x00906000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00a93000)
    /lib/ld-linux.so.2 (0x008e7000)

The use of libc.so suggests C or C++. The use of libstdc++.so suggests C++. In fact that was a C++ program.

Searching the program executable for human readable strings can also given clues, especially if it has debugging information present.

For example, running the strings command on that same executable revealled (among much other text) the following tell-tale strings:

virtual std::ostream* XmlToDcs::AmsResultsHandler::createOutputFileIfPossible()
pointer != static_cast< unsigned int >(-1)
std::ofstream* XmlToDcs::IndexElementsHandler::createStatementsFile(const tm&, char, char, unsigned int)
EamResultsHandler.cpp

The first three look like fragments of C++, the last looks like the name of a C++ source code file.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
2

I'd say that nowadays, most common programming languages used for desktop applications would be C++, .Net and Java (don't know about apps on Macs).

I think the thing to consider is more what you want to achieve and on which plateforms you want it to run. Java will give you all platforms for free, provided the user has a JVM on his computer. .Net will make it easy to develop for Windows but requires tools from Microsoft sometimes having a free but limiting license but usually expensive. C++ will allow you to develop for multiple platforms but involves more effort to make your program portable and to compile it for several OS/processors.

To identify .Net or Java programs, simply read the README file provided with the program. I will state that you need a certain version of the .Net framework or of a Java Virtual Machine to run the program.

Also check if the program is simply a script, if it needs an interpreter (PHP, LUA, Python, ...). That should also be mentionned in the README file.

Harder will be to distinguish between C and C++. Both get compiled to an EXE file and do not require any kind of external virtual machine to run.

Vincent Mimoun-Prat
  • 28,208
  • 16
  • 81
  • 124