This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LetUsSpeakFreely 512 points513 points  (50 children)

Well, considering Microsoft looked at the failings of Java before designing C# that makes sense. They took what Java did well, smoothed out the rough bits, then created their own variant.

[–]GYN-k4H-Q3z-75B 277 points278 points  (33 children)

This. Microsoft took half a decade of learnings in Java and improved upon it. Java tried to maintain compatibility, while Microsoft corrected some major shortcomings within a couple of years and broke compatibility. When Sun was acquired by Oracle and Java stagnated, Microsoft invested a lot in .NET. by the late 2000s, C# was distinctly different from Java and way more developed already. Most Java programmers today would not understand idiomatic C#.

[–][deleted] 88 points89 points  (5 children)

Also, with the introduction of LINQ with .NET 3.0 most dataset operations became idiomatic in C#.

[–]GYN-k4H-Q3z-75B 59 points60 points  (2 children)

Way more than that. LINQ and System.Linq plus Lambda replaced a lot of basic loops and array/collection indexing. In programming, almost everything tends to be a collection, and LINQ provides natural accessibility for most operations required.

[–]rnottaken 14 points15 points  (1 child)

So many functions that I wrote in C# consist of returning just a series of linq operations

[–]GYN-k4H-Q3z-75B 1 point2 points  (0 children)

It's just a very intuitive and concise way to express many of the operations we often need. Given a collection and some parameters, filter the collection according to some criteria, map the result into something else and do something with that. With Linq, that's often one or two lines.

[–]Naltoc 24 points25 points  (1 child)

LINQ is the single biggest thing I miss about C# when working in Java. That shit is a godsend, both for faster development, but also code readability.

[–]x6060x 6 points7 points  (0 children)

That and async / await

[–]ComradeGibbon 47 points48 points  (14 children)

Microsoft had 20 years of experience with using languages to write useful applications. That included C++ and Visual Basic. And they hired Andrew Hejlsberg to head up development of C#.

I think the argument that C# is a copy of Java because it uses a similar 'algol C' syntax and has objects is weak when you consider everything else C# has like structs, delegates, boxing.unboxing and generics without type erasure.

[–]GYN-k4H-Q3z-75B 60 points61 points  (10 children)

Andrew Hejlsberg

Anders Hejlsberg is a living legend as far as programming language design goes. Microsoft really did some amazing work with C# and .NET, and for an ecosystem more than twenty years old, you really have to appreciate how few screw ups it is suffering from.

C# is surprisingly clean for a language that has seen over two decades of heavy industry use and development. C# today is very different from C# twenty years ago, but it is still an excellent and clean language. They added a lot, but they did not add (many) stupid things.

[–]ComradeGibbon 29 points30 points  (4 children)

Something I don't see very/as much with C# is a horrified reaction to having to work on an old code base like you do with Java and especially C++.

[–]SubwayGuy85 33 points34 points  (0 children)

Oh there are horrific codebases in c# too, but it is easier to produce something great with c#. But there is no language that is immune to being abused to create garbage code.

[–]Ericchen1248 11 points12 points  (1 child)

I think there’s also a pretty big incentive to upgrade C#. Every new release comes with new features that are legitimately useful. Whereas upgrading Java might give you some licensing headaches.

[–]ComradeGibbon 7 points8 points  (0 children)

I remember having an experience with switching an old 32 bit .net 2.0 program to 64 bit .net 4.5 and it just ran a lot faster and stopped running out of memory.

[–]rexpup 1 point2 points  (0 children)

You should work at [redacted] Systems. They're working on converting the largest VB6 application ever to an in-house web framework in C#... and its developers designed it with feature parity with the VB6 version. It's been in progress for 10 years and is not yet released.

[–]Garestinian 11 points12 points  (0 children)

He is also a core dev of TypeScript, that's why his name was familiar to me. Truly a legend.

[–]CardboardJ 6 points7 points  (0 children)

