News for hackers. Stuff that matters.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by lmkg on Thursday October 20, 2011 @12:23AM (#3133438)
So I read Eric Lippert's blog post on Roslyn[1], where he says the motivation for the project was because other teams within Microsoft were re-implementing parts of the C# compiler piecemeal, so it made sense to expose those parts as an API. You know what that reminds me of? Steve Yegge's Platform rant. Specifically, the part where Bezos made Amazon convert all of their existing development infrastructure into services, that other units can make use of. That's what Roslyn is, on a much smaller scale: refactoring an application (the compiler) to be services-oriented platform.

http://blogs.msdn.com/b/ericlippert/archive/2011/10/19/the-r...

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by contextfree on Thursday October 20, 2011 @12:30AM (#3133458)
Not only that, but iirc the project Steve Yegge is actually working on at Google is something along the same lines - a code analysis platform (for the JVM I think?)
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by mullr on Thursday October 20, 2011 @12:30AM (#3133453)
Not really, no. It's more like a compiler as a library with a nice API.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by barrkel on Thursday October 20, 2011 @02:50AM (#3133756)
Libraries can be platforms too.

Platforms are a mode of operating when providing, on an ongoing basis, something that third parties use. There are several "promises" around platforms: a promise not to break compatibility, a promise not to coopt client software features, and - oddly enough - a promise to be incomplete, so that third parties have opportunities to build.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by scott_s on Saturday October 22, 2011 @07:39PM (#3144638)
The authors certainly see it in this way: The transition to compilers as services dramatically lowers the barrier to entry for creating code focused tools and applications.

From http://msdn.microsoft.com/en-us/hh500769

I agree with the parent. Yegge's platform rants is what I thought of, too.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by Jupe on Wednesday October 19, 2011 @10:11PM (#3133089)
I think this is quite interesting. The ability to treat code as data is an incredibly powerful concept. I don't know exactly what Roslyn does, but I see a lot of potential:

1. Measuring code complexity. I've often felt that code complexity can be gauged several ways, and one is the number of "if" statements (or select..case). Being able to query the code base of an extremely large solution is a big step in that direction.

2. Being able to "query" the call stack - how do I get from this line to the base constructor of my "user" object. Rather than stepping through the debugger, it could be a query of the code base to find the path from here to there.

3. Detecting bit-rot. Finding any method class that's simply never used could be another "query" of the code base. Yes, proper test-coverage would help detect this, but not every production system has unit tests.

4. I've worked on projects in the past where we really wanted to add guid tracing to the preamble of each function to dynamically trace the code at run time. If Roslyn supports "update" queries of the code, it might be easy to add such a feature across the whole code base (or perhaps only classes that inherit from some known base class).

Managing a code base like this (rather than grepping/searching) is a powerful concept. Perhaps we could see a LINQ for source code some day?

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by solutionyogi on Wednesday October 19, 2011 @11:34PM (#3133333)
Great points. Resharper already does some of this.

1. ReSharper has a plugin to analyze cyclomatic complexity. http://confluence.jetbrains.net/display/ReSharper/Cyclomatic...

2. ReSharper has Call Tracking and Value Tracking.

http://www.jetbrains.com/resharper/features/code_analysis.ht...

3. Once again, if you are not shipping code to outside customers, you can use Solution Wide Analsys to find out unused code.

http://www.jetbrains.com/resharper/features/code_analysis.ht...

4. PostSharp helps you with your Aspect oriented programming.

http://www.sharpcrafters.com/postsharp/features

ReSharper is already very powerful, imagine if they don't have to write their own lexer and parser and can use the lexer/parser used by the C# compiler. I think they can build more useful features and users are isolated from bugs in their lexing/parsing.

I think this is an amazing development and I can't wait for this to go live so that there will be many products like Resharper helping us analyze and improve our code.

Relevant SO thread: What would you do with Compiler as a Service.

http://stackoverflow.com/questions/4222524/what-would-you-do...

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by euroclydon on Thursday October 20, 2011 @12:50AM (#3133487)
Yes, but who will help us analyze and improve our use of compiler as a service?
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by SeveredCross on Wednesday October 19, 2011 @11:29PM (#3133319)
I agree with all of your points, though the only one I can address is the LINQ for source code quip and amend it somewhat to an already possible "LINQ for codebases." It should, in theory, be just a few weekends worth of work to use Mono.Cecil (https://github.com/jbevain/cecil) to provide a nice queryable API to inspect an (already compiled) codebase. I'm sure some nice static evaluation tools could be written based on this that nobody's thought of yet.

That said, being able to inspect the source-code pre-compilation is a whole other level above and beyond—as a fan of the compile-time safety that statically-typed languages provide, any opportunity to eliminate bugs and complexity before the code makes it to a customer is a welcome one, and if Roslyn is good, it could be huge.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by solutionyogi on Wednesday October 19, 2011 @11:37PM (#3133339)
Roslyn will be good. It has to be because from what I understand, the MS team themselves will use Roslyn in Visual Studio and other products. Roslyn isn't just a public API for others to analyze code. It will be the foundation on which .NET framework languages will depend upon.

See Eric Lippert (Member of the Roslyn team, C# Principal) notes here:

http://blogs.msdn.com/b/ericlippert/archive/2011/10/19/the-r...

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by SeveredCross on Thursday October 20, 2011 @12:25AM (#3133447)
Well…I think Roslyn will be good, but I think it's reaching to say it must be because the MS team themselves will use it.

After all, these are the same people who invented (and used!) MFC, long known as the Microsoft Frustration Classes.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by xpaulbettsx on Thursday October 20, 2011 @01:04AM (#3133528)
1992 called and wants its Microsoft stereotype back.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by SeveredCross on Thursday October 20, 2011 @01:16AM (#3133554)
It was a joke, lighten up. For what it's worth, I'm a .NET developer and think it's awesome.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by solutionyogi on Thursday October 20, 2011 @04:04AM (#3133933)
Well, MFC was actually a library. And I know it was a poor library. But this is a different ball game.

With Roslyn, they are going to write C# compiler in C# itself (and VB compiler in VB). And if they expose this as an API, it's guaranteed that I will be able to parse every valid C# file.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by viggity on Thursday October 20, 2011 @10:00AM (#3134836)
I wrote a static code analysis tool with Cecil (you can write linq statements against your assemblies). And it is free. www.nitriq.com
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by vogonj on Wednesday October 19, 2011 @11:46PM (#3133353)
as someone who's tried to use Mono.Cecil, it kind of sucks if you're not already developing on the Mono toolchain (among other things, there's no interoperability between System.Reflection types and Mono.Cecil types, and even if you're on Mono, I don't think you can "vivisect" running Assemblies.) Microsoft has a product called FxCop (http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx) which does style analysis and linting -- however, the code analysis is all embedded in the FxCop binary and undocumented.

suffice to say, I'm psyched about Roslyn -- more about code transformations than correctness aids.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by rbanffy on Thursday October 20, 2011 @12:25AM (#3133446)
> The ability to treat code as data is an incredibly powerful concept.

It was innovative too, in the late 50's...

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by rbanffy on Thursday October 20, 2011 @04:13AM (#3133950)
It's an old saying, "Those who do not know Lisp are doomed to reimplement it."
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by duncan_bayne on Thursday October 20, 2011 @05:58AM (#3134173)
Interesting. Some years ago my business partner and I wrote a server in Ruby on Rails that used Mono to compile customised .NET assemblies on the fly. Worked very nicely for our problem domain but was ultimately scuppered by CAS workarounds.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by equark on Thursday October 20, 2011 @02:24AM (#3133701)
If Rosyln is written in C# does this mean Roslyn can run on Mono?
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by chrisbennet on Wednesday October 19, 2011 @09:32PM (#3132986)
I image keeping my development tool in Redmond ensure I keep paying fees but what does this do for developers?
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by contextfree on Wednesday October 19, 2011 @10:37PM (#3133168)
This has nothing to do with tools running on a server. The "compiler as a service" phrase they were using apparently misled people into thinking it had something to do with "software as a service", which is why they aren't using it anymore. It's about allowing external programs to plug into the compiler pipeline and reuse its syntactic and semantic analysis capabilities.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by bjg on Wednesday October 19, 2011 @10:42PM (#3133183)
As mentioned in the link, there are two presentations you can view.

Interesting demo during BUILD: http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-816T

You can skip to 35:40ish

Cool presentation from MSR: http://research.microsoft.com/apps/video/?id=152281

You can skip to around 5:00

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by mullr on Thursday October 20, 2011 @12:32AM (#3133461)
The build video is somewhat amusing to me. The crowd was WAY into the REPL demo, wherein they showed things that any dynamic language has been doing for decades, all the while trumpeting the "power of static typing". There IS power in static typing, but by the time you're in the REPL you don't need much of it.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by jules on Thursday October 20, 2011 @06:27AM (#3134221)
Intellisense in a REPL based on static type information is novel, as far as I know. Some dynamic languages do this based on dynamic type information, but that is limited to expressions whose value is known. For example you have a variable A in scope at the REPL, and it has a method A.foo(), then you'll get completion on .foo. But you'll not get completion on A.foo().bar(), because the value of A.foo() is not known at the time of typing that expression.
Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by ajanuary on Thursday October 20, 2011 @03:58AM (#3133924)
I dunno, the reliability of Intellisense static typing gives combined with a REPL would be even more useful for exploration.

That aside, it's exciting to have the ability to have both.

Re:Microsoft previews Roslyn: .NET Compiler-as-a-Service inf... by skrebbel on Thursday October 20, 2011 @02:34AM (#3133722)
I was equally confused about this for a while. With SaaS in practice being "runs on the vendor's servers", I think "CaaS" is a badly chosen name.

I think it's ridiculous to thumb down the parent just because he misunderstood this.