Live data from Hacker News

Understanding .NET 2015

blogs.msdn.com

41–50 of 107 posts

Re: Understanding .NET 2015

#42
post #13

Earlier quoted context omitted.

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

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.

It is not so bad in JavaScript anymore. With Lodash:

    _(myList)
        .filter(x => x.name == 'Person')
        .filter(x => x.age > 18)
        .value()
Used like this Lodash is lazy, so the first value of myList will run through all the filters before the next item gets processed.

Re: Understanding .NET 2015

#43
post #17

Earlier quoted context omitted.

I spend most of my time in C# and it's always a sad moment when I start typing .Where(x => ...) in another language and realize it doesn't exist.

It's spelled filter http://en.wikipedia.org/wiki/Filter_%28higher-order_function...

Not sure why this is getting downvoted, that's what it's called in most other languages.

Re: Understanding .NET 2015

#44
post #20
post #17

Earlier quoted context omitted.

It's spelled filter http://en.wikipedia.org/wiki/Filter_%28higher-order_function...

I don't mind C# not using that name because .Where doesn't actually filter the object, it returns an IQueryable, which you can chain further statements onto, then filter.

That's basically what filter does in Clojure (and probably any other language with lazy evaluation): http://debasishg.blogspot.com/2010/05/laziness-in-clojure-so...

Re: Understanding .NET 2015

#45

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.

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.

Re: Understanding .NET 2015

#46
post #36
post #21

Earlier quoted context omitted.

"we'll start seeing more back-end usage of .NET." Outside of startup world, it is already used everywhere.

Well, I can assure you that Java is used.. more everywhere.

From itjobswatch.co.uk:

C# - 16748 jobs [1]; Java - 13816 jobs [2]

[1] http://www.itjobswatch.co.uk/jobs/uk/csharp.do

[2] http://www.itjobswatch.co.uk/jobs/uk/java.do

Re: Understanding .NET 2015

#47
post #13

Earlier quoted context omitted.

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

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.

Re: Understanding .NET 2015

#48

Earlier quoted context omitted.

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.

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.

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.

Re: Understanding .NET 2015

#49

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…

You don't need to use Java for Android or for the JVM, you can just use Scala. See Scaloid [1] for setting up Scala for Android and Scala Async [2] to get that nice "async" syntax you've mentioned. [1] https://github.com/pocorall/scaloid [2] https://github.com/scala/async

Switching to Scala would mean learning all the Scala baggage (which has good intentions - granted). C# is much more accessible, while still being elegant - hence the ever-rising popularity.

Re: Understanding .NET 2015

#50
post #6

Earlier quoted context omitted.

Just out of curiosity, what is your go-to language? C# is probably my favorite general purpose language so far, although I really prefer Golang's goroutines/channels over C#'s async model. Curious to hear other perspectives!

Python for smaller self-contained projects and scripting. Erlang/Elixir for larger projects where fault tolerance or concurrency is needed. C/C++ where GC is a no-go (games, low latency, time critical data processing). Next up in the pipeline to learn and use: Rust

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

Post reply on HN