
Understanding .NET 2015 - pjmlp
http://blogs.msdn.com/b/bethmassi/archive/2015/02/25/understanding-net-2015.aspx
======
rdtsc
Recently I got to use some C# on Linux (with Mono framework), and I gotta say
it wasn't bad. I didn't do anything with GUI elements, was all back-end server
code.

C# wouldn't be my top "go to" language, but I would put it above Java. I liked
some of the generics handling better, it can be less verbose it seems.

Monodevelop is not on par with Visual Studio, but it is solid and worked well
for me. I usually don't like IDEs, but for a new language/framework and large
projects it was very helpful to have it.

Wondering if open sourcing .NET core will breathe a new life into Mono project
and maybe it is going to be bigger thing that what we expected -- we'll start
seeing more back-end usage of .NET.

F# is nice too, and if anyone stayed away because of having to use Windows,
maybe now is a time to take a second look.

~~~
edgyswingset
> I liked some of the generics handling better, it can be less verbose it
> seems.

It pays off in spades in a lot of situations, but the biggest I've noticed is
Android development. Hitting a network from a button press in Xamarin is as
simple as:

    
    
        button.OnClick += async
        {
           var data = HitTheNetworkForSomeData();
          
           // Note that since this is still async,
           // you may want to set a global or have a
           // different approach to handling data than
           // "standard" Android development.
           DoSomethingWithTheData(data);
        }
    

In native Android, it usually looked like this:

    
    
        button.SetOnClickListener(new OnClickListener() {
           new HitTheNetworkTask(this, this).execute()
        });
    
        @Override
        public void onNetworkTaskDataRecieved(String data) {
           doSomething(data);
        }
    
        public class HitTheNetworkTask extends AsyncTask<Void, Void, String> {
           Context mContext;
           NetworkDataTaskCallbacks mCallbacks;
    
           public HitTheNetworkTask(Context context, NetworkDataTaskCallbacks callbacks) {
              mContext = context;
              mCallBacks = callbacks;
           }
    
           @Override
           public String doInBackGround(Void... voids){ // I'm not pulling your leg here
              return doTheNetworkTask();
           }
    
           @Override
           public void onPostExecute(String data) {
              callbacks.onNetworkTaskDataRecieved(data);
           }
        }
    

It's downright frustrating having to use Java once you're used to C# and .NET.

~~~
benjiweber
It's a shame Android is still stuck on Java pre-8, as your Java example could
be nearly as consise as the c# with Java 8.

~~~
edgyswingset
In this particular case, yes. Another issue that comes up is when you've got
fairly type-heavy code. C# having real generics just makes things much simpler
than in Java.

~~~
benjiweber
Yes c# generics are often a lot less painful, due to lack of type erasure, and
support for variable number of type parameters etc.

Having said that, more is possible with Java than many people realise. You can
read statically available generic type params at runtime (field declarations,
supertype tokens etc) . There are also workarounds for most of the erasure
problems like methods that vary by generic type parameter only.

Java has some nice things itself too. Structural typing of single method
interfaces/lambdas makes numerous things much easier. Default methods on
interfaces let you do trait-like things nicer than with extension methods.
Static imports reduce verbosity. More powerful enums etc.

c# approach to type inference seems to be to infer the left hand side of
expressions with "var". Java infers types on the right hand side with the
diamond operator, method type parameter inference, lambda to interface type
inference. The Java approach makes code using fluent chained invocations less
verbose, while the c# approach reduces the verbosity of assigning to lots of
intermediate variables.

~~~
hacknat
Having to rely on reflection is bad though.

~~~
eropple
Why? I hear this a lot, but I never understood it. I do a lot of work with
reflection to achieve things I can't otherwise do (around application
extension, dynamic systems for games, etc.).

I mean, _attributes_ are reflection, and they're absolutely invaluable.

~~~
hacknat
Because it's not maintainable in a large code base. You write your code, and
move on to something else, someone else comes a long and does a refactor, but
they and/or the IDE misses the member names that were in strings. The program
crashes on the next deploy because it built just fine.

Reflection is like anything else it can be used properly and it can be abused.
I've seen it abused far too many times.

I realize there are times in Java when reflection is unavoidable (Android's
animation libraries rely on it), but I consider it to be a feature of C# that,
so far, I've never had to use reflection in C#.

~~~
marvelous
A killer feature of the Ceylon programming language is its typesafe metamodel.
Metamodel references are refactored like everything else in eclipse.

------
stinos
There are spelling squiggles in the article's first image :]

[http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-
bl...](http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-
components-
weblogfiles/00-00-00-81-88-metablogapi/1425.image_5F00_2D285E88.png)

Apart from that: I'm really curious and sort of excited to see what the next
years will bring in terms of development using .Net in general and C#/F#
specifically, on multiple platforms.

------
Eyas
What I still don't understand in this picture is the what does the _future_
look like in terms of the .NET _framework_.

.NET Core sounds great, and its great that they are unifying the
implementation, not just the API, for many of the "app models". But, its
unclear to me if there's the intention for .NET Core to fully succeed .NET
Framework at some point in the future. Or, rather, will some of the app models
we see on top of the Framework right now (WinForms, WPF apps) be built with
.NET Core in some future version?

