News for hackers. Stuff that matters.
Re:Announcing .NET Core 1.0 by ngrilly on Monday June 27, 2016 @03:00PM (#11988559)
A few years ago, I wouldn't have thought I would write this, but it looks like Microsoft is definitely changing, for the best!

Two questions:

- Does .NET Core offers something similar to Go goroutines or Erlang "lightweight" processes?

- And something similar to gofmt?

Re:Announcing .NET Core 1.0 by oblio on Monday June 27, 2016 @03:19PM (#11988701)
1. I can't say for sure. Maybe this? http://getakka.net/

2. There's https://msdn.microsoft.com/en-us/library/ff926074.aspx + your favorite IDE which can automatically reformat the code. Visual Studio can do this. If you want to enforce things, there's: https://stylecop.codeplex.com/

Re:Announcing .NET Core 1.0 by edgyswingset on Monday June 27, 2016 @05:01PM (#11989447)
> Does .NET Core offers something similar to Go goroutines or Erlang "lightweight" processes?

Not quite the same thing, but F# has the MailboxProcessor<'T> type which is conceptually similar to Erlang processes and can be used in the same way.

Re:Announcing .NET Core 1.0 by niba on Monday June 27, 2016 @04:04PM (#11989028)
Re:Announcing .NET Core 1.0 by jdmichal on Monday June 27, 2016 @03:28PM (#11988773)
I don't know of any green threads in .NET -- at least, not built in. However, .NET does have a built-in thread pooling / task execution service. You generally interface via `System.Threading.Tasks.Task`[0], which has static `Run` functions, or use the `Factory` property to get the underlying `TaskFactory` for more fun. Since the executors are pooled, the creation costs will be amortized over your program's lifetime.

Then there's `async`/`await`[1], which is built on top of tasks.

[0] https://msdn.microsoft.com/en-us/library/system.threading.ta...

[1] https://msdn.microsoft.com/en-us/library/mt674882.aspx

Re:Announcing .NET Core 1.0 by int_19h on Monday June 27, 2016 @04:45PM (#11989325)
I remember that a long time ago, .NET threading was implemented in such a way that it should, in theory, support Win32 fibers. It's why all the low-level .NET APIs don't use the OS thread IDs, but instead have their own IDs, and require explicit mapping.

I believe that it was abandoned as a supported scenario a while ago, though. But you can still see artifacts of that in the docs, e.g.:

https://msdn.microsoft.com/en-us/library/system.threading.th...

"The value of the ManagedThreadId property does not vary over time, even if unmanaged code that hosts the common language runtime implements the thread as a fiber."

Re:Announcing .NET Core 1.0 by louthy on Wednesday June 29, 2016 @01:41AM (#11999724)
Not out of the box, but this library does exactly that (with lots of functional niceness too). Disclaimer, I wrote it, so I'm obviously biased

https://github.com/louthy/language-ext

Re:Announcing .NET Core 1.0 by ngrilly on Wednesday June 29, 2016 @04:04AM (#12000159)
Just had a cursory look at the README. Is each lightweight process mapped to an OS thread? What is the minimal memory used by each lightweight process?
Re:Announcing .NET Core 1.0 by louthy on Wednesday June 29, 2016 @08:19AM (#12001150)
It wraps the F# MailboxProcessor mentioned in a comment above. A thread is only allocated when a message is processed, and then free'd up afterwards. So there's no permanent thread overhead and 100,000s can be created.

The overhead in terms of memory is the internal state of each Process + the user's Process state. To see the internal overhead, check out the member variables for the Actor class [1].

It's pretty lightweight, although could probably shave a few bytes here and there.

[1] https://github.com/louthy/language-ext/blob/master/LanguageE...