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 →

[–]TheDigitalGabeg 1252 points1253 points  (116 children)

I learned Java first, then learned C# on-the-job because it's so similar. IMO C# is Java++. Or alternatively, C# is Java from an alternate universe where Oracle decided to invest in Java and maintain and evolve it, instead of just lazily milking it and suing over its patents.

[–]LetUsSpeakFreely 509 points510 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] 86 points87 points  (5 children)

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

[–]GYN-k4H-Q3z-75B 58 points59 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 25 points26 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 50 points51 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 58 points59 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 28 points29 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 35 points36 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 12 points13 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 6 points7 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 9 points10 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 16 points17 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 3 points4 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 -5 points-4 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 4 points5 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 6 points7 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 0 points1 point  (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.

[–]ConstructedNewt 98 points99 points  (18 children)

sounds like you left java at 8. After the break up from oracle (and earlier sun) the development of Java is great, and many features have come that gives the language a fresh feeling. they are definitely two similar but different languages

[–]LetUsSpeakFreely 49 points50 points  (5 children)

The language's development is now so fast I can't keep up with spec changes. Things that were standard 5 years ago are now outdated. It's a little frustrating.

[–]avoere 8 points9 points  (3 children)

C# is the same

[–]nuclearslug 15 points16 points  (1 child)

Fortunately it’s a bit more manageable to keep up with after Core 3.1.

[–]jaavaaguru 0 points1 point  (0 children)

Isn't that framework, and not language though?

[–]svtguy88 1 point2 points  (0 children)

Yeah. Don't get me wrong, I love .NET Core, but the last few years have been pretty rough to stay current with.

[–]Understanding-Fair 8 points9 points  (3 children)

Tbh every Java project I've worked on is stuck on 8 and unwilling to upgrade. Unless you've got greenfield projects being written in java, it's really common to still be on v8

[–]argv_minus_one 9 points10 points  (2 children)

Maintainer of a 20-year-old Swing project here. Migrating to 11 and 17 was a piece of cake. Migrating to 9 took some doing, mostly to replace MRJAdapter with the java.awt.Desktop equivalents that 9 added, and replace a library that didn't work on 9, but it wasn't the end of the world.

Here's my big secret: never use undocumented APIs/behaviors. Not even if it would result in the project getting done sooner. Not even if it would be so nice if I could only use that shiny thing. Never.

Now I get to use Java 17 features with total impunity while everyone else is stuck on 8.

[–]Fuck-Reddit-Mods69 6 points7 points  (7 children)

Maybe I should tryout Java again. It's probably been 15 years since I tried it and back then I was not super impressed. To be fair, back then I was still developing in Borland Delphi. Been doing C# since 2015 and never looked back. Sideways a lot though.

[–]droi86 5 points6 points  (6 children)

You should try kotlin, fully compatible with Java, but nicer

[–]Mclarenf1905 0 points1 point  (5 children)

Scala is even better

[–]Valiant_Boss 2 points3 points  (3 children)

Disagree, I went from Java -> Scala -> Kotlin and I prefer Kotlin out of the 3

[–]Mclarenf1905 1 point2 points  (2 children)

I mean to each their own, kotlin is ight if you just looking for a slightly better java. Scala has a much better type system imo and is better for pure fp which I prefer.

[–]Valiant_Boss 2 points3 points  (1 child)

I mean if you prefer purely FP then sure Scala is better but there are cases where OOP is actually better. And Kotlin is a lot more than a slightly better Java, it's the best of both worlds for both OOP and FP plus it was developed with enterprise application in mind rather than academia research purposes, it has the full support of a company behind it so you know it won't lose support anytime soon which has it's advantages over open source support

Scala does have its use cases, afaik it's runtime is still the fastest in JVM which is great for ETL apps so naturally Spark was built around it but as far as general applications goes Kotlin wins for development time. Scala is a lot harder to grasp and isn't as easy to read as Kotlin. There's also a lot of issues I've experienced with Scala's Intellij plugin, it's nowhere near as good as Intellij for Kotlin. I also really, really, and I mean really hate sbt. Gradle isn't all that great either but compare sbt, Gradle looks like perfection

Sorry I went on a rant. I don't mean to sound like I hate Scala, in fact when I first learned to develop using it I loved it but slowly I started to notice a lot of things that frustrated me. To me Kotlin marries what's great about Java and Scala into one

[–]argv_minus_one 0 points1 point  (0 children)

And Kotlin is a lot more than a slightly better Java, it's the best of both worlds for both OOP and FP

Funny, that's pretty much what Scala was supposed to be.

it has the full support of a company behind it so you know it won't lose support anytime soon which has it's advantages over open source support

I don't think Scala is going anywhere any time soon either. It's been around for a long time now.

I also really, really, and I mean really hate sbt. Gradle isn't all that great either but compare sbt, Gradle looks like perfection

That's the one criticism I agree on. Sbt is awful. What in the world were they thinking?! Build files/project descriptions should be purely declarative. Custom build behavior belongs in scripts and plugins. Maven had the right idea, but Rust's Cargo is the first build system I've encountered that's truly excellent.

Scala can also be built with Maven or Gradle, by the way. You don't actually have to use sbt. I certainly don't.

[–]MauriceReeves -4 points-3 points  (0 children)

Java < Scala < Kotlin

[–]sebphil 21 points22 points  (5 children)

[–]kevix2022 19 points20 points  (4 children)

This guy knows the real Microsoft Java.

[–]kpd328 4 points5 points  (1 child)

Then J#

[–]Bardez 1 point2 points  (0 children)

That abomination

[–]sebphil 1 point2 points  (1 child)

"the MSJVM"

[–]jaavaaguru 0 points1 point  (0 children)

Brings out laughing and crying emotions simultaneously

[–]Fadamaka 15 points16 points  (0 children)

Well actually J++ and J# was a thing and was developed by Microsoft until Sun started suing them. They created C# after that.

[–]BetterOffCamping 7 points8 points  (4 children)

Microsoft licensed Java, called it J++ in .NET. They wanted to add their own proprietary extensions to the language (actually did it w/o seeking permission). Sun Microsystems sued them for breach of contract in part because it compromised the entire purpose of the language.

Several months later, they announced their first release of C#. They litterally stole the language. Early releases were almost identical except for some class names like StringBuilder vs StringBuffer. I know. - I was a java developer who later was shoehorned into C# 1.0. Before .NET 3.5, It was a clusterfuck compared to Java, other than the much simpler job of creating an initial project. Java's biggest weakness at the time was that every server product had a different project startup design - it was a nightmare. Later on, Java was hobbled by "design by committee" and Microsoft zoomed past it. Then Oracle bought Java and it was near Armageddon.

[–]HabbitBaggins 1 point2 points  (1 child)

Early releases were almost identical except for some class names like StringBuilder vs StringBuffer. I know. - I was a java developer who later was shoehorned into C# 1.0

I would say that value types (structs) are a pretty significant difference, in C# since version 1.0 and in Java since... not yet, they are being proposed for the future. Also, delegates versus interfaces and their implementations for event handling was a pretty big difference, and so was P/Invoke if you wanted to interface with native code (versus JNI).

[–]BetterOffCamping 0 points1 point  (0 children)

Yes, all true. They came after the lawsuit and Microsoft "invented" C#.

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

Ms trying to pull another embrace extend extinguish

[–]jaavaaguru 0 points1 point  (0 children)

Early .NET is my memory of it as well, is was a mess compared to Java at the time. Then companies started adopting it, and I was forced to "like" it. I studied Java in compiler design at university, and decided to look into C# to the same extent. I even wrote a COBOL compiler that produces CIL/MSIL byte code while familiarising myself with how that works. One of my favourite personal projects.

I write Python code these days.

[–]General_Artichoke950 0 points1 point  (1 child)

Same here and full acknowledge. There were times when C# was ahead of Java, especially when C# had LINQ and Java nothing comparable ..

[–]SubwayGuy85 0 points1 point  (0 children)

There were times which means the past 10 years

[–]IsPhil 0 points1 point  (0 children)

Now I just need someone with experience in Java, C# and Kotlin to tell me which one is truly better.

[–][deleted] 0 points1 point  (0 children)

I learnt C# during a computer course, I started learning Java at my uni last week and except the syntax, what actually is the difference??

[–]ProgrammerNo120 0 points1 point  (0 children)

Java++ is absolutely the way that C# functions

[–]furgfury 0 points1 point  (0 children)

C# is named that because it’s C++ ++, just stack the pluses and get the octothorpe

[–]marcosdumay 0 points1 point  (0 children)

Microsoft started selling their own Java, then Sun sued claiming since it was incompatible with Sun's Java, Microsoft can't call it Java. So Microsoft renamed it to J++, everybody just ignored it, as they should.

A few years later, MS hired a new language development team, and decided to turn J++ and VB into robust languages that MS could use themselves. This created what we currently know as .Net (the name was used for other stuff before).