~~~
cpayne
I think the reason why the future isn't spelt out is because they don't know
(or haven't decided). The last 12 months have been massive steps for Microsoft
(open source, multi platform). I would expect they would wait and see how
their customers & community react.

Also Azure is a massive component to all of this (they make money of Azure,
they don't make a massive amount of cash from someone using .Net).

Microsoft have a long history of keeping old versions alive (unlike say
Apple). Eg Internet Explorer, Windows XP, Office, Win Forms vs MVC

I'm sure .Net core will take over one day. In the same way .Net 4.5 overtook
.Net 2 / 1.1 etc.

------
doczoidberg
Any reasons I should switch to Java or other technologies?

What I get with the (much hated) Microsoft stack:

\- C# with LINQ and async await

\- Roslyn compiler as a service which speeds up development

\- mature .NET framework

\- more and more open source and cross platform parts and smaller independent
libs

\- typescript

\- Xamarin cross platform tools

I also use python and used Java in the past. I don't see any reason why Java
should be better?

~~~
olavgg
\- JRebel or Spring Loaded

\- Groovy is nice and still very similar to Java(no learning curve)when you
want syntactic sugar like LINQ or JDBC SQL without all the boilerplate code.

\- IntelliJ Idea is similar to Visual Studio + Resharper.

But the biggest reason to start using Java is its extremely mature and rich
ecosystem!

I'm currently doing software development on Windows with C#.Net and Visual
Studio without ReSharper and I really miss Linux, Java and IntelliJ Idea :(

------
thebouv
Happy to have a in depth article like this; bookmarked for later today
hopefully.

My background is in the LAMP stack but now work in an enterprise environment
where everything is .NET (though much older .NET than this article is talking
about).

I want to throw myself into it but right when I started there was all this new
talk about vNext and changes to .NET and all this other excited, though
daunting, discussion around it.

Was hard to know where to start.

------
guiomie
.NET Native ... It would be great to have it for back-end also as opposed to
only front-end. I'd take that 60% startup increase in IIS also, the first
request is always slow...

~~~
PantaloonFlames
> I'd take that 60% startup increase in IIS also, the first request is always
> slow...

But startup cost is less relevant in a server scenario. In a server you
startup once per ~1B requests or more. In a front-end app, it might run 10
requests and then stop.

~~~
guiomie
Agreed. But we do have API for internal jobs that are only used a few times a
week. Then there is also the other 15%-20% memory reduction discussed in the
article that I'd like to have back.

------
cmdrfred
I learned to code with python, php, and javascript mostly. I could never get
into visual studio / .net, it always felt so long winded compared to python.

~~~
smortaz
give [http://pytools.codeplex.com](http://pytools.codeplex.com) a try!

------
dkarapetyan
I like that now there is a viable alternative to Java across various
platforms. Java the language is alright but the ecosystem is something else
entirely.

------
0x0
It looks like the open source cross-platform version of .NET, v5 ("core"?), is
something that was written completely from scratch?

Why wouldn't they open source the v4.x version? And why is WPF, Windows Forms,
and ASP.NET placed above the .NET 4.x block in the diagram?

Is .NET v5 Core a from-scratch lightweight reimplementation that can't run the
full stack? If not, why the huge separation?

~~~
mwg66
It is fairly clear on the GitHub repositories.

It's not a reimplementation but a gradual publish of existing code, upgraded
to meet the required standards (some of it was not written with being open in
mind).

WPF will not be available on non-Windows platforms. That has always been the
case and will remain so - it has a far to deep integration with the OS for it
to ever be platform independent and a reimplementation would be an absolutely
ginormous effort.

~~~
0x0
Thanks for clarifying.

And on a tangent, I guess the WPF thing was expected. But! I also thought WPF
is mostly a re-implementation of all the windows widgets on top of a
framebuffer - it doesn't use native win32 buttons, dropdowns, text rendering,
etc etc...?

~~~
seanmcdirmid
It doesn't depend on Win32, but MilCore depends on DirectX 9, so I guess it
would be hard to port to other platforms.

------
wluu
The discussion in this corefx github issue is pretty interesting to follow.

[https://github.com/dotnet/corefx/issues/973](https://github.com/dotnet/corefx/issues/973)

It probably answers a few of the questions several have asked in this thread
with regards to what the .NET Core is.

------
Animats
I thought Microsoft was phasing out .NET and encouraging people to write their
GUIs in JavaScript. That's what they were saying early last year.

~~~
douche
I think the state of the Windows Store shows that approximately nobody took
that seriously.

Unfortunately there are a few libraries I use at work that were released
around the whole Windows RT/JS debacle, so their documentation takes a little
more figuring, and is frequently incorrect, due to only having code samples in
these dead/orphaned variants.

~~~
emodendroket
I think part of it is that MS tied WinRT to full screen-only apps, a mistake
they're fixing in Windows 10. Some of the features of the WinRT API look neat.

