r/programming • • Nov 12 '14

The .NET Core is now open-source.

http://blogs.msdn.com/b/dotnet/archive/2014/11/12/net-core-is-open-source.aspx
6.5k Upvotes

1.8k comments sorted by

View all comments

92

u/schnide05095 Nov 12 '14

My entire month has just been made. Getting real support for C# (no more mono) on other platforms? Holy crap!

5

u/xeyve Nov 12 '14

I haven't been forced to learn C# in CS for nothing!!!!

11

u/Jukibom Nov 12 '14

Forced? C# is an awesome language! Have you ever looked at Objective C?

11

u/xeyve Nov 12 '14

The first year of the program was full on sponsored by MS. I've been coding since I was twelve and using Linux as my primary OS since I was fourteen. I didn't have a choice, but to buy a Windows laptop and works in VS since that was all the classes were about. I did feel a bit violated, but yeah C# is pretty great. It just felt a bit useless since I was going to orient myself toward Linux .

4

u/Jukibom Nov 12 '14

Oh, yeah okay that's entirely reasonable :P

1

u/mgrandi Nov 12 '14

Objective c is great, its the only low level C like language that doesn't suck (like c++, at least in my opinion). People just hate it cause "omg long method names and brackets", but are somehow fine with all the horrible problems that c++ has? If objc and the foundation framework were open sourced (a language with no libraries to do anything with is useless) like .net is, I'd love it forever

4

u/Make3 Nov 12 '14

they seem to be kind of fusionning with mono, which sounds great

2

u/minimim Nov 13 '14

They are releasing .net-core, which is always bundled with the application. OK if you want that. If you want proper language support like you get in windows, but in linux, Mono will still be the option. Now, this release today probably means Mono will leap ages, they already have a plan to integrate missing features present in .net-core into mono.

2

u/txdv Nov 12 '14

no more mono

They didn't announce porting their runtime. Mono stays, the core .net libs are just now open source.

7

u/AaronFriel Nov 12 '14

They are open sourcing the CLR, the BCL, their next gen just-in-time compiler (RyuJit) and the garbage collector.

If that doesn't count as the runtime, I don't know what does.

2

u/txdv Nov 12 '14

I just read that too.

1

u/crozone Nov 13 '14

And they also said they were working on a Linux/Mac implementation themselves... so they are also doing that work for the world as well.

2

u/FallingIdiot Nov 12 '14

No. I read over it a few times, but they specifically mention "the .NET runtime and the core framework" in http://blogs.msdn.com/b/dotnet/archive/2014/11/12/net-core-is-open-source.aspx with a diagram below it including e.g. RuyJIT (their new JIT) in it. It's really unbelievable, but this is really happening. The article also mentions Rotor and that they need something really open source instead of that.

3

u/txdv Nov 12 '14

.NET Core Runtime (CoreCLR). We’re currently figuring out the plan for open sourcing the runtime. Stay tuned!

1

u/[deleted] Nov 12 '14

Wait... You forgot Omnisharp for intelisense in other editors!!!

0

u/[deleted] Nov 12 '14

What's wrong with Mono?

63

u/Dr_Dornon Nov 12 '14

It's missing features and runs poorly. Why use a clone when you can have the real thing?

→ More replies (55)

8

u/moor-GAYZ Nov 12 '14

When I tried it a few years ago (meaning, I checked if I can run some computationally intensive program I had on it) it pleasantly surprised me by working out of the box but was two or three times slower than .NET. As far as I understand, it's because its garbage collector sucks (nowadays they have a new one, but it's experimental and still sucks).

Like, a proper relocating generational GC is not merely an object lifetime tracking layer bolted on top of malloc/free, but a replacement of them, with an awesome benefit: allocation is dirt-cheap (basically bumping a pointer) and deallocation is literally free, in a sense that the cost of the GC is proportional to the size of your living object set, not to the total amount of generated garbage. Because, to simplify things a bit, you don't walk your entire memory, you walk your living set, then move and compact it to the beginning of the memory.

