Live data from Hacker News

Why C# is the best language for mobile development

blog.xamarin.com

31–40 of 125 posts

Re: Why C# is the best language for mobile development

#31

While a bit of an aside, personally I find LINQ to have been a horrendous misstep in the evolution of the language. While the argument that it makes code more concise and easy to maintain holds in the small, once a project grows it becomes a terrible cancer -- everything becomes an amorphous blob of stuff, unintuitive, performance-disaster LINQ filters applied everywhere to bend it into shape.

Can you expand on what exactly you mean by LINQ? Do you mean the .NET library support (extension methods on IEnumerable/IQueryable)? Do you mean the language features added to C# (anonymous types, expression trees, nicer lambdas, query syntax)? The language features, with the possible exception of query syntax, seem like hugely beneficial additions, to me.

Re: Why C# is the best language for mobile development

#32
post #28

As languages go, C# may be the ultimate "middle ground" because it really excels and providing a middling implementation of [your-favorite-language-feature]. That is, if you're a functional programming enthusiast, you can do a lot of functional programming in C#. Sure, it's often more painful than haskell or lisp or F#, but it's workable. If you're a dynamic programming enthusiast, C# has a perfectly workable (but ul…

Why is C#'s OOP disappointing to Smalltalk guys?

Well, off the top of my head C# doesn't support mixins or multiple inheritance.

You can get around the lack of mixins with extension methods and tight scoping but it's messy.

Re: Why C# is the best language for mobile development

#33
post #21

Earlier quoted context omitted.

This is a fundamental place where the worlds of C# and Java differ. Where the Java world would say, "developers might misuse this, better not have it in the language," the C# world says, "developers could really use this, better put it in the language."

And if you've worked on a large project with a lot of cats to herd for both platforms, you will appreciate java very quickly.

I work on a pretty huge C# code base. Use of LINQ is the least of it's problems. If anything I'd say one problem is people not knowing about things like lambda expressions, linq, generics or whatever. It can really make code harder to parse when it's written in ways that don't take advantage of the full power of the platform.

Re: Why C# is the best language for mobile development

#34
post #3

Earlier quoted context omitted.

Yes, but it's not specific to LINQ or MS or C#. If you give a tool to mediocre developers to make things easier they will use it right away. If you don't supervise its usage (how it fits into the architectural goals of the project you are on) you will end up with a mess. Anonymous methods, unnamed classes, try catch blocks are all examples of these type of tools that when used improperly will kill the system performa…

Yes, but it's not specific to LINQ or MS or C# We are specifically talking about C#. LINQ was specifically held as one of the improvements to the language. I am not quite sure what your point is relative to that. There are shockingly few examples where LINQ is superior to alternatives. LINQ is the brute force technique of avoiding proper collections/algorithms.

I don't understand. Are you saying that map, filter, reduce and al. on lazy sequences in functional languages are inferior to loops, or that Python list comprehensions and generators are inferior to loops? That's basically LINQ to objects.

Maybe you're refering to LINQ-to-whatever (LINQ to SQL, etc.), a LINQ generalization where you can quote your expressions, rewrite the AST and emit something else (a very constrained kind of macros, if you will).

MS is probably to blame here, but people keep conflating the two.

Re: Why C# is the best language for mobile development

#35

While a bit of an aside, personally I find LINQ to have been a horrendous misstep in the evolution of the language. While the argument that it makes code more concise and easy to maintain holds in the small, once a project grows it becomes a terrible cancer -- everything becomes an amorphous blob of stuff, unintuitive, performance-disaster LINQ filters applied everywhere to bend it into shape.

You don't even have to use LINQ at all with C#, it's an extension library and not one that needs to be referenced or is even included as a default namespace. LINQ is very convenient to use on in memory objects where there's no noticable performance hits. Even LINQ->SQL produces somewhat optimized SQL. How else would you bend data into shape without an ORM layer? Writing custom stored procedures, adding a whole bunch…

LINQ is indeed optional, but this discussion is about the evolution of the language, with LINQ being held as an improvement. And because it is new and shiny, C# code across the globe quickly became infected with it.

Your comment on "where there is no noticeable performance hits" strikes a chord because when first used there are no noticeable performance hits. But then that application grows and scales and suddenly it is death by a million paper cuts, thousands of grossly inefficient set operations devastating performance. That's aside from the fact that LINQ is often a short-circuit saving from having to think about appropriate algorithms of object-methods to deal with the likely uses.

Re: Why C# is the best language for mobile development

#37

While a bit of an aside, personally I find LINQ to have been a horrendous misstep in the evolution of the language. While the argument that it makes code more concise and easy to maintain holds in the small, once a project grows it becomes a terrible cancer -- everything becomes an amorphous blob of stuff, unintuitive, performance-disaster LINQ filters applied everywhere to bend it into shape.

We need to separate LINQ, the C# language feature, from the library implementation, LINQ to SQL or Entity Framework. The later does tend to cause issue because it offers a rather leaky abstraction over your database and poor performance. But it doesn't have to be this way. Case in point BLToolkit, a lesser known database access library that uses LINQ. It is light and almost as fast as native access. Very close to Dapper in performance or pretty much the same in performance if you compile your expression trees, but of course you have type-safety. Of course it doesn't have all the bells and whistles of L2S or EF, but you gain speed and simplicity.

Re: Why C# is the best language for mobile development

#38
post #10

The vast majority of the code in most apps is not core code, it's display code. That's STILL entirely device specific. I think the C# advocates oversell how much it is reusable If you STARTED with a great pile of C# code, say, running on the desktop or server, then wanted to port that to an iOS device, then you have a point. One big problem with non-native code is that example code is almost always written in native…

Xamarin's examples for MonoDroid are (IMHO) pretty solid, to the point where I'll go to them first instead of the Android docs (even though I'm writing Java[0]). It's true you have to re-write the UI code on every platform, but it's still the same language on all platforms, so less of a barrier vs. a total ground-up rewrite. Frankly, I see that as a plus, else you end up with badly cloned iOS-like UIs everywhere. [0]…

I've looked at MonoDroid as I really hated Appcellerator when I tried titanium, and the default Android toolchain is painful.

I too was worried about the accidentally importing iPhone UI into Android. Any tips on avoiding it?

Re: Why C# is the best language for mobile development

#39

Sigh . Okay, let's play this game. 1. "Cutting edge", first thing listed is asynchronous programming. Okay, don't get me wrong, I like C#, I like the Task Parallel Library, but Grand Central Dispatch in OS X/iOS is beautifully simple and incredibly powerful. It does everything I need it to do. 2. "Powerful features" - OOP. Really? And Java/Objective-C don't support OOP/encapsulation? You can't do dependency injection…

for #1, there's a bit more to asynchronous programming in C# these days than the TPL. Take a look at the new async/await keywords in C# 5. Lets you write asynchronous code without having to deal with callbacks.

True. That being said, I don't really feel like I am hugely more productive with C#'s asynchronous support than Obj-C's.

I'm a huge fan of GCD's serial/parallel queues. I haven't found anything in C# with similar functionality that is as simple as GCD.

Re: Why C# is the best language for mobile development

#40

Earlier quoted context omitted.

Yes, but it's not specific to LINQ or MS or C# We are specifically talking about C#. LINQ was specifically held as one of the improvements to the language. I am not quite sure what your point is relative to that. There are shockingly few examples where LINQ is superior to alternatives. LINQ is the brute force technique of avoiding proper collections/algorithms.

The point is relevant in relation to the fact that you held LINQ out as a misstep, but the reasons you cite can be applied to many features of many different languages.

Yes, but rather than actually arguing with his point, you are showing how it could also be used to criticize some other language features not in an attempt to prove him wrong, but rather to pander to anybody reading the argument who likes those language features.
Post reply on HN