write a programme which will show you which programming language you used to write this programme

Dani AI

Generated

The original request from can be read two ways: a trivial self-reporting program that prints its own language, or a detector that examines source (or binaries) and guesses the language. As noted, variations of this question appear often; was right to ask for effort; linked an earlier thread.

For a self-reporting program the usual, reliable approach is to embed the language name (or let the runtime report itself). Examples:

# Python
import sys
print("This program was written in Python", sys.version.split()[0])
/* C */
#include <stdio.h>
#define LANG "C"
int main(void) {
    puts("This program was written in " LANG);
    return 0;
}
#!/bin/sh
# Shell
echo "This program was written in sh/bash"

For a general detector (guessing the language of a file), use simple heuristics first: file extension, a shebang (#!) line for scripts, and a few language-specific tokens. For robust detection, use an existing library such as GitHub Linguist (used by GitHub for repo language stats) or a lexer-based tool like Pygments. These tools combine extension, filename, and content statistics and are far more reliable than ad-hoc regexes:

A cautionary note: compiled binaries or bytecode often do not uniquely identify the original source language (JVM/CLR bytecode can come from many languages). For reproducible results, add an explicit header comment or metadata during build (version info, LANG macro, or an embedded resource) so the resulting artifact can report its origin.

For forum follow-ups, include a clear goal (self-report vs. detector), a sample file or build command, and any constraints (interpreted vs compiled). This prevents duplicate answers and speeds useful replies.

Recommended Answers

All 4 Replies

This has been posted before. Please use the search function

Ok, I see. What is your question? Or your contribution? Well, I tell you, nobody will help you, unless you show some effort. So please, ask (a) question(s).

>Are you suggesting they're incapable of finding their own ass in the dark\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b post? ;)
http://www.daniweb.com/forums/thread145077.html

Considing it was the same person.. Yes :) I would suggest they would suffer from the affliction you mention.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.