Live data from Hacker News

Understanding .NET 2015

blogs.msdn.com

81–90 of 107 posts

Re: Understanding .NET 2015

#81

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…

Scala has almost every feature of C#, while the inverse is not true. I miss visual studio a bit when doing scala, but never the language. When I'm doing .NET work, I sorely miss scala.

Re: Understanding .NET 2015

#82
post #78

Earlier quoted context omitted.

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…

Having to rely on reflection is bad though.

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.

Re: Understanding .NET 2015

#83
post #8

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 t…

I'm wondering the exact same thing. What is the relationship between the two? How easy is it to bridge them or is that not possible? I mean suppose I want to write some typical backend utility code like extensions for collections etc: can the same code for .NET framework be used for .NET core? Eventually with some #ifdefs?

Re: Understanding .NET 2015

#84
post #61

Earlier quoted context omitted.

> games Ever played something like e.g. Bastion? http://en.wikipedia.org/wiki/Bastion_%28video_game%29 I mean if you are developing the new Unreal Engine - sure. But otherwise gaming industry would benefit from more of maintainable code.

For context, Bastion was written in C#. Here's what the lead developer said on the topic of GC: http://www.reddit.com/r/IAmA/comments/lwljh/iama_dev_team_of...

This is more appropriate

http://www.reddit.com/r/IAmA/comments/lwljh/iama_dev_team_of...

Re: Understanding .NET 2015

#85
post #82
post #78

Earlier quoted context omitted.

Having to rely on reflection is bad though.

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.

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#.

Re: Understanding .NET 2015

#86
post #15

Earlier quoted context omitted.

This. The amount of new Thread(new Runnable(){...}).start() I have in my Android code is awful. And then inside the Thread you have to use runOnUiThread() to change UI stuff. Given how common it is for an app to hit the network, this should be much much easier. Looking at your example it might be slightly easier but it also isn't inlineable. C# solves both of these problems

Hah; check out RX & http://reactiveui.net/ which is the framework behind GitHub for Windows. You will never have to worry about which thread your running on ever again. Doesn't just support WPF - it also works on Windows Phone, iPhone, Mac OSX & Android: public SearchViewModel(ISearchService searchService = null) : ReactiveObject, IRoutableViewHost { SearchService = searchService ?? Locator.Current.GetService (); //…

"Not worrying about the thread" is actually a feature of TPL. A SynchronizationContext[1] is stored in thread local storage for UI threads, which can be used to queue calls back to that thread (a .Net 2.0 feature). When you `await` something, TPL takes advantage of the original SynchronizationContext and the callback will be automatically made on the UI thread.

If you implement SynchronizationContext and set it, you can actually have the TPL call back into whatever special threading stuff you want.

It doesn't work for WPF bindings, but for the quick'n'dirty procedural UI code it works great.

[1]: https://msdn.microsoft.com/en-us/library/system.threading.sy...

Re: Understanding .NET 2015

#87
post #13

Earlier quoted context omitted.

It is and it isn't. LINQ is actually incredibly smart under the hood, so if I ran: myList.Where(x => x.name = 'Person'); .Where(x => x.age > 18); .ToList(); it wouldn't actually run two different array filters - it would combine them. You can imagine the performance gains to be had there.

Citation? I was unaware that the little IEnumerable functions did fusion. If you mean an IQueryable execution, like LINQ-To-SQL, then sure.

LINQ IEnumerable functions are implemented using the `yield return` operator:

  public static IEnumerable Where(IEnumerable source, 
                                        Predicate predicate)
  {
    foreach(var item in source)
    {
      if(predicate(item))
        yield return item;
    }
  }
which means

  var results = myList
    .Where(x => x.name == 'Person');
    .Where(x => x.age > 18);
    .ToList();
is executed just like

  var results = new List();
  foreach(var x in myList)
  {
    if(x.name == 'Person')
    {
      if(x.age > 18)
        results.Add(x);
    }
  }

Re: Understanding .NET 2015

#88
post #3

Earlier quoted context omitted.

I used to work in C# (now mostly live in JavaScript land) and I miss things like LINQ a lot. So here's hoping we see wider adoption of C# in the future.

It's pretty trivial to implement Linq-like functions in JavaScript, or, I think stuff like undersocre has them.

Lazy.js (http://danieltao.com/lazy.js/) is probably a closer equivalent. Linq statements are evaluated lazily, generally without needing to create intermediate arrays.

Re: Understanding .NET 2015

#89

Earlier quoted context omitted.

> 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 ha…

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.

How Google handles the whole developer quality experience in Android, Java 8 might eventually be supported by the time we have Java 10, with reifeid generics, modular, value types, JNI replacement, ...

If ever, given their attitude on last year's Google IO.

Re: Understanding .NET 2015

#90

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…

- 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 :(

Post reply on HN