C# 7 Work List of Features
github.com
github.com
* Tuples (Proposal: #347)
* Pattern matching (Proposal: #206)
* Records / algebraic data types (Proposal: #206)
* Nullability tracking (Proposal: #227)
* Async streams and disposal (Proposals: #114, #261)
They seem to be really useful for a "more-functional style" of programming.
When comparing these ambitions and the level of transparency to Java's ambitions & transparency, then it seems that C# is (or has) overtaking Java. Combine that to the fact that dotnet is now an opensource project, and MS seems to be more "open" nowadays then Oracle has ever been: I'm stoked about this news.
(personal anecdote - as senior java guy with 10+ years of experience, I've got recently assigned a small project of amending legacy MFC C++ (but mostly C) app - I could write a book about the pain. Language itself is a minor obstacle in this effort (albeit MFC/WinAPI has very steep learning curve for me).
Where Java wins, and will win for many years to come is maturity of toolset, quality of open source libraries and also probably the most important thing - the amount of skilled developers any employer can pick from.
.NET platform will probably get (finally) on track, but it's an uphill battle against Oracle's current position. But I like the situation - improvement in MS camp will force competition to improve as well, so we all benefit :)
Eh? .NET land has been on a higher technical superiority level to Java for almost a decade. Pretty much as soon as .NET got generics at the CLR level the tide was changing. Then that so-called LINQ feature in C# put the final nail in the Java coffin. The fact that .NET has always had value types and function/delegate types from day one has meant the third party .NET toolset has emerged in a different less clumsy way than in Java land.
> "but it's an uphill battle against Oracle's current position"
Eh? Java isn't even open source in any meaningful sense. Just look what happened to Google/Android when they mistakenly thought Java was open source.
I'm not sure what this so called "maturity of toolset" for Java really is either. Most of it is just piles of garbage libraries and frameworks to work around fundamental flaws of the language, and/or to continue pedalling the broken enterprise styles of OOP and SOLID bandwagon onto yet more innocents.
> "the amount of skilled developers any employer can pick from."
Eh? Ever tried picking a good one from a batch of Java Enterprise devs? It can be a costly exercise. There is almost nothing to distinguish them, that is the problem. Because they're all just Gang Of Four Do-Repeat-Yourself-But-Claim-Not-To code monkeys.
On the matter of the toolset, let's call it a draw. Visual Studio is IMHO vastly better and more reliable than Eclipse or IntelliJ. Java has a longer and richer history of good third-party tools with Apache, the Maven ecosystem, etc., which are still ahead of NuGet and its siblings. I think Maven still gives the edge to Java for dependency management, building, and packaging, although it takes a long time to get into its mindset. It sure is nice to have the same IDE and same build process across Windows, Linux, and OS X development environments (I use all three during the course of a day and it helps keep the build honest).
Now, the runtime and hosting... I can't say enough good things about being able to throw together executable-JAR docker images with Java. On the other hand, I'll take IIS over other web servers, given the choice. CLR vs. JVM is a tough call... the myriad versions and OpenJDK vs. Oracle JDK licensing fracture are not helpful for Java. On a technical basis CLR and JVM have rarely bitten me often or badly enough to produce a clear bias--provided the code is sound and there's _no_ _JNI_.
Whether JNI's awfulness is really a feature is a discussion for another time...
P.S. I worked with Java (now only Scala) and C#, so I have experience with both languages/envs.
Even if they did open those, they're of very little use outside Windows platforms without a huge amount of work to remove how tightly they bind to the windows APIs. There's much better alternatives if you want to do UI cross platform (or just 'not windows').
Now, if on top of the IDE, which is at least on par with VS + Resharper, you add things like build tools, project management tools, testing and code coverage tools, Java is basically the Godfather. xUnit, including NUnit, comes from Junit (Java), Nant was inspired by Ant (Java), Nuget was inspired by Maven (Java), etc.
For day-to-day Scala development incremental compilation etc. mean that a typical build in my IDE takes about a second. I think it has more to do with Java being the default/official language for the JVM (and the Scala learning curve). Similarly, F# is a great language, but C# has always been seen as the default go-to language for the CLR (VB.NET anyone?).
I mean, to be fair, these are all things that Haskell offers me, but more languages getting these can't hurt! Good steps forward! Now, all I have to hope for is that the nix support for .NET becomes more robust so I can actually code in C# on platforms that I care about supporting ^_^ (Note: this is not meant as a slight towards Windows, I just prefer working with / coding for nix).
For example, Pattern Matching. From my glance it appears a nice way to assign bindings from an expression, but I didn't see anything about guards. Also, any kind of pattern matching without the ability to check for exhaustiveness defeats the safety they provide usually comparable with inheritance.
Which comes to Algebraic data types. All I know is there are several boxes you must tick to really call it "Algebraic data types". I am not sure all those boxes are "ticked" here. This question came up when swift introduced "Algebraic data types", but no-one could get recursive ADT's to compile. it does look like this proposal allows recursion, but there are other things i'm sure are at play such as how it works with generics.
Well, I hope that they manage to fill out each feature a little more. Fingers crossed!
It's still a bit of a stretch to say that C# has "overtaken" Java in general, or to read too much into Microsoft's moves (they haven't open sourced any of their main profit-generating software (SQLServer, Windows etc.), just enough to earn a bit of street cred. amongst developers).
In terms of features C# is far ahead of Java, but many Java developers simply don't care as C# is far from being widely established and broadly used outside of Windows. Even on the JVM many Java developers will use Java the language as it's the standard, rather than because it is a fantastic language. Those who do care have moved on to Scala, Clojure etc. We've relegated Java (the language) largely to legacy status, but rely heavily on the Java ecosystem (JVM, IntellJ, java libs etc.).
They are fairly transparent if you ask me. Here are a few examples[1][2], there are more to be found on the openjdk page
Additionally, scala already has some of the features proposed for the inclusion in C# in the future.
I was really hoping for better integration of tests and pre/post conditions
On testing and pre/post, this is an area around which I am quite sympathetic. However, I'm ambivalent about the unintended consequences of fleshing it out too far. It seems that by encouraging testable code, I get much of the relief to my pain. That said, it's a cat and mouse game for things like async-await features... followed by support for testing said language feature.
I think reducing friction and increasing productivity is really important, it's not as sexy as some of these other features but it makes real difference in big projects.
I'm getting a little worried about the async-await and task methodology. It's true that they've made a lot of that kind of programming much much easier, but it also means that orchestration is cluttering our code. It seems that now that we've elevated the level of abstraction it should be possible to get rid of it (more or less) by being more declarative in our intent and structures. We're programming on at least one layer below what we should.
Unfortunately I think that might require so large fundamental changes that you need a new language. Many might say, what about F#? While F# is great for certain more algorithm oriented solutions for me it never seemed to quite fit the paradigm of certain applications and enterprise systems.
I think in the end there's a skeleton of a next generation language embedded in what c# has become. If we removed some of the crud and used LINQ style syntax as template perhaps we could take parallelism, asynchronicity and productivity to the next level
PL's are a part product of all of history of computing, but a bigger part is a product of the programming Zeitgeist. It's better to be a young language than to have matured 15-20 years already. Certain syntactic or other choices bite you inthe ass in a new zeitgeist. When I saw Java's implementations of lambda stuff, I cringed a bit. Java's friction in generics, due to choices made about typing, also made me say, "Ouch."
I like to think I've matured out of the language and platform warrior mode enough to yield more objective consideration beyond my most-used and favorites (and are they favorites because they are most used or because they are so good?).
F# has given C# a nice boost in the juicer, but certain earlier choices are ossified and make later adaptations more challenging or, potentially, near impossible to do, do well/right.
I like that C# is going across OS's, but were also entering the Age of Containers and there are implications, opportunities, and challenges we have barely started considering.
I don't know what the future holds, but I know there will be curly braces and that tabs will win the day again... ducks
Or as Don Syme said (I think it was him or perhaps SPJ), features get done in Haskell, trickle into F#, then into C#. Even generics was in F# before C#.
And the current proposal on records does not appear to be compatible with F#. I'd give a somewhat higher probability to the F# compiler changing to deal with C# than vice versa.
We are slooooooooooooooooooowly seeing the ship turn around with NuGet, and many MS-build libs appearing on Github and the CLR and compiler going cross-platform but it's 15 years too fucking late to matter.
Java and the JVM won.
C# seems to be used in (mostly) slow-paced, slow-moving, conservative environments based fully on an MS stack top-to-bottom.
Java jobs seem to be all of those above, plus a lot of start-ups and places like Amazon/Google. Not many C# jobs at Amazon/Google besides some public facing client API; there's no MS tech in their actual back-ends, that I'm sure of.
And C# could have absolutely destroyed Java. It was already better when it was introduced and the Java eco-system hadn't acquired enough steam. But MS "wisely" decided to keep it Windows-only as if somehow C# was so awesome that it would make companies switch from Linux server farms and back-ends to Windows servers just to be able to experience the joy and glory that is C#.
Nope.
It may be very true that Java jobs outnumber C#. It doesn't change the fact that it is pretty easy to get a job in either, and both lead to generally very boring jobs. I currently service .NET clients in the above $100/hr range and have had no trouble finding work from a rather remote city also (it's no Seattle or Silicon Valley, that is for sure).
But I don't understand your obsession with "destruction" and "domination". There is plenty of room in this world for lots of technologies and they don't have to all be focused on destroying/replacing each other.
But yeah, both are kind of boring, haha. I'm in the process of transitioning to more startup-friendly technologies and languages as it's more fun for me to work on those kinds of projects.
And awesome work you have there - $100/hr? Lucky!!! Consulting work?
It's great if you have to work on projects that are stuck with C# (but can freely use the latest compiler).
Non the less: cool "new" features in C#, and thank you very much MS for investing so generously in Haskell!
It would be a mistake to think that from Microsoft's perspective they feel they have spent enough money to even begin to think about extracting some sort of reciprocal benefit from that.
Admittedly my comment was ambiguous.
F# probably is a better functional-with-OO-aspects language, but C#/Scala are clearly better OO-with-functional-aspects languages and programmers currently want the latter.
You're probably right that it feels unfamiliar to Java/C#/Scala programmers, but I enjoy the sense of security that F# and other restricting languages provide.
I completely agree, as a language C# is more rounded, but as far as the ecosystem and tooling concerned its literally nowhere near to Java.
I LOVE the language and I've found the entire ecosystem fine. There are some corner cases for some more advanced systems level stuff, but I've yet to be unable to do something I needed to.
Java feels like a clunky dinosaur to me now. But hey, different strokes for different folks.
Maybe I've just worked with too much enterprise-y Java code which always tends to be a cluster. Anytime the acronyms "SOA" or "ESB" enter the mix I start fearing for my sanity. But even Android programming seems to have more quirks than WinPhone development, although I'm comparing my experience w/ ICS 4.0 to WP 8.1 here.
What annoyed you about C#? I'm curious where you think the ecosystem or tooling is better than C#.
You are not helping anyone out here. Why does C# suck for you?
I find the tooling for C# projects using VS as a very nice feature set. Look at what VS supports today. Grunt, npm and bower are supported by VS out of the box. Also, nuget package manager has saved me many DLL hell problems that could have occurred without it. VS also supports many third-party extensions and tooling, which is what makes me thinks it is one of the best IDEs out there.
1. On the same machine, I find VS 2012 was dragging (but memory was always hovering around 400MB)
2. Couldn't stand for .csproj style solution files (may be I'm spoiled by pom.xml, but its way better)
3. We as a team working on the same project and merging those .csproj files are literally pain in the ass.
4. The windows layout in the IDE is quite un-intuitive. You should see how IntelliJ manages all those windows.
5. The disconnected namespace and folder structure is another pain.
6. Related to the point 5, looking the source code and namespace imports, I can't see from which file those Classes are being "imported".
7. Maintaining and adding references is PITA compared to Java projects that uses maven.
Again, as I clearly mentioned, C# as language is better, but the tooling and ecosystem are not.
Its not always about the better language, Software is mostly written once, but read, refactored, maintained thousands of times by dozens of people. So the tooling and ecosystem has its place, so as the backward compatibility.
3. Did you try adding "*.csproj merge=union" to the gitattributes? I have never had a csproj merge conflict since adding that.
4. That really comes down to a preference. For me I feel the IntelliJ style keymap is better, but I would take the window layout of VS over WebStorm (just naming one i use often) any day of the week.
5. If your team decided to not have namespaces match the folder structure, thats their prerogative.
6. "Go to Declaration"?
7. NuGet has solved this problem for me.
But you're right, the C# ecosystem is certainly not perfect. Most people seem to agree that msbuild is frustrating to work with. And I really really wish csproj had wildcard support for including files.
this is an interesting claim
I'd fully expect someone coming from a .NET ecosystem to have a similar reaction, and the truth lies somewhere in the middle: both of them have their things they excel at and things they are less good at, but a lot of it comes down to what you are used to.
Even though my gut reaction is sometimes similar to yours, I'd jump at the chance to do C# full-time, because I think there is some really nice stuff in the language and the platform seems really interesting once you get past the parts that feel unfamiliar.
[1] http://www.spenceruresk.com/2011/01/visual-studio-2010-a-bun...
Can you imagine the feature list of C# 1.0 being discussed like this?
Mahatma Gandhi supposedly said: "First they ignore you, then they laugh at you, then they fight you, then you win." Which I think is very applicable to MS attitude to open source.
Now they have a new attitude: If you can't beat'm, join'm.
[1] http://blogs.msdn.com/b/efdesign/archive/2008/06/23/transpar...
Overall looks like C# 7 is going to be awesome even if only a few of these get implemented.
Edit: OK so it does suck that it's a reference type for even small tuples. But it's not C#/F#'s fault the CLR doesn't do a better job on those kinda things.
let (a, b) = Foo()
Compared to var tuple = Foo();
var a = tuple.Item1;
var b = tuple.Item2;
You could consider them equivalent, but conceptually it is faster to understand that a is the first result IMO.I'm not sure I find either more fun than the other.
The existing tuple type doesn't work well because its members are generically named; and very few people want to make lots of little classes that are only used to pass results from one method to its callers.
I do believe at least 'ref' should be in the language to simplify C/C++ interop, but I think it they should firmly nudge devs into thinking of that more as a convenience feature for .NET marshalling.
The beauty of tuples is that you get both a useful data type and nicer data passing in one bang with the tuple deconstructors, without requiring pointer semantics. Really a lot to win with just one concept.
At what point would it make more sense to just leave c# as it is and move on to a new "language"?
I like all the changes and more importantly I guess I actually understand the intention and the need for them, at same time I'd like to question how all those actually fit into one language...
I understand MS has a very strong record for support of legacy software, systems etc. So for sure on point would be to still "support" legacy C# code and allow for more modern paradimes in the same language, but given all the other .net languages and the interoperability provided: what is the drive behind pulling it all in into C#?
Also consider working in enterprise and asking your manager if it's ok to "change language" from C# to MSNEW#, vs doing a "minor update" from c# 6.0 to 7.0. Even if MSNEW# was backwards compatible and C# 7.0 wasn't, i imagine the answer on the second question to much more likely get an ok.
They can add these features, let less ... able ... customers argue over "var" and what they'll use, while pleasing other users. C#'s seriously annoying to code in due to it's statement-oriented nature and lack of basic features.
Additionally, because libraries take dependencies on C# compiler implementation details, other languages do not interop as seamlessly as the .NET/CLR concept would have us believe. Looking at things like the precise output of lambda expressions, or all these APIs that take object, then read the properties as an argument list (which should just take a list of tuples instead).
Also, just imagine the fallout of "Microsoft abandons main .NET language!"
What does it tell about the the real life "interoperability" on the .net platform, when every language needs all the features? My guess would be: the technical "possibility" is there yet the eco-system as a whole of day to day developers, technical managers, project life-cycles and real life products with some legacy heavily bends towards single application development language even though developers mostly already use several other languages like for scripting or sql, html, css, javascript etc.
Plenty of people think C++ is a good idea for common apps. Plenty of people think node and JS are awesome. Plenty of people loved Flash. What's your point?
Because C# is so popular (like JS), its questionable decisions ripple all over and affect people even if they aren't directly using C#.
With the "strong interest" features and type providers, is there any reason left to use F#?
Also, I don't see why array slicing would require CLR support. That would be a welcome addition.
But more fundamentally, adding features like these to C# is awesome, but there's no way to remove now-obsolete patterns without breaking legacy code, so it's still possible to shoot yourself in the foot in many ways that you can't in F#.
Some other authors have also addressed this question recently: [1], [2].
[1] http://fsharpforfunandprofit.com/posts/is-your-language-unre... [2] http://blog.ploeh.dk/2015/04/15/c-will-eventually-get-all-f-...
I picked up F# in about 3 months by reading a few books, then refactoring a C# library into F# (this taught me a lot of the interop quirks), and then doing a full project in as much of the F# idiomatic way as possible.
As far as jobs, I don't know anyone who uses the .NET stack that considers themselves strictly an "X" programmer. I've never used VB on a project, but I'd be pretty confident I could consult on a large VB project based on how much C# I've written. Mixed projects are really the best of both worlds anyway, learning F# will improve your C# simply because it teaches you new ways of reasoning about your domain.
If C# 7 ends up implementing Tuples, pattern matching, ADTs, etc... those are all bread-and-butter of F#, might as well learn how to use them ahead of time.
I already improved my C# by reading about F#, there is nothing magical about deconstructible tuples, pattern matching and ADTs that needs too much time to learn. It's the rest of the "succinct" ML syntax that puts me off. That and lack of ReSharper.
When i want move to RoR, they provide asp mvc 3 include EF migration.
When i want move to js, they provide async keyword.
Now when i want move to f#, they provide it all in c# language
Also C#'s statement-oriented nature just makes things ugly. Stuff like:
Bar x;
if (...) {
var a = frob();
x = Foo + a
} else {
x = Baz
}
That's much nicer as a sub-block expression. It also allows you to scope things better. F# allows you to shadow variables, which comes in handy a: to avoid using an "old" variable, b: with nested lambdas.F#'s Active Patterns are pretty damn nifty. F#'s also has deeper support for immutability. Even simple stuff like optional parameters C# gets wrong.
Overall, it's like using vim. There's some big things (like macros) that really help, but a ton of small things really do add up. I find it enjoyable to write in F#, I can be concise and write what I'm thinking. In C# I've got all this extra boilerplate that doesn't benefit me.
There's no doubt that C# can try to close the gap and certainly provide huge improvements from where they are today. But their overall approach seems to get the biggest "bang for buck" while confusing as few of their users as possible. And elegance/consistency be damned[1]. It's not a bad choice for certain projects (I dunno, maybe writing an ERP where you're adding all sorts of boring rules and need to be able to throw interns and get a known-quantity of quality) but it's hardly terrific if you've got control over your developers.
1: Look at C#'s duck typing, or type inference, or lambda expression support - they were forced in for the LINQ use case and nothing more.
I am not following what is bad about the example. Could you reproduce that same code in F# or whatever you're saying is better. It might help explain what you're getting at.
let x =
if ... then
let a = frob()
Foo + a
else Baz
`x` is never in an invalid/uninitialized state, and it's immediately clear exactly what code contributes toward computing its value.Somewhat related, you can also define nested functions in F#, which is very convenient and tidy. No need for a pile of one-off private helpers at the same syntactic level as your public APIs - just tuck them inside the members which need them.
var x = ...
? Foo + frob()
: Baz;
Or to be truer to the original (using my lib): var x = ...
? map(frob(), a => Foo + a)
: Baz;
But the idioms of the language mean that in the real world you see the ugly version with the associated risks of uninitialised variables. I applaud the C# team for the direction they're taking. I suspect C# will end up closer to Scala than it will to F#, which isn't a bad niche for it to be.[1] http://www.mono-project.com/
[2] https://msdn.microsoft.com/en-us/library/k1sx6ed2.aspx
You have two problems to tackle, as I see it: 1) building and environment 2) learning the language
1. Download Sun VirtualBox (free). Set up a virtual machine with your favorite build of windows (windows 10 preview is free) @http://windows.microsoft.com/en-us/windows/preview-iso
Install Visual Studio Community edition. You could learn C# from the command line, but this gives you a great IDE and debugger: https://www.visualstudio.com/products/visual-studio-communit... In the early days of learning c#, you'll value that debugger.
2. Language. Learning the language in isolation isn't very useful -- it's the dotnet libraries which give the real power of course. Everyone will have their own favourites for texts, but the one I used for myself and my teams over the years is "Learning c#" by Jesse Liberty. The first version, c#1.0. (IMO, the later books which were co-authored were not up to the standards of the first one; they tend to muddle and wander. Most of what you learn will apply, and once you feel like you've got your sea legs, you can grab a tutorial for an up-to-date version (c#6) and learn about the changes.) http://www.amazon.com/Programming-Building-Applications-Jess...
Best of luck to you!
I have no experience with C# on a mac, but I know it is possible. See: http://www.mono-project.com/docs/about-mono/supported-platfo.... You'd probably have pretty good support for anything on the CLI, but might run in to issues if/when you make the jum pto GUIs. Good luck!
The main reason why you want to use VS is because if you just want to learn the language most of the resources out there assume you're coming from Visual Studio/Windows. There's enough crap to worry about without trying to figure out issues with your IDE/compiler/etc.
1) Code up some simple C# code in a text editor (sublime) and then compile it using the mono c# compiler.
2) Run Windows on Parallels and download visual studio community edition.
Folks are working on a CLR that will run on Darwin and the core framework as well as an alternative to Mono. This won't be released until later this year though, and tooling is still TBD.
Why not just Monodevelop[1] instead? It's an open-source .NET IDE. Although not on par with Visual Studio, I doubt anyone would expect that anytime soon.
For a beginner it will probably be very relieving having Intellisense and code-completion, not to mention it will encourage exploration of the APIs in a much more playful manner than trying to read MSDN docs.
If you're going to start getting into C#, don't start with your hands tied behind your back. Get the full package!
It focuses on the language, not any specific implementation. The examples all use the command-line compiler, not Visual Studio. So you would be able to use the Mono Development Kit.
Most of the C++ warts are caused by the need to be copy-paste compatible with C, expectations of C developers being lured into this new language and be a drop-in compatible replacement for C tooling.
"The Design and Evolution of C++", http://www.amazon.com/The-Design-Evolution-Bjarne-Stroustrup...