Search code examples
programming-languages

How do I find out what programming language a specific piece of software is written in?


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.


Solution

  • 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.