How does the integration between IDE and compiler take place?

4

Taken from here: What is programming language, IDE and compiler?

  

In general the compiler is a console program, but there are cases that they are libraries that can be used in conjunction with other programs.

The integration between the IDE (integrated development environment) and the compiler leaves me with doubts.

When there are errors in the user code, the IDE needs to convert the errors reported by the compiler into something friendly to mount on the text editor screen and show the user (with red / yellow underscore under the warning , etc.).

When the compiler is a library I imagine it is friendlier to do this integration, but when is it a console program? How does the IDE do to read the information provided by the compiler?

Can the compiler itself be configured to return the errors in a more user-friendly way to the IDE, or does it have to turn around to parse all that standard output that the compiler shows when we try to compile by the command line? / p>     

asked by anonymous 14.10.2018 / 16:53

1 answer

3

A compiler is a program, that is, it is a set of algorithms. The way it is encapsulated to run on a computer matters little. It is common to be a console application, but it can be anything else. There are compilers that have been written to be primarily a library and be used in many ways, console is just one of them.

Those that were not written like this, do not have a specific form of integration and no adaptation was made, communication is done via console itself, ie, calls the executable in another process passing the specific arguments to do what want and capture the result it emits in console (does not have to be showing on the screen). It's simple and rough like that :) He takes the text that comes out there, gives a slight interpretation and shows in a convenient way the way he thinks best.

It is possible that some compiler has some configuration that facilitates something, but in general does not have or is something very simple, nothing that will change much the final result. Nothing prevents, but I do not know anything that is really flexible, that can be used by IDE for additional information.

Some cases the IDE may want to use a compiler itself to do some tasks, usually something more limited and it will not do all the work that the real compiler does, but it can be based on it since today almost everything is open source and can be scrambled as needed. But of course some are made from scratch and the compiler is from the IDE (even though it's from it, it's not the IDE that's doing the work).

These underscores are usually made by this internal compiler and not by the official compiler. So it's usually a library, even if it's adapted to it. It would be impractical to invoke all the time a full compiler to indicate the errors in every thing you are typing.

There are languages that provide a language server where the IDE can communicate through an API. It's no different than a library, only the API access is that it's different. I prefer everything in the same process.

One of the reasons that the .NET Compiler Platform was created is that it does not have to write another compiler for each type of need, and it's something other languages are doing, such as Rust case .

There is no single solution, but the default compiler in the language console is not usually used to help with code editing. Almost all IDEs have their own syntax compiler and even semantics, but without optimizers or code generator, of course.

    
14.10.2018 / 17:17