5 ms·
Microsoft previews Compiler-as-a-Service software
- CurtHagenlocher 15y agoUnfortunately, this article conflates two things: the C# REPL, and the C# compiler-as-a-service. Both are part of Roslyn, which is a reimplementation of the C# compiler written in C#. (It was previously written in C++.) The REPL could have been implemented on top of the older C++ compiler. The C# REPL is something that Mono has had for a few years now. The compiler-as-a-service has some resemblance to what LLVM + Clang enable for a C compiler.
- haasted 15y agoDoes anyone have more information on this bit? "It resembles a model developed by Miguel de Icaza's Mono Project, in which the information the compiler generates about a program can be reused as a library." Sounds very interesting, but the article unfortunately doesn't go into much detail about the information that is made available.
- bad_user 15y agoBasically you can just compile and execute arbitrary strings of C# code at runtime. Here's a small tutorial on doing something with Mono's implementation: http://weblogs.asp.net/jgalloway/archive/2011/05/26/dynamic-asp-net-mvc-3-models-using-mono-s-compiler-as-a-service.aspx http://weblogs.asp.net/jgalloway/archive/2011/05/26/dynamic-...
- thwarted 15y agoSo it's eval, and they skip all the dire warnings from everyone about eval being bad by calling it Compiler as a Service.
- LeafStorm 15y agoThe main issues with using eval come when eval has access to the scope of whatever is calling it, as it can make unpredictable changes. Just compiling and running code constructed at runtime isn't a bad idea in itself, as long as you use proper techniques to ensure that users can't do code injection.
- thwarted 15y agoThat's a good point, and is an language design/implementation specific condition. PHP doesn't create a new stack frame for eval'ed code, so it runs right in the context of the calling function. In constrast, LambdaMOO does create a separate stack frame, which is subjected to the same scope rules as any other function call. You can control if it does or not in perl (by stuffing some additional syntax into the eval'ed string). But the usual issue that is bandied about is how it's inefficient because it needs to invoke the code parser. Searching hacker news for eval shows the wide range of positions, a lot (but not a wide majority) just parrot the inefficiency argument. But there are also a few posts with solid reasons to use eval too.
- michaelfeathers 15y agoThe title scared me. My first thought was that they were going to charge per compile.
- FrancescoRizzi 15y agoyou are giving them ideas... and me nightmares!
- codedivine 15y agoI found a presentation here (pdf): http://research.microsoft.com/en-us/events/fs2011/ng_codename_roslyn.pdf http://research.microsoft.com/en-us/events/fs2011/ng_codenam...
- chappi42 15y agoHere is the link to the Hejlsberg presentation at build: http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-816T http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-816T (the Roslyn part starts at 00:35:45)