9 ms·
Much to the derision many of the developers I know, I still say that C# is the best language I've ever worked in. But the .NET platform is one of the worst I've
by untog 12y ago
Much to the derision many of the developers I know, I still say that C# is the best language I've ever worked in. But the .NET platform is one of the worst I've ever worked in. So opening up C# to more platforms sounds very, very good to my ears.
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.
- hosay123 12y agoUnless of course, you want your side projects to work on non-Apple platforms. Aside from mobile stuff (and who really cares about that ;), the remainder of the Xamarin/Mono toolset is feature complete and almost entirely open source.
- akmiller 12y agoXamarin's value proposition is developing for multiple platforms at once (or at least, as a current Xamarin user, sharing as much as possible between platforms). Swift still offers nothing for that scenario so I don't really understand the comparison. 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.
- untog 12y agoLast time I tried Xamarin (and I'll admit it's been a while) cross-platform was surprisingly difficult. A project had to be either iOS or Android - and that included projects that had no UI code in them. So the concept was there, but the execution wasn't yet. Of course, this may have changed.
- eropple 12y agoPortable Class Libraries help here. They aren't perfect, and honestly they're justly badly reinventing Java's loosely coupled jars, but they give you the ability to link stuff together in a little more general of a way. 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.)
- JonathonW 12y agoAssuming you don't need to pass around binary libraries, take a look at shared projects-- added in Visual Studio 2013 and Xamarin Studio 5, IIRC. Unlike PCL projects, they compile in the context of the projects that reference them, so you have full access to the libraries that are common between each platform, and (if your coding style allows it) full access to platform-dependent APIs as long as they're protected by the appropriate #if __IOS__/#if __WIN32__/etc. Keeping common code in shared projects is like night and day compared to the mess that is keeping common code in a PCL and having to deal with common APIs that aren't present (or worse, are incomplete) in your chosen PCL subset. They really clean things up a lot, even if you're treating them like they're a PCL and avoiding any platform-dependent code.
- eropple 12y agoOoh. I didn't know about this. I'm using VS2012, because I don't want to shell out again for VS2013 but want ReSharper - I'll have to look at this...thank you!
- jdhawk 12y agoThere is still a degree of that, depending on how you structure the application, and how much of it is reliant on your UI layer vs backend business logic. 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.
- Alphasite_ 12y agoPicking up languages really isn't that te key, it's always been the library that's hard, so I can't say I can see the value if it's just that.
- jbergens 12y agoI suppose the value is that you don't have to rewrite your application logic multiple times. That takes time even if you're fluent in all languages. It is also a duplicatio which increases the risk of later bugs due to not doing all changes in all copies.
- jdhawk 12y agoExactly - and as a after work only developer, the less I have to do over, the less I have to consult the docs, the more comfortable I am with a single tool, the more productive I become.
- usea 12y agoAt work we use Xamarin for iOS-only projects, as we're primarily a C# consultancy. It's expensive, but it would be more expensive and difficult to find or train native iOS developers. Or at least, that's the impression management is under. The fact that we could port an app to Android somewhat easily when a client requests it is just icing on the cake, since almost all of our mobile projects are iOS only.
- lordnacho 12y agoInterestingly, most of my experience is in c#, but I've now got a side project that requires apps. I wrote them in Android and iOS. I looked at Xamarin as well, but I couldn't see the point of learning essentially a new framework. I figure whatever pattern you use (probably MVC) it will be the same on both. And the layout paradigms are different between them, so how is Xamarin going to fix that? My solution was just to use webviews instead of the native layouts (decided after bashing my head against both layout engines). 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.
- usea 12y agoI agree. However, there is a lot of fear among developers in my area with regards to learning new languages. Many developers I know would rather learn 20 new frameworks than a single new language. Managers feel even more strongly along those lines. I don't share their views, but I think I am in a minority.
- V-2 12y agoI hope that Microsoft buys Xamarin (I know, I'm evil) and makes it free, or very reasonably priced.
- jbigelow76 12y agoI bet Microsoft would like to buy Xamarin too, but worry that might strain Xamarin's relationship with Apple and/or Google. This could be a "if it aint broke, don't fix it" scenario.
- aespinoza 12y agoActually that sounds so reasonable. I have been asking myself why Microsoft hasn't bought Xamarin. But Xamarin is actually an amazing Trojan Horse for Microsoft.
- rl3 12y agoIf by some miracle Visual Studio ever ran on non-Windows platforms, Microsoft would then be free to kill off Xamarin Studio. 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.
- ijk 12y agoI suspect they'd have to rewrite Visual Studio into ClojureScript or similar if they went that route. Which would certainly be interesting. Though I'd certainly be all in favor of inline eval and live coding in VS!
- rjbwork 12y agoBoth of which it has have via Roslyn/Edit and Continue.
- ijk 12y agoInteresting. I knew VS had been working toward features like that; I wasn't aware they'd come as far as they have. Though from my poking around there appear to be some limitations: no redefining lambdas in a live session, for example. And I'm pretty sure that Instaparse is still out of reach, though that's not really what was being referred to. But thank you for reminding me, it's been a while since I've had an occasion to touch VS.
- zaphar 12y agoI have been working in a C# codebase for the last 4-5 months. I've summed up my experience with the language like this: C# is a really good language. C#'s stdlib however is subpar. 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.
- danbruc 12y agoWho provides a better standard library? I am a C# developer and have not that much exposure to other standard libraries, but from what I used, .NET is by far my favorite one.
- AndrewDucker 12y agoThere's a fair number of patterns which are now outdated, because they were created before, e.g. Generics. 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.
- danbruc 12y agoAnd they would not make arrays covariant again, the reflection API would surely use IEnumerable<T> instead of arrays, there are a couple of glitches in the inheritance hierarchy of the collections...but that doesn't really make it a bad standard library.
- Pxtl 12y agoWhat's frustrating is how few things got the needed TLC after generics and nullables were added. Also, I'm constantly frustrated how many core libs freak the heck out over a null string vs. an empty string. Obviously there are places to distinguish those, but if I'm trying to create a nullable int out of the text that is not one of them.
- ap22213 12y agoI used to be a hardcore C# developer. From the initial beta of .NET through v3.5, I used it at least 25% of my time. But, since then I've not used it. 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.
- ygra 12y agoCould you elaborate what's so messy in your eyes? Most features that were added are more or less only visible if you actively use them and shouldn't distract from anything.
- ap22213 12y agoAgain, I could be using C# stupidly, or the existing code that I have could be all hacked up. But, it seems like C# is trying to be everything to everyone. There are too many features of the language that allow things to be done many different ways. This leads to a lot of inconsistencies when the code base is relatively large and there are lots of developers working on it. Some things just seem 'bolted on', like unit tests, functional idioms, NuGet, etc. 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.
- mattmanser 12y ago3.5 => 4 hasn't really changed the way you should code much, so it's a bit confusing what about it you suddenly don't like? All the functional stuff was added in 3.5, 4 was really optional/named params, which are a godsend, dynamic, which you should use once in a blue moon, and a bunch of stuff to make COM interop easier. The big question is when using LINQ whether to use the pseudo SQL syntax (I have no idea what it's formally called) or just use the methods. I find the former hard to read/write and as far as I can tell most people have simply avoided the pseudo SQL. A quick scan through SO's LINQ tag seems to confirm that the methods are much more commonly used, whereas when it first came out it seemed to be the other way around. Then again I don;t really do much on SO any more, so may be out of touch on that. Is that the problem you're hitting, given you are saying there are too many ways to do something?
- WorldWideWayne 12y agoHow is the .NET platform one of the worst? (The worst for cross-platform or simply the worst?)
- collyw 12y agoI was more curious why C# is one of the best. Last time I looked at it (quite a while ago now), it was very like Java, and not many people rant about Java any more.
- UK-AL 12y agoIt's because modern idiomatic c# uses a lot functional programming inspiration.
- schrodinger 12y agoLook again... much less like Java now, in my opinion
- _random_ 12y agoIt's like Java 9. That hasn't been released yet. But so is C# 6.
- jbergens 12y agoC# has improved a lot faster than Java the last 5-6 years. I would say it is has been a much better language until recently when Java 8 was released. Now they are more equal with Java probably having some advantages since it was the last to update.
- pjungwir 12y ago> C# is the best language I've ever worked in. But the .NET platform is one of the worst 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.
- garrettheaver 12y agoAs a developer with experience in .NET, Java and Ruby, I'm curious as to what makes you say C# collections are a mess? At least relative to Java?
- pjungwir 12y agoI haven't used either in a few years, but Java's are trivial to remember: * 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. :-)
- usea 12y agoIn C#: IList<T>: implemented by List<T> and T[] (arrays) ISet<T>: implemented by HashSet<T> and SortedSet<T> IDictionary<T,U>: implemented by Dictionary<T,U> all implement ICollection<T> and IEnumerable<T>. In the case of dictionary, it implements ICollection<KeyValuePair<T,U>>, IEnumerable<T> (.Keys) and IEnumerable<U> (.Values), etc It's all basically the same thing. Organized and unified. IList<T> is actually implemented by a lot of things, and the more general you go, the more things implement it. IEnumerable just allows you to get an iterator that will go through the elements. ICollection adds the ability to add and remove elements. IList further adds indexed access and order. The generic collections and operations on them are one of the best aspects of C# and the standard lib.
- pjmlp 12y ago> But the .NET platform is one of the worst I've ever worked in. 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?
- Groxx 12y agoThey might be referring to the core framework? If that's the case, I completely agree with them: wonderful language, nasty framework.
- pjmlp 12y ago> nasty framework. Only for those that never had the pleasure to enjoy enterprise astronaut architects with their DCOM, CORBA and JEE designs.
- edwinnathaniel 12y agoJEE is not bad, J2EE is bad. JEE has no comparable .NET framework/library/tools.
- pjmlp 12y agoEnterprise astronaut architects never stop to surprise me.
- edwinnathaniel 12y agoDitto with cowboy coders.. hacked-up solutions, allegedly "MVP", lean/mean stack that hits the ceiling pretty fast that begs for re-write.
- pjmlp 12y agoI guess I've hit a sore point.
- robodale 12y agoI've developed in C# professionally since 2002, but also have created endless critical systems with Java, C/C++, and VB6 (yes I said Visual Basic 6...real world programming can be an unholy bitch sometimes.) 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.