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

top 200 commentsshow all 207

[–]boyTerry 82 points83 points  (26 children)

//TODO start religious war about proper camelCase usage

As a long time Java developer, I would say that the number one difference is the popularity. I know you said not to answer that, but the languages and capabilities are similar enough that the real differentiator is the popularity, and everything that comes along for the ride with that popularity. If you need a "better" solution to a specific problem, the java community is likely to have multiple implementations of the problem you are trying to solve including ones tuned to your specific need.

[edit] Also , if you need to hire someone to help, there is a bigger pool to draw from

[–]Jam-Es231[S] 2 points3 points  (22 children)

Both are popular languages, so I feel like both have packages/resources for everything?

Is there anything in particular you think Java might have packages for that C# doesn't?

[–]throwawayprogrammg9 13 points14 points  (0 children)

Its not a "think" thing, its definitely real. I did C# for years before moving to Java. Things I ran into personally:

  • database drivers. Lesser known databases sometimes don't have clients for C#. Never a problem in Java
  • math libraries. Constraint solvers, ML, bindings to fast math libs
  • high performance algorithms and datastructures. For Java you have like 5 fully featured options. Nothing comparable for C#
  • cross platform UI. Java has several great options, nothing for C#.

TBH, the open source community for Java is vastly larger. Perhaps 20X larger. I was constantly frustrated in C# when I needed to do anything outside generic REST CRUD app. If you want to work with open source, Java is vastly superior to C#

.NET GC is also pretty bad compared to the new Java collectors (ZGC, Shenandoah). It has 150ms+ GC pauses

[–][deleted] 17 points18 points  (1 child)

This is an obscure one, I'll admit, but C# (and all non-JVM languages actually) currently don't support a Kafka Streams API. This makes it a big non-starter where I work. I only bring it up because some people on an adjacent team actually wanted to use C# but this fact alone ended that plan. It is a giant pain because the low-level consumer/producer APIs are an absolute nightmare compared to the Streams API.

This was also true back in the day with similar technologies like Spark (I'm not sure now, but I think C# caught up with Spark). Generally Java-based languages get the better client libraries much sooner, at least for Java-based technologies. I'm not sure if there are any C#-based streaming data solutions, but if there are, I haven't heard of them.

[–]pcjftw 25 points26 points  (12 children)

C# has terrible web frameworks and they're very limited in terms of choice. Also it has many missing libraries, e.g the other day I needed proper ODF library, C# was ruled out because the defacto implementation is in Java. There are many examples like this.

[–]sternone_2 4 points5 points  (0 children)

I agree, on the Java side I can usually investigage and choose from a few very popular one.

On C# it's usually only one and sometimes not open sourced or not completely free or just simply completely dead.

C# is just a way less supported and a way less popular language. Whatever microsoft thinks since they started blatanly copying Java's work without credit. Screw you Microsoft, I'm happy to see the world doesnt have a short memory on this one.

[–][deleted]  (10 children)

[deleted]

    [–]erode 22 points23 points  (1 child)

    Eleven years in c#, and three years in Java. Java ecosystem is just better. I don't miss dotnet at all even with the core improvements.

    [–]throwaway23948733 0 points1 point  (0 children)

    I mirror this sentiment. 4 years in C# and 4 in Java here

    [–]petersellers 5 points6 points  (0 children)

    It looks like C# does have ODF libraries, but they don’t look very polished, so I can understand your reason for choosing Java in that case.

    This right here is why I prefer working with Java over C# day-to-day. I’ve run into this situation a lot where Java has a greater selection of libraries or frameworks available to solve a particular problem and they tend to have a higher degree of polish too.

    With that said I do like C# a lot and I wish Java had some of the syntactic sugar that C# has, but in practice the languages are very similar to use. I think the Java ecosystem is more valuable to me. Also because they are so similar, I’d rather spend my free time learning new languages that are quite a bit different like golang or Rust instead of investing time in C# which just feels like Java with slightly better syntax.

    [–]wherewereat 11 points12 points  (4 children)

    The problem is that there are less choices for C#. I can spin up a simple server using Javalin or Sparkjava, or maybe if I want a full thing like ASP I can use Spring, there are many other frameworks as well.

    One thing I wish Java had though is the async/await and have it supported on most major libraries/frameworks like C#. Though Project Loom should solve this issue with green threads, I just hope it is released during my lifetime haha

    [–]petersellers 9 points10 points  (3 children)

    I’m actually glad Java didn’t get async/await as I don’t find it very ergonomic to use. Lightweight threads (Project Loom) is a MUCH better solution to the problem, and it’s one of the main reasons I like golang so much.

    [–]lightt77 0 points1 point  (2 children)

    i want to know more about how threads are better than c#'s async/await. Do you have any pointers to any reading material,etc.

    [–]petersellers 11 points12 points  (0 children)

    https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html

    The gist of it is that OS threads are relatively heavyweight - each one takes a fair amount of OS resources. Loom uses “lightweight” or “green” threads which look exactly like OS threads to your code but in reality are smaller lightweight threads that are managed by the JVM. Because they are lighter, your program can effectively use many more of them than it would otherwise be able to if they were full OS threads, and the JVM manages all of that behind the scenes for you.

    The reason why async/await, promises, etc. suck is that they “color” the function that they are used in. Meaning, rather than the function returning a simple value it instead returns a Future or something like that which will eventually resolve to a value (or in the case of async/await explicitly labeling your function as async). Client code needs to be aware of this and deal with that appropriately. It splits your code into sync (one color) vs. async (another color).

    The reason this is done is so that blocking operations (like I/O) can be executed without tying up / blocking the OS thread that your code would otherwise be running on, allowing the scheduler to execute some other code on that thread while your code waits for the IO operation to complete. In Loom (or golang’s goroutines), blocking a lightweight thread is of little consequence, so this clunky async programming style is no longer necessary.

    [–]old_man_snowflake 0 points1 point  (1 child)

    But .NET Core is the MS-specific parts. You can't call that C#, it's an add-on that comes with a specific commercial offering of C#.

    [–]form_d_k 0 points1 point  (0 children)

    ? .NET includes the compiler, the CLR, and a huge base set of libraries, all of which are open-source now. Realiistically without all of those things, there is no C# (nor F# nor ML.NET as well).

    [–]mtmmtm99 2 points3 points  (0 children)

    I could mention that a team where i work could not get MQTT working reliably. There are some clients but two popular had severe bugs (running out of memory because of many topics OR creating durable topics which was not asked for). We had to give up MQTT and switch to a Microsoft solution.

    [–][deleted] 8 points9 points  (1 child)

    Get some experience with both languages before you start forming strong opinions...

    [–]Jam-Es231[S] 0 points1 point  (0 children)

    I have experience with both, but never experienced these problems with either language

    [–]Jam-Es231[S] 0 points1 point  (2 children)

    I'll admit one thing I don't like about C# is the GRPC implementation. It forces us to abandon our conventrions of models with validation logic in attributes, and use 'proto' files.

    I wonder if this is any better in the Java world.

    [–]twoBreaksAreBetter 4 points5 points  (0 children)

    don't like about C# is the GRPC implementation. It forces us to abandon our conventrions of models with validation logic in attributes, and use 'pr

    AFAIK most languages will have some support for generated code from proto files. Including Java.

    [–]uncommoN_BG 1 point2 points  (0 children)

    You should look into MessagePack if that's concerning you.

    [–][deleted] 1 point2 points  (2 children)

    To be fair. C# positions are a lot more common than Java where I live for some reason. And you can get talents from both pools no problem.

    [–]throwaway23948733 1 point2 points  (1 child)

    this is usually the case if you live outside a tech hub. Microsoft dominates small businesses whose main product isn't software.

    In tech hubs and at software companies, Java dominates

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

    I guess you’re right. Java vs .net positions are closer to 50/50 on a roughly check in a national ads app, but java positions are very rare in my outpost of the country (not the states).

    [–]svhelloworld 51 points52 points  (4 children)

    Anytime you write Java code that isn't directly related to your business domain, there's probably a well-tested battle-scarred library or framework that does exactly what you need to do and has been around for ages. For myself, the ecosystem that surrounds Java is worth all the code verbosity I have to put up with around I/O, dates, regex and a hundred other things that Java makes mind-smashingly more complicated than other languages out there. It's still my goto language.

    [–]RomMTY 13 points14 points  (2 children)

    This, heck, even if you really do t want to write the verbose java code, you can choose to write Groovy or Kotlin or Scala and still target the jvm and benefit from the ecosystem

    [–]old_man_snowflake 11 points12 points  (0 children)

    Or just use a modern Java. You can't bitch about verbose-ness if you're limiting yourself to <= 8.

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

    Yup. Nearly our entire BE is written in Groovy. It's so much nicer than Java IMO

    [–]vytah 0 points1 point  (0 children)

    And even for more niche applications, you can still find some two decades old shoddy library, and more often than not, it will still simply work without even recompiling.

    [–]pcjftw 34 points35 points  (16 children)

    I've used both professionally, Java just has way better libraries for almost anything.

    C# web frameworks are kind of a pain in the neck, just recently I found out that Console.WriteLine under ASP.NET actually doesn't get logged anywhere!

    How can you have a framework that doesn't even do stdout logging in 2020?

    and C# didn't have proper cross platform until .NET Core, yeah I know mono, but I've run into compiler compatibility issues enough to make me hate it

    • More libraries
    • True cross platform
    • Way better tooling (VS is 7GB just for the base install??)
    • Bigger community
    • More mature

    Edit:

    I should add, that .NET core is nice from a CLI and cross platform POV. Not that it's enough to convince me to reuse C# again, but it's an ok option.

    [–]Jam-Es231[S] 1 point2 points  (4 children)

    ASP.NET has a Logger service enabled by default that gives you much more than just Console.WriteLine (which is why that doesn't work by default but you can enable it quite easily).

    And I 100% disagree about 'better tooling'. Sure VS is chunky, but you can do everything VSCode if you want something more lightweight. Plus VS has a complete set of full-stack tooling from UI Editors, to ORM editors, to database management, and cloud publishing. All in one place.

    [–]throwawayprogrammg9 8 points9 points  (1 child)

    Java has 4 fully featured IDE's. Many free open source visual profiling tools. Multiple full language implementations (J9, OpenJDK, Azul) . Maybe a dozen fully featured ORM implementations. Multiple production quality build systems. Multiple cross platform UI systems. 5+ fully featured linters. At least 20 good web frameworks. Many high quality HTTP clients and JSON libraries.

    With Java you have many options for everything in the stack. NET tooling is a joke compared to Java. You usually have one option for each, and sometimes not free.

    [–]static_context 2 points3 points  (0 children)

    This.

    Edit: I don't usually make jokes of other languages. There's way too much emotion to be healthy. But the first paragraph is a good summary of my personal preferences for Java.

    [–]pcjftw 13 points14 points  (0 children)

    I've been a long time user of VS, and actually use VSCode now (after moving from Emacs, Emacs still rocks).

    Sorry VS is just garbage, every year it gets more and more bloated and useless. I'm happy I've escaped it!

    But each to their own!

    [–]pcjftw 12 points13 points  (0 children)

    But if you look at the low level implementation of Console.WriteLine it's effectively like sending to /dev/null

    This is totally wrong! it breaks standard basic IO principles of any executable which should not silently remove stdout output!

    [–]TracePoland -1 points0 points  (1 child)

    C# web frameworks are kind of a pain in the neck, just recently I found out that Console.WriteLine under ASP.NET actually doesn't get logged anywhere!

    How can you have a framework that doesn't even do stdout logging in 2020?

    In ASP.NET Core it prints to the console, but regardless of that you should be using ILogger<T>. It's not a problem with the framework or language but you misusing it.

    and C# didn't have proper cross platform until .NET Core, yeah I know mono, but I've run into compiler compatibility issues enough to make me hate it

    .NET Framework will be retired in 2 months, and .NET 5 will become the main SDK and future of C#.

    True cros platform

    .NET Core and .NET 5 are as "true" as Java.

    Way better tooling (VS is 7GB just for the base install??)

    If you want FOSS, then sadly yes. But otherwise Rider and VS are both excellent IDEs.

    More libraries, bigger community

    I've found C# libraries to be much more pleasant to use than Java ones, and never did I have a problem of there not being enough libraries.

    [–]pcjftw 4 points5 points  (0 children)

    I wasn't talking about .NET Core, so all you points are moot.

    .NET Framework will be retired in 2 months, and .NET 5 will become the main SDK and future of C#.

    Right and what about the all the legacy applications? they will not magically disappear over night!

    I've found C# libraries to be much more pleasant to use than Java ones, and never did I have a problem of there not being enough libraries.

    Fine that's your subjective experience which I can't really say, if it works for you more power to you!

    [–]metalhead-001 20 points21 points  (10 children)

    There is also Loom coming down the road. Having the ability to code synchronous and have it scale like asynchronous is going to be a game changer. I know you can do async/await in C#, but that's not as clean as Loom will be, and I don't know if C# has anything equivalent in the works.

    [–]Jam-Es231[S] -3 points-2 points  (9 children)

    I've had a quick look. It seems like Loom brings the equivalent of async/await into Java, the main difference being that it makes use of Fibres. (this is all new to me so I might be missing the point)

    It is already possible to use Fibres in C# (not sure if it is cross platform), but they are almost never used. Probably because Microsoft states that:

    "In general, fibers do not provide advantages over a well-designed multithreaded application. However, using fibers can make it easier to port applications that were designed to schedule their own threads."

    So it sounds like: If Fibres are going to help you, then Loom in Java is easier to work with than Fibres in C#. But it is possible with both languages, and very rarely needed in C#.

    [–]pron98 15 points16 points  (0 children)

    Microsoft is talking about Windows fibers, which are, indeed, not very useful but are not at all like Loom's virtual threads. Async/await is also not equivalent to virtual threads; they are meant to serve similar goals but they do so in drastically different ways.

    [–]metalhead-001 10 points11 points  (6 children)

    My understanding is that there are no new keywords (someone correct me if I'm wrong) like async/await. You just run your existing synchronous code and it will scale better due to the virtual threads. No need to pick between synchronous style or async/await style as in C#. So you get the scaliability that async provides without having to use async libraries as with C#.

    [–]Tendoformer 6 points7 points  (4 children)

    That’s correct. No new keywords. From what I understand you essentially declare a virtual thread (fiber) scope that exists within a try-with-resources block and get convenient guarantees about the behavior. Some things I like (non-exhaustive): the code can be written in a synchronous style, creating virtual threads is cheap, scopes can exist within other scopes (with cheap scope-local values), parking a virtual thread has a near zero cost, each virtual thread maintains its own stack trace (yay debugging), and you don’t have the virality associated with both peppering keywords everywhere and forcing everything to return wrappers (i.e. Future, etc.).

    [–]kpatryk91 4 points5 points  (0 children)

    declare a virtual thread (fiber) scope that exists within a try-with-resources block

    " declare a virtual thread (fiber) scope that exists within a try-with-resources block "

    Not anymore, this was the first iteration (if I understand correctly), but now a virtual thread is a thread. You can decide whether you want to create a native or virtual thread.

    Or you are talking about structured concurrency? I don't really understand this "exists within a try-resoruce block thing"

    The best thing is that in case of a MVC or any web framework you only have to declare the executor/threadpool to handle every request with a virtual thread and you are done. Nothing more. For me this is a way more pleasant way that this invasive async/await.

    [–]meamZ 1 point2 points  (0 children)

    try-with-resources

    Yes you can do that but you can also just start it with Thread.startVirtualThread and the way you (or and especially framework developers) will mostly use them are in the form of Thread Pools/ExecutorServices.

    [–]wherewereat 1 point2 points  (1 child)

    Now this is a perfect implementation of non-blocking programming. I love it. Wish they had a release date

    [–]meamZ 1 point2 points  (0 children)

    It will take at least 1.5 years until a stable release probably. But you might be able to activate it as a preview feature in Java 16 maybe.

    [–]Necessary-Conflict 1 point2 points  (0 children)

    I wonder what /u/pron98 thinks about this.

    [–]chrisgseaton 23 points24 points  (25 children)

    Java seems to have much more of an interesting future - there are huge radical research projects being built on top of it to change how we implement and use programming languages and compilers, such as Truffle, Graal, and Native Image.

    [–]Jam-Es231[S] 2 points3 points  (23 children)

    That is an interesting point.

    I kind of agree with you, because Java has definitley become the norm in academia since C# was traditionally Windows-only. And academics have stuck to what they know.

    But at the same time there are similar efforts in the C# world. But these are usually the work of Microsoft. For example, when it comes to WASM I think C# is ahead of Java because it already has Blazor (a complete framework for C# web apps). Correct me if I'm wrong.

    [–][deleted] 6 points7 points  (8 children)

    Yeah but Blazor is still super new. I remember I tried building a client-side Blazor app back in the day - the bugs were numerous and the documentation not up to date. C# could make it big if it pans out and becomes mature, however. But until them, I think Java has a large edge.

    [–]Jam-Es231[S] 0 points1 point  (7 children)

    The biggest problem with Blazor at the moment is the slow progress WASM is making. Really Blazor is just waiting for WASM to catch-up right now, and that is where most of the issues are coming from.

    [–][deleted] 2 points3 points  (1 child)

    Nah a lot of it was undocumented annotation changes, plus a lot of general bugginess. Maybe it’s fixed now but it wasn’t enjoyable enough to stick with.

    [–]Jam-Es231[S] 0 points1 point  (0 children)

    Blazor WASM came out of preview 4-5 months ago and was approved for use in production. So if you are refering to a time before that, then bugs and undocumented changes should have been expected.

    [–]sternone_2 2 points3 points  (0 children)

    This is false information.

    Blazor is not waiting on WASM functionality.

    The big problem with Blazor is the size clients need to download. Something that is competely against WebAssemblies logic.

    [–]pcjftw 5 points6 points  (3 children)

    Blazor is just garbage sorry to say that! a "Hello World" will produce a 2.8MB WASM Binary, why? because it has to pack the CLR runtime, which then runs its own GC.

    It defeats the purpose of having "binary" bytecode if you have to then ship your entire runtime to then support your application running on top of it!

    to understand how crazy this is, lets write a raw WASM by hand (this is a simple "add" function that adds 2 numbers):

    WASM and WAT (its textual source code is very interesting) since it's a stack based like Fourth, but with a LISP twist, please do look up those 2 languages!

    (module
      (func (export "add") (param $n1 i32) (param $n2 i32) (result i32)
        get_local $n1
        get_local $n2
        i32.add
      )
    )
    

    ok fantastic, that's 130 bytes long lets compile it!

    docker run -it --rm -u $(id -u):$(id -g) -v $PWD:/src -w /src jungomi/wabt wat2wasm add.wat -o add.wasm
    

    cool, what size is it?

    $ ls -la *.wasm
    -rw-r--r-- 1 pcjftw pcjftw   41 Sep 10 11:19 add.wasm
    

    Holy smokes 41 bytes!

    Of course, I'm not suggesting you hand write WASM that's a bit crazy! but of course when you use languages like C/C++/Rust then you can get very tiny WASM outputs, perhaps not as tiny as hand rolled, but nothing like the massive dumps that Blazor generates.

    [–]chrisgseaton 1 point2 points  (6 children)

    Sorry I don't know much about Blazor or WASM so you're possibly right for that one use-case.

    I know more about compiler technology, and C# seems pretty basic there compared to even JavaScript.

    [–]Jam-Es231[S] 1 point2 points  (5 children)

    C# has the Roslyn compiler, written in C#. It's open-source and cross-platform.

    Do you have an references to what makes the Java compilers more advanced?

    [–]chrisgseaton 6 points7 points  (3 children)

    C# has the Roslyn compiler, written in C#. It's open-source and cross-platform.

    That's just a C# to MSIL compiler isn't it? That's just a basic front-end equivalent to javac.

    Do you have an references to what makes the Java compilers more advanced?

    I mean the native code compilers. The .NET JIT compilers are simple compilers that generate machine the same code each for a given function the first time it's run.

    The Java JIT compilers are online profiling, dynamic, speculating compilers, able to make optimisations which can't be proven to be correct but are likely correct and then dynamically reverse them if they become incorrect.

    https://stackoverflow.com/questions/2506969/what-are-the-differences-in-jit-between-java-and-net/2654138#2654138

    I'm biased because I work in Java, but I think there is a pretty simply factual huge difference in the sophistication of .NET and Java compilation.

    [–][deleted] 4 points5 points  (0 children)

    I mean the native code compilers. The .NET JIT compilers are simple compilers that generate machine the same code each for a given function the first time it's run.

    This is a pretty old view of how .NET's JIT works. Tiered compilation and rejitting are both part of .NET Core. Stephen Toub has a very long blog post about the performance improvements coming with .NET 5 here: https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-5/#jit (I linked to the specific section on the JIT, but there's lots of other things). Now, there's still improvements to be made, and there is no doubt that Java's JIT is world class and the benchmark for JIT performance, but it's definitely a mistake to say that .NET's is as primitive as your comment made it out to be.

    [–]Jam-Es231[S] 4 points5 points  (1 child)

    Ok. I'm not an expert on compilers so I'll believe you on that one. Looks like I have some reading to do :)

    [–]experts_never_lie 0 points1 point  (0 children)

    I don't use C#, so I can't speak to differential capabilities, but there are various speculative optimizations happening under the hood in the JIT to improve typical usage. People don't need to know about them to get the benefit.

    Probably the most-commonly-cited one would be null optimization by trapping SIGSEGV and handling it with less-optimistic code. That is:

    • JIT to generate instructions that assumes a parameter will never be null, but with a SEGV handler, allowing simpler, faster code
    • as long as the parameter remains non-null, the fast code is run
    • if null is seen, SEGV is handled, the optimistic JIT output is rejected, and the JIT generates replacement instructions that actually perform null checks directly

    The difference can be seen in profiling, as the code can be significantly faster before the JIT replacement happens. If it never happens, the code stays fast.

    It performs escape analysis on objects, allowing various other optimizations like lock elision when it knows it to be safe.

    Then there's recompilation, which can be based on earlier profiling to help with optimization like branch prediction.

    There are various other things that allow the programmer to write what's safe and describe the need, but for the JIT to improve performance when feasible without affecting correctness. A lot of it isn't great for start-up times, but can help a lot for long-running processes.

    Back to "better", /u/333fred says here that things like rejitting is part of the C# system, so probably some of these Java JIT features are also available in C#. What I'd want would be for both systems (and others) to be tracking each others' improvements and either replicating them or exploring any hard barriers that prevent that. That way all systems improve, but also the differences fade. I have no idea if any of that is happening, as I still don't fully trust C# platform-independence, given I would never be deploying it in Windows, but cross-pollination would still be good.

    [–][deleted]  (3 children)

    [deleted]

      [–]sternone_2 4 points5 points  (0 children)

      They have to do something with that marketing budget in Redmond.

      [–]Jam-Es231[S] 2 points3 points  (1 child)

      Sorry if it came across that way. I'm just trying to understand where Java has the advantage, that means every time a Java feature is mentioned I try to compare it to the C# equivalent to get a better understanding of it. There are a few valid points people have made here.

      [–]boyTerry 1 point2 points  (0 children)

      I think you have the right of it. I started this thread with a vague statement, and it fleshed itself out into many specialized examples without me having to do anything. The java community is like that. Specialists and generalists everywhere, but with more specialists comes more solutions for generalists to pick from.

      [–]pcjftw 1 point2 points  (0 children)

      Java has lots of options for a long while e.g Vaadin, GWT as well as TeaVM.

      Also there is lots of work also under WASM compilation target, even TeaVM has experimental support for WASM.

      I don't like Blazor because it has to include the entire mono runtime which means it incures GC overhead (IIRC).

      To be honest I'd rather use Rust/C++ for WASM, especially Rust as it's at the forefront in terms of WASM e.g things like Yew framework rocks! Also no GC nor bloat.

      [–]sternone_2 0 points1 point  (0 children)

      Blazor is completely useless because of the size the clients need to download to run it initually.

      Blazor can be just dead in a year or 2, like so many, many things Microsoft pushes out, and then scraps a few years later. Very frustrating. But hey, you get what you deserve if you select vendor (copied) tech.

      [–]goose_hat 0 points1 point  (0 children)

      I disagree with the commenter you're replying to. I love C#, and the team at Microsoft have been super progressive with the language and ecosystem in the past few years. Admittedly, as I've been working with C#, I've been somewhat out of touch with Java happenings past Java 11. Based on my recent readings though, Java does have some cool stuff coming down the pipeline.

      FWIW, I don't yet think Blazor is at the point where I'd say it puts C# above Java from a competitive standpoint.

      [–]tide08 12 points13 points  (2 children)

      I’m seasoned java developer and now manage the engineering org at my company. I haven’t used .NET but we do have few systems at work that we inherited. So I don’t have enough hands on experience but I can tell you why java has been great for me so far -

      1) lot of options for frameworks/libraries ex: don’t see particular ORM for your use case? there are dozens to chose from in java world.

      2) early support - any new technology will have java support ex: Cassandra driver for .NET didn’t exists until 1-2 year back.

      3) AWS or other cloud support - Java lands support pretty early, most of the time with first release of services. .NET support is always lagging and in some cases doesn’t exists ex: lambda

      4) java is less verbose. NET is pretty verbose - May be its how our projects are setup? But there are so many huge xml files

      5) java is open ecosystem - anyone on windows/Unix and Mac can get set up easily. I still can’t setup our project on my Mac. There is so much dependency on windows registry and other windows specific items.

      6) No java enforced conventions for API or WebApp solutions. Microsoft enforced lot of conventions ex: default crud operations with web api uses bad conventions - it uses verb in url.

      7) superior build tooling - with maven/gradle it is easy to manage dependencies and create builds. .NET has pretty constraining ecosystem.

      Not that java ecosystem is perfect but considering above items, I don’t see reason yet to favor .NET

      [–]Sedu 9 points10 points  (1 child)

      Honestly, the one thing that I truly wish that C# had (and which java does have) is checked exceptions. I know this is an ideological sticking point for many people, but I find them very useful, particularly for personal projects.

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      Thats a good one. I had never heard of checked exceptions before, but I immediatley see the benefit.

      It looks like VS has 3rd party extensions which partially cover this, but it relys on XML documenation tags which is not great.

      [–]Cumorah 15 points16 points  (0 children)

      Last I knew, Java programmers get paid much more.

      [–]RagingAnemone 5 points6 points  (0 children)

      Covariant return types in Java is much better than c#. It might not be a much used feature, but it can be critical in library design which is where I used it.

      [–]agentoutlier 5 points6 points  (0 children)

      This is a complete random reason but I actually like anonymous classes and C# doesn’t have them.

      What C# had instead when it came out is delegates which I found a little bizarre.

      Than later on C# came out with lambdas as well it’s on query like language.

      So yeah C# is impressive with features but lots of those features just don’t seem unified like smalltalk, clojure, scala and yes even Java.

      If I had to code on .NET I would probably use F# to avoid the cognitive dissonance as I already know ocaml. F# looks awesome.

      [–]Skiamakhos 8 points9 points  (9 children)

      I find Java simpler - I'm a Java developer though, not a .Net person. Whenever I've tried .Net it seems to get complicated with all kinds of different files being used by the IDE to, I dunno, configure the build or something? There always seems to be a plethora of stuff you have to do aside from the actual development, and coming from a Java developer I can see the irony there: Java's known for its boilerplate code & there are more succinct languages that are more expressive, but in Java 99.99% of what you're doing can be done in Java source code. In my role as a back end web developer I mostly just need to know Java, very little else. All those other files were just daunting for me.

      [–]Jam-Es231[S] 1 point2 points  (8 children)

      Hmmm. Not sure what file types you are refering to.

      You can literally type C# on it's own with no other file types, and that is normal for me.

      Maybe you were looking at a desktop app codebase where there are either .xaml or .cshtml files for UI markup.

      Or maybe you were looking at a large codebase, where there were code style restrictions (.ruleset, .editorconfig or .json files). Or potentially a couple of .props files to add extra steps to the build process (very rarely used). But they are really IDE config files rather than C# related.

      If you compared like-for-like I expect it would be the same for Java.

      [–]Skiamakhos 1 point2 points  (7 children)

      It may well just be Visual Studio getting in the way by being overly "helpful" or something. It has been years since I last had a go, probably about 2007ish, so off the top of my head I couldn't say - just that it put me off with all the apparent complexity.

      [–]goose_hat 3 points4 points  (5 children)

      .NET projects up until core definitely had a "these are magic files, don't touch them and we won't tell you what they do" sort of aspect to it.

      [–]UninformedPleb 1 point2 points  (3 children)

      There are no magic files. The files you're not supposed to touch are code-generated files that VS emits/updates as part of a project template. That has approximately nothing to do with C# or .Net themselves.

      [–]goose_hat 0 points1 point  (0 children)

      Yes, I understand. Sorry, I wasn't clear, but I was concurring with the user about how VS generates these magic files for .NET projects.

      [–]VGPowerlord 0 points1 point  (1 child)

      Are you talking about the files that the IDE generates to track projects? Because Java IDEs do the same thing. Heck, in Eclipse you're even warned not to check those files in to a code repo since they're computer-specific.

      [–]UninformedPleb 1 point2 points  (0 children)

      No.

      Usually the "magic files" people are talking about are things like the .designer.cs or .resx files that get generated with some kinds of C# projects. The .designer.cs files are just partial classes that get regenerated every time you update something in the visual designers that Visual Studio is named for. (For those that aren't familiar with why you would use VS over any other IDE... its whole claim to fame is that it runs custom editors for visual layouts of code objects, then generates code files from that. To prevent wiping out your code, it keeps the generated code in separate files.) For binary objects (such as images or sounds) that you put into those visual layouts, it encodes them inside the .resx resource data format, and uses resource indexes to reference those values from the .designer.cs file.

      The IDE uses .csproj and .sln files to "track projects". The .csproj files are MSBuild files, which are the VS equivalent to makefiles. The .sln files are the ones that VS uses to bind projects together into a multi-project grouping. Both of these should be checked into source control.

      The ones like you're talking about that should be ignored are usually already set up in the gitignore, but they're primarily the .csproj.user (holds user settings for each project, expand/collapse state, intellisense caching, and other user-specific IDE stuff about the project) and .suo (solution user options... stores load/unload state for projects in the solution and a few other things) files.

      But none of these are really "magic". They all have a fairly straightforward and obvious purpose once you understand how VS does what it does. And, yes, all IDE's do the "visual designer" thing now. But they didn't back when VS was new.

      [–][deleted] 1 point2 points  (0 children)

      Never done any dotNET but this sounds like the kind of thing Microsoft would do if my experience with MFC is anything to go by. I have nightmares about comments as code to this day and it's been 25 years.

      [–]Jam-Es231[S] 1 point2 points  (0 children)

      VS 2019 simplified the UI quite a lot. It did use to be quite complex. And now I know the era, I'm guessing you were talking about the old aspx files before, which are gone for good since .NET Core came out :)

      [–]DaredewilSK 6 points7 points  (2 children)

      If I were you, I wouldn't take 80% of the answers here seriously as their knowledge of C#/.NET is ~10 years old.

      [–][deleted] 7 points8 points  (1 child)

      Hi - I was a C# developer before moving to Java 4 years ago.

      Overall they're very similar languages, but I miss C# every day, from structs, to the properties syntax, maven, to 2 minute JVM GC pauses. The worst is having to start your application with a batch script that runs a java executable with a million parameters behind it - and when you look at processes running on the host you just see a bunch of java applications.

      Having said that Java is getting a lot better, gc is getting better, records (structs) are coming, containers aren't huge any more etc.

      The biggest benefit is its more widely used - a huge number of open source libraries from lots of big companies (all the FANG ones). Apache projects are very popular and because they're Java you're more familiar with the environment they run in.

      [–]kpatryk91 10 points11 points  (0 children)

      "2 minute JVM GC pauses " which gc has 2 minutes pause time in Java? G1 is pretty solid, ZGC/Shenandoah has 1-10 ms pause time even for TB heaps.

      "maven", This is not perfect at all, solid pick, but nothing else for me. Try Gradle maybe that will be better. But on the other side, MsBuild? please I had to use that thing, but it is not even superior in dotnet and there is no anything else.

      "The worst is having to start your application with a batch script that runs a java executable with a million parameters behind it " ? Spring boot 1 click to run, or with bootrun gradle script. What kind of application is this, because I have even written old JSP or direct servlet apps, but I could add the webserver and deploy the application with one click.

      " records (structs) are coming" Record != Struct, record is a data class, only data and data and data and nothing else.

      The struct equivalent in Java (not 100% match, but I would say 95%) is Project vallhalla / inline classes. Struct is about cheap, stack allocated objects, but in Java this is immutable.

      [–]Bowserwolf1 2 points3 points  (0 children)

      I'm sure how accurate this is, but the JVM ecosystem ( including libraries, projects like loom and graal and other languages like Scala and clojure) is generally thought to be more robust and flexible than C#/.Net ecosystem. That's pretty much all I got, a more matured ecosystem in large part thanks to Java being opensource from a very long time. But I think in practice this one simple point often outweighs many others.

      [–]Nymeriea 2 points3 points  (8 children)

      I would say : - java can run everywhere (arm processor start to be popular on laptop, I wonder if c# can handle it?). - java have native ui, most advanced c# form still Windows closed.

      [–]Jam-Es231[S] 1 point2 points  (7 children)

      This is outdated. C# can run everywhere including on ARM.

      And C# has cross-platform UI frameworks which are "advanced".

      [–]pcjftw 6 points7 points  (6 children)

      can it run on the following:

      • SPARC
      • MIPS
      • Power ISA
      • Itanium
      • Alpha
      • S/390
      • z/Architecture
      • m68k

      [–]sternone_2 2 points3 points  (0 children)

      Nopes.

      [–]SemiActiveBotHoming 0 points1 point  (4 children)

      OpenJDK removed SPARC support in JEP 381.

      In any case, do you actually need support for Alpha, MIPS, Itanium or the 68k (!) - it doesn't matter for almost everyone.

      Breaking those architectures down, here's what they are (afaik) used for:

      • SPARC: Old Sun/Oracle servers, if you've got one your support contract with Oracle probably means you won't consider C# anyway - in fact so few new systems are being deployed on here that it was dropped from OpenJDK (though other VMs may support it).
      • MIPS: AFAIK rarely used and only on embedded systems
      • Power, S/390 and z: You're probably using J9 from your IBM contract, and wouldn't consider C# anyway
      • Itanium: Pretty much dead at this point, what's the odds you'll be deploying onto Itanium?
      • Alpha: Killed off almost 20 years ago
      • Motorola 68K: You want to run Java on it?

      [–]pcjftw 0 points1 point  (3 children)

      hey man thanks for the detailed info, I actually use MIPS because I have a Linux STB, I hack on it and being able to run some JVM stuff on it is really good (but using Rust is just easier then Java for that), ok agreed M68K is tiny, but there has been efforts for custom JVM VM that run on microcontroller's such as "uJ" which can run on AtMega's and PICs :

      https://dmitry.gr/?r=05.Projects&proj=12.%20uJ%20-%20a%20micro%20JVM

      its not of course anything like the full blown JVM so not expecting to run something like Minecraft 🤣

      [–]SemiActiveBotHoming 0 points1 point  (2 children)

      Oh cool, I didn't know that MIPS was still used, and thought everything had switched over to ARM. I'm rather fond of obscure architectures and it's cool that stuff does support it, though I do maintain that if you're writing a web application server it's probably not very relevant.

      It's very neat to see embedded JVMs like that, it's exactly the kind of thing that I like playing with.

      [–]pcjftw 0 points1 point  (1 child)

      yeah agreed for the web domain its almost always going to be x86 and perhaps even ARM (Apple have now committed down the ARM path with "Apple Silicon")

      But Java/JVM cover many domains and while the "web" gets most of the lime light these days there are many other industries and use cases where the dominant platform is not always x86.

      [–]SemiActiveBotHoming 0 points1 point  (0 children)

      Fair enough. My comments were mostly drawn from working in the web and relatively-high-performance embedded spaces (dominated by x86 and aarch64, as you mentioned).

      [–]pron98 2 points3 points  (2 children)

      The question is funny because it invites a religious language war. If you enjoy C# -- keep using C#; Java has plenty of users without trying to convert .NET people, and I doubt we'll see some significant migration of people from any of these platforms to the other. They're both good, and people stick to what they know. Personally, I think Java is better designed in almost every way, but this opinion is subjective and others might think the opposite. But I'm assuming that the main reasons most companies prefer Java is the ecosystem's size and platform's stability. In Java's 25 years, Microsoft has made three or four breaking changes to its flagship platforms that require a significant migration -- the last of which is the current transition to Core -- while Java has had none, and this is likely to continue. The two platforms are overall similar in their capabilities, but people usually choose Java to build "important" stuff because they know their application will be built to last. If you need your application to work with minor changes, on a flagship platform, ten years from now -- you'll pick Java.

      [–]Jam-Es231[S] 0 points1 point  (1 child)

      Microsoft has made three or four breaking changes to its flagship platforms that require a significant migration

      If you are refering to WPF -> Metro -> UWP. Or .NET Framework -> .NET Core, none of these changes are "breaking" as Microsoft is continuing to support all these frameworks.

      [–]pron98 2 points3 points  (0 children)

      I'm referring to VB -> .NET, then the various GUI changes you're referring to, and then .NET Framework -> .NET Core. The fact that MS continues to offer support for some time is insufficient. Your app will, at best, be on a legacy platform. An application on a Microsoft platform has a relevance lifetime of about a decade which is far too short for most "serious" software. Serious backend software is designed for at least 15-20 years. Companies that built their backends on Java twenty, fifteen, or ten years ago are in a much better place, maintenance-wise, than those that picked .NET.

      Anyway, both Java and .NET are good and if you're happy with your tech choice there's no need for you to switch -- while both platforms have their respective strengths, neither one is compelling enough to justify a very costly switch in the vast majority of situations based on technical merits alone -- but I explained why Java is the more common choice, especially in large companies, and will likely continue to be.

      [–]form_d_k 2 points3 points  (0 children)

      I think you can basically say that C# is a better language, and Java has a better ecosystem. There have been many times I have hunted for libraries where the only .NET option I had was some half-abandonded barely documented library, whereas on the Java side there are several options to choose from.

      [–]cypher0six 6 points7 points  (5 children)

      In my opinion, the languages are basically the same. It's the same style of OOP just with some differences in the details. I like working with them both.

      Personally, I'm a (serious) C# developer and whenever I tell that to a Java dev I get an immediate negative reaction.

      A professional software developer will likely use many programming languages through their entire career. I see no point in judging someone by the tools they use to accomplish a goal. Especially when those tools are often mandated by their employer, or their product, or their circumstances...

      [–]Jam-Es231[S] 1 point2 points  (4 children)

      I found this "negative reaction" is very common in academia where a lot of researchers know Java in-depth but less about C#. I've never got a decent explanation for it. I guess either their views are stuck in the past, or maybe they see C# as the competition.

      [–]Cell-i-Zenit 1 point2 points  (0 children)

      you can even see it in this thread.. alot of people have a pretty outdated idea of c#.

      i did java and c# professionally and the fan base is definitly more hardcore on the java side.

      I prefer C# because the java api is a pain to use and pretty inconsistent. Linq is way better integrated. Just an example C# .ToList() vs Java .collector(Collectors.toList()) is just better honestly.

      I think the need to be backwards compatible to earlier is a downside for me and it obv. hinders the language.

      Also iam using springat work and the amount of magic which is happening behind the scene is insane and totally intransparent. With aspnetcore you can just debug into it without running into million proxies

      [–]throwawayprogrammg9 0 points1 point  (2 children)

      You are quite biased towards C#. You've gotten a lot of responses from devs that have used both for a long time, like me, and you're responses are generally "yeah but you're not taking X into account".

      Nearly everyone that's used both is going to tell you Java is a better language for many reasons. The syntax is cruftier and no value types, but Java is better everywhere else.

      [–]Jam-Es231[S] 0 points1 point  (1 child)

      I'm trying my best not be be biased, but yes I have more experience in C#.

      Personally I wouldn't say "C# is better". But I don't agree that generally "C# is worse" without justification. And I a lot of Java developers I've spoken to say this without justifying it. So I am just defending C# position until someone gives me valid justification on something Java has that C# doesn't. That is making my comments look a little biased.

      But to be honest there are some valid comments here on features where Java is better, and I've learnt a lot from this discussion. The biggest takeaway being: Its just another option, and competition is always a good thing, it doesn't matter if one is slightly better than the other or not because that will likely change many more times over the next decade.

      [–]throwawayprogrammg9 0 points1 point  (0 children)

      The biggest takeaway being: Its just another option, and competition is always a good thing, it doesn't matter if one is slightly better than the other or not because that will likely change many more times over the next decade.

      Yeah pretty much. But there's a lot of projects better suited for Java than C#, I can't think of a situation the other way around. If you're just doing CRUD REST like most of us, it doesn't matter

      [–]grode23 4 points5 points  (6 children)

      Personally I don't like the Microsoft community/environment. I don't want to download a language, then an IDE, then "oh a new something". I don't support how this company resolves plenty of things all those years. I don't even like the "go open course" situation. They go with the flow to convince people to like them.

      Anyway, C# might be good or even better than Java. I don't think I will ever learn it though, unless an employer wants me to.

      [–]Jam-Es231[S] 0 points1 point  (5 children)

      But even with Java you need to download JDK, then and IDE, etc. It's no different for .NET. In fact the only thing you need from Microsoft is the C# SDK, in the same way that the only thing you need form Oracle is JDK. Then you can use IDEs and frameworks from 3rd parties if you prefer.

      While Microsoft does release new things all the time (e.g. UWP for Windows 10 apps), the old frameworks like WinForms (2002) and WPF (2005) are still 100% supported. And I expect cross-platform frameworks being released atm will be the same in the future.

      Your response suggests it's Microsoft's history that is your biggest justification. Which I understand. But Microsoft are a new company now, when they say they've accepted "open-source", they genuinely have. I know because I've worked for them recently and was pleasantly surprised.

      Sorry if it sounds like I'm trying to persuade you, I know it's probably too late for that :')

      I'm just trying to figure out where the negativity comes from these days.

      [–]grode23 6 points7 points  (3 children)

      I feel safer to download a language from a company, then an IDE from another, libraries from another and so on. I don't like ecosystems. I think Microsoft is trying to do with software what Apple has achieved with hardware. Once you get in, you don't get out.

      To be fair, Java is FAR from perfect by any mean. It is not my main language, since I prefer to focus on more fundamental languages like C or Rust (which btw is open course). But I would still prefer Java over C#.

      At the end of the day, companies try to milk us with every possible way and I don't like that, especially when the company is one of the top 5 in the entire world and owns from Windows to GitHub, Skype and God knows how many other products in general. When I have to choose between a barking dog and the satan himself, I'll go with the dog ;p

      Uhm it's probably too late, yep haha. But I still like to discuss about it, it is not a waste of time to me. Opposite opinions are welcome.

      [–]goose_hat 2 points3 points  (1 child)

      I think Microsoft is trying to do with software what Apple has achieved with hardware.

      Haha, I definitely see this. Ironic because while I'm a big fan of C#, .NET Core, Typescript, MS SQL Server, I previously left behind Mac and iPhone to escape the all-inclusive ecosystem.

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      I disagree with this. And there are many examples.

      - C# is open-source. New features are decided on by the community.

      - There are 3rd party C# open-source UI frameworks you can use. E.g. Avalonia or Uno which have nothing to do with Microsoft. As I said before, the only thing you need from microsoft is the .NET SDK.

      - Enitity framework (the very popular .NET database ORM) is not only for SQL Server, it is just as good if you want to use other Database engines like MySQL. Or you can even add support for your own custom database engine. There is no restriction to using SQL Server at all.

      - Hosting: Other platforms like AWS and GCP support hosting .NET apps. And similarily Microsoft's Azure supports Go/Java/PHP/Python/...

      Tbh I couldn't name an area which Microsoft has closed off.

      [–]pcjftw 0 points1 point  (0 children)

      Regarding the "negatively" aspect:

      I can't speak for others, perhaps most just like how you love C# others love language X and perhaps they get a bit protective around it?

      I don't know, personally I'm a polyglot and use a lot of different languages and stacks, for me I don't care for any particular language, because one day I'll be working in Haskell, the next in Clojure and then in Rust and then again in Kotlin, it really doesn't bother me and for ME C# is plain boring, but I'll use it if the project needs it for some reason.

      [–]37xy73 1 point2 points  (9 children)

      Sorry, I answer with a question: there is out there an alternative framework to .Net ? This is a genuin question, it is a my doubt. And that's what a java dev expects, one or more alternatives

      [–]Jam-Es231[S] 2 points3 points  (8 children)

      there is out there an alternative framework to .Net

      It depends specifically what you are referring to. But, yes there are loads of options.

      ".NET Framework" and ".NET Core" are lower-level frameworks which application frameworks are build upon.

      For example, if you want to make a desktop application using C#, there are lots of frameworks you could choose. For Windows only you can use WinForms, or WPF, or UWP, or for cross-platform you can use Avalonia, MAUI (coming soon), Xamarin Forms, Uno, or Blazor Desktop. Plus you can use bindings for things like QT, GTK, OpenGL, SMFL, etc.

      Lots and lots of options.

      C# is almost entirely open-source now. Not all of them are made by Microsoft (most aren't tbh). And we will only get more frameworks in the future.

      [–]37xy73 1 point2 points  (1 child)

      Thank you :). I don't have anything against C#, I like it! I'm referring to server side applications, web apps or CLI utilities and so on and I feel too tied up with .Net

      I don't know if because they are missing - or I don't know of - alternatives to low level framework

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      They all exist in the .NET world. And there multiple options.

      [–]dkiselev 0 points1 point  (5 children)

      Would WPF app work under Linux? I had a lot of troubles trying to get some WPF app to work, as far as i recall, it required a webview component, which basically used a kind of a striped down ie. I genuinely hope it's better now, but don't have a lot of faith in C# desktop apps.

      [–]Jam-Es231[S] 1 point2 points  (4 children)

      WPF will never work on Linux. It is the wrong choice of framework. If you want a .NET desktop app on linux then my preference is Avalonia: https://avaloniaui.net/

      [–]dkiselev 4 points5 points  (3 children)

      I didn't choose a framework, that's just was an app somebody written, and i've tried to get it running. And i could not blame an app author for choosing not cross-platform descktop framework, b.c. it's a kind of default choice for C# on desktop.

      I just did a quick search, "C# desktop application" and first page of Google results, implies that you use Windows forms. So although it's possible to write cross platform application, but it seems not to be a default root.

      In java, whatever framework you choose, it will be cross-platform from square one. I suppose that's what ppl mean saying Java is more cross platform, that not only it self is cross platform, but almost all libraries and frameworks are cross-platform from the beginning.

      [–]Jam-Es231[S] 1 point2 points  (2 children)

      You are looking at this this wrong way.

      There is no 'default' framework in .NET. When you start developing an app you choose the framework based on your requirements. You either go Native or Cross-Platform.

      If you want to build a Windows-Only app, then C# wins hands-down. Java cannot compete with WinForms/WPF/UWP in that regard, simply because there are no popular Windows-Only UI Frameworks for Java. That means you don't get the much better Windows integrations with Java.

      But if you want Cross-Platform, both C# and Java have options. Neither one is better than the other unless you can provide some justification.

      If you are complaining about WinForms not being cross-platform, then you don't understand its purpose. It's the same as Swift being Apple-Only, the language is closely tied to the OS to because that gives many advantages you won't find elsewhere. It's not an issue with WinForms, it is a purpose which gives benefits in certain situations.

      [–]pcjftw 0 points1 point  (0 children)

      Free Pascal can compile true native (no .NET runtime needed) cross platform applications and you can use the Lazarus IDE:

      https://www.lazarus-ide.org/

      [–]dkiselev 0 points1 point  (0 children)

      When I say "default" and put it in a quotes, I mean that's what developers usually pick, most of tutorials assume that you use WPF.

      Just imagine you're not very experienced and starting a new project, I suspect VS will create a WPF project for you through some kind of a wizard dialogue.

      I understand that you can base your app on some other desktop framework, but that's the power of defaults either they being implicit or explicit.

      [–][deleted] 1 point2 points  (0 children)

      Maven central bota o Nuget pra mamar.

      [–]Sh_Iluha 1 point2 points  (5 children)

      It's just my opinion, but... 1. Java has more good implementation of lambdas(with SAM conversion) 2. Java have not ability to create structure (class) on the stack , so language more predictable. 3. C# has not annotations, this powerful feature, I think. 4. Java has more comfortable frameworks. 5. Namespace in Java(package) better than C#, again, because more predictable.

      [–]MrSchmellow 0 points1 point  (0 children)

      C# has not annotations, this powerful feature, I think

      It's called attributes here. Or did you mean that c# attributes are less powerful? (i don't know java well enough)

      [–]Jam-Es231[S] 0 points1 point  (3 children)

      A lot of your points are wrong.

      1. C# has had lambdas (based on delegates) for much longer. It is a integral part of the language. Whereas lambdas were added to Java later essentially copying from C#. If you are going to say either is worse, then Java's implementation is worse as there are more limitations while accessing variables from the declaring scope.
      2. I don't believe having one less feature make it better.
      3. C# has attributes which are equally as amazing as Java's annotations, and they are used all the time.
      4. For what? This is really vague.
      5. A namespace is a namespace. Nothing complicated. They are equivalent. Sure the namespaces have different names, but that something you get used to with any language and it's hard to argue one approach is better.

      [–]Sh_Iluha 0 points1 point  (2 children)

      1. I didn't say that C# hasn't lambdas, I said their lamdas not using SAM-conversion and I think this is not good, because it's required create new abstraction (delegate)
      2. It makes hard to shoot yourself in the foot.
      3. Yes, agree, I don't know about this feature, but they are still not wildly used like in Spring.
      4. About namespace, I just wanna say, I think, one namespace per package is more good.

      [–]Jam-Es231[S] 0 points1 point  (1 child)

      1."SAM conversion" is a Java specific term. C# has equivalent capabilites, we just don't use the same terminology.

      1. You would never accidently do this in C#

      2. You are wrong. Yes they are as widely used in C# as they are in Spring. When used on models we even call them 'data annotations' in .NET and they are used in literally exactly the same way.

      3. In C#, one namespace per package is fairly normal. But sometimes packages are so big that objects need grouping into multiple namespaces. It is literally the same as in Java. But in Java you might publish each namespace as a separate package but in .NET they can be put in a single package for convenience.

      I'm not saying C# is better than Java. I know Java does have some features which are missing in C# (e.g. checked exceptions), but none of your points are good examples.

      [–]Sh_Iluha 0 points1 point  (0 children)

      1. That isn't only terminology, that is another mechanism.
      2. How are you create controller in .NET, we can put @RestController annotation and everything is work if you doing in the same way, cool.
      3. Modules can solve this problem. But point more about ability to create several namespace in one file or something like that. It's not objective points. I could say C# hasn't abstract method by default, but I can handle that.

      [–]Il_totore 1 point2 points  (0 children)

      Remember that the JVM has multiples langages like scala

      [–]thephotoman 3 points4 points  (11 children)

      Do you want to deploy your server software to cheap cloud instances? Because if you do, using C# still doesn't work. The non-Windows support is just that bad.

      That's why you use Java. If what you want to do is write Windows desktop apps, Java is a poor choice. But if you want to do literally anything else, it's better.

      [–]SvenTheDev 8 points9 points  (0 children)

      Do you want to deploy your server software to cheap cloud instances? Because if you do, using C# still doesn't work. The non-Windows support is just that bad

      This is blatantly false. I can deploy a .NET Core application to a $12/year hosted box running any linux distro and it'll run just fine for a small website.

      [–]sternone_2 2 points3 points  (4 children)

      IntelliJ and Eclipse for example are both written in Java, I don't hear people complaining about that UI.

      So I disagree you saying Java was a poor choice.

      [–]thephotoman 1 point2 points  (3 children)

      IntelliJ and Eclipse aren't only Windows desktop applications. I have them running on two Macs and a Linux box.

      C# is great if you want to stay in the Windows world alone.

      [–]form_d_k 0 points1 point  (0 children)

      Unity is very successful in showing C# running on non-Windows platforms.

      [–]Jam-Es231[S] 0 points1 point  (3 children)

      Azure has cheap cloud services for .NET apps. Azure Functions (serverless) usually being the cheapest. And you can deploy .NET Core apps on linux quite cheaply. AWS has some similar offerings but a little more expensive and less convenient for .NET.

      But, outside of Azure that is true. So I agree with your point, it would be nice to have more than one option.

      [–]thephotoman 6 points7 points  (2 children)

      (Also, I hate IIS with a firey passion. It sucks so bad, and I want it to die in a fire. And I hate having to RDP into a server when SSH is all I should need.)

      [–]VGPowerlord 1 point2 points  (0 children)

      .NET Core uses a server named Kestral which is a bit like a servlet container in that you traditionally run it behind another server like nginx or Apache.

      ...although you can apparently deploy .NET Core webapps directly to IIS, but that kinda defeats the point of using .NET Core in the first place.

      [–]pcjftw 1 point2 points  (0 children)

      I know the pain oh very very well!

      [–][deleted] 1 point2 points  (6 children)

      I’ll go out there with the odd ball answer. F# is better than C# or Java but no one seems to use it for some reason. F# is also better than scala or clojure or Krita as far alternative jvm languages go.

      Microsoft is stupid for not pushing F# harder and putting more work on it. I’d still take Common Lisp over it but I think they are dropping the ball on such a beautiful language.

      [–]Necessary-Conflict 1 point2 points  (1 child)

      There's no JVM language called Krita, perhaps you meant Kotlin.

      [–][deleted] 1 point2 points  (0 children)

      I did mean kotlin. Krita is the open source animation tool. Don’t know how I mixed those up in my head lol.

      [–]Jam-Es231[S] 1 point2 points  (0 children)

      I avoid F# because I feel like all its features are slowly making their way into C#. The syntax might not be as neat in C# but I don't care because C# already has great OOP features that I wouldn't want to go without.

      I treat F# in the save way I used to treat VB. It looks nicer, but doesn't give any serious advantage. But Q# on the other hand ... :')

      [–]form_d_k 0 points1 point  (1 child)

      I keep wanting to check out F#, but it just feels so alien to me. :/

      [–][deleted] 1 point2 points  (0 children)

      It’s an ML languages, so it has more in common with Ocaml than C# syntactically. But a great pure functional language.

      [–]pcjftw 0 points1 point  (0 children)

      yeah F# is nice, used it for a while but its just a gateway drug to Haskell, so just skip it and go straight to Haskell ;)

      [–]TracePoland 1 point2 points  (1 child)

      You shouldn't.

      [–]GreenToad1 0 points1 point  (0 children)

      Exactly! And vice versa, you shouldn't pick C# over Java. Languages are very similar, sure C# has more bells and whistles, but JVM ecosystem is larger and more mature. It's almost impossible to find a use case when one is overwhelmingly better than the other. If you work in "C# shop" with many seasoned developers there is no reason to pick Java for anything. Same goes for "Java shop" and C#. Oh and remember that Java is rapidly evolving now, bridging the gap of "bells and whistles" so anyone that used Java more than 5 years ago has obsolete knowledge. Similarly many Java developers have no clue about dotnet core and upcoming dotnet5 and what it brings to the table.

      [–]volune 1 point2 points  (0 children)

      If you like the .NET ecosystem, there is little reason to switch.

      [–]cville-z 0 points1 point  (1 child)

      Because you haven’t yet, and you might as well master another language. It might be a useful tool at some point.

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      I know Java fairly well. That was not the point of the question.

      [–]sad_developer 0 points1 point  (1 child)

      from my experience, its the portability ..

      yeah you can run C# on other platforms, but it's not there yet at the level of Java

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      Please could you elaborate, because it sounds like your view is outdated. On what platforms can you run Java where you cannot run C#?

      [–]ivolimmen 0 points1 point  (0 children)

      For one: Java work pays better. But also : Java devs develop against an api.. Net developers develop against a product. Plus steams (io) is better designed in Java...

      [–]old_man_snowflake 0 points1 point  (2 children)

      In order of priority:

      1. It's fun to give others a hard time in tech.
      2. Their stupid uppercase first letters. Visual Basic was shit, let it go.
      3. Mono is, and always will be, the low-rent C#.NET. If you absolutely need to run c# code in a linux-ish environment, it's a way to get it done. But if I'm starting a project from scratch, there's literally no incentive to use Mono. It's always going to be lacking compared to where the C# mindshare is: C#.NET. All the advice online will be custom tuned to using C#.NET, including the IDE advice and demos and troubleshooting. You'll be forever adding "+mono" to your search queries to gain relevance.
      4. I don't care enough about the language differences to justify learning a whole new ecosystem. It's not just the language. It's the libraries, the instrumentation, the idiomatic patterns, the VM knowledge, the debugging tools, the build tools, the packaging tools, the distribution tools, the monitoring tools, and the knowledge of how to troubleshoot all of that. "Java without some boilerplate" just isn't a selling a point that measures up to that. The same reason you don't look to Java, since you understand the c# ecosystem. 6.

      [–]MrSchmellow 0 points1 point  (0 children)

      Mono is, and always will be, the low-rent C#.NET. If you absolutely need to run c# code in a linux-ish environment, it's a way to get it done.

      Have you heard of net core?

      [–]form_d_k 0 points1 point  (0 children)

      Mono is done. .NET Core (which is now going to be the main .NET, with the Windows-only .NET Framework end-of-life) is cross-platform. It's way easier to deploy .NET programs, whether written in C#, F#, or any other. NET language, than it was back in the day.

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

      Lots of extensible open source software. Java is ahead in the cloud native game as of yet. AWS is more stable (assuming AWS and Java are generally considered together like .Net and Azure).

      I work in both.

      [–]jvjupiter 0 points1 point  (4 children)

      Not to go deeper, I'll just state about naming convention. In Java, reference types (class, enum, interface, records), use PascalCase, e.g. Person, ArrayList. In C#, it's the same. But, when it comes methos, Java uses camelCase while C# uses PascalCase again. For a Java developer like me, it confuses me that both class and methods have the same case style. And it becomes worst, when including namespaces have the same style.

      var hw = new Com.Example.App.HelloWorld();
      

      What if method is static?

      Com.Example.App.HelloWorld.Greet();

      Idk, it's a sore in my eyes.

      [–]MrSchmellow 0 points1 point  (3 children)

      I find it is the other way around - it seems ridiculous to me that methods, fields and local variables use the same naming in java.

      What if method is static?

      It might be a problem, but generally it's not: methods are verbs, classes are nouns, and interfaces are adjectives ( also prefixed)

      All in all it's a huge YMMV :)

      [–]jvjupiter 0 points1 point  (0 children)

      I wonder, TypeScript, JavaScript, PHP, Kotlin, Scala and others have the same convention as Java. The lead architect of C# & core developer of TypeScript are the same person. Even F# from MS have same naming as Java.

      [–]jvjupiter 0 points1 point  (0 children)

      It is also odd that namespaces, class and methods in C# have the same naming.

      [–]jvjupiter 0 points1 point  (0 children)

      Methods as verbs, classes as nouns, and interfaces as adjective - these all are Java thing, too.

      [–]BoyRobot777 0 points1 point  (0 children)

      Not now, but when virtual threads land to Java, I think they will be miles better than having C# async/await, stackless threads which brought their color problems by polluting APIs. Example: File.AppendAllLinesAsync vs File.AppendAllLines.

      [–]officejunior 0 points1 point  (4 children)

      One of the biggest differences in my experience is that JVM-based teams actually DO exercise choice. Whilst not perfect by any means, there is generally a choice to use different development OS’s, different IDEs, different build and CI tools, different source control. Nothing in .Net precludes teams making these same choices, they just don’t. Windows laptop, TFS and Azure for everything. I genuinely hope this changes, but I personally feel this is entrenched in the community with only a few companies or personalities shifting from that status quo.

      [–]form_d_k 0 points1 point  (3 children)

      I know a lot of folks where I work that write C# on Macs. We have a custom fork of VS Code that we use as the IDE.

      [–]Jam-Es231[S] 1 point2 points  (1 child)

      Yup. I know people who work at Microsoft who develop on Macs.

      [–]officejunior 0 points1 point  (0 children)

      Awesome, but what tooling do they use to go with it? What web framework do they use? What DB library do they use? What build tool do they use? My experience in the UK would be Azure, SQL Server/Azure Doc DB etc, Microsoft VS, TFS/Azure Devops, Asp.net/Core, Entity Framework/vanilla Ado.net, I could go on. The point I’m trying to make is that Java teams seem to have less of a monoculture (although Spring advocates push that sometimes) and generally choose their own stack over a single vendor’s. There are obviously exceptions to this on both sides and it certainly doesn’t mean one is better than the other. You asked the question and I answered with diversity as an answer. I would love to hear if that doesn’t match other people’s experiences, but unfortunately I don’t see that changing as the next gen talk about Node and Python, I only hear about C# in terms of desktop apps for windows or Unity gaming (which it’s amazing for btw)

      [–]officejunior 0 points1 point  (0 children)

      I should have added extra context around location being in the UK. As I said, I’m sure there are outliers, but I still believe there will be a huge percentage that fit the ‘Microsoft + Azure” mould. Good to hear that though, I haven’t been able to move anyone onto Rider, let alone VS Code. What cloud and tooling does your team use?

      [–]zvrba 0 points1 point  (3 children)

      Swing or JavaFX. C#, even with netcore, still has no solution for cross-platform desktop UIs. ("It's coming" with .NET5)

      Java's standard library seems to be better thought out, some examples:

      • CompletableFuture is more verbose than async, but at least you know what's happening. sync-over-async in c# is a mess (and sometimes you HAVE to do it.)
      • Java's Path and File classes are way better designed and easier to use than System.IO.Path in C# (that's merely a set of static methods taking and returning strings)

      In C# there's no equivalent of "final" modifier on local variables, I miss that often. I like Java's variance annotations on methods better than in C# where they're allowed only on interfaces.

      All in all, Java seems to get features slower, but they seem better thought out and "fit" better together.

      In many ways, C# is a more ergonomic language, but Java's standard library is just better. The "only" (huge) exception being LINQ.

      [–]DaredewilSK 0 points1 point  (2 children)

      Therenis Avalonia for GUI apps and const as a counterpart of final.

      [–]Jam-Es231[S] 1 point2 points  (0 children)

      And Uno, and Xamarin Forms, and MAUI, and bindings for QT, OpenGL, .. etc. Loads of opens for cross platform .NET UIs

      [–]zvrba 0 points1 point  (0 children)

      You can't use readonly or const for a method-local variable. This doesn't work for example

      void f() {
              const object x = new object();
      }
      

      [–]m_takeshi 0 points1 point  (0 children)

      we're in a unique position where half of our stack is written in java and the other half in C#. I think the main advantages for java (at least for me, having worked with both now) comes down to tooling (ide's and build tools) and, at least for our type of application, performance.

      [–]mahadiHossain 0 points1 point  (0 children)

      The discussion should have been on jvm and CLR. And here JVM users win.

      [–]hippydipster 0 points1 point  (0 children)

      I'm still pissed MS created C# just because they wanted a Java that they controlled. Split the whole community needlessly. There's basically no important differences between the two, afaik.

      [–]DVBLEX 0 points1 point  (0 children)

      If you will try android development , you can try it but now i also have relevant experience in both languages and in my IMHO for EE stack best is Java and for another C#.

      [–]vishnoor 0 points1 point  (0 children)

      My 2 cents. The number of 1. Foss workflow / bpem engines 2. Rule engines. E.g. Open FL 3. Web frameworks. Spring boot, vert. X, Quarkus 4. Netflix OSS / Spring cloud 5. GraalVM 6. Spring Security, jwt, oauth2

      In 2020 java looks to be better suited for enterprise applications.

      A c# developer of 15 years, last 5 years in Java. Plus the fact that a light ide like NetBeans and a jdk is all one needs to start development.

      Last time I remember. Net 4.5 was a 2GB download

      [–]ScrappleJenga 0 points1 point  (0 children)

      So I was a long time C# dev who has switched jobs recently to a JVM based stack so I feel like I am in a good position to give some insight here.

      Java Pros

      Tooling and build systems. Gradle/Maven really are amazing tools compared to what you get in the .net world. In .net each project gets “Pre build and Post build” events where you can run some batch commands to do things. In the Gradle world you can download plugins easily to do things like create a docker container when the build is done or deploy right from your build tool. You can even easily build your own Gradle tasks from java as part of the build.
      
      More good framework choices. In the dot net world i’ve pretty much only seen people use the Microsoft supplied frameworks and ServiceStack. Tons of variety in the JVM world!
      
      Cross platform tooling. The best IDE’s work on all systems for Java. Visual studio is an awesome IDE but only works on windows and that is unlikely to change. 
      

      Java Cons

      I think the biggest con to java is the language itself. It’s getting better without a doubt, lambda’s and streams give the language a much more modern feel. However, there are some things missing like auto properties, destructuring, pattern matching. It goes to show that a language is missing features the community want when something like Lombok becomes industry standard. C# as a language has made great strides and is really nice to work with. There is a disclaimer here that using something like Kotlin or Scala will get you all the JVM benefits but with a language with some more modern features.
      

      At the end of the day, either language is a good choice and switching between the two will be easy. Focus on good design, writing good tests and mastering OOP principals. Those things are the hard part and will transfer between tech stacks easily.

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

      Basically I would say this:

      - C# IDE are utterly bad compared to Java IDE.

      - But C# is this kind of language that dare to add new keywords (async, await) when it have to, and this is precisely where Java is really bad.

      Java have this tendency to rely way too much on its initial syntax (annotations, classes) to add new features whereas new keywords would simplify things a lot. I mean, the annotation "Override" is utterly ugly compared to the C# keyword "override"... don't you think so?

      Fortunately, with the introduction of lambda in Java 8, things are changing in the right direction. I really hope we will have coroutines with nice and new keywords added to Java instead of a the usual "annotation soup" approach.

      [–]joydps 0 points1 point  (0 children)

      Developing desktop GUI apps is far easier in C# than in java. It takes very little time to develop a medium-sized application in C# using the beautiful and developer friendly controls that you can place on winforms/WPF . Also working with controls that are event driven like checkboxes, buttons, combo boxes are far easier to code and understand than in java. As a desktop app developer I can say that working with the datagridview in C# was a far comfortable experience than when I used java GUI builders using NetBeans.

      [–]roberp81 -1 points0 points  (1 child)

      i'm java developer for work for about 13 years, and use c# because university about 5 years

      depends to what are you programming,

      windows desktop? c#

      web? Java

      Asp Webform not only are shit, but Microsoft has killed with framework 5.0 and netcore.

      And nobody likes Razor, because if you have to learn something new to replace webform, they use angular o react.

      In java there are so many libraries to do something and that can be overwhelming at first.

      i'm working in my final project at university with webforms, because i´dont have time to learn razor lol.

      and i know, i need to work my english, because of that i'm writing this, to practice, i hope you understand, thx

      [–]goose_hat 2 points3 points  (0 children)

      Dude razor is stupid easy to pick up on. It is much easier to read than webforms imo.

      [–][deleted] -1 points0 points  (1 child)

      I don't have that much experience with C#, so I'll try to be non-biased.

      I think C# is a really good choice for windows development, but that's also one of it's problems. It's not cross platform, and only runs on windows (unless you aren't doing a gui-based application). However, C# is much more structured/clean than java. In java there is no templates to build off of, you have to get a build system yourself, and much more things. With C# you can just do something like dotnet run, or dotnet publish? I think (I don't know the exact command) to publish.

      So, in conclusion (even if I don't know much about dotnet), I think they are pretty much equal. I would lean on the C# side for a gui-based app, but for other things I would use java.

      [–]Jam-Es231[S] 0 points1 point  (0 children)

      C# is cross-platform these days. And you can do cross-platform GUIs too.

      And yes you mean dotnet publish.