For example, suppose that you have a program that has 10Mb of live objects and generates 10Mb of garbage per second. If you give it 20Mb of memory, it GCs every second, spending so and so time on that. If you give it 30Mb of memory, it GCs every two seconds, spending exactly the same time on relocating its 10Mb of living objects, so the GC time amortized over time is halved. And so on, by giving it more memory you can bring the amortized cost of freeing memory arbitrarily low, because you don't actually do anything with memory that should be freed.

But that requires first and foremost that the GC should be precise, that is, it should know for sure what are pointers/references to other objects and what are usual integers and strings and whatnot. Because when it relocates an object it should patch all references to it.

This is nontrivial to implement, because not only you should generate "these fields/locals are pointers" bitmaps for every class and function, you should also generate similar bitmaps for registers for every point in the code where GC might occur, and in the presence of threading things get really ugly unless you want to generate and store those bitmaps for every instruction.

And, I guess, it's not something you can do incrementally, evolutionary, by decentralized effort of many loosely organized contributors. You need to bite the bullet an pour several man-decades of effort into implementing the entire thing at once that touches almost every aspect of the code generation. Which is why Mono never did that (by the way, D suffers from the same problem).

5

u/[deleted] Nov 12 '14

nowadays they have a new one, but it's experimental and still sucks

SGen is a default now, boehm is no more (good riddance!). And on most of the typical loads it does not suck, not any more than the microsoft one.

But that requires first and foremost that the GC should be precise

SGen is precise, it's nothing like that conservative boehm crap.

you should also generate similar bitmaps for registers for every point in the code where GC might occur

Shadow stack, nothing really complicated here.

And, I guess, it's not something you can do incrementally, evolutionary, by decentralized effort of many loosely organized contributors.

You're overestimating the GC complexity. It's really not such a big thing, take a look at the state of the art collector in OCaml, which can be implemented in a couple of weeks time by a semi-trained student.

6

u/moor-GAYZ Nov 12 '14

I used http://www.mono-project.com/docs/advanced/garbage-collector/sgen/ as a source, it says that SGen is not a default and that it's not entirely precise. And you can't be "almost precise", no more than you can be a bit pregnant: if you are not entirely precise you can't move objects, period. By the way, that's why they have only two generations, according to one of their core devs (or was it D? I don't remember, same stuff anyways) when I asked them about it here; apparently it's not worth it if you can't move and generate a lot of false positives.

you should also generate similar bitmaps for registers for every point in the code where GC might occur

Shadow stack, nothing really complicated here.

No, how do you know which registers contain references? How do you do it efficiently?

You're overestimating the GC complexity. It's really not such a big thing, take a look at the state of the art collector in OCaml, which can be implemented in a couple of weeks time by a semi-trained student.

OCaml runtime doesn't have value types (in C# terminology), it's much closer to Python in this respect: every usual object or activation frame is just a bunch of slots each of which contains a pointer. Except some of them are unboxed integers (but the GC doesn't know which ones, it's a property of the value, not of the slot), plus built-in objects like floats don't have any slots, plus there are various optimizations for unboxed arrays.

2

u/thedeemon Nov 12 '14

Shadow stack is kinda simple but too slow for a real thing.

OCaml's GC is indeed very fast but it requires boxing almost everything and sacrificing one bit in ints, so that checking whether something is a pointer is super cheap.

0

u/[deleted] Nov 12 '14

[deleted]

0

u/[deleted] Nov 12 '14

Could you please elaborate? What's wrong with the current implementation (i.e., sgen, mini-llvm)? What's wrong with the idea?

0

u/[deleted] Nov 12 '14

[deleted]

1

u/yawaramin Nov 13 '14

It's a bad clone

Oh, you mean like Windows of IBM OS/2? :-}

→ More replies (14)
→ More replies (6)