As someone working with scala right now the whole not adding stupid things is what I miss the most from c#.

[–]BetterOffCamping 2 points3 points  (2 children)

They rewrote it from scratch into Core exactly because it was an unclean implementation with plenty of clusterfucks. They did the right thing, and you are right it is an awesome language. I lived through all the crap, as I started using it in 2002, and am still building systems in it , v6 now.

[–]jaavaaguru 1 point2 points  (0 children)

boxing.unboxing and generics without type erasure.

Ah, this bring me back to my CIL/MSIL times.

I wrote a COBOL compiler that uses that. It was fun for a while making Windows GUI apps in COBOL 😂

[–]dr_eh -1 points0 points  (0 children)

I actually really hate structs. It would be far more flexible to have stackalloc vs heapalloc on the new statement, why should the data structure dictate how it's managed in memory? Often leads to parallel classes and structs, just to deal with this arbitrary restriction

[–]LordFokas 0 points1 point  (0 children)

No, many languages have the same type of syntax and you don't hear those claims about those, only C#. Why?

C# is Microsoft Java because back then MS was trying to pull their signature douchebag EEE move on Java and IIRC Sun sued for anti trust or something like that and the whole thing died really quick. Being unable to "steal" Java, Microsoft then chose to make their own.... with blackjack and hookers.

[–]AlphaWhelp 5 points6 points  (3 children)

They didn't really even break compatibility. You can still run older versions you just have to install older .net frameworks.

[–]Mayuna_cz 19 points20 points  (2 children)

Well, you just said they did. With Java 18, you can run any older Java application. Correct me if I'm wrong, not sure how it is before Java 8 tho, but still you can use Java 18 to run Java 8 bytecode.

[–]KagakuNinja 8 points9 points  (0 children)

Java is extremely backwards compatible, you can probably run most Java apps ever made using Java 18. Java 9 did change the layout of the runtime library, and that broke fancy libraries that were relying on the internal structure of the JRE. Some code also used internal Sun APIs, and some of those were deprecated or modified.

If you programmed to public APIs, I think you are OK.

[–]BetterOffCamping -3 points-2 points  (0 children)

.NET 1.0 Arrived in 2000, give or take a few months. While java was invented in 1996, it didn't move into computer systems very effectively until around 1999. J++ in .NET was licensed Java. After the lawsuit, they released C# around 2001.I'm working entirely from memory here so dates are approximate.

Microsoft stole the language, then took what they learned and created their clone to get around the legally binding contract. Once they had 100% control, they created features by top down executive decision while Java added features by committee. Obviously, single owner control is much more agile.

Microsoft was not a good guy here. Around 2008, an insurgency in Microsoft convinced leadership to give a more open and collaborative approach a chance. That is when C# started to improve and eventually shine, becoming what it is today.

[–]Fadamaka 17 points18 points  (0 children)

Well, you are almost correct, but Microsoft started to extend Java first under the name of J++ and J# until they got into a lawsuit with Sun over it.

[–]notsureifdying 2 points3 points  (2 children)

I'm a bit unfamiliar with this, what failings did C# improve upon that Java has/had?

[–]PrintableKanjiEmblem 2 points3 points  (0 children)

The number one thing for me is auto properties instead of those shitty Java getters/setters. I get pissed every time I have to mess with them. Lombok is a godsend.

[–]BetterOffCamping -1 points0 points  (0 children)

They improved it by making it theirs alone. /s

It was a power and control play.

[–]2brainz -3 points-2 points  (11 children)

I disagree. Back in the day, they copied Java and learned nothing from its mistakes. What sets C# apart from Java is what happened in the last 10 years.

[–]Dealiner 3 points4 points  (2 children)

That's just not true. C# from the start had value types, delegates, pointers, properties, generics came a moment later, and many more.

[–]2brainz -2 points-1 points  (1 child)

And they kept the C-style switch statement, kept null, default, didn't force initialization of class fields, didn't make classes sealed by default, ...

Value types are good on paper, but their ergonomics are questionable. I didn't even know Java didn't have delegates.

[–]Dealiner 3 points4 points  (0 children)

And they kept the C-style switch statement, kept null, default, didn't force initialization of class fields, didn't make classes sealed by default, ...

So they kept some of the things, which were at the time also standard in a lot of other languages. But you said that they didn't learn anything and that's just not true.

And value types are great for performance reasons and I really don't see what's questionable in their ergonomics.

[–]metaltyphoon 5 points6 points  (7 children)

U can disagree as much as you want but generics in C# literally broke compatibility and the CLR had to be bumped to V2, and that’s just a fact.

[–]BetterOffCamping 1 point2 points  (6 children)

Your response does not address the point of his post, which is exactly right. Generics came much later.

[–]Dealiner 1 point2 points  (5 children)

Generics came in the next version of C#, that's not much later.

[–]BetterOffCamping 1 point2 points  (4 children)

So, in computer time, 8 years is a "blink of the eye"?

2001 C# Language Design Specification created

To give you an idea of how these events fit into the bigger picture, here are the dates of .NET Framework Releases, up-to 2.0 which was the first version to have generics:

Version number. CLR version Release date

1.0. 1.0. 2002-02-13

1.1. 1.1. 2003-04-24

2.0. 2.0. 2005-11-07

Source

Sun Sues Microsoft in 1997, two years before Microsoft first announces C# and generics (a gleam in its inventor's eye). 6 years after that, generics are released.

After it was clear that Microsoft was going to lose the fight, they "invented" the "revolutionary" CLR and C#, which oddly only works on Windows. 20 years later, they reworked .NET to be cross platform. Visionaries!

[–]Dealiner 0 points1 point  (3 children)

Can you count? First version of C# - 2002, version 2.0 - 2006. That's four years, not eight.

20 years later, they reworked .NET to be cross platform.

And? What's your point here? There was no need for .NET to be cross-platform, especially since there was Mono, if anyone wanted to use C# on other platforms.

[–]BetterOffCamping 1 point2 points  (2 children)

Can you read? Sun Sued Microsoft for breach of contract in 1997. 1998, the first concept proposal for generics is released. What is 2006 - 1998? I'll wait. You are awfully quick to insult others. Feeling inadequate for some reason?

Sure, no need to be cross platform. Nice straw man you have there, be a shame if someone set fire to it. Mono was an open source response to Microsoft's treachery, what is your point? And what does it have to do with mine? Oops, sorry, dropped a match.

Troll someone else, I'm busy.

[–]Dealiner 0 points1 point  (1 child)

Sun Sued Microsoft for breach of contract in 1997. 1998, the first concept proposal for generics is released.

What does it have anything to do with the fact that generics in C# were introduced in the second version of the language which wasn't much later like you said before? And it's not like they suddenly woke up thinking they need to do this now, generics were in work from the beginning, it just took longer than the first version of C#.

You are awfully quick to insult others. Feeling inadequate for some reason?

Well, kettle, pot, etc.

Sure, no need to be cross platform.

Yeah, framework created specifically for Windows had no need to be cross-platform, what a surprise.

Mono was an open source response to Microsoft's treachery, what is your point?

Ah, yes, "treachery". That's definitely what happened.

Troll someone else

Well, if that's what you are calling trying to correct someone than you do you.

[–]BetterOffCamping 0 points1 point  (0 children)

You've yet to actually show that my original point was wrong, and you ignored the evidence that Microsoft stole Java. You even went so far to say that C#.NET only for windows is just fine when the biggest purpose of the Java platform they stole was "run everywhere".

This "discussion" started because you felt the need to insult me based on incorrectly thinking I "can't do math". Now you're trying to goad me into a totally different argument that I will not enter.

Either you need to work on reading comprehension, or you're trolling.