Using Mono Compiler / Creating New With Windows EXE Output?

This is just a thought now, but I wonder how hard it would be to use the Mono Compiler or write a new one while still displaying the Windows EXE?

The reason for this thought is that I see that people "abuse" the C # language and get some things creatively, such as code contracts or aspect-oriented programming, and sometimes it seems that people are stretched too much.

The good thing about .net is that in the end, all we want is a valid IL for the .net 2.0 CLR. However, the Microsoft C # compiler is closed and cannot be extended. Mixing different languages ​​is possible only in different assemblies.

The thought (warning: may sound awful) is to use a compiler that can be expanded and run as a kind of preprocessor. Thus, it would be possible to add new concepts of keywords and languages, while maintaining a valid IL.

The obvious drawback is, of course, that a) it is not C #, but C # is a deficit that no one understands, b) it is difficult to write a compiler, since many rules must be respected to maintain high quality and logical syntax.

But, as said, this is just a thought. This is a bit in the same direction as Mono.Cecil, but a completely different approach.

+4
source share
1 answer

I look forward to the evolution of programming away from text and something more structured. Programs are already very structured, but still edited as plain text, which makes the IDE the main exercise in inventiveness. Add a compiler extension on top of it, and creating an IDE that is as friendly as Visual Studio sounds even more intimidating.

Macros based on AST + C # would significantly advance even more “creative abuse” of the language, but I feel that the real way forward is Language Programming . This approach has been advocated for years, but the first system of this paradigm that I personally found really attractive is the Meta Programming System> JetBrains. This is not very well known yet, and of course I do not have practical experience in its use, but they deliver an excellent product created using this system, so it should be quite practical. The textbook shows how extensible it is, which is really amazing, especially if you have not seen language systems before.

If someone had to go down this route, only parts of the existing Mono compiler are important. You could probably significantly reuse large parts of the gen code, but obviously the parser is generally useless.

A system like MPS, but compiled before .NET and integrating perfectly into Visual Studio, would be very welcome.

(And to answer the question that you ask directly: I think it would be very difficult to do it well enough to see widespread acceptance, but, of course, not impossible for several great and motivated developers)

+2
source

Source: https://habr.com/ru/post/1302906/


All Articles