8 ms·
In case you missed: "dotnet compile --native" is basically like the Go compiler, it statically links all the DLLs and produces a single PXE/ELF executable. Thi
by alpb 11y ago
In case you missed: "dotnet compile --native" is basically like the Go compiler, it statically links all the DLLs and produces a single PXE/ELF executable.
This is the most exciting thing for me in the new dotnet CLI as a person writing Go full-time at Microsoft. Most developers will be able to take advantage of single-binary shipping, they'll just put that in a Docker container and happily run everywhere.
- pjmlp 11y agoWhy does everyone need to bring up Go for what is a standard feature from AOT compilers to native code?
- KirinDave 11y agoBecause it is 2016 I guess? So many languages did this for so long and then VMs got in vogue. Go not doing it was, for many people, a reminder it could be done. But for a managed language runtime like the CLR to start supporting it is a big deal.
- pjmlp 11y agoI guess this tells how much mono-culture is still prevalent in the industry, with silo language programming and no CS knowledge. But I do agree it is a big deal, specially for getting more developers to adopt safer programming languages.
- Skinney 11y agoWell, mono has supported this for a while now. This is what Xamarin.iOS is based on.
- justncase80 11y agoThis is true. It's funny because the api's have always existed in the Microsoft compliers but they would litterally throw not implemented errors when run. Mono actually implemented them.
- revelation 11y agoParticularly on the topic of binaries. I've tried using gccgo (the Go backend for GCC, or "the stepchild Go compiler for sake of having a second compiler") for use on an embedded device. It turns out that gccgo stores critical information for the program execution as debug information, which strip will happily remove, leaving you with an undecipherable error on execution.
- qwertyuiop924 11y agoBecause static linking has been out of vogue for so incredibly long in the C/C++ worlds, and above that, most languages either compile down to C, or are interpreted.
- pjmlp 11y agoDepends which C and C++ worlds you mean. In the GNU/Linux world maybe, but that is just one planet in the C and C++ galaxy.
- qwertyuiop924 11y agoI mean broadly almost all unixes, Mac, and Windows. All the big platforms. In embedded systems and plan9, static linking never left. But for mainstream development for desktop and server systems? Static linking has been out for a while.
- vvanders 11y agoGamedev is also very pro-static linking. *nix doesn't encompass all of C/C++.
- qwertyuiop924 11y agoHuh. You learn something every day. But for the most part, everybody still links against libc dynamically. Solaris has actually stopped providing libc.a!
- sveiss 11y agoWhich makes sense when you think of libc as "the library which provides the system call interface to the OS, and just happens to provide a C runtime library as well". Making libc dynamic link only allows the OS developers to change the userland/kernel land interface as they see fit without breaking compatibility. The fact that this also ties you to a dynamically linked C runtime library is an artifact of the close ties between Unix and C. Over in Windows land, there isn't a tight coupling between libc and the system call interface. libc is provided by your compiler (Visual C++ provides static and dynamic versions), while the system call interface is provided by ntdll.dll and friends, which are part of the OS and free to change in future OS versions.
- sergiotapia 11y agoBecause Go made it popular with mainstream developers.
- pjmlp 11y agoMainstream compiled languages (to native code) always supported static linking. Maybe you mean developers of scripting languages?
- sergiotapia 11y agoC# never really had this if I recall (years ago), and Java had it but required monkeying around.
- deleted 11y ago[deleted]
- pjmlp 11y agoI specifically singled them out by stating compilation to native code by default. Java and C# compile firstly to intermediate code. In any case, C# always had this in Singularity OS. Java always had this in comercial JVMs targeted to embedded market.
- serge2k 11y agoFor the same reason why gofmt is hailed as a great achievement that's never before been done. except for every other code formatter ever.
- mintplant 11y agoWhat does Microsoft use Go for?
- pjmlp 11y agoI imagine it might be the Docker related tooling for Azure.
- jen20 11y agoThey also have an Azure SDK for Go which we are using at HashiCorp in Terraform and Packer - https://github.com/Azure/azure-sdk-for-go https://github.com/Azure/azure-sdk-for-go. I believe the Visual Studio Code editor supports Go as well.
- pjmlp 11y agoYes, the Visual Studio Code was demoed at the latest developers' event.
- userbinator 11y agoIf I'm reading the article correctly, that's a 656KB "Hello World" binary. 671,644 bytes just to print a single string to standard output and exit? That is smaller than the whole .NET framework, but considering that a real native "Hello World" binary is <1KB, what's the other 655KB doing?
- jamespo 11y agoHave you seen the size of go executables generally?
- dbattaglia 11y agoIf it's truly just a single binary, wouldn't that include the whole GC and runtime system? If so its probably the entire core runtime plus a few bytes to console.writeline a string.
- nolok 11y agoWhile your point is absolutely true, the rule of thumb in those case is that the growing curve in file size is not linear; while the very minimal executable already brings lots of things it doesn't need, adding functionalities make it grow slowly (since a lot is already there). Not saying this is not an issue (although it isn't really in most fields, except for things like embedded), but that the 656 KB for "Hello World" is because of the "upfront cost" in binary size. I have spent sometime developing in Delphi years back, and this was even more true with it (simple hello world GUI app was over a megabyte [create new project and compile], complex GUI app was barely above it).
- oblio 11y agoPlus embedded environments which have problems with an executable weighing 656KB aren't really a good target for .NET, to start with.
- pjmlp 11y ago> but considering that a real native "Hello World" binary is <1KB, what's the other 655KB doing? Language runtime.
- brusch64 11y agoThat's great. Could've used this in a project last year.
- doktrin 11y agoThis is, in fact, really cool. Asking as someone who's relatively unfamiliar with .NET - what are the most significant differences between compile --native and ngen.exe? If I understand ngen correctly, it only compiles to native code at install time - meaning that the assembly and its IL code needs to be included. Is this correct, and are there other key differences that I've missed?
- vive-la-liberte 11y agoWhat's the purpose of using Docker if it's a single-binary only?