Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would you do with Compiler as a Service

Seeing that we'll probably get this feature in the next release what are some of the things you either think you'll be able to do or things you would like to use this feature to do?

Personally, during code generation (say in a MSBuild task) I sometimes wish I could grok the code in the project and thus have the option to produce better (more code).

For example, if I have a partial class that has a partial method with a parameter of some type being sent in, then at the time of code generation I could use that information to generate better code.

In other words, I publish my "Intent" at the time of writing code and I could have code generators to the heavy lifting.

partial void InitCommandForStoredProc(ref DbCommand command, string storedProcName);

Given this info in a partial method I could generate the correct code.

So what do you all hope to be able to do with Compiler as a service?

like image 552
Shiv Kumar Avatar asked Nov 19 '10 06:11

Shiv Kumar


People also ask

What is the purpose of compiler?

Compilers analyze and convert source code written in languages such as Java, C++, C# or Swift. They're commonly used to generate machine code or bytecode that can be executed by the target host system. Interpreters do not generate IR code or save generated machine code.

What is Roslyn used for?

Roslyn is a collection of open-source compilers, code analysis and refactoring tools which work with C# and Visual Basic source codes. This set of compilers and tools can be used to create full-fledged compilers, including, first and foremost, source code analysis tools.

What is compiler and example?

1. Compiler : The language processor that reads the complete source program written in high-level language as a whole in one go and translates it into an equivalent program in machine language is called a Compiler. Example: C, C++, C#, Java.

What is a compiler in computer programming?

compiler, computer software that translates (compiles) source code written in a high-level language (e.g., C++) into a set of machine-language instructions that can be understood by a digital computer's CPU. Compilers are very large programs, with error-checking and other abilities.


4 Answers

To give (one) practical answer, LINQPad's IntelliSense will benefit immensely from CaaS. It will allow autocompletion to work with both C# and VB (assuming CaaS works for VB, too). It will also make it easy to write cool new refactoring tools.

Give us CaaS, and I'll make LINQPad a showpiece of what you can do with it :)

This feature is far too good to wait until C# 6 / VB 12

like image 140
Joe Albahari Avatar answered Oct 14 '22 01:10

Joe Albahari


Seeing that we'll probably get this feature in the next release

We have not announced scheduling or ship vehicles for any feature or product associated with the "compiler as a service" strategy. CaaS is a long-term forward-looking strategy for how we hope to build compiler architectures in the future. It's not a language feature, it's a strategy for building tools. At the recent PDC Anders did some demos of the sorts of things one might be able to do with such tools, but he specifically did not say when anything like that would ship. You should not expect it any time soon. The only feature we have announced will be in the next release is the asynchronous await feature of C# 5, and we haven't announced a schedule for that either.

what are some of the things you either think you'll be able to do or things you would like to use this feature to do?

Though I am personally very interested in answers to this question, I note that it is not a good candidate for a StackOverflow question. It's vague, speculative and subjective, rather than being about a specific technical coding problem.

Thanks for giving your scenarios though; they are useful to me.

UPDATE: October 2011

We have just shipped a preview release of the "Compiler As A Service" project, aka "Roslyn".

We are still not announcing a ship vehicle; it will be post Visual Studio 11.

like image 41
Eric Lippert Avatar answered Oct 14 '22 01:10

Eric Lippert


I think it would make the weaving process that Aspect Oriented frameworks do, much more powerful. Right now they almost all use some hacky technique that put's requirements on your implementation like inherit from ContextBoundObject, or make all your methods virtual. Having CaaS would make AOP frameworks first class citizens in .NET and I think that would be a huge benefit.

like image 38
Matt Dotson Avatar answered Oct 14 '22 03:10

Matt Dotson


On episode #541 of .NET Rocks!, Anders said the theme of C# 5 will be Compiler as a Service.

Anders Hejlsberg: I could tell you though that one of the things we're working on is this theme and every release has sort of had a theme.

Richard Campbell: Right.

Anders Hejlsberg: In 4.0, you could say the theme is Dynamic, and in 3.0 it was LINQ. The theme for 5.0 is compiler at the service, it's how we're thinking about it

http://www.dotnetrocks.com/text/0541/index12.html

Since April 2010, when this podcast was aired, further announcements at the 2010 PDC indicate the theme will no longer be Compiler as a Service, but instead will be Async programming. No announcements have been made to indicate why a change of theme was required.

like image 34
RichB Avatar answered Oct 14 '22 01:10

RichB