Slashdot Mirror


.NET Native Compilation Preview Released

atrader42 (687933) writes "Microsoft announced a new .NET compiler that compiles .NET code to native code using the C++ compiler backend. It produces performance like C++ while still enabling .NET features like garbage collection, generics, and reflection. Popular apps have been measured to start up to 60% faster and use 15% less memory. The preview currently only supports Windows Store applications, but is expected to apply to more .NET applications in the long term. A preview of the compiler is available for download now. (Caveat: I both work for MS and read Slashdot.)"

40 of 217 comments (clear)

  1. Huh? by Desler · · Score: 5, Funny

    Popular apps have been measured to start up to 60% and use 15% less memory.

    So they no longer fully start up? Why is that a benefit?

    1. Re:Huh? by Soulskill · · Score: 2, Informative

      The word 'faster' was omitted. I've updated to fix.

  2. Open source compiler by rabtech · · Score: 5, Interesting

    They also open-sourced their new C# compiler:

    http://roslyn.codeplex.com/

    --
    Natural != (nontoxic || beneficial)
    1. Re:Open source compiler by ackthpt · · Score: 2, Insightful

      Isn't it time for yet-another-language? How about C$ ?

      --

      A feeling of having made the same mistake before: Deja Foobar
    2. Re:Open source compiler by Bacon+Bits · · Score: 4, Funny

      I'm not going back to GW-BASIC, thanks,

      --
      The road to tyranny has always been paved with claims of necessity.
    3. Re:Open source compiler by datapharmer · · Score: 2

      It's already in use by the administrative share.

      --
      Get a web developer
  3. So no more .net redistributable? by Kenja · · Score: 2

    This can only be a good thing as every game I install these days also installs the redistribution files for .net.

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
    1. Re:So no more .net redistributable? by PhrostyMcByte · · Score: 5, Informative
      Yep! From their FAQ:

      apps will get deployed on end-user devices as fully self-contained natively compiled code (when .NET Native enters production), and will not have a dependency on the .NET Framework on the target device/machine.

    2. Re:So no more .net redistributable? by QuasiSteve · · Score: 2

      every game I install these days also installs the redistribution files for .net.

      Do they actually install them, or are they merely included in the installer packaging and installed if and only if the files are missing or outdated?

    3. Re:So no more .net redistributable? by dbraden · · Score: 2

      Actually, that's not the case. As already mentioned by PhrostyMcByte above, here's the quote from Microsoft's FAQ:

      apps will get deployed on end-user devices as fully self-contained natively compiled code (when .NET Native enters production), and will not have a dependency on the .NET Framework on the target device/machine.

      Pretty cool in my book.

    4. Re:So no more .net redistributable? by MightyMartian · · Score: 4, Insightful

      Yeah, I can't wait for a half-gigabyte executables.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    5. Re:So no more .net redistributable? by Cenan · · Score: 2

      This new compiler actually links the dependent parts of the .Net framework into your native code, to produce a stand alone executable.

      --
      ... whatever ...
  4. Translator? by Anonymous Coward · · Score: 3, Interesting

    compiles .NET code to native code using the C++ compiler backend

    Can it output the generated C++ source?

    1. Re:Translator? by Calavar · · Score: 3, Informative

      Correct me if I am mistaken, but I'm pretty sure that if they are using the backend they are skipping the lexing and parsing steps and going straight to the generation of the intermediate representation. That would mean that there is no generated C++ code to see.

  5. Re:I thought April fools was 2 days ago? by Tough+Love · · Score: 3, Interesting

    It actually sounds like gcj.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  6. Run more native Windows apps on Linux by common-lisp · · Score: 2, Insightful

    From the article:

    the .NET Native runtime [is] a refactored and optimized CLR

    According to the article, the .NET Native runtime is a (not yet complete) implementation of .NET. This means that Wine + .NET Native = a Microsoft-built .NET runtime on Linux. This is good news because this may be a way to take those .NET technologies missing from Mono, such as WPF, and still use them on Linux.

    Another reason this is good news is, we're one step closer to being able to develop Windows installers in .NET. Lately I've been using NSIS and it is the most stupid, idiotic language I've ever used. It's been described as a mixture of PHP and assembly.

    Another thought: the article doesn't seem to mention it, but judging by the design, the .NET Native compiler may be able to compile any .NET DLLs and EXEs, not just C# ones.

    1. Re:Run more native Windows apps on Linux by common-lisp · · Score: 3, Insightful

      If you care so much about all that windows crap, why are you running Linux at all?

      Because Linux is much easier to develop with.

      Some Windows technologies (WPF, .NET, C#) are well designed, as are many Linux technologies. Seeing the benefits of one platform isn't mutually exclusive with seeing the benefits of another platform.

      However, what is mutually exclusive is a tribal mindset and the ability to see two sides of the situation.

    2. Re:Run more native Windows apps on Linux by wonkey_monkey · · Score: 2

      Breaking news! Some people use Linux but have a need for something that's only ostensibly available for Windows!

      --
      systemd is Roko's Basilisk.
    3. Re:Run more native Windows apps on Linux by EvilIdler · · Score: 2

      Linq isn't missing from Mono: http://stackoverflow.com/quest... All the WPF stuff definitely is, but a good chunk of .NET 3.5 and up is implemented. They haven't been assaulted by attack-lawyers yet either.

  7. Re:New technology! by Bengie · · Score: 2

    Next up, compiled java that doesn't churn through memory.

  8. Re:Ah... by i+kan+reed · · Score: 3, Insightful

    Yeah, sorry, GUIs won. Like 20 years ago. You can stop pretending that our multicore processors with 64 gigs of ram can't handle them.

  9. Re:Ah... by jafac · · Score: 2, Informative

    When installing a security update for .NET takes 45 minutes, there is no pretending involved.

    --

    These are my friends, See how they glisten. See this one shine, how he smiles in the light.
  10. Re:Only benefits smaller devices by robmv · · Score: 2

    Well, the ART preview native compiler on Android 4.4 is on device so it could compile to native on the device, but I expect Google will accelerate that step precompiling on their servers taking into account device characteristics. Microsoft could do that too if they want

  11. What about number-crunching performance? by Theovon · · Score: 2

    I skimmed over the links, but I probably just missed it. So apps take 60% less time to start, and they use 15% less memory. What about run-time performance? How much faster are they when executing?

    1. Re:What about number-crunching performance? by benjymouse · · Score: 2

      I skimmed over the links, but I probably just missed it. So apps take 60% less time to start, and they use 15% less memory. What about run-time performance? How much faster are they when executing?

      During runtime, a.NET already runs compiled. This saves on the JIT compiler.

      However, they also announced (later session at /Build//) that the new compilers (including the JITs) will take advantage of SIMD. For some application types this can allegedly lead to serious (like in 60%) performance gains. Games were mentioned.

      --
      Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
    2. Re:What about number-crunching performance? by cbhacking · · Score: 2

      Well, that depends. JIT needs to be *really* fast. That limits the optimization it can do. Pre-compilation to native allows more processing time for optimizations between the CIL and the machine code than a JIT can really afford.

      --
      There's no place I could be, since I've found Serenity...
  12. Is JITC finally going to die? by IamTheRealMike · · Score: 3, Insightful

    Many years ago there was an R&D project inside a large tech company. It was exploring many of the hot research topics of the day, topics like mobile code, type based security, distributed computing and just in time compilation using "virtual machines". This project became Java.

    Were all these ideas actually good? Arguably, no. Mobile code turned out to be harder to do securely than anyone had imagined, to the extent that all attempts to sandbox malicious programs of any complexity have repeatedly failed. Integrating distributed computing into the core of an OO language invariably caused problems due to the super leaky abstraction, for instance, normal languages typically have no way to impose a deadline on a method call written in the standard manner.

    Just in time compilation was perhaps one of the worst ideas of all. Take a complex memory and CPU intensive program, like an optimising compiler, and run it over and over again on cheap consumer hardware? Throw away the results each time the user quits and do it all again when they next start it up? Brilliant, sounds like just the thing we all need!

    But unfortunately the obvious conceptual problems with just in time compilers did not kill Java's love for it, because writing them was kind of fun and hey, Sun wasn't going to make any major changes in Java's direction after launch - that might imply it was imperfect, or that they made a mistake. And it was successful despite JITC. So when Microsoft decided to clone Java, they wanted to copy a formula that worked, and the JITC concept came along for the ride.

    Now, many years later, people are starting to realise that perhaps this wasn't such a great idea after all. .NET Native sounds like a great thing, except it's also an obvious thing that should have been the way .NET worked right from the start. Android is also moving to a hybrid "compile to native at install time" model with the new ART runtime, but at least Android has the excuse that they wanted to optimise for memory and a slow interpreter seemed like the best way to do that. The .NET and Java guys have no such excuses.

    1. Re:Is JITC finally going to die? by aberglas · · Score: 5, Informative
      You miss the point entirely. The vast majority of CPU time in most applications is spent in a relatively few leaf subroutines. What the JIT does is just compile those bits that are found to be CPU intensive.

      In tests I had done some time ago with the early compilers, .Net code was actually faster than C implementing the same algorithm. The reason is that it can perform global optimizations, in-lining aggressively. Sure that can be done with C (and you do not even need macros), but it takes extra work, slows down the compiler if too much is put into header files, and programmers usually miss some of the routines that need in-lining.

      Modern generational garbage collectors are also faster than malloc/free, and do not suffer fragmentation.

      Delaying compilation makes it architecture neutral, same distro for 32, 64bit, ARM etc. What is needed is to cache the results of previous compiles which causes a slight but usually negligible start up penalty.

      Compiling all the way to machine code at build time is an archaic C-grade idea that became obsolete thirty years ago for most common applications.

    2. Re:Is JITC finally going to die? by shutdown+-p+now · · Score: 2

      Dynamically compiling code has some advantages unrelated to security or portability. For example, try efficiently implementing generic virtual methods without a JIT.

      (Coincidentally, .NET Native doesn't support this feature of C#)

  13. Re:Only benefits smaller devices by benjymouse · · Score: 2

    The raw speed of the code might actually diminish since the .net runtime could have optimized it better for the specific environment (CPU model, available RAM, phase of the moon, etc).

    MS announced that developers still need to pass hints to the compiler on what architecture, CPU core count, available memory etch, to compile for. You can (cross) compile to multiple architectures.

    This technology is already at work when deploying apps for Windows Phone 8: Developers pass IL code to the store, native compilation is performed per device type in the cloud (CPU architecture, OS version, memory, ...) and the binary is passed to the device.

    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
  14. Re:It produces performance like C++ by ThePhilips · · Score: 2

    Raw C can be X-able.

    It's just plain PITA to do it.

    Otherwise, performance of the raw C is overrated. Or better: the developers who benefit most from C performance are the ones who can't algorithms. Also, developing reusable algorithms in C is a major PITA.

    --
    All hope abandon ye who enter here.
  15. Re:So when is MS Office going to be built with .NE by ThePhilips · · Score: 2

    Microsoft were unable to use .NET to build their own applications, presumably because of poor performance.

    Unlikely. MSO is very old. Very likely the source code is poorly documented and not completely understood. Porting that to anything is going to be a major and very risky undertaking.

    .NET has clearly failed.

    Still clearly better than VB.

    --
    All hope abandon ye who enter here.
  16. Re:It produces performance like C++ by ralphbecket · · Score: 4, Insightful

    "After all, the chief advantages of C# isn't really C#, but the .NET libraries."

    You can't be serious! C is *substantially* lower-level than C#; you should only use C as a portable assembly language. I've spent decades writing assembly, C, and higher level languages and I'd pick C# over C in an eyeblink for anything that doesn't require access to the bare metal (well, personally I'd pick a functional language, but these days I work in industry...)

  17. Re:It produces performance like C++ by ebno-10db · · Score: 3, Funny

    I have never seen an unintended buffer overflow problem in C# or Java.

    So you've seen intended ones?

  18. Re:Ah... by cavreader · · Score: 2

    Memory and CPU power are there to be used so why not take advantage of it. And what the hell is a hand coded app? Or are you referring to programming against a runtime versus programming directly against the OS? And what does eschewing OO approaches mean? Are you talking about an application that encapsulates all it's functionalities without referencing any external resources or dependencies?

  19. Re:It produces performance like C++ by Desler · · Score: 2, Insightful

    You can't be serious! C is *substantially* lower-level than C#; you should only use C as a portable assembly language.

    Why? C is extremely easy to write and has vast amounts of libraries to use.

  20. Re:Ah... by fyngyrz · · Score: 4, Insightful

    You could write everything in assembly if you wanted to and with careful optimization you could probably produce faster code but it would take several orders of magnitude faster to do.

    No. You can't do that unless the platform is locked down hardware wise, and that's not been the case with the major OS's for quite some time now. The best tool -- to date -- for anything serious aimed at a major OS is c. By far. Not C++. not objective c, not C#, not asm ... just c.

    due to NIH syndrome

    No. That's not it at all. I don't care where it was invented; that's a symptom, not the actual problem. The problem is bringing in other people's code results in a loss of maintainability, quite often a loss of focus on the precise problem one is attempting to address, a loss of understanding of exactly what is going on, which in turn leads to other bugs and performance shortcomings. OPC comes into play at multiple levels: attempts to manage memory for you; libraries; canned packages of every type and "handy" language features that hide the details from you. NIH because it wasn't you just *looks* like the problem, but the problem is what NIH code actually does to the end result, and that's a real thing, not a matter of I don't like your style, or some personality syndrome. If the goal is the highest possible quality, then the job has to be fully understood and carefully crafted from components you can service from start to finish, the only exceptions being where it *must* interface with the host OS. Even then you're likely to get screwed. Need UDP ports to work right? Stay away from OSX. Need file dialogs to handle complex selections? MS's were broken for at least a decade straight. Need font routines that rotate consistently? Windows would give it to you various ways depending on the platform. And so on. Better off to write your own code if you can possibly manage it. You know, so it'll work, and if your customer finds an error, so you can fix it instead of punting it into Apple or MS's lap.

    It boggles the mind that people *still* use the term "bloated" simply because they are utilizing frameworks that might not be limited to just the exact set of things you need

    I use "bloated" when my version of something is 1 mb, and a friend's, with fewer lines of code, is 50 mb and runs the target functionality at a fraction of the speed, not to mention loading differences and startup differences. It's not just about a library routine that isn't called (well, until there are a lot of them, or if they're very large... linkers really ought to toss those out anyway), it's primarily about waste in every function call, clumsy memory management that tries to be everything to everybody and ends up causing hiccups and brain farts at random times, libraries that bring in other libraries that bring in other libraries until you've got a house of a thousand bricks, where you only actually laid a few of them, and you have *no idea* of the integrity of the remaining structure. Code like that is largely out of your control. Bloated. Unmaintainable. Opaque. Unfriendly to concurrently running tasks.

    Look at your average iOS application. 20 megs. 50 megs. Or more. For the most simpleminded shite you ever saw; could have been implemented in 32k of good code and (maybe) a couple megs of image objects. That's what I'm talking about, right there. Bloat. It's that zone where a craft is swamped by clumsy apprentices who think they understand a lot more than they do. Where one fellow creates beautiful, strong, custom furniture, and the other guy buys a 59.95 box from IKEA and turns a few cams. The good news is that there will always be a place for those who can really craft, because there's a never-ending source of challenges where crap just won't do. And despite rumors to the contrary, end users do know the difference -- especially once they've been exposed to both sides of the coin.

    --
    I've fallen off your lawn, and I can't get up.
  21. Re:So when is MS Office going to be built with .NE by shutdown+-p+now · · Score: 2

    .NET apps compiled for "AnyCPU" will, technically, run just fine on Windows RT on ARM. The reason why you can't actually run such desktop apps is because it is blocked by signature verifier (any desktop app must be signed by MS to run on RT). It's a DRM thing, not a technical limitation.

    Oh, and huge parts of Office use .NET these days, alongside the older native code. Ditto for VS, and many other products.

  22. or just use c++ in the first place by BestNicksRTaken · · Score: 2

    never seen the point of c#

    --
    #include <sig.h>
  23. Re:Ah... by serviscope_minor · · Score: 2

    The best tool -- to date -- for anything serious aimed at a major OS is c. By far. Not C++

    Not only that, but it must only be written by a true Scotsman as well.

    There are many major, serious, projects written in C++.

    GCC, LLVM, Firefox, QT, Webkit, the JVM, libre/open office.

    In fact GCC recently switched from C to C++. Basically, C++ provides exactly the same machine model as C, except that it gives you a more programmable compiler and richer abstractions. There are very, very few places that it's worth using C over C++, unless you have a thing for writing yet another resizable array implementasegmentation fault (core dumped).

    --
    SJW n. One who posts facts.