

C# 6.0: An Introduction - bookerio
https://booker.codes/csharp-6-an-introduction/

======
jasode
Fyi, Mads Torgersen from Microsoft has given several " _What 's New in C#
6.0_" presentations:

[https://channel9.msdn.com/Search?term=torgersen#ch9Search&pu...](https://channel9.msdn.com/Search?term=torgersen#ch9Search&pubDate=year)

You can pick the 7 minute quick overview, or the 1 hour session at Ignite2015.

(Side note to the poster... your blog layout displays a constant masthead
using over 40% of the width. A technical audience for your blog might find it
excessive to have that much space dedicated to "brand awareness" about your
availability to create custom websites.)

~~~
bookerio
Indeed, those are some really nice resources. Thank you for mentioning them.

In response to your side note: 40% is a bit of an exaggeration (unless your
resolution is extremely low) but I do appreciate your point - I can see how
the masthead might be a bit obnoxious. I will tweak the theme accordingly in
the near future. Thanks.

~~~
jasode
_> 40% is a bit of an exaggeration (unless your resolution is extremely low)_

No, it's not exaggeration.

I'm measuring the _width of your actual text content_. I'm guessing you're
measuring the width of _the browser window_ which is not relevant to the ratio
calculation.

Your masthead takes up 530 pixels. The total width from left edge of masthead
to right edge of _actual text_ is about 1296 pixels. On my Chrome browser,
even if I maximize the window (press F11) to be 2560 pixels, your _text
content_ still maxes out at 1296 pixels (which leaves 1264 pixels of empty
space on the right).

40.9% = 530/1296

------
kule
This article doesn't seem to have any info on the syntax changes yet - here's
a run through: [https://github.com/dotnet/roslyn/wiki/New-Language-
Features-...](https://github.com/dotnet/roslyn/wiki/New-Language-Features-
in-C%23-6)

------
mattmanser
Out of interest, how many people here actually use async methods? Excluding
being forced to by a library.

They haven't revolutionized my code at all. I can't decide if I'm too stupid
to realize when to use them, or if they're really just a bit useless for most
normal code. I can see the point to it, it's just that most of the time I'd
consider using it, it just isn't worth the extra effort. Usually seems to be a
premature optimization.

Lambda expressions, now they revolutionized my code completely.

~~~
edgyswingset
Think of it this way:

What happens when IIS runs out of threads?

Without async code, it queues of requests and users sit there getting nothing
from your server.

With async code, that's not the case! Well, until you reach the limit of what
async code does, but that limit is quite high.

Typically a request thread that ends up blocking on I/O in some way (like
accessing a database) sits there doing absolutely nothing for a very long
time. The time it takes to get data from a database could be spent servicing
many, many more requests! Async does just that. And before you ask, it doesn't
spawn off any threads ... it leverages the asynchronous nature of the
operating system to service I/O requests. It's actually really, really rad.

> Usually seems to be a premature optimization

If you have a user-facing system, it's most definitely not a premature
optimization. If you know, for a fact, that you'll never need to worry about
responsiveness, they're not worth it.

~~~
louthy
There are 32,768 threads in the thread-pool on a 64bit machine. How many do
you need?

~~~
edgyswingset
> How many do you need?

That's an irrelevant question until you legitimately need to scale out. Async
code lets you scale up so that when 32,769 users access a site relatively at
the same time, you don't force a user to wait for IIS to free up a new thread.

~~~
louthy
> 'to wait for IIS to free up a new thread.'

Apologies if I'm not following your train of thought here. The thread-pool has
the threads right, not IIS? When you do something like Task.Run(...) the task-
scheduler will schedule your work on a thread-pool thread (32,768 pre-
allocated at start-up). Of course you have to wait for the scheduler to give
you one of the threads from the pool.

Are you saying async doesn't need threads/TPL? I know it has some funky
concurrency stuff that allows interleaved processing (rather than thread-pool
processing), is this what you're referring to? Even IO would have to do
something like this behind the scenes:

    
    
        Result IOMethod()
        {
           EventWaitHandle wait = new AutoResetEvent(false);
    
           // Do your IO - pass in the handle
    
           wait.WaitOne();
           return result;
        }
    

Wouldn't the pre-IO and post-IO need to be run via the scheduler if you want
it to run asynchronously? The WaitOne will release the thread back to the
pool. How is async any different?

~~~
louthy
Ok, did a bit of reading for myself. I had obviously only vaguely took in what
was said when it was first released as a language feature. So async will run
all code on the current thread, until it gets to some IO. At that point it
switches to running the code that you'd normally expect to run asynchronously.
Once the IO returns it runs the remainder of the async 'closure' (for want of
a better word) with the result. A kind of coroutines system, I guess similar
to node.js.

~~~
edgyswingset
Yep! The async model in node.js is very similar.

Here's a _fantastic_ blog post about the details of it all:
[http://blog.stephencleary.com/2013/11/there-is-no-
thread.htm...](http://blog.stephencleary.com/2013/11/there-is-no-thread.html)

------
VinzO
I take the opportunity of this thread to ask for good ressources and books to
learn C#, .NET, databases. I have a background in C, C++ for embedded systems
but I would like to learn higher level stuff. Any recommendation on where to
start? The final goal would be to be able to switch career from embedded to
higher level development.

~~~
aikah
C# isn't hard to learn , it's one of the easiest language to pick up , and
Visual Studio will make you productive in no time. The hardest is usually the
APIs and diverse libraries and frameworks you'll have to know, what do you
want to do ? Web dev? windows apps ? Plural sight has good education material
that covers all these topics.

~~~
ghuntley
Check out [https://github.com/quozd/awesome-
dotnet](https://github.com/quozd/awesome-dotnet) :-)

------
mcintyre1994
FYI Alex:

> Read-Only Auto-Implemented Properties - Allow you to omit the getter from an
> automatic property, which makes it read-only.

This should be omit the setter right? :)

BTW, is there somewhere I can get notified as the new chapters become
available? I'll probably miss the tweet and I don't think this is your blog?

~~~
bookerio
Thank you so much for pointing that out. I have
[updated]([https://github.com/alexbooker/articles/commit/735f8558851ce3...](https://github.com/alexbooker/articles/commit/735f8558851ce3af08b5d2a58465264d11b16e48))
the article.

Thank you for your interest in the series, too. If you want to be notified
when new articles come out, you could
[subscribe]([https://booker.codes/rss/](https://booker.codes/rss/)) to the
blog via an RSS client or you could "watch" this [GitHub
repository]([https://github.com/alexbooker/articles](https://github.com/alexbooker/articles)).

~~~
WeaselNo7
There seems to be a bug at the end of the first page ('an introduction'),
where the link to the subsequent page loops back to the introduction page!

------
srean
Just to put it out there: If you like C# the language but rue the fact that it
will execute on a VM layer, you might want to take a look at D. Especially if
you are into number crunching with small memory footprint, it seems C# is not
a good language for that. Otherwise, there is really a lot to like about C#

~~~
jeremiep
Coming from using D for personal projects and now working in C# at work (in
.NET 2.0 as well because of Unity) I find myself constantly missing D
features. Especially given one of the main requirements of the work I'm doing
is performance.

Things like array slices being first class in D while ArraySegment<> looks
like a hack in C#, D templates beating the hell out of C# generics, functional
programming in D is actually inlined almost 100% at compile-time while LINQ
adds noticeable overhead, and the list goes on :)

~~~
jaked89
Templating is one of the strongest features of D IMO, and the only reason I
would ever consider using it over C#.

No decent IDE/debugging story though, so overall C# still wins for me at the
moment. Especially for large projects.

~~~
jeremiep
I use Emacs as an IDE and gdb for debugging and it works like a charm.

------
smileybarry
Hey, just a heads up: your site's cert is coming up as invalid on my Nexus 5:
[http://i.imgur.com/kXNSygM.jpg](http://i.imgur.com/kXNSygM.jpg)

This is on stock Android 5.1.1, unrooted.

~~~
ubojan
Yup, looks like CA bundle is not installed, causing issues on some browsers:
[https://www.sslshopper.com/ssl-
checker.html#hostname=booker....](https://www.sslshopper.com/ssl-
checker.html#hostname=booker.codes)

------
scottc
Dang, c# looks so awesome! Was super interested in using for our most recent
project, but alas, we chose python.

Looking forward to using these features someday but I'll pass on Windows and
Azure for now.

------
dafrankenstein2
C# plus Visual Studio plus MSDN is real awesome

~~~
diimdeep
and very huge download size and windows only, hope this changes soon.

