Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Microsoft Roslyn: Reinventing the Compiler As We Know It

Soulskill posted more than 2 years ago | from the now-with-3d dept.

Programming 195

snydeq writes "Fatal Exception's Neil McAllister sees Microsoft's Project Roslyn potentially reinventing how we view compilers and compiled languages. 'Roslyn is a complete reengineering of Microsoft's .NET compiler toolchain in a new way, such that each phase of the code compilation process is exposed as a service that can be consumed by other applications,' McAllister writes. 'The most obvious advantage of this kind of "deconstructed" compiler is that it allows the entire compile-execute process to be invoked from within .NET applications. With the Roslyn technology, C# may still be a compiled language, but it effectively gains all the flexibility and expressiveness that dynamic languages such as Python and Ruby have to offer.'"

cancel ×

195 comments

Sorry! There are no comments related to the filter you selected.

security? (0)

Anonymous Coward | more than 2 years ago | (#37793274)

doesn't this allow for malicious programs to get even more malicious?

Re:security? (1)

ackthpt (218170) | more than 2 years ago | (#37793444)

doesn't this allow for malicious programs to get even more malicious?

If some weasel can figure a way to insert malicious code between Source and Executable, there's always the possibility (and always has been.)

Re:security? (1)

Eponymous Coward (6097) | more than 2 years ago | (#37793654)

Isn't the point of having the compiler as a service so that your executable can feed source code to a compiler?

Re:security? (2)

ByOhTek (1181381) | more than 2 years ago | (#37793978)

char *src = /*...*/;
FILE *fp = open("myfile.c", "w");
fwrite(src, strlen(src), 1, fp);
fclose(fp);
fp = popen("gcc myfile.c", "r");
fclose(fp);

Filling in a few blanks and tweaks, that can be done on ANY unix system. It allows ANY software to feed source code to a compiler. Nobody has complained of this as a security risk before.

Now, it might be a *slight* security risk if it is running as a background process that is always on, and therefore corrupting it once could potentially corrupt all future output, but I doubt MS means it as that type of service. As long as it doesn't run in that method, it's no worse than having the GCC binary callable as I showed above.

Re:security? What about.... (1)

JetScootr (319545) | more than 2 years ago | (#37794144)

"each phase of the code compilation process is exposed as a service that can be consumed by other applications."
How bout if the 'other app' is a web browser window? TFA suggests this will be possible with MS's product.

Re:security? What about.... (2)

ByOhTek (1181381) | more than 2 years ago | (#37794210)

So? my code could be put in an apache module. Use WSGI and it is available in Python. PHP has the ability to do it straight away.

It's still not adding any vulnerabilities to the ecosystem that haven't existed before. Yes they used it as a demo, but that's probably because it's a quickly visible demo that everyone can easily see what it is doing. Only an idiot would use it like that on a production system, just like only an idiot would use C, PHP or Python to do the same thing, and those have had that feature for almost as long as they've been around.

Re:security? What about.... (1)

wootest (694923) | more than 2 years ago | (#37795010)

There are already APIs to emit IL or to invoke a C# compiler built into .NET and the security systems built into .NET give you a way to prohibit them. There's no additional risk exposed by Roslyn. Rather, it's a way of getting at the juicy knowledge about the code that the compiler builds up before it exits and that libraries have been written to poorly piece together. That's a good idea that I'd like to see accompany more official language compilers, static or not.

Re:security? (2)

Cassini2 (956052) | more than 2 years ago | (#37794442)

This is the reason why gcc (or any other compiler) should never be installed on any production Linux machine.

Having a compiler installed permits the add-hoc creation of code, with all the resultant security risks. Self-modifying code, including compiled self-modifying code, is an elegant solution in certain environments, however it is a huge security and reliability risk in any production application.

The problem with the Windows NT 4.0 security model was that security was present almost everywhere, except if an application could be tricked into loading a DLL which then permitted uncontrolled code execution. Microsoft developed Internet Explorer and Active/X, and Microsoft Windows platform security has been weak every since. If you want a secure system, it is necessary to block all methods of running unapproved and unverified code.

Re:security? (1)

ByOhTek (1181381) | more than 2 years ago | (#37794794)

This is the reason why gcc (or any other compiler) should never be installed on any production Linux machine.

Having a compiler installed permits the add-hoc creation of code, with all the resultant security risks. Self-modifying code, including compiled self-modifying code, is an elegant solution in certain environments, however it is a huge security and reliability risk in any production application.

By that logic, Python, PHP, Perl and any other scripting language that can popen() or eval() should not be allowed on a production server as well.

Re:security? (1)

Bill, Shooter of Bul (629286) | more than 2 years ago | (#37794540)

But this feature will be encouraging developers to write applications that accept source at run time. If you don't write that into your app, you only have to protect it from malicious code before compilation, in most cases. Which is much, much easier.

Of course there are always other security threats after compilation as well, and those will still be there in addition to the ones this opens up.

Re:security? My first thot, too... (1)

JetScootr (319545) | more than 2 years ago | (#37793692)

Now malware can be shipped in various partially-compiled steps and in different packaging (one,two,three modules, arriving from different vectors, etc), making detection harder, and can then be compiled targetting the cpu it lands on. Oh, what a fricken great IDEA! platform-independence for malware just got easier! It''s really getting hard to distinguish between the bad guys and producers of ideas like this.

Re:security? My first thot, too... (2)

ozmanjusri (601766) | more than 2 years ago | (#37793776)

platform-independence for malware just got easier!

.NET isn't platform-independant, and neither will this be.

Re:security? My first thot, too... (1)

JetScootr (319545) | more than 2 years ago | (#37793956)

I was thinking cpu-specific, not OS-independent. Sorry for ambiguity. CPU-specific compilation may allow for use of idiosyncratic features/bugs in the production of invasive code, something a little more difficult if the target hardware is unknown.

Re:security? My first thot, too... (1)

ByOhTek (1181381) | more than 2 years ago | (#37794046)

Oh?
I run it on Windows, Linux, FreeBSD and MacOS.

I run it on x86 and ARM.

Seems pretty damn independent to me.

Regarding what the GP stated though, with the right libraries and a little clever coding, a similar independent 'partially compiled' method could be used with C as well. Of course the partial compile of the windows version would have to check for a C compiler, and download/install one if it isn't available. Java and Flash could conceivably be used to do the same. So, it's really not adding a whole lot of new threats to the ecosystem.

Re:security? (1)

luder (923306) | more than 2 years ago | (#37793696)

It allows for something similar to eval [wikipedia.org] in .NET. From the article:

"Hejlsberg demonstrated a C# program that passed a few code snippets to the C# compiler as strings; the compiler returned the resulting IL assembly code as an object, which was then passed to the Common Language Runtime (CLR) for execution. Voilà! With Roslyn, C# gains a dynamic language's ability to generate and invoke code at runtime.

Put that same code into a loop that accepts input from the user, and you've created a fully interactive read-eval-print loop (REPL) console for C#, allowing you to manipulate and experiment with .Net APIs and objects in real time."

If your program is doing what the demo code does, then sure, you're asking for code injection attacks.

Re:security? (1)

ByOhTek (1181381) | more than 2 years ago | (#37794106)

Consider cases like the console interpreter for Python or Perl, you could do malicious things with them, but I wouldn't call them code injection attacks. Mind you, using a REPL in a more complex piece of code that has other functions is probably a bad idea, but I think the REPL is more of an easy demo to show what it can do, not the intended use.

Re:security? (1)

luder (923306) | more than 2 years ago | (#37794720)

Yes, that's true. When I talked about injection attacks I was thinking more about using this to run JSON-like strings of code when you don't trust the source.

Re:security? (1)

ByOhTek (1181381) | more than 2 years ago | (#37793736)

They may not necessarily mean 'service' as runtime service (the Windows world equivalent of a Daemon), but rather more a sense of a software library (provides a service to other applications, without actually being standalone itself).

In this case, it's not much different from python/ruby on any system. I could execute arbitrary python code from a C executable without much difficulty. That doesn't mean that there is a problem with how, C, Python or the underlying OS is written.

3 years ago (1)

ZeroExistenZ (721849) | more than 2 years ago | (#37793342)

What do they exactly mean by "flexibility and expressiveness of other dynamic languages" ?

I remember a demo at a Microsoft Developer congress where C# would be able to execute and rebuilt itself dynamically.

At the time it got me really excited (as I've bumped into many problem which would have a much more beautiful solution should I be able to compile during runtime.) but this seems yet another technology?

Re:3 years ago (2)

Dexter Herbivore (1322345) | more than 2 years ago | (#37793390)

I'm wondering if my programming skills have fallen away so much through lack of use that I don't understand this as well anymore, or if the summary/article is just full of buzzwords and impressive sounding jargon.

Re:3 years ago (0)

Anonymous Coward | more than 2 years ago | (#37794076)

I suspect it is the latter.

To be honest, there isn't much difference between compiled and interpreted languages anymore. It used to be speed, but really - nowadays I don't see a big difference in speed between by Python scripts and the C# programs.

This might have some use but I am not really sure if it is a reinvention of the entire paradigm (Or whatever buzzwords the article uses).

Re:3 years ago (0)

Anonymous Coward | more than 2 years ago | (#37794710)

To be honest, there isn't much difference between compiled and interpreted languages anymore. It used to be speed, but really - nowadays I don't see a big difference in speed between by Python scripts and the C# programs.

Actually, it's the same difference it's always been. The only real "new thing" in the field is Java-style virtual machines bridging compiled code and an interpreter, but even that goes way back (e.g. P-code).

The bottom line is that faster machines made the difference between native and interpreted code mostly irrelevant.

Re:3 years ago (2)

ackthpt (218170) | more than 2 years ago | (#37793508)

What do they exactly mean by "flexibility and expressiveness of other dynamic languages" ?

I remember a demo at a Microsoft Developer congress where C# would be able to execute and rebuilt itself dynamically.

At the time it got me really excited (as I've bumped into many problem which would have a much more beautiful solution should I be able to compile during runtime.) but this seems yet another technology?

I don't think of it as a new technology, but Microsoft is finally getting around to it. They are such a big dog now that some people don't recognize change until Microsoft rolls it out - years after others have already been mucking about in it for years.

If they roll it out in a good package, that's a good thing. If they price it above most developers budgets than they're going to be bypassed.

Re:3 years ago (-1)

Anonymous Coward | more than 2 years ago | (#37793580)

They are such a big dog now that some people don't recognize change until Microsoft rolls it out - years after others have already been mucking about in it for years.

I love how you just randomly shit on MS for no reason because they're releasing a nice feature. The redundancy in your sentence (years) shows that you were mostly going for impressive sounding shit "People have been doing this for decades OGM11!! MS so slow!!" rather than an actual argument.

Re:3 years ago (1)

ByOhTek (1181381) | more than 2 years ago | (#37793828)

They'll probably do exactly what they've done with the past 2 or 3 releases of Visual Studio.

Roll it out, have something that's actually pretty damn good, and as long as you aren't making a commercial product, it is all free (except for a couple reporting tools and their code repository server, the latter of which can easily be replaced with 90% of the features by using Mercurial using VisualHG + TortoiseHG, which are free and better suited for most non-corporate development models anyway).

Now, if you want to use it commercially, that's $750 or so a seat. For the quality of the software, I think it is worth it, but others may disagree.

Re:3 years ago (0)

Anonymous Coward | more than 2 years ago | (#37794284)

There are no licensing limitations on using Visual Studio Express or the freely downloadable command line compilers commercially. The limitations are strictly around specific forms of features, like the lack of addins and source control.

Re:3 years ago (1)

ByOhTek (1181381) | more than 2 years ago | (#37794590)

I thought there was a limit of one or two commercial projects from VS Express.

Re:3 years ago (1)

wootest (694923) | more than 2 years ago | (#37795108)

I'm not about to debate anyone on the Visual Studio segmented pricing, but Anders Hejlsberg has gone on record saying he'd like for Roslyn to be open source, by which he likely means Ms-PL. If they do that, they could indeed close it later, at the cost of an enormous shitstorm. (When Microsoft has stopped providing open source before, they've stopped developing the software (see: Rotor). This is the new version of the C# compiler and its IDE integration so that's not going to happen.)

Re:3 years ago (0)

Anonymous Coward | more than 2 years ago | (#37793904)

If they price it above most developers budgets than they're going to be bypassed.

Agreed. For only $11,899 you too could own Visual Studio 2010 Ultimate [microsoftstore.com] . Either that, or you could pay your rent, buy a nice boat, or a decent car.

Re:3 years ago (1)

ByOhTek (1181381) | more than 2 years ago | (#37794158)

Very few would need more features than the professional version, which is $750 or so a seat from many retailers. Still steep for a lot of users, but unless you are a huge software corporation, Ultimate is overkill.

Re:3 years ago (1)

kcitren (72383) | more than 2 years ago | (#37795378)

Gee, it looks like $3,799.00 to me, must be the font I use. Oh, and that includes: Visual Studio Team Foundation Server, Visual Studio Client, Expression Studio, Office Professional Plus 2010, Project Professional 2010, Visio Premium 2010, Development versions of all Microsoft OS's and applications

Re:3 years ago (1)

Flyerman (1728812) | more than 2 years ago | (#37795488)

That price includes an MSDN subscription, no surprise that you're an AC.

Re:3 years ago (1)

Anonymous Coward | more than 2 years ago | (#37794322)

The C# Compiler has always been free. It's the Visual Studio IDE that's mega-bucks. The C# Compiler is part of the the .NET Framework (not the SDK, which is also) and is shipped on every Windows machine since Windows XP SP2. It's analogous to having the GCC on every Linux install.

And yes, you can write code dynamically without a text file, the feature is called the Interactive Window and ships with the new Roslyn release. At BUILD Anders Heljsberg demoed it by writing one line of code in the Interactive Window and Roslyn ran it without any thing else. I believe it was a file operation. Here is the video where he talks about Roslyn: http://channel9.msdn.com/events/BUILD/BUILD2011/TOOL-816T

Re:3 years ago (1)

Sique (173459) | more than 2 years ago | (#37794648)

This is what I used (and later programmed myself) about 20 years ago in LPC (Lars Pensjö C, later called Pike).
It was a command called "lpc", and it just took a piece of code as argument, wrote it into a file, compiled it on the fly and called its main and only method.

Re:3 years ago (1)

Aladrin (926209) | more than 2 years ago | (#37793610)

In the past, you could compile C# source code at runtime and load it into memory and use it. (I know, I was doing it for a MUD that didn't pan out.) But it wasn't very dynamic. (We were using it to reload the code without restarting the MUD.)

I assume this news means that you can write code dynamically, without writing it to a text file first.

Re:3 years ago (4, Insightful)

sourcerror (1718066) | more than 2 years ago | (#37793662)

Tiny C compiler does this for years:
http://bellard.org/tcc/ [bellard.org]

Features

SMALL! You can compile and execute C code everywhere, for example on rescue disks (about 100KB for x86 TCC executable, including C preprocessor, C compiler, assembler and linker).

FAST! tcc generates x86 code. No byte code overhead. Compile, assemble and link several times faster than GCC.

UNLIMITED! Any C dynamic library can be used directly. TCC is heading torward full ISOC99 compliance. TCC can of course compile itself.

SAFE! tcc includes an optional memory and bound checker. Bound checked code can be mixed freely with standard code.
Compile and execute C source directly. No linking or assembly necessary. Full C preprocessor and GNU-like assembler included.

C script supported : just add '#!/usr/local/bin/tcc -run' at the first line of your C source, and execute it directly from the command line.

With libtcc, you can use TCC as a backend for dynamic code generation.

Re:3 years ago (2, Interesting)

Anonymous Coward | more than 2 years ago | (#37793880)

You might want to read this wrt tinycc: http://www.landley.net/code/tinycc/
Also, no x86-64.

Re:3 years ago (1)

pclminion (145572) | more than 2 years ago | (#37794260)

You might want to read this wrt tinycc: http://www.landley.net/code/tinycc/ [landley.net]

Jesus. That is the saddest story I've ever read. I want to find that guy and give him a hug.

That's a pretty good summary of why I never bother contributing to open source any more, even though I have tons of code lying around including cool modifications of some pretty big-name projects. I've been lucky enough to never work with douchebags in the salaried, closed source world. I sure as hell will not suffer it while also not making any money from my efforts.

Re:3 years ago (1)

ByOhTek (1181381) | more than 2 years ago | (#37793756)

I think the idea is that it will be easier than the current methods. Also, if I remember correctly from previous articles, there will be more profiling information available to help with optimization tasks.

Re:3 years ago (1)

gbjbaanb (229885) | more than 2 years ago | (#37794274)

yes, but a lot of that was built through the reflection feature of .NET, which in turn makes it very slow and clumsy. Reflection has its uses, but the easiest way to tell is to use the following rule: "if you're using it you're doing things wrong."

Re:3 years ago (1)

tixxit (1107127) | more than 2 years ago | (#37794686)

It makes little sense, in that the dynamism of dynamic languages have nothing to do with "eval" (how many people write Python programs that write Python programs?). More over, runtime compilation is hardly new. Clojure, for example, is always compiled to bytecode, even at runtime, and is a dynamic language. Scala's REPL is a great example of a statically typed language being dynamically compiled and run. With Scala, you can even easily hook into the compiler tools to create your own interpreter and compile code on the fly and run it. There may be new things in Roslyn (I don't know), but, if so, the summary/article missed them.

Re:3 years ago (0)

Anonymous Coward | more than 2 years ago | (#37794738)

There are mechanisms for this in current .NET but it's a kind of kludgey and an add on. Also it this a bit of an all or nothing (load, link, compile, run) sort of activity if I remember correctly. I assume based on the article that the new technology embeds these capabilities deeper in the .NET stack and let's the programmer call each piece of the tool chain independently as a service so that you can compile all of your dynamic code at spin up but execute it later or some other thing I haven't thought of.

old news? (3, Interesting)

Verunks (1000826) | more than 2 years ago | (#37793360)

Re:old news? (1)

wootest (694923) | more than 2 years ago | (#37795142)

That was the announcement of the release. This was the actual release.

The compiler as I know it (1, Insightful)

dkleinsc (563838) | more than 2 years ago | (#37793378)

If I wanted to, I could rig GCC and the like to do that too: That's the wonderful thing about command-line tools and piping, you can munge things together any way you want. And of course you can always tell gcc to stop partway through the compilation if you need assembler code or a parse tree or something. This sort of thing is common in open-source compilers, because they need these features for debugging purposes and have no reason to leave them out of the released version.

Of course, I probably don't want to include a feature like this dynamic code execution, because if I screw up, it would be a fantastic way to get a machine to execute code that it's not supposed to.

Re:The compiler as I know it (1)

Mr. McGibby (41471) | more than 2 years ago | (#37793438)

Yeah, just try it wtih GCC. Not easy. CLANG on the other hand is looking AWESOME for this sort of thing. Once a libraryized version of CLANG is good, it'll make this sort of thing easy.

Re:The compiler as I know it (0)

jader3rd (2222716) | more than 2 years ago | (#37794224)

If I wanted to, I could rig GCC and the like to do that too: That's the wonderful thing about command-line tools and piping, you can munge things together any way you want.

What I find useful about Roslyn is that it'll be running as part of Visual Studio, allowing for extensions access to the sytnax tree. My VS extension no longer needs to make guesses based off of the text in the file. The extension can actually see the structure of the code and make the changes I want it to in the IDE. I don't see how piping in the command line will help with the IDE experience.

Re:The compiler as I know it (1)

wootest (694923) | more than 2 years ago | (#37795312)

The "dynamic code execution" just builds on top of support that's already there. You could build a string of a C# program, feed it to a compiler and run it dynamically previously as well. This just makes the compilation part less of a headache.

Rigging GCC (other comments have already brought up clang) would maybe be more dangerous because arbitrary C code could do anything. Arbitrary IL code can be hamstrung by some security layers. Of course, the differences between managed and native code pale in comparison to what permissions they are executing with, the robustness of any jailing or sandboxing that might be in place and so on.

If you worry that people can compile programs into executable code, you're not worrying about the right thing. You could write a C compiler in JavaScript or QBASIC. You should be worrying about what happens when that code executes.

Never heard of Clang? (4, Informative)

gnasher719 (869701) | more than 2 years ago | (#37793400)

It seems that Neil McAllister has never heard of LLVM and Clang, while Microsoft obviously has.

Re:Never heard of Clang? (0)

Anonymous Coward | more than 2 years ago | (#37793568)

This was the first I thought of as well.

Re:Never heard of Clang? (1)

bames53 (300438) | more than 2 years ago | (#37793594)

Yeah, LLVM and Clang are designed as libraries to be used by other client programs. One of the main developers actually worked on similar stuff at Microsoft.

Apple is making use of LLVM and Clang in their IDE for exactly the kinds of things talked about in the article, replacing custom parsers used for syntax highlighting or expression parsing in the debugger.

This is just the direction compilers are going these days. I wonder if older compilers like GCC will be able to adapt or if they'll just continue being monolithic.

Re:Never heard of Clang? (1)

paugq (443696) | more than 2 years ago | (#37794244)

Apple is making use of LLVM and Clang in their IDE for exactly the kinds of things talked about in the article, replacing custom parsers used for syntax highlighting or expression parsing in the debugger.

Nokia recently adopted Clang too for Qt Creator:

http://labs.qt.nokia.com/2011/10/19/qt-creator-and-clang/ [nokia.com]

Interactive Compilation (1)

Toonol (1057698) | more than 2 years ago | (#37793452)

That's something that I haven't seen a language really get right since FORTH. I'd love to be able to use C# in a similar way, entering small function definitions from the command line, compiling them as they're entered, interactively testing functions as they're written. It's a great way to speed development.

Re:Interactive Compilation (1)

Forbman (794277) | more than 2 years ago | (#37794120)

Boo (boo.codehaus.org) lets you work this way... It's a Python-esque, type-safe scripting language for .Net...

Re:Interactive Compilation (0)

Anonymous Coward | more than 2 years ago | (#37795410)

That's something that I haven't seen a language really get right since FORTH. I'd love to be able to use C# in a similar way, entering small function definitions from the command line, compiling them as they're entered, interactively testing functions as they're written. It's a great way to speed development.

You can do some of that already during development with visual studio. Which is set a break point, break, edit the code, and continue. I do this all the time. Really speeds things up.

That's great! (0)

Anonymous Coward | more than 2 years ago | (#37793456)

Oh look, M$ has found a new way to infect windows with viruses.

Great for a tiny minority, meh for everyone else (1)

Raul654 (453029) | more than 2 years ago | (#37793480)

This sounds great if you're doing stuff like autotuning, but for the vast (vast, vast, vast) majority of programmers out there I don't really see how opening up the internals of the compiler is useful. Who cares if that loop gets fused or that function gets unrolled?

Re:Great for a tiny minority, meh for everyone els (0)

Anonymous Coward | more than 2 years ago | (#37793726)

Its not so much about seeing what the compiler did, but changing what will do. Roslyn will enable tool writers to parse and analyze programs consistently. This seems most helpful for tools like Resharper and NDepend. I think you could also use it to make AOP possible without an IoC container, i.e., you mutate the compiled partially compiled output to cleanly integrate cross cutting concerns.

Re:Great for a tiny minority, meh for everyone els (0)

Anonymous Coward | more than 2 years ago | (#37795048)

It's only "meh for everyone else" until the few folks who are interested start building tools that other people can use.

I'd love to have a toolchain that gave me the option of directly integrating what are now stand-alone tools into my build process. Static analysis tools, syntax checkers, security analysis, and even future tools that nobody has even every thought of creating yet.

Hm... (0)

Anonymous Coward | more than 2 years ago | (#37793530)

This mean that they are taking out the Linker?

Sounds like LLVM (2, Informative)

Dwonis (52652) | more than 2 years ago | (#37793574)

Roslyn is a complete reengineering of Microsoft's .NET compiler toolchain in a new way, such that each phase of the code compilation process is exposed as a service that can be consumed by other applications,

Sounds like LLVM.

big difference (0)

Anonymous Coward | more than 2 years ago | (#37793894)

Microsoft has patents to this. only joking

Re:Sounds like LLVM (0)

Anonymous Coward | more than 2 years ago | (#37794412)

"Absolutely not. Low-Level Virtual Machine (LLVM) is a tool that takes code in an intermediate form from the semantic analysis of a compiler, optimizes that intermediate form, and then emits optimized machine code. Roslyn takes in C# and VB source code and produces a lexical, syntactic and semantic analysis of it for you, and then emits the code in an intermediate form. The thing in .NET that most closely resembles LLVM is the jitter. -- Eric"

Re:Sounds like LLVM (1)

Eirenarch (1099517) | more than 2 years ago | (#37794538)

Neal McAllister is an idiot of course. Compiling code at runtime is a side effect from this project. The main purpose of the project is that the compiler now exposes its internal parsing/lexing structures as APIs that can be used from IDEs, refactoring tools, etc. By definition they are the most correct and complete which (at least in theory) would lead to great advancement in productivity tools for C# and VB.NET. There is a bonus - a REPL for C#

opengtl, llvm, krita (1, Informative)

vurian (645456) | more than 2 years ago | (#37793592)

Compile and execute code from within an application? That's exactly what Krita (http://www.krita.org) does with OpenGTL (http://opengtl.org) -- we have code written in special languages for filters and so on which gets compiled by Krita and then executed as native code. It's pretty safe as well.

LISP had that 40 years ago (4, Informative)

Animats (122034) | more than 2 years ago | (#37793606)

This isn't exactly new. LISP had it from the early days. It's an idea that's been tried before, now available with more modern buzzwords, like "the compiler as a service".

.NET as a virtual machine environment has become somewhat pointless, since the Windows/.NET environment is pretty much "write once, run on X86" now. Itanium support was dropped in 2010, and Microsoft's "Windows 8 for ARM" is apparently Metro-only.

Re:LISP had that 40 years ago (2)

Richard_at_work (517087) | more than 2 years ago | (#37793688)

You can develop for Metro in .Net after the last announcement, and it will be supported on ARM.

Re:LISP had that 40 years ago (1)

Sez Zero (586611) | more than 2 years ago | (#37794696)

"Windows 8 for ARM" is apparently Metro-only.

I'm not sure why, but that makes me snicker.

Probably because I'm juvenile.

Re:LISP had that 40 years ago (0)

Anonymous Coward | more than 2 years ago | (#37795434)

.. a service you have to pay for per compile, per file, per line.

Sounds cool (1)

GameboyRMH (1153867) | more than 2 years ago | (#37793614)

Can't wait to get my hands on a FOSS clone of it.

Re:Sounds cool (0)

Anonymous Coward | more than 2 years ago | (#37793770)

Try boo: http://boo.codehaus.org/

It's being doing this for years.

Re:Sounds cool (0)

Anonymous Coward | more than 2 years ago | (#37794154)

You mean, the commercial clone of LLVM

Re:Sounds cool (-1)

Anonymous Coward | more than 2 years ago | (#37794256)

Can't wait to get my hands on a FOSS clone of it.

It's called LLVM [llvm.org] . As usual, Microsoft is trailing everyone else, including FOSS, and claiming it as their own; albeit in traditional embrace and extend fashion, with some unique tweaks.

Malware writers (0)

Anonymous Coward | more than 2 years ago | (#37793628)

...and the Malware writer community collectively cried: WOOHOO!!! :-)

Scala (1)

robmv (855035) | more than 2 years ago | (#37793698)

like the Scala compiler? an API, plugin support and more? the Scala shell uses it as an example of how to use it

Cool (-1)

Anonymous Coward | more than 2 years ago | (#37793744)

Now you fags that write your own makefiles and use 20 different unrelated tools for development can start using a real managed language.

Wow, sort of like UNIX command-line utilities (0)

Coop (9778) | more than 2 years ago | (#37793752)

Small modules that can be assembled in different ways to achieve many objectives -- great idea!

How is this different from... (0)

Anonymous Coward | more than 2 years ago | (#37793774)

LISP has been compiled, and has a eval statement.

SPITBOL is a compiled version of Snobol and supports the Snobol CODE statement which allows one to construct code and invoke it dynamically.

The Java Compiler can be invoked from within Java.

Am I missing something?

Common Lisp, 1956 (1, Insightful)

Anonymous Coward | more than 2 years ago | (#37793810)

If I get a dime for each time someone "reinvents" Common Lisp, I would be rich.

Please continue innovating, Microsoft. Hint: I think whoever invents the bicycle again, will get to headlines too.

http://de.wikipedia.org/wiki/Klein_Zaches,_genannt_Zinnober

That's fine, but can it answer this question... (0)

Anonymous Coward | more than 2 years ago | (#37793840)

"Rosalyn, who's your daddy?"

Parse tree, AST, symbol tables (1)

oldhack (1037484) | more than 2 years ago | (#37793882)

Progressive compilation that allows access to parse tree, AST, symbol tables, and other such artifacts is a great help in IDE and other "introspective" applications.

LISP? (0)

Anonymous Coward | more than 2 years ago | (#37793988)

So, they're reinventing LISP?

Compiled vs. Dynamic? (1)

DragonWriter (970822) | more than 2 years ago | (#37794030)

With the Roslyn technology, C# may still be a compiled language, but it effectively gains all the flexibility and expressiveness that dynamic languages such as Python and Ruby have to offer.

C#, Ruby, and Python are all (in their main implementations) compiled languages. Where they differ is that C# is mostly-statically-typed, and Ruby and Python are dynamically-typed. The .NET compiler toolchain being exposed as a runtime service doesn't really make C# much more like Ruby or Python, since it doesn't change their main area of difference between the languages. It does mean that you can implement the equivalent of eval for .NET languages that don't already have it (like C#), which makes it a little bit more like Ruby or Python, but I don't think "C# doesn't have eval" is really the main reason people would think Ruby or Python is better for certain tasks than C#.

Re:Compiled vs. Dynamic? (1)

Xest (935314) | more than 2 years ago | (#37794922)

C# got optional dynamic typing in version 4 with the DLR, although the DLR is really a set of libraries that just helps with building the required expression tree at run time to allow the dynamic behaviour.

I do somewhat agree though that I don't see how this gives it any more of the benefits of Python and Ruby than it already had.

Re:Compiled vs. Dynamic? (1)

DragonWriter (970822) | more than 2 years ago | (#37795428)

C# got optional dynamic typing in version 4 with the DLR

Right. That's why I said it was mostly-statically-typed rather than just plain statically-typed.

Compiler-as-a-service is a nice feature for the .NET runtime (and, as I understand it, this is a .NET runtime feature, not a C# language feature), but the Ruby/Python comparison doesn't really seem to be on-point as to why.

Last I checked... (1)

p4nther2004 (1171621) | more than 2 years ago | (#37795012)

Ruby and Javascript were interpreted languages. The kicker isn't the eval function, but rather the def/prototype functions. In Ruby, you can instantiate a String object named str, add a method to String, and then immediately call that method on str. Upshot? - Imagine for a moment replacing (or removing) an object's toString method on the fly.

Re:Last I checked... (1)

DragonWriter (970822) | more than 2 years ago | (#37795366)

Ruby and Javascript were interpreted languages.

Ruby's primary implementation is a bytecode compiler and a runtime VM..

The kicker isn't the eval function, but rather the def/prototype functions. In Ruby, you can instantiate a String object named str, add a method to String, and then immediately call that method on str.

That has nothing to do with compiled vs. interpreted, but with the semantics of method call resolution.

forget first-time submitters, warn about shills! (0)

Anonymous Coward | more than 2 years ago | (#37794148)

I think when a content producer submits their own article, Slashdot ought to flag that fact - just like they do "whoever is a first-time submitter" - have language to that effect:

"This article was submitted by the same company that originally produced it."

I also think that a self-submitted article ought to be given the most negative rating possible so it is buried. If it's any good, someone will find it and submit it.

I also think Slashdot ought to disclose financial relationships, if any, with content producers for article placements. InfoWorld, Computer World, certain book publishers like Packt, etc are over-represented especially considering the quality of their articles is low.

Where's that survey link again?

Just like what Mono does (0)

ndogg (158021) | more than 2 years ago | (#37794172)

Sounds pretty familiar. Oh, yeah, Mono does this already [mono-project.com] .

Re:Just like what Mono does (1)

wootest (694923) | more than 2 years ago | (#37795442)

Really? I like the REPL, but I wasn't aware that they had fixed the entanglement issues.

Thanks to Roslyn being designed explicitly for these kinds of scenarios, it can give you helpful information from nearly every stage of the compilation progress. You can get syntax trees! Not only that, you can feed it an invalid program and you'll get back a syntax tree that says that it's invalid, but knows when it stopped parsing, what kind of token it expected and can be stringified to the exact text you fed it. You can do flow analysis. There's a solidified model for how C# works in a REPL or scripting environment outside of everything-is-in-a-class mode, which admittedly it was never up to Mono to define.

csharp-repl is a very good REPL and the mcs family (which now seems to be merging into a single compiler) are very good compilers with source readily available, but I think it takes something that's designed from the start for reusability and being a library as much as a tool to get you these things.

AWESoMe fp! (-1)

Anonymous Coward | more than 2 years ago | (#37794454)

im4lementa7ion to a child knows

Yawn... (-1)

Anonymous Coward | more than 2 years ago | (#37794476)

Stopped reading when I saw it was for M$'s .NET. .NET is pretty worthless for any real development work which has to run on real (UNIX) servers since it has to be 24/7/365 and .NET just doesn't cut it... So as with most things M$ - it's worthless as far as real innovation...

EUREKA! (1)

menkhaura (103150) | more than 2 years ago | (#37794580)

They found a way to shove XML into the compiler! Kudos to MS!

(see sig)

It's not a new idea (1)

juancn (596002) | more than 2 years ago | (#37794990)

We used that approach for PBL [goo.gl] some years ago. It is wasteful to having to rewrite parsers and lexers for languages to build IDEs, and other tooling.

For example, code indentation can be done by walking the AST (you need to be careful to preserve hidden tokens, such as comments).

You can also allow code completion by changing the compiler to accept a "COMPLETION" token in some places in the grammar. Then, from the editor, when someone presses "Ctrl+SPACE" (or whatever) you mark the location in the lexer and send the code to the compiler. When you build the ast, you insert a completion node in the AST, and you have now contextual information about what can go in there and produce a list of potential things that can go in there.

Also, syntax highlighting can use the lexer for basic coloring and some type information to then add more information (such as what are field, or functions, etc.)

What's new is exposing these phases in a standardized manner in the language. That's a bold move, since backward compatibility will be tricky to maintain. Maybe they're thinking in finally stabilizing C#.

Yes folks...the first thought is the "eval" funct. (1)

p4nther2004 (1171621) | more than 2 years ago | (#37795084)

But that's NOT the advantage to this.

Ever used JSP before? You know that JSP pages are compiled (either on the fly or precompiled) and (if you're smart) you stored off the compiled .java files so you can debug when you page goes belly-up.

(You have to store the pages, because the line numbers match the .java classes, not the JSP pages themselves)

Now, we're removing the compiling mess, moving it to .NET as a service, and standardizing the calling of compiling those pages.

Managed AST + Managed Compiler == Boo (1)

LordMyren (15499) | more than 2 years ago | (#37795132)

This premise, a managed AST you can manipulate programmatically (a SOM, Source Object Model), plus a managed compiler pipeline to compile, is nothing new. Boo language was doing this on .NET , and I'm sure there are many examples before it: Boo was started in 2003.

The expressiveness of C# (0)

Anonymous Coward | more than 2 years ago | (#37795148)

"C# may still be a compiled language, but it effectively gains all the flexibility and expressiveness that dynamic languages such as Python and Ruby have to offer".

And ties you even more effectively into the mothership ..

Gasping for air (1)

sl4shd0rk (755837) | more than 2 years ago | (#37795274)

Seems to me Microsoft is now attempting to do with compilers what they attempted to do with the mobile phone.

Javassist? (1)

brunes69 (86786) | more than 2 years ago | (#37795502)

How is this any different at all from Javassist?

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?