What is the programming language made of? [Closed]

Asked 1 years ago, Updated 1 years ago, 68 views

Do you want to improve this question?Edit this post and update the question to focus on one issue

Closed 7 years ago.

7 years ago

What is programming language made of?

What is that object that you can compile?
Why does that make your computer work?

Is it possible to write it by hand?

Also, I heard that PHP will eventually be converted to C language, but will other languages end up with C?

c language-specification programming-language

2022-09-30 15:04

3 Answers

A file that can be compiled with source code lists instructions and data for the CPU.The instructions are numbered one by one, such as reading data from memory to CPU if number 2 or adding data from memory to data from CPU if number 4.This number itself, or a list of these, is called machine language.Executable マシン Machine language.

Early CPUs didn't have many of these instructions, so I could memorize the numbers and write the executable directly.

However, it is so inconvenient that an assembly language is created.This is a name that changed the previous number to be a little easier to understand.The example above shows MOV and ADD.If you multiply the text file (the assembly language source file) by the assembly (this is a program that converts the text file to machine language), you can create a machine language executable.Assembled machine language according to source file

The assembler is much easier than the machine language itself, but it's still troublesome. 1+1 would like to write 1+1 and puts("hoge") to print characters on the screen.That's where programming languages such as C were born.The compiler converts the source files of programs written in human-readable grammar into machine language.(Some can print assembly source files instead of machine language)

The compiler will eventually output machine words, so you can write machine words that have the same meaning as long as you know the logic.

Typically, the compiler prints the executable file, but some languages run on the spot rather than convert it to the executable (interpreter language), and PHP is one of them.(There are some complicated concepts such as intermediate language, but I will omit them.)

If the PHP interpreter is written in C, that's right, but if you're running a PHP program and you're translating it into C language, that's wrong.

However, some languages are created in the form of converting themselves to C-language source files rather than outputting them, and then using the C compiler to make them into executables, but this is not common.


2022-09-30 15:04

I heard that PHP will eventually be converted to C language

I was curious about this, so I looked into it, but at least it doesn't seem to be the case with the official Zend Engine.

In addition, there is also an implementation that converts PHP to C++ because it can be expected to improve processing speed by compiling to machine language in advance.

Like the HipHop VM mentioned above, there is also a pattern of compiling and executing in machine language on the spot without going through C/C++.


2022-09-30 15:04

In general, compiler features are roughly divided into front-end and back-end.

The front end is the process of analyzing the meaning of the source code in a particular language.The programming language is usually made up of grammatical definitions such as Bacchus Nowa notation, and functional definitions of each grammar, so we analyze them according to the rules.

The backend, on the other hand, is the part that uses the structure of the analyzed code at the front end to create something else."That object that is compiled" is not always defined, and even in the same language, the compiler will print code for CPUs, virtual machines, other languages, and possibly documents.

In addition, CPU and virtual machines usually have a one-to-one corresponding language to the assembly language, which allows you to create executable files.Of course, it is also possible in principle to type machine language directly without using an assembler.


2022-09-30 15:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.