有一个简单的解释编译器是什么? [英] Is there a simple explanation of what a compiler is?

查看:130
本文介绍了有一个简单的解释编译器是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试提供有关的编译器


In trying to provide a simple answer to a post about a "C++ compiled app" I was surprised that there weren't any questions or answers about this basic topic. Even searches on Meta didn't find anything helpful, whether on explaining compilers or beginning compiler questions in general.

We want Stackoverflow to be a good place to find answers about programming. We shouldn't leave something so fundamental to Wikipedia. A simple analogy would be asking a master carpenter what a 10-penny nail is and getting brushed off. Sure it's a simple question but a carpenter who thinks explaining something so simple is beneath him/her is just being a snob in the best case, politely, or a jerk if otherwise.

At the very least, this question provides a place to gather links to compiler-related explanations inside or outside of Stackoverflow.

[Id make this CW but don't see the checkbox, has it been moved or deleted?]

In that spirit, I provide the link to the Wikipedia on compilers. Please edit this post with more links to compiler explanations.

Wikipedia entry on compilers.

解决方案

The Short Answer

To just summarize very briefly what the role of a compiler would be and leave the extensive explanation to Wikipedia's Compiler page, I'd just say that in general a compiler is a computer software which transforms an input source code written in a given form (usually targeted towards humans for readability) into an output program in a compressed form (usually targeted towards machines for execution). Alternatively, said software might go through several stages and produce multiple intermediate forms during processing, and might need to execute multiple passes and merge multiples input sources into one or more output.

The compiler thus simply acts as a static translator for a (usually formal) human language into a (usually even more formal and minimalistic) machine language or instruction set.

Some Distinctions to Keep in Mind

This being said, usually the term "compilation" gets mangled with other terms describing other steps of a full software production cycle, and might be used to refer to steps like pre-processing (to prepare the input before processing and apply other kinds of transformations in advance, for instance possibly using meta-programming concepts) or linkage (to assemble multiple intermediate objects).

A typical example could be the one of a C program, being compiled with a single command-line but which actually processes multiple .c (source) and .h (header) files into multiple .o (object) file and might then link these to multiple .a (assembly/library) files to produce an output program (.exe, .out, ...) or another .a or .dll or .so (assembly for dynamic or shared library for different platforms).

Said steps could also be performed by executing multiple command-lines instead, to dissociate the different operations occurring.

                     


This obviously is a very high-level explanation geared towards the IT-world, but there's no doubt that you can refer to the term "compiler" for other software and machines transforming an input of any kind into somehow executable or usable output of another kind.


Graphics courtesy of Wikipedia's Compiler page

这篇关于有一个简单的解释编译器是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