Programming languages?

Home » Programming & Design » Programming languages?
Programming & Design No Comments

When launching a computer program how does a computer recognize initially which programming language is being used and does every individual alphanumerical character have its own binary expression unique to each programming language or is it only the written lines of code that have their own unique binary

When launching a computer program how does a computer recognize initially which programming language is being used and does every individual alphanumerical character have its own binary expression unique to each programming language or is it only the written lines of code that have their own unique binary expressions for each programming language?

Best Answer:

Laurence: Imagine that you only speak English. A German person would have to speak through an interpreter (compiler) for you to understand. The same for a French person or a Russian person or a Chinese person. So no matter what language was being spoken, the end result is that it is converted into English – your native language. All you ever hear is English.

That is how it works with computers. It doesn't matter what language the program was written in, it always just ends up in the native language of the computer's CPU. Just like you need a different interpreter for each human language, a French interpreter for French and a German interpreter for German, likewise you need a different compiler for each computer language.

So in the end the computer only sees everything in it's own native language – machine code.

Other answer:

Laurence:
So many levels that this can be answered on…
Assuming you mean an executable file, like a .exe on Windows. Then the file would be in some executable format, like ELF (Executable and Linkable Format), which the OS loads into the process' virtual memory space and kicks off execution of. The original Language does not matter. The Language's Compiler and Linker produce the executable file.
Some languages require run-time environment support, so the run-time environment libraries have to be linked into the executable file, but that is taken care of by the Linker before the file is executed, so to the OS/Computer they just look like library calls.

With interpreted languages, you have to start the interpreter first, then it uses the text program as data to drive the interpreter. So, for example, if you are using a Python program, when you start a file named xyz.py, the OS will see the .py extension and automatically start the Python interpreter and pass xyz.py to it as the program to be executed.
Or you could start the Python interpreter and tell it to execute xyz.py

EddieJ:
A computer doesn't need to recognize which programming language is being used — it is always machine language.

The programmer has to run a compiler to convert the source code into machine language. Different compilers are used depending on the language the program was written in.

In terms of a language like Java which is NOT fully compiled, the Java interpreter is in machine language, so the program is not being executed directly by the computer. The computer only knows machine language.

Kevin:
Imagine that you only speak English. A German person would have to speak through an interpreter (compiler) for you to understand. The same for a French person or a Russian person or a Chinese person. So no matter what language was being spoken, the end result is that it is converted into English – your native language. All you ever hear is English.
Chris:
When you write a Java program, you can't tell Windows to run it; you have to tell the Java compiler to compile it, then tell Java to run it.

When you write a Python program, you launch Python and tell it to run your program.

When you write a JavaScript program, you insert it into HTML code, then open that in your browser, which has a built-in JavaScript interpreter.

And so on.

Once a program is compiled, the original language doesn't matter; compilation translates it into the computer's / OS's native language.

injanier:
The source code that a programmer creates is compiled into a binary file that is specific to the operating system it is intended for. Each command in the program is translated into a specific sequence of machine-specific binary commands; the variables are assigned pointers to memory locations.
jplatt39:
Character encoding is usually handled by the OS. Computers are usually told, for example by file extensions like .cc .c .java or .pas when something is source code and what to do with it. And if you feed it something which is not source code it will complain.
Owen:
a program is a text file or compressed binary file that is read by an application
sarah:
No

LEAVE A COMMENT