177 points · by nstart · 12y ago · 171 comments
I only wish Xamarin's products didn't cost so much. With Swift on the scene I really can't justify spending money to write my side projects in C# instead of in the environment Apple provides. Or Java for Android, which let's face it, is already similar to C# anyway.
For the stdlib there is no one single problem it's death by a thousand cuts in a lot of various ways. Over reliance on inheritance for polymorphism which limits composability in a lot of ways. Too little use of interfaces.
Some of this seems like it's due to backwards compatibility concerns but it definitely degrades the developer experience with the language. Which is a shame because c# has a lot to offer.
I was once told that a lot of the original libs were effectively ported from C++ libs by C++ devs in a hurry. There are nuget packages with decent data structure / collections missing from the core BCL.
Interfaces like IEnumerable<T>, IComparable<T> and IEquatable<T> I find to be extremely useful and if you're following interface segregation principle and not chucking round the actual concrete implementations. I concede though that the BCL would be richer if one didn't have to think about this stuff too much.
I guess there's enough experienced C# devs around to know how to avoid those pitfalls. As the BCL is shrunk I expect it will be easier to substitute any structures your not happy with, with alternatives.
Some of C#'s interfaces are simple and well designed, but the OOP model used is kind of weak for composition of them. For example, one would often like an IIndexable interface to cover both arrays and lists, or an numeric interface for which we can perform common operations over any number type. Without the ability to extend existing implementations with new interfaces, we're stuck using various patterns and wrappers to get the abstraction we need.
I was a C# developer for about 6 years before I got tired of the same old problems and decided it's not for me. I still use it occasionally when required, but not if other options are available.
So the
bool Int32.TryParse(string value, out number)
method would probably nowadays be better done as Int? Int32.TryParse(string value)
Similarly, WinForms has loads of different events of different types with individual delegates created for them. Nowadays you'd use Func and Action instead.Obviously if you are only going to ever develop for iOS then going with Swift could make sense but then it seems that Xamarin would've never really have been an option anyhow, irrelevant of cost.
Of course, this may have changed.
In my current project (a video game), the core library is a PCL - it contains data structures and the interfaces and abstract classes that content (mods as well as the base game) must fulfill. I have a "desktop" library that's a normal .NET 4.5 class library that contains stuff like "load your config data from files, include the runtime-compilation mod system", and I have runner projects--text-mode via curses for now, eventually graphical post-prototype--for MacOS, Windows, and Linux[1]. I use configurations (not platforms, leave everything as AnyCPU unless you want to hate your life) to provide preprocessor flags for #if; my solution has ended up with an ugly number of "Windows-Debug", "MacOS-Release", etc., but the differences between XS and VS make it hard to do things "right".
[1] - all source/content files added via a single template .csproj, using a Ruby watcher I'm going to eventually open-source, because using MSBuild correctly to handle this situation breaks in both VS and Xamarin. (That last bit, you may be realizing, is a common theme. .NET has such good stuff, but half of it is broken at any time.)
Xamarin.Forms is their solution - common UI components wrapped in a generic layer.
They have a nice way to blend Xamarin.Forms, native UI controls and library projects that is getting much better, but still a bit of a pain.
They true value in my eye is that I only have to be proficient in one language, and they have very good documentation.
I still need to have a firm understanding of the API's for both Android, iOS, and WinPhone if I want to make a non-Xamarin.Forms application, but at least I'm not mentally shifting between 3 languages.
Anyway, my point is once you understand how things are organised, the language shouldn't make much of a difference. Especially not between popular, run-of-the-mill languages like c#, java and ObjC. Your devs could probably learn iOS pretty easily.
That sums it up for me, too. I'm mostly a Ruby developer, and in C# I get tons of Ruby-like features, plus static typing and better performance. But my years with Java spoiled me for a clean and consistent stdlib. For instance in C# collections are just a mess. If I could build Rails apps in C# and deploy on Linux, I'd probably do it.
* List: implemented by ArrayList and LinkedLink
* Set: implemented by HashSet
* Map: implemented by HashMap
All are Collections.
Then it's easy to get immutable versions, synchronized versions, Sorted{Set,Map}s (implemented by Tree{Set,Map}).
They work with Comparator and Iterator in a consistent way.
There is symmetry and unity. I don't even remember the C# analogues, but my recollection is that sometimes they come with an interface, sometimes not, the names are messier, generics are less consistent, and there isn't a unified way to get immutable versions etc.
I don't think C#'s collections were that bad, and probably people here can correct my memory about some of the above, but they weren't as clean, and to me that was a motif throughout the framework. A messy collections API is no big deal really, but when it's the same story for I/O, networking, GUI, etc. . . . (I do think layout was a lot easier in WinForms than Swing though.)
On balance I'd take C#'s rapid evolution over Java's slowness, but what Java got from its conservatism was purity and low cognitive overhead, which as a working programmer was pretty nice.
That said, it'd still be really cool if I could write Rails apps in C# on Linux. With vim. :-)
Then how come is Java 9+ catching up with AOT compilation, value types, making unsafe a public API, reifeid generics and replacing JNI with something more akin to P/Invoke?
Only for those that never had the pleasure to enjoy enterprise astronaut architects with their DCOM, CORBA and JEE designs.
I love the current crazy ecosystem of languages out there, but when I need to get shit done...C# is my first choice. I've bet my career on it, and it's paid off nicely.
And as long as we're being evil, I wouldn't mind seeing Microsoft buy up Light Table (if that's even possible) and build some of its features into Visual Studio. Namely inline eval and live code modification.
Though I'd certainly be all in favor of inline eval and live coding in VS!
Last year, I inherited a .NET v4.0 project, so I've been back in Visual Studio quite a lot. And, maybe it's that my skills are rusty. That very well could be. But, the latest version of C# just feels like a sloppy mess.
It's almost as if MS started C# as a competitor to Java and now has tried to make it a competitor to everything else (Python, JavaScript, Java, etc.). I'd rather that MS have created new languages and provided transformations to port existing C# code to those languages.
Or, perhaps I've been spoiled over the last few years working with dynamically typed languages with lots of functional idioms designed in from the start.
Edit: Obviously there are some die-hard C# advocates here. So, I hope to retract my opinions. I'm clearly doing something wrong.
EDIT: Interesting to see Neal Gafter is involved (See Roslyn mention here: http://www.gafter.com/~neal/), who is rather fond of Scala from what I've read: http://www.infoq.com/articles/neal-gafter-on-java
This already makes a lot of difference in the tooling that one gets from the platform owner.
Another thing is from the point of view of customers.
With C# I can get all the goodies on customer projects.
With Scala, I can only play with it at home and try to be happy with Java 8 on customer projects.
http://www.reddit.com/r/csharp/comments/2dc6ge/easier_immuta...
It does, but then that begs the question of "why use c# at all?". C# is still missing (along with F#) scala's most powerful features, and I prefer the JVM and openness of the ecosystem to .NET
The contact I'm on, we're having a lot of success porting away a large C# application to Scala.
> I don't think Scala usage will grow much more now that Java 8 is released.
I don't get that reasoning. As the GP mentioned, even C# projects migrate, so why would Java's more concise anonymous inner classes be a show-stopper?
Do you think the main reason people use Scala is because of lambdas and type inference?
From my experience with C# null checking before method calling or indexing is such a pain and the coffeescript like null propagation is a much needed feature.
I don't think this will have any effect on Xamarin licenses at all.
C++/C#/F#/MSSQL/PowerShell is all they really need to concentrate on.
Mind you I don't think there's anything wrong with that as an attitude. Anyway, Microsoft puts resources into it because they probably have zillions of paying customers using it.
[1] https://web.archive.org/web/20080218051638/http://www.nikhil...
Microsoft made it so VB 6.0 needed the Microsoft Java Runtime to install and it works with Windows 95 to XP, but in Vista and above it has problems installing. There are ways you can trick it to install but in the long run it is not worth it as it causes OS instability.
I got an XP Pro Virtual Machine in Virtualbox that I develop VB 6.0 apps inside of. GIT only works with XP and up, so Windows 2000 and under are out of the question. (Something about IPV6 support in the Git app and the first Windows to support that was XP so it fails in earlier Windows) So if you want to do legacy Windows programming and use Git, XP is your best choice. Visual Sourcesafe never seemed to work properly and I always had coworkers and management get in and scramble the files by accessing them directly on the NT Server or whatever and load them in MS-Word or MS-Frontpage that changed the formatting and then they saved bypassing source control. At least in Visual Sourcesafe 6 this was true, and I believe that Git is much better.
Since 1983 I have learned over 37 different programming languages on many different platforms. I only did Visual BASIC programming from 1995-2002 because in my area the IT shops were Microsoft shops and management decided to use Visual BASIC. While I knew Non-Microsoft languages, management never wanted me to use them.
I ended up on disability in 2003, and by that time Visual BASIC evolved into VB.Net influenced by Java and took a turn for the worse. Then Visual C# got used because it is more like Java than VB.Net is, and the high schools and colleges teach C# and Java so these new programmers learn it.
In high school I learned Pascal, in college I learned Pre-ANSI C, COBOL, FORTRAN, Ada, X86 Assembly, and others.\
Around 1995 I was learning Java and JavaScript. Then later Python and a few others. But on my spare time at home, because my managers didn't want me to use them.
I just recently took a Ruby on Rails MOOC and passed it with 100% on each programming assignment. I used to do VBScript ASP 3.0 programming. ASP.Net changed all of that apparently.
So yes I am one of the legions of VB programmers out there, got forced into disability, too old to work in my 40s (They only want young people), and read Hacker News because my interests are scattered all over the place in learning stuff.
The die hard Visual BASIC only programmers were the ones I had a coworkers who I had to hand-hold and teach Visual BASIC to them. Most earned university degrees but had no idea how to program. They secret handshaked their way to a job, while I had to pass tests and show code. I super debugged their code, and their code was sloppy and crashed systems and servers. They moved on without me into the Dotnet era and Visual C# and stick to Microsoft websites for their news using Bing as a search engine. They find me on social networks and ask me to apply for my old job so I could help them, but I cannot go back, I can only go forward. Work on my side-projects and do it as a hobby until I can get off disability one day.
Of interest: he states that both languages have (had?) "roughly equal adoption".
[1] http://blogs.msdn.com/b/scottwil/archive/2010/03/09/vb-and-c...
Roslyn is not the runtime, it is the compiler which emits IL code. Its different from the runtime.
It'd be amazing if there was an official and well supported Linux port of .NET. Just imagine having C#, F# and .NET libs available in a Linux environment and talking to Linux tools.
After watching this video for 20 minutes of all the fancy GUI details, I have couple of higher level questions:
1) Do C#/VB still only build for Windows, Win Mobile?
Can they build targets for IOS, Android, Linux?
I heard the new CEO of MSFT suppose to be more supportive of cross platforms.
2) I began to like the concurrency model in golang a lot.
Does the C#, VB support that kind of concurrency in their language design?2 - Not at a syntax level, but there is good concurrency support in the .NET stack.
The concept is built into the language itself.
Anything wrong with that?
https://gist.github.com/malkia/ebf7f54063c5aec6d1b0
Some answers from Eric Lippert about it (declaration spaces) http://blogs.msdn.com/b/ericlippert/archive/tags/declaration...
And this stackoverflow: http://stackoverflow.com/questions/2976628/question-on-c-sha...
It's not something I've seen in other languages/vm's. And seems like "ngen install" with some attributes would help it:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int func1(int flag)
But I'm no longer able to think of C# as closer (not close) to the metal, because of this exactly. It'll affect me how I look at it and code in it.If they included libraries that could compile the Windows GUI Forms to other operating systems like GNU/Linux, *BSD Unix, iOS, Android, Mac OSX ect it would be used more for those platforms.
Instead you have an incompatibility and it prevents developers on Non-Windows platforms to take it seriously. How can you claim it is cross platform when the GUI parts won't even compile?
Visual BASIC 6.0 was the last version of Visual BASIC that didn't stink and add in a bunch of Java features. I consider it Classic Visual BASIC for version 6.0 and under.
This Visual BASIC is really VB.Net and not Classic Visual BASIC. I'd much rather use the BASIC based Jabaco http://www.jabaco.org/ to make Java Bytecode JAR files than use VB.Net to make binaries. At least the Java JAR files are cross platform better than VB.Net and C#.
Also for cross-platform development there are even dialects that compile to HTML+JS: http://pewtersoftware.com/browserbasic/
And other platforms: http://www.monkey-x.com
Monkey-X looks like Blitz BASIC rather than Visual BASIC. But I like the fact that it can go cross platform.
edit: is it "same as a public readonly field, but it's a property"?
Similar to the JVM, the CLR can offer binary compatibility of libraries, which is something Microsoft cares a great deal about. Changing a public readonly field in to a public readonly property is source-compatible, but not binary-compatible. That's why properties are generally preferred, even when you don't strictly need one. The language was actively discouraging either immutability or binary-compatibility by making it more verbose to get a trivial readonly property.
In its simplest form, it means you can do this:
public property Foo { get; } = 5;
Your class now has a Foo property that nobody can set, not even methods in the class itself, but that can be publicly read.These become a lot more useful with primary constructors (also a new C# 6 feature):
public class MyImmutableClass(int usersFoo) {
public property Foo { get; } = usersFoo;
}
This will create a constructor on the class that takes the usersFoo argument, and immediately assign the value of that argument to your read-only automatic property. It makes immutable classes a lot easier to create, and guarantees that they'll stay immutable.edit: Permit made it clear that primary contructors have been dropped from the C# 6 spec. You'll just have to assign your readonly properties from regular constructors then :)
Internally, .Net automatic properties are compiled with a backing field and a getter and setter method. In the case of a read-only auto property, they will omit the setter, so there is no public artifact that could be abused.
A bit messy, but an overview with code samples can be found at http://msdn.microsoft.com/en-us/magazine/dn683793.aspx
Primary constructors have been removed: https://roslyn.codeplex.com/discussions/568820
thanks!
"Automatic" is clear, "getter-only" is clear, but "automatic getter-only" leaves me scratching my head.
public bool IsOpen{get; private set;}
public void Open(){
try{
// do some complex work
this.IsOpen = true;
}
catch{
this.IsOpen = false;
}
}
public void Close(){
// do some other work
this.IsOpen = false;
}I often write stuff like this:
public RxProperty<bool> IsFoo{get;private set;}
I could do without the private set.
If you've been ignoring other languages to concentrate on Python of all things in the last few years then you have missed the gravy train. Object C, Java, and C are the most popular, and both Java and C are cross-platform (and better still actually used cross-platform unlike Python).
As an aside I see significantly more Java, PHP, and C# jobs than any other language (mostly for web-apps). Then after those I see pure mobile development (Java-Android, and Object C).
Where have you been looking? Maybe if you only focus on pure web-dev, but I see Python and Python jobs everywhere. But I will concede that many of those jobs are science, engineering or analysis jobs that primarily involved programming python, rather than pure programming jobs.
It also isn't a particularly popular language on any platform but Linux
That is not my experience at all. Of all the cross platform scripting languages (Perl/Ruby/PHP/Lua/Javascript etc) it is by far the most popular on Windows, and certainly the best supported. I can probably also name a half dozen big commercial Windows apps that use Python as its main scripting language.
The normal places you'd find developer jobs. I didn't check the Python forums or other Python specific job boards.
> Maybe if you only focus on pure web-dev, but I see Python and Python jobs everywhere.
That's strange. In what industries? Doing what?
I see C engineering jobs, tons of webapp jobs (PHP, C#, Ruby on Rails, etc), Java for all the things, VB.net for business desktop applications, and so on. I cannot think of the last time I ran across a Python job except they're occasionally listed as a "useful skill" in a SysAdmin job advert.
> Of all the cross platform scripting languages (Perl/Ruby/PHP/Lua/Javascript etc) it is by far the most popular on Windows, and certainly the best supported.
I see a decent amount of PHP on Windows and it seems to be very well supported. JavaScript I guess more so but that seems like an odd thing to list in that context.
The reasons: It is cross platform (VFX is a mix of Linux and Windows, leaning more towards Linux at the high end), there are Python integrations for each major desktop 3D editing tool, and there is Qt for the GUI. You write one and use in multiple different places.
Python is huge in this market. I guess it may not be elsewhere, but generally if you can use Python for a tool, you do. It avoids the pain of C++, which is really horrible across distributions and OSes.
And TechPro rates it #1. http://tech.pro/blog/1885/top-10-programming-languages-to-le...
There are many surveys that may show other rankings, but it is very hard to argue that Python isn't popular.
It is too limiting though. For now, the web (and native mobile) looks like the future. Although, I don't want the web to be the future because I think that HTML/JS/CSS is a horrible way to build an app. Hopefully a better "web" will come along with some kind of universal runtime. I could totally specialize as an iOS/Android dev and escape the current web, but I'm not a big mobile user - I'm surrounded by huge screens all day and I really don't use my phone much.
Case 3 could be excluded by using ienumerable here but in many other cases its not that simple.
I'm not asking for c++ and manual memory management here, just some kind of constraints on what a function may do with its arguments. I've seen case 4 cause so many bugs its ridiculous, it doesn't even have to involve multi threading before it gets nasty.
There are more languages then C# which tend to have these problems, and for all of them these problems can be avoided in a number of ways merely by applying the typical good practices and well known design patterns. For instance just giving your functions proper names (examples 1. GetLongestString 2. StoreReferencesToAllStrings (still hacky, not sure if there are proper usecases for that?) 3. RemoveDuplicates 4. InstallList or so) and making sure functions do One Thing only will get you a long way in preventing problems. Not saying it is easy, but I've been using C# for at least 5 years and don't really recall problems with it. Did have problems with weak event handlers disappearing due to gc but after learning it it didn't happen again.