As a developer who has a lot of experience in both of these languages, I believe you did a very good job in comparing the two. That said, I strongly believe if you CAN do what you want in C#, there's almost no argument that persuades you to use Java. Basically, if you have to use Java to use a certain library, by all means, do it. But if I had to choose either of these languages I would NEVER choose Java. There are so many things wrong with it (Unicode?)
You are missing 3 enormous benefits in C# : - C# can build "unsafe" code ! You can manage un-managed memory, access it like in C ! - Fine grain C/C++ Interop, build -in. - awesome async / await mode ! For me, C# seems to be more versatil and modern. No question about that.
@Gipsy_T. " 🎶 ... 'bout that LINQ, no bubble (sort!). I'm all about that LINQ, 'bout that LINQ, no troubles. Every API is threaded from the bottom to the top.... 🎶 "
Cuz you know, I'm all 🎶 ... 'bout that LINQ, 'bout that LINQ, no bubble (sort!). I'm all about that LINQ, 'bout that LINQ, no troubles. (2x) Every API is threaded from the bottom to the top.... 🎶
.. Compiled Regex (with named groups, suckas!) Async queues Generics Reflection Roslyn compiler IL code EXPANDO😂 Native AOT Cross Platform Razor Pages (w HTMX) Blazor SSR Avalonia Android support CLR and C++ in same project Sdk and runtimes separately installed LTS support Monthly updates .... and soooo much more.
C# has less boilerplate, fantastic syntactical sugar features which make coding a breeze (Once you know them), extension methods are really awesome for configuring services for application startup (IServiceCollection). The new MinimalApi makes writing API endpoints super simple and fast for simple dev testing etc. All in all, it feels like a more modern language which has matured well, unlike Java. Sorry if I ruffled some feathers but it's just my opinion. :)
Syntactically Java is very out of date, and in my mind it always will be until it can do simple things like auto properties (adding a library like Lombok that requires IDE plugins and build alterations doesn’t count), and more advanced things like Async Await. I believe it’s advantage is that is has a good trusted ecosystem in spring, Apache commons, and a few others. I want to say Kotlin is the answer here but even that language seems to stumble in a lot of places. At least that’s how it seems with my current understanding of it.
@@pauldanielmooney Agree with everything that was commented here, by everyone. Completely. Yeah, Java is just out of date. And it can't change that - Oracle has to support backward compatibility with everything that was made before. So it's just stuck there, with 1990s format. Yep, Lombok is nice autoprops copy, but it's not that integrated, and requires another library. Etc.
@@staubsauger2305 Oh lord, I haven't even touched on Groovy lol More learning? When do I get to actually DO in Java? lolol Java is one big chore and headache, and all these half-arsed attempts to make it human - like Maven, Gradle, Groovy, Kotlin - it's just another layer of headaches. Instead of actually giving us simple tools to BUILD - Oracle is focused on pandering to their corporate overlords.
In 2008, I got the option to choose either PHP or Dotnet for my career path. But, now I am proudly saying that it was the best decision of my life forever. My current goal is to bag a C# Web Application Developer job in the USA, and I hope very soon will succeed.
i program in php all day for web and C# in the evening for personal desktop apps, I'm also using C++ for some heavy lifting. Programmers should see languages at tools, you don't pick just one to do everything, the right tool for the job. I don't care what language i'm coding in, so long as it's easiest way to get the job done. It's all just code, some languages are just better at certain things.
C# only has two characters in its name, whereas Java has four. Obviously C# is faster to type. Java on the other hand takes up more of your life, two characters more to be precise, every time you need to mention it in an email or doc, etc... Of course, I only ever use C.
you forget about async-await. one of the most important think that java doesn't have till now and c# was one of the first languages to introduce async-await.
Microsoft sacrificed backwards compatibility by implementing generics from the ground up the right way. Java maintained backward compatibility by utilizing type erasure. However, there are more implications than just Reflection. The vast majority of generic programming surrounds the collection types, which use an array as their backing store, and the difference is particularly evident for primitive value types. If you wanted a Java List and the bools have to be converted to objects (boxed), they're taking significantly more space on the heap and getting scattered (your array now holds references to other heap locations). A .NET List uses an actual concrete array of bool behind the scenes, should hold the data in a contiguous block of memory, and doesn't suffer from the same inefficiencies.
Thank God for the competition created by Java. Otherwise, there would not be such a shining and powerfull language called c#. For more than 20 years I have been coming across such comparisons. In the beginning, it was "c vs java". C# takes features from java (vm, open-source philosophy), java takes features from kotlin (records) , c# (lambdas, virtual-threads), javascript (promises, declarative programming, reactive)(and golang latest version supports generics at last). The thing you have chosen is not only the language itself, it 's also the open-source community behind the scenes. Long live open-source, even the companies have been funding foundations to drive the open-source community.
Kotlin/Swift/Typescript front ends with a C# backend, and I have to say, languages are in a good place at the moment. All of the native front ends do a great job of not getting in the way while providing great developer experiences. C# and .NET are great as well, with batteries included. If I had to use the JVM, I would go with Kotlin over Java.
I like java because it's simple. When I program in C++, it looks a lot like java, and is easier to read in my opinion than C++ code I read on the internet that makes use of all C++'s special features.
Thank you for this Chuck. As someone trained on Java and C++ I'd been wondering for some time what exactly the difference was in C#. After watching this and your C++ vs C# video, I now have a much better appreciation of the differences. Going to see if you've made any videos on Kotlin now, as I'm learning that language on the side for funsies atm. Cheers.
I believe in C# supremacy ! It feels more modern and Microsoft is upgrading it a lot since NET5 open-source. Anyway, I'll always respect Java and we'll still see it around for a while, but working with C# and Typescript for frontend (also Microsoft) is a great combination!
you forgot that C# gives you the option to write low level code. So i can just write my Application using all of C#s benefits and only write the performance critical parts in a unsafe way without having to write them in a whole other language. I also like how C# adopts so many functional features, combining the best of both worlds
Amazing comparison! My main language is C# and I recently learned Java and... I don't hate Java per say, but it just seems inferior to C# in every way, especially since C# is now multiplatform (though I've only ever used Windows anyway). My typical workflow relies heavily on things like properties, events, nullables, and LINQ, so whenever I use Java I'm constantly bumping into inconvenience after inconvenience. Even if they're minor, they add up to frustrate me quite a bit, so this video kind of validates those feelings lol.
Thank you so much! My only comment is: you didn't mention database integration. I'm still a bit of a programmer newb but all my coder friends are clear: if you're going to build an application that is tied a database, go with C#. And I can't argue with that. I've done the integration in Java and it is annoying but I've seen it in C# and it was seamless.
Generic classes being generated for each generic type doesn't just matter for reflection. It also matters for performance and static fields. Java uses type erasure, which means generics are fake. Every value type is boxed to an object. C# uses real generics where value types are not boxed and can be accessed directly. C# generics are closer to C++ templates, but not exactly the same.
@@fnamelname9077 That's only true for AOT compiled applications, which most are not (native AOT is still in preview). The JIT creates the types on the fly at runtime so the application size can remain small. That's part of why AOT uses stripping to remove unused code to reduce application size.
@obeid_s In Java you can leverage memory mapped files using the RandomAccessFile class. I use it heavily for streaming in world data in my game engine.
Small clarification: Both Java and C# offer features through classes, but C# simply offers syntax aliases for these classes, which are sometimes structs. Like with the nullable example, the question mark is removed in CL and becomes a reference to the generic Nullable struct. You may use the struct like any other and the values are interchangable with variables defined using the nullable syntax, but IDEs may detect the use of the struct and suggest the designated syntax. This also extends to LINQ for which the query syntax shown is an alias for a chain of LINQ extension method calls. This doesn't mean the lack of extension methods is preventing Java from having something comparabie to LINQ. In reality, you could always use method calls inside method calls just like you can in C# through the static Enumerable class. The reason LINQ is based on extension methods in the first place was to simplify the syntax when calling the methods. The query syntax was only added later to further, making it ressemble SQL. As for checked exceptions, although there is no way to signal potential exceptions that will have an impact on the assembly, C# does support signaling of potential exceptions through XML documentation that references the assembly. This allows for an IDE to read the documentation file and show context-sensitive documentation including possible exception at the programmer's request.
Newer languages stand on the shoulders of the great languages that preceded them. Java is great and we would not be here in software programming without Java. There would definitely be no C#. Microsoft took a lot of ideas from Java and added their own stuff to make it better and that's how C# was born. Initially, the languages were very similar but they are quite different now because of the effort put into developing it by Microsoft. It doesn't feel like there was enough effort and innovation put into the language after Java gained popularity. For this reason, Java feels quite outdated to me despite being a great language.
The only feature that Oracle cares about is backwards compatibility. The newest JVM will still run java applications from a lifetime ago. (Sometimes re-configuration is required.) If that wasn't true, Java would already have moved beyond type-erasure. For that matter, look at how long Lombok has been around, before Oracle added records to java.
@Jan Krynicky Java's highly-regular syntax is one of its strengths. It's easy to parse - which is why it has such a rich ecosystem of automatic code-generating tools, why it's so easy for syntax-highlighters and debuggers to interpret, why it's always had great linting support. And more than anything - why it's so easy to work on collaboratively, at scale.
@Jan Krynicky That doesn't make any sense. The JVM is powerful and useful, but Java as a language is a value unto itself. The greatest strength of "scripting" languages are that they "just run" - usually incorrectly. But they protect small minds from the psychic violence of being able to tell WTF they've programmed and how incorrect it is.
C# is pure comfort, compared to Java... And also MS Visual Studio is the ultimate best editor by far! I really wouldn't want to use anything else ever again.
Visual Studio does have some very comfortable features, but to me it felt cumbersome how many times it tried to incorrectly predict what I wanted to write. I could probably tweak it if I wanted to spend time with it, but I mainly use Java and IntelliJ has to be my #1 choice, i never had problems like I do with VS.
@@martinsandor707 bruh. You're talking about intellicode which is a copilot assistant. Just turn it off if you don't like it. "I don't like this car because there was a pack of bad tasting chocolates in the glove box".
Both are good, for me it depends on what I'm doing, but I do lean toward java, thers a Order about it that helps me remember more of my code for those big projects
@@alessioantinoro5713 I'm afraid you are being overly optimistic on the timeline. Project Valhalla has yet to finish even "phase 1" (value types), and from there it's still a long way towards specialized generics. An inofficial estimate I've read on that is around 2025. And even that sounds optimistic to me.
Thanks for the video Chuck. I'm starting a new position at work and have a flexible manager willing to put me on teams that either work with java or C#. I don't have much industry experience or experience with those languges outside of a few projects. This video helped me understand things differently and has me leaning towards joining the C# developers more than I already was. Thanks again
Chuck - great work, great content. Thank you for sharing your experience, your wisdom. I really like your level-headed language comparisons. Having worked with software development for 40 yrs I cherish a valuable source when I see one. You earned my subscription after just one video.
Having to be a ‘soft’ engineer, this is what I realized. From a C/C++ bg I moved to php and C# in a month for some projects, after a year I started Java and what exactly what you say now is what I got to know after .net5 was being realized. What I can simply say is that Csharp is clean Java.
Pretty good summary. I think one historical difference had been start-up time. With Red Hat's Quarkus and using GraalVM, this issue has been fairly addressed. I think one area not covered may be library SDK Ecosystem in relation to Cloud Providers. If using Azure, both are covered fully, with edge to C# (broader functionality). If one is talking Google Compute Cloud or AWS, they may or may not be as fully comprehensive for C# as they are for Java. As for speed, as long as one follows standard best practices, either are adequate and you are correct, absolute speed really means another choice (C++, Rust, or even Golang depending on specific coding requirements).
i'm definitely in the C# camp... the last time i TRIED to do anything in Java I got totally lost just installing the tools. TO BE FAIR, it's very possible a Java guru would have the same reaction to getting started with C#. I used to believe the same things about performance... and for the desktop you're right. it's fast enough -- and when it's not, optimize the hot path and move on. in the cloud however, performance can affect the bill you get at the end of the month -- so performance needs to be a higher priority. anyway -- excellent and fair comparison of these languages without insulting anybody's mother ;)
Don't get worried if people say one language is better than the other. Learn whatever language that is most in demand in your area and after you land a job and gather enough experience and knowledge you can easily jump to any other language as you please
C#/.NET has delegates (type-safe function pointers) whereas Java doesn't. Java's generics depend on Type Erasure, where a type parameter is essentially stripped when compiled, but .NET is completely aware of what type a parameter is at runtime. A List is a List at runtime.
"Is C# better than Java?" Yes. I stand by how I describe it, that being: "C# is what Java would have been, if Java creators, before creating it, stopped to think: 'How do we design this language so that it makes sense and it's not shit?' "
lol this is some thick material. Awesome comparison. I work in both, and I greatly greatly prefer C# and .NET. I could go on for hours why - it's just everything is already packaged for you, from a single source really - Microsoft. In Java, you, the programmer, has to sit there and configure third-party tools - it's a major nightmare! Version matching is horrendous. Yes, there is Maven, etc. But it's another thing you have to waste time and effort on, just to make it work! And any issues with that - you are on your own, good luck lol!
"a single source really - Microsoft" That exactly what kills C# for me. Being dependent on a single source is never a good idea. Especially if that source is Microsoft.
Sun's Java, like the referent one, has been running generational GC since late nineties. Technically speaking, GC is not mandatory part of JVM, and varius JVM implementations have completly different GC algorithms at any point of time. Being "generational" is also not a significat benefit or a failure, as implementation details are far more important than "generational", "copy", "segmented", "precise", "stop-the-world", "realtime" or whatever else comes.. Also for running server code, the most important aspect of GC, is ability of allocator to reuse unused "holes" within memoryspace as not using those leads to memory leak because of fragmentation. A classic C problem. The remedy for that is usually "copy collector", or in modern times, segmented one. Many "generational" GC algorithms are often also "copy collectors", but they don't have to be.
I have a feeling, that Chuck maybe was confused by G1GC because it is complicated and it was in development for a very long time, or maybe by J2ME due to it's difference in memory management or maybe by difference between "server" and "desktop" versions of JIT compilers (I actually don't know where else that "desktop" idea could came from)... But anyway, this part of the video could be better: I work with Java and I see evolution of the GCs: first it was CMS, then G1GC and now Shenandoah so I'm curious how it's going in the .Net world, especially after seeing the failure of Go's GCs, but eh...
I know this is probably a horrible analogy, but it almost feels like when you compare C# and Java. It sounds like the same arguments the C and C++ camps debate over. But to be honest? If I had to choose, I think I would go with C# and .NET for the simple fact everything you need is all together under the .NET framework. Java feels all over the place. Don't get me wrong? I like Java as well; they feel like the same language even though they aren't. Basically, finding learning material for C# seems to be so far easier to find in comparison to Java. For example, for Java to set up my environment was such a difficult task. I had to download from Oracle I think they call it an SDK. Next, I forgot what they call it I had to download some file. finally, I downloaded IntelliJ which is a cool IDE and finally when I tried to run Java on VSCode, my code wouldn't run. I found the C# ecosystem a little bit easier to find material to learn from. Also, there are different versions of Java which isn't recommended to use? I found this confusing. For example, what is Java FX? With C# I downloaded Visual Studio and I quickly found lots of material for how to get started and had an easier time figuring things out. At the moment I stopped this, and I am purely focused on JavaScript. But after I learned React, I will pick up most likely Java because of the huge job market. I am in NYC, and I can tell you that from indeed.com there were only 237 jobs post for C# and .NET and over 1,227 jobs post for Java. Despite what my personal feelings are if you want to find your first job you have to go where everyone fishing to catch fish. Sorry for the horrible analogies but I hope you get the point. This is from a newbie's perspective I am not a professional. This was my struggle as a newbie so far. Also, I would like to thank everyone for providing me with such insightful advice throughout my learning path. It has given me much needed guidance throughout these past couple of months.
Miss anonymous classes in C# which has been in Java from the beginning. C# supports anonymous methods (delegates and lambda expressions) and types (properties) but for some reason not full classes.
Anonymous classes are supported in C# albeit most programmers will use them just to bunch together a set of properties. However an astute observer may notice that a property can be in fact a lambda. These classes are extremely useful in Linq, especially in fluent form when results from previous method calls are chained in the next call as anonymous objects.
You cannot compare the two because C# is one of the most advanced programming languages and has one of the best compilers on the planet and Java is so far down the list as far as performance, syntax, and popularity is concerned that it just cannot compare.
If It wasn't for Java I probably would have gave up programming as I hated C at Uni. Then Java doing android games got me interested in game engines so Unity and C# never looked back since! A sprinkle of Html/css/js, tiny bit of python but don't get the hype and I use some C++/Blueprints on UE4/5, but C# is my fav language...so far will take something special to beat C# for me anyway. ✌
Python is the worst language, it's like a worst version of Javascript and Javascript has gotten much better in recent years. The whole point of the language is to be needlessly complicated so academic types can pretend they are smarter then everyone because they write unreadable code.
@@FilipCordas I agree JS has gotten better especially after ES5/6, I like flow but prefer Typescript obviously coming from C/C++/Java/C# background. I made a Django ecommerce project and I just did not get where things were coming from and I just felt why do people Love Python? Because it has less code? Ì think as well def__init__(self) I just don't think is very intuitive coming from a different language, not a fan of looking at __init__ calling a function def and having(self). There are parts of Python I like others I dont, Var everywhere can lead to problems fast and Django I just can't see me using it again, I did however like the built in admin. I really have yet to come across my no.1 server side framework. I'm toying with Express, made some simple asp. Net sites nothing large. I have done some simple php stuff too but not yet full done a full laravel project, I will after express. Ive read some Golang its interesting. I might even do a Spring project as well. ROR I just feel it will be a mix of Python/JS, could be wrong and might try that as well, but my main thing is games so only do web now and again mobile not so much anymore. But yeah I hear you with Python, the scripters love it fir automation on Unix systems along with bash. Thats prob why its popular plus its recommended as starting language and a lot never leave it.
If a developer asked me which the learn, one of my first questions would be what kinds of companies do you want to work for? If you want to work on line of business apps in established companies, C#. If you want to work in west coast startups or big tech, Java. I definitely like the C# language and tool stack better, but because C# started out life as Windows-dependent, Java ended up dominant in cultures that didn’t want to depend on Windows. Thankfully the dependency went away, but the inertia from that history remains
in my opinion, with java the difference between theory and implementation is minimal as compared to C#. What i mean is that if the theory has 3 components in a concept, then the implementation of that concept in Java would also have 3 components in code. But, in C# the implementation would have 5-10 extra components that we would have to understand. Example, like, in this video you see that java uses existing concepts to implement new functionality, but c# has introduced a separate standard/princple/concept just to add a new feature. that is why there are more than twice as many keywords in C#. Java class library is more natural, while with C# it seems like every different concept has been implemented by a very different person. Although, with .NET Core things are getting better.
After many years of C#, I thought it would be a cakewalk to work in Java. After all, they are virtually identical languages aren't they?? NO!!! I had a very tough time trying to actually work in Java. There were numerous technical quirks and annoyances that were difficult for me to surmount. I gave up!!
You Can make pretty blazing fast applications in C#, but it's no magic bullet you'll need to put in the same effort into the code and algorithms as you would in a lower level language to achieve it.
@@McCulloughAssociates I suspected as much, and that is totally fine. Both languages are still evolving allot so a statement that was true a moment ago is not necessarily true now. Anyway I found your video to be very informative and provides a good overview of either language. Keep up the good work.
Think of it this way - exceptions (c++) replaced return codes. Return codes required each function on the call stack between the error and the handler to recognize and propagate the error. Lots of points of failure. Exceptions allow the thrower and the catcher to be the only code to be exception aware - everything else is exception illiterate. Forcing each method to declare a throw puts us back into the return code paradigm. In practice, error conditions are usually considered in later iterations. An error detection would occur in lower level code whilst handling in application layer code. One would have to modify all of the code inbetween with the throw declarations. Take HttpServlet as an example. The doXxx methods all throw Servlet and IO exceptions. A subclass probably invokes other methods that might throw SQL exceptions. The override can only throw the declared exceptions. Many developers make the mistake of catching and dumping the SQL exception. The right answer is to catch and rethrow one of the declared exceptions or runtime exception. This is just more code where mistakes can be made. If the exception were just a runtime (unchecked) to start with, maintenance would be much easier because the middle code wouldn't have to deal with it. This is why the DispatcherServlet in Spring catches checked exceptions and rethrows runtime exceptions - so that the application code doesn't have to get boxed into throw decls. Stroustrup cites a similar scenario to justify the change in C++ 11 to have the compiler ignore exception declarations. It looked good on paper, but in reality, exception declarations on function signatures caused more harm than good.
You were actually helpful. I took no offense to the fact Java is slow. It blocking IO vs Node.js Non-blocking IO is something I knew. C# being faster then Java is not something I am surprised at even though I have been in Java for 27 years.
Hi McCullough, I know Java and C# are both OOP languages but the language I am learning at the moment JavaScript isn't? JavaScript is prototypically written. I find this very confusing. What exactly is prototypical? Would this hinder my learning or understanding of what real OOP is in comparison to Java or C#? Which is real OOP? I am at the stage where I understand the fundamentals and I am trying to learn more advance topics with JavaScript like recursive functions and gain a better understanding of pure functions versus class-based functions. Eventually I will migrate to either Java or C# for a back-end language. I am trying to learn JavaScript on a deep level so that I am able to better understand other languages with better ease when I move onto the next one. Or would it be best if I gained a deeper knowledge of languages like C# and Java versus learning from a prototypical language like JavaScript since Java and C# are true OOP languages? What would be your recommendations? Thanks McCullough most appreciative.
Great question. But the answer is a little tough to elaborate in a comment! For basic stuff like loops, conditionals and functions, conceptually similar. I think strongly typed vs untyped JavaScript is as big a hump as perhaps the object oriented features. Remember, ultimately everything executes machine code using memory, cpu, and IO. I have several videos on SOLID design- take a look. They might shine some light on OOP concepts
@@McCulloughAssociates OK, I will check out your videos on solid design. I think I may have heard of solid design with C#, sounds interesting, thank you for the direction.
Issues with running .NET anywhere? Been developing in Windows .NET that run in a Linux server. Never had any issue during deployment. That comment confused me.
i think java's remained current thank to spring, spring is used in a lot of big companies and it's a great framework, i would say the best in the industry
Great video, but there is one thing missing here - comparing the project structure. In modern C# you have 5 lines in a csproj for, and you already are able to build, run and debug the program both by running "dotnet build" command, and in Visual studio. For Java, at least in templates, it's by far way more complicated. First of of all, you need to know me syntax, groovy (while everyone knows basic XML). Secondly, you cannot use javac, if you want to have any maven dependency, you need Gradle to compile. Please, correct me if I'm wrong, but I tried to replicate few programs in Java to compare them myself and got stuck at the setup part - I just wanted single Java file with ability to add dependencies and to be able to F5 debug in InteliJ. Never got there, either in Java nor Kotlin, just a simple console app. I admit, it was only one evening of trying, but in other evenings I managed to setup Zig, Rust, node.js, Go without any issues
Thanks for the video sir, great explanation!, i want to move into C# .NET environment from Java, and found this video and i could get an overview about C# development
C# allows C++ inside the code (with the proper compiler settings). I prefer C# over Java, and recently played around with Kotlin for the first time (Android relies on it heavily). They both work, but I found C# just prettier, feels better, makes more sense to me. Java feels like it's somewhere between C++ and C# and with all the 3rd party libraries, I often find myself lost in the maze of different (and often terrible) naming conventions and bad documentation. Kotlin doesn't have that problem (as much), but that's probably for the same reason C# doesn't have that problem (as much); A big and solid enough foundation, support and use by others for the time and effort put into making great documentation. I'm not against Java by any means, but it just doesn't work for me 😅
WHAT?? C++ inside the code? Who ever made you believe that? You probably just mean unsafe programming with pointers, however that's still far from C and C++. And it's not even a real subset of these languages, since there are multiple fundamental differences as well.
C# target multiple platforms, write once execute everywhere like web, Windows, Android, Mac .Net MAUI uses c# will point to Windows, Android, and Mac. if you are a C# developer then I can say that you are an android developer, IOS developer and😁 windows app developer and web developer😃😃
Xamarin has been around for well over a decade many companies have apps developed in it. Dotnet MAUI is a new push to simplify and clean up Xamarin. It's early days for it but looks promising, so more inroads. Flutter/ReactNative/Ionic there are no cross platform winners.
Hi, great question. Ran the code just as it appears. However, since the code iterates thousands of loops, the respective vm''s "warmed up." I also ran the C# code marked as *unsafe* which disables the runtime safety checks. It did not make a huge difference. In order to _warm up_ the VM, I think one would have to write an additional layer to run the code shown several times within a single execution. Homework!
@@McCulloughAssociates Did you use tools like JMH which has warmup included as a separate feature. It would be interesting to see how quick each VM is when they had warmups included.
I wonder why chacked exceptions are a bad Idea? Because without being a Java Dev, it sounds really great. It always bothered me in C# that you never know when a method could throw.
It is good in theory, but in practice it can be a problem. Think about the HttpServlet class in Java. To create a servlet, one must subclass and override doGet, doPost, etc. The superclass methods declare throws ServletException and IOException. These must be replicated in the override. However, most developers will access a database that throws SqlExceptions. Now the developer must try/catch those. A common programming error is to simply ignore the error, leaving the application in a 'good' state even though the operation failed. The correct move is to rethrow a runtime or servlet exception with the original nested. This clutters up the code and doesn't add any value. Code that can really handle the exception probably doesn't care what the problem is. It will simply log the error and redirect the user to a sanitary error page. Having all the layers of code in between have to be exception aware defeats the purpose (essentially becoming a return code that has to be propagated)! Bjarne Stroustrup explains the reasoning for dropping the feature in C++ 11 by saying after decades of use, most applications handle all exceptions the same way near or in main and all the exception declaring just made everything more cumbersome and error prone.
It seems like you are doing this comparison with an old version of Java. There is another type specifier that you said is only in C#, Record. BTW Enums in Java are much better than in C#. And when mentioning Linq, you could have also shown Streams. The way it is done seems a tiny bit biased.
Thanks for your comment! Yes, latest version of Java 18 has records. The video was produced before the release of J18 in March 2022. Our original script included a mention of Streams in the Linq topic, however, it was cut because Streams only apply to collections and files while Linq can also operate on data sources (relational databases) and includes a query language.
@@McCulloughAssociates Thank you for finding time to answer. I like the video, I just wanted to point out a few inacuracies I noticed. About the Records thing, Records were part of the Java 14 release in 2020 as a preview feature and then released fully in Java 16 a year later. Java is releasing new versions very often these days so I understand that it is easy to miss new features. It's probably a good idea to use the current LTS version for these kind of videos.
@@McCulloughAssociates plus there is no syntactic sugar for streams. In addition Linq will operate on any IEnumerable or IQueryable. Plus there is now IAsyncEnumerable also a target for Linq. I am not aware of anything similar in Java
There are so many books for each. Everyone has a different learning style, so hard to recommend a specific book. Take a look at my intro C# playlist also. ua-cam.com/play/PLXd94bZTzZ-QaMgLp41ZUb_w0sjLBGjUp.html I have a lot more content coming soon!
I am a C# fan. Easy to learn syntaxes. Programmers are well 'spoonfeeded' with built-in algorithms and data structures through its rich libraries, which helps speed up function implementations of the app.
@@kevinstefanov2841 programming is just assembling legos, some like to do it piece by piece not using anything prefabricated, others wants to make it fast. Thinking of programmers becoming "code monkeys" because they use stuff that has been normalized and simplified to make debugging and writing efficient and readable code more easy is as stupid as saying "people nowadays are stupid prefab users, back in the days I would have built my pc entirely myself"
@@quelqunderandom6143 and how is that stupid? that's literally what engineering is about - building stuff yourself from scratch. They can call themselves anything they want but not software ENGINEERS if all they do is use prefabricated ready-to-use bs lol
@@kevinstefanov2841 then go ahead and build your own computer from bottom up, component by component since you are an engineer. Elitism is idiotic, of course as things go on we are gonna move away from low level code, because there is no real need for it 90% of the time
when .net runs faster than java, java says 'hey, speed does not matter'; when java's mvc runs faster than webform/.net mvc, java says 'hey, .net sucks'
That's a strawman. No one said that speed does not matter. Performance is just a much more complicated topic than raw number crunching throughput (which may or may not matter, depending on usage scenario). That said, I believe everyone with a minimum of professional attitude can agree that both .NET and Java offer good enough baseline performance for the jobs they were designed to do, and both have their strengths and shortcomings in specific scenarios. Everything else is just noise coming from childish amateurs.
So why are very large systems such as core banking software, stock market and very large financial software implemented with Java, I have seen companies that still use Spring and ejb for banking software development.
Workforce - inertia, and most of those efforts began in the late 90's looking for a COBOL replacement. Java was blessed by everyone, including MS. Oddly enough, Java was designed as a desktop or applet development tool (hence lazy GC), not long running server applications. .Net was designed for server based apps (windows server, of course) and the marketplace used them exactly the opposite. Not saying the banks made the _wrong_ choice, but that they made an arbitrary choice. Also, the choices then weren't the same as the choices today.
@@McCulloughAssociates As far as I know, before .NET Core, .NET depended on Windows Server and was also paid. For this reason, companies are moving towards open source technologies such as Java. Do you think that .NET Core market is good? I want to learn new technology and I am very interested in .NET Core and C#.
@@shahramamiri6790 Well, the market doesn't always do what we want, but I am seeing a very strong demand for C# & ASP.Net developers. Without question, it is easier than Java _IF_ you already know it. In any case, knowing more than one language and platform makes you better at all of them.
No se trata si uno es mejor que el otro, se trata que si es empleable una persona que sabe del lenguaje... al final todo se reduce a la empleabilidad, si existe o no trabajo....
To me, eventhough c# seems nice to write, it seems alot more difficult to maneuver. Like where does things live, where are implementations etc? Things are splitted into multiple files with partials, ide seem to be not helptful at all you are trying to look up sourcefile implementations for an interface or an abstract class.
Well it s the symptom of a stranger in a strange land. The same could be argued for any toolset over language. Maven is not easy, nodejs makes you want to pull your hair, etc...
@@eugenpaval Not really. If you write java your idee will help you alot with finding implementations. That does not seem to be possible with c# sourcefiles, atleast not without alot of extra work. I don't agree with maven not being easy, it is pretty straight forward, and node js doesn't have a difficult classhiarchy to manouver in, as it is not class based/oop-based.
@Nein, not only Visual Studio finds the implementation but you can even see implementations of libraries you are using. Plus you can even set breakpoints in said libraries to help you understand why your call to a specific function does not perform the way you imagined.
the fact i can do this similar to js/ts makes me pick c#: var foo = new { // Some object props } Thats just one thing without a LinQs example or any of that and C# 12 is on another level.
C# is clearly the better language; Java is the worst language on the JVM which seems to be a lot of what you're comparing. Compare C# to a modern jvm language like kotlin and it's a whole lot closer. Java is the price you pay to get onto a platform: jvm, android, etc. Java the language is rarely chosen for technical reasons, usually its things like finding devs who know it, supporting legacy code bases, vendor integration, etc.
@@aliksargsyan2782 Technical merit is a small part of language success. Most DEVS would prefer C#, most CTOs wouldn't. Java came out during a time when people were charging for compilers, when there wasn't a portable class library etc. The 'free' java stuff created one of the largest and most vibrant OSS ecosystems in software. Remember, java was a loss leader for a hardware company Sunn. C# has a notorious vendor, bad blood from their fake java they were sued and lost over, closed source and not cross platform (its changed a lot over the decades)
I mean. On a core, fundamental principle i hate OOP enforcing languages but this is besides the point. If it wasnt for the fact that in the market i am, like out of 10 companies 8 will use java as backend, you have the odd one using Python and the remining one does use C# i would, in a Heartbeat, go with C# without even thinking about it. Modern C# might not be gods grace to programmers in terms of what a beautiful language can be like, but its more than acceptable and you are avoiding the JVM.
Your video helped narrow it down a bit more, thank you. I never touched C# but I played with Java for 3 weeks. At the moment I am 4 months into learning JavaScript. I have time to think about this but I figured in 8 to 12 months from now I would like to learn either C# or Java. From what you mentioned in this video could it be said that Java is light weight where C# is overly complex? My end goal is to learn one of these languages for backend and mobile. But I don’t want to spend years learning to many technologies or something overly complex, what is your opinion? Thank-you.
In my opinion, C# has more features built in, sure. But it does not make it more complex. Moreover, in professional Java development you will likely search for them, but it will be then some third party package implementation or your own boilerplate or even there will be no substitute. You just have more possibilities built in, but core is of the same complexity. Problem is different - I personally like C# much more but there more jobs on Java usually)
If I had to start learning a full language again, from scratch - I would go with C#. So many reasons why! Documentation on C# is FANTASTIC - Microsoft supported official doc.Microsoft site is just everything you could dream of. Visual Studio has all the reference information already built into it - you can quickly look up classes, interfaces and methods you are pulling, directly from within VS. Vast majority of C# programmers are American/Western, so there is massive amount of English speaking forums, and help. While Java is dominated by Indian guys, and so you won't find any good forums in english, at all lol Everything is 3rd party in Java - literally NO documentation, of any sort lolol Maybe some support on the CURRENT versions only, but anything 1-2 years older+, you are totally on your own. Go with C#, if you are in doubt. Javascript by the way, might give you incorrect perception of real programming - JS is not really a full language. So I would advise to quickly move into a good enterprise language, or you might get wrong ideas. Cheers, GL
@@victorbukowsky7496 I really appreciate the wisdom. Also, documentation is very important I noticed, perfect example React has really good documentation. Originally I was thinking about Vue but a lot of the documentation is decent. I felt React had better documentation which is why I decided to use this library. Also, I see where your going with learning JavaScript, its a complicated language. Class system is prototypical? it isn't like Java or C#, a class is a class. At the moment I had learned the fundamentals and I am learning to work with the DOM now. Once I have a handle on the DOM, CSS- flex-box, and high array functions. I will move onto React. After I have a good handle on React. Finally I will choose C#. Just want to make sure I know the tool kit well before adopting another tool set. But I appreciate your invaluable insight it is much appreciated. I am strongly considering C#. I will revue the documentation for C#, thank you once again.
@@DevlogBill yes, classes in Javascript are just syntactic sugar - meaning they just look like classes, but aren't'. For many reason, because there is no even compilation in Javascript anyway, it's all just interpreted runtime. DOM is great - this your foundation, for entire front end. What DOM really is just the browser object, that you are allowed to work with, using Javascript. But DOM is just an object, written in C++ or Swift for Apple or whatever a particular browser is written in. React - I would advise to wait with it. I know it, it's pretty confusing. If you want to learn front end framework - go with Angular, you won't miss out on that. Much better choice than React. Yes, React is hot, but it's weird, and has very limited niche - it's for highly reactive quick websites. You shouldn't clog your mind with that stuff right now. My advise - finish up with Javascript, maybe go into Angular, and then quickly move into C#. This is where the real programming is, and REAL MONEY is. Job market for C# is very hot, specially in the USA, Canada, etc. I don't know where you are. Skip Vue as well, don't waste time on it. It's junk anyway, I kinda know it - just skip it. Good luck, friend! lol you have a quite a road ahead of you, but it's massively fun. I enjoyed my trip. And money is ridiculous lol Plus freelancing/consulting possibility down the road.
@@victorbukowsky7496 I really appreciate your insight, you give a different perspective on things. What I think is confusing with React is JSX. It looks like JavaScript with HTML plugged into the code break. I hear from some developers that you could learn JSX and React first then jump into the fundamentals. But me personally? I figured it would be much smarter to get a strong grasp on the fundamentals since these libraries and frameworks are constructed for JavaScript. I will begin a framework around mid-May. What is the best approach to learn Angular? I believe the best approach is to take the entire framework Angular and learn the syntax first. Next learn about the modules and components next. What was your approach with learning Angular? Today I will download the documentation and visit the website to gain a better understanding of Angular. Also, I live in NYC so there is a strong market for C#, JavaScript, Java, etc. etc. When I check indeed I see jobs for C# but I keep on running into so many jobs for Java. But I noticed something. Most of those jobs from what it looks like I am not sure but it seems they are looking for people to update their back-end or maintain it. I don't see anything mentioned about creating new products using Java. Also, I downloaded some plugins for C# into my visual studio code, soon I will look into what is C#.
The funny thing is all that semantic abstraction turns out to be just bytes that were put in memory in a logical arrangement wich are sequentially read by the CPU wich reacts to them in a certain manner depending on their values and, in turn, outputs signals in certain ways as to control devices such as video cards, sound cards etc. so that we can see or hear the result of all that and use it to our advantage. LOL.
It's sad to see the comparison between Java and C# usually boiling down to syntax. This is the uninteresting part. Both, the Java and C# virtual machines are fascinating pieces of technology with wildly different approaches. C# goes all-out on static optimization, while the Java Virtual Machine is very dynamic and unmatched in terms of runtime analysis and dynamic optimizations. And each philosophies have their merit and use-cases. There's also performance implications in using async-await vs. Java Futures etc. Also, the actively developed parts of C# and Java are very different, trying to make up for what each language is lacking. With Java having unified generics and value types or Continuations and C# being more modular and portable, making it applicable in more use cases (WASM support, MAUI, .net core, etc.). Sure, syntax is the shiny thing that newcomers are fascinated by, but there is too much interesting technologies and investments being made. It's a shame not to see this being mentioned.
Syntax is the most important part of the language though because it's the core of the human/machine interface. Like Python isn't popular because it's fast it's popular because it's readable and LISP is unpopular because it's not.
@@abebuckingham8198 Of course syntax is the shiny thing that attracts novice programmers, but it tells you fairly little about the underlying semantics. On a syntax level, you would think that Properties are a clear advantage. But given the modern mentality of more immutability, they only let you do the wrong thing easier. You might also think that delegates are a cleaner approach to working with functions as data. But with functional interfaces, Java has function pointers directly integrated into the type system and all the advantages that come with it. Don't get me wrong, there are areas in which C# is the best de-facto choice. Blazor and WASM support just to name one unique advantage which is derived from its technology.
@@ImaginaryNumb3r The engineering problems are easy to solve, the social and communication challenges, not so much. Python isn't popular because it's fast, it's popular because it's readable and that's the advantage of clean syntax. Technical considerations are typically of lesser importance.
@@abebuckingham8198 if you say something like this then I can only assume that your major business semantics are basic IO operations, mathematical operations or data analysis where frameworks do all the heavy lifting. I come from Enterprise Software Engineering and Cloud where demands are very different.
@@ImaginaryNumb3r I have to write code that will be maintained by other people and I have to answer the phone if they call me because they can't figure out what I did. Most of these people do all of their programming in Excel. I'm told this is Dante's forgotten 10th circle of hell.
C# developer for 5 years. My company wants me to learn Java for new projects and I have 0 interest coding in Java smh. I feel like thats going backwards for my career
Unless some specific scenarios, I'd always choose C#. Your video gave me the impression that java tried to do more with less, which is an interesting idea for the implementation, but not for the programmer. There is one point I think you forgot to mention: the IDE you work with. I mean, if a new language pops up, one factor that will help it spread is having a good IDE. And I think C# in Eclipse would be way less usable.
I’m a complete beginner and about to start school for a bachelors in software engineering. I have the option to choose a Java or c# route. Anyone wanna help me on what to choose? I’m so torn about which one!
@@kirkshammett94 if you are new then just choose the one that has mlre job offerings in your market, it would be too confusing studying two or mlre la guages at the same time when you're new, just pick one and master it, on the I dustri you will have to learn other la guages but you can just learn them on demand
I think it would be more useful if you kept both the C# and Java syntax on screen at once so you can visually compare them. Instead of "transforming" the code into the different language, so you have to rewind to check the previous syntax.
As a developer who has a lot of experience in both of these languages, I believe you did a very good job in comparing the two. That said, I strongly believe if you CAN do what you want in C#, there's almost no argument that persuades you to use Java. Basically, if you have to use Java to use a certain library, by all means, do it. But if I had to choose either of these languages I would NEVER choose Java. There are so many things wrong with it (Unicode?)
Ya I'm not against 3rd party dependencies but I do cringe a little bit when I take one on. 😖
Generics.
Java's generics are the most annoying thing in the history of the universe.
Done both, i love javas simplicity. Who wants to drive a Mercedes If He can just fly
I love Java, have used it for over 20 years. I know it inside and out. It's a terrible language... ;-(
@Jan Krynicky Yes, but 'this.equals(that)' takes second place imo
You are missing 3 enormous benefits in C# :
- C# can build "unsafe" code ! You can manage un-managed memory, access it like in C !
- Fine grain C/C++ Interop, build -in.
- awesome async / await mode !
For me, C# seems to be more versatil and modern. No question about that.
why I love C#:
- Async / Await
- Extension Methods
- Expression Bodies
- Optional Params
- Ref, Out Params
- Auto Properties
- Events, Delegates
- Linq
- Structs
- Interop
and.....
string.IsNullOrEmpty(), an important feature that java lacks😆
For me is all about LinQ
@Gipsy_T. " 🎶 ... 'bout that LINQ, no bubble (sort!).
I'm all about that LINQ, 'bout that LINQ, no troubles.
Every API is threaded from the bottom to the top.... 🎶 "
Cuz you know, I'm all 🎶 ... 'bout that LINQ, 'bout that LINQ, no bubble (sort!).
I'm all about that LINQ, 'bout that LINQ, no troubles. (2x)
Every API is threaded from the bottom to the top.... 🎶
@@NickTheCodeMechanic 😄
..
Compiled Regex (with named groups, suckas!)
Async queues
Generics
Reflection
Roslyn compiler
IL code
EXPANDO😂
Native AOT
Cross Platform
Razor Pages (w HTMX)
Blazor SSR
Avalonia
Android support
CLR and C++ in same project
Sdk and runtimes separately installed
LTS support
Monthly updates
.... and soooo much more.
C# has less boilerplate, fantastic syntactical sugar features which make coding a breeze (Once you know them), extension methods are really awesome for configuring services for application startup (IServiceCollection). The new MinimalApi makes writing API endpoints super simple and fast for simple dev testing etc. All in all, it feels like a more modern language which has matured well, unlike Java. Sorry if I ruffled some feathers but it's just my opinion. :)
Try Groovy as a "Better Java" sometime.
Syntactically Java is very out of date, and in my mind it always will be until it can do simple things like auto properties (adding a library like Lombok that requires IDE plugins and build alterations doesn’t count), and more advanced things like Async Await.
I believe it’s advantage is that is has a good trusted ecosystem in spring, Apache commons, and a few others.
I want to say Kotlin is the answer here but even that language seems to stumble in a lot of places. At least that’s how it seems with my current understanding of it.
@@pauldanielmooney Sadly, Kotlin will always be limited by Java itself. It simply can't solve what a mess it has become.
@@pauldanielmooney Agree with everything that was commented here, by everyone. Completely. Yeah, Java is just out of date. And it can't change that - Oracle has to support backward compatibility with everything that was made before. So it's just stuck there, with 1990s format. Yep, Lombok is nice autoprops copy, but it's not that integrated, and requires another library. Etc.
@@staubsauger2305 Oh lord, I haven't even touched on Groovy lol More learning? When do I get to actually DO in Java? lolol Java is one big chore and headache, and all these half-arsed attempts to make it human - like Maven, Gradle, Groovy, Kotlin - it's just another layer of headaches. Instead of actually giving us simple tools to BUILD - Oracle is focused on pandering to their corporate overlords.
Another different is that Java developers wear glasses, because they can't C# ;)
😀😀
Get outta here 😂
Another difference is that java methods have a higher divorce rate
...
because they have constant arguments :)
This is true, i wear glasses because i can’t C# enough
😂
In 2008, I got the option to choose either PHP or Dotnet for my career path. But, now I am proudly saying that it was the best decision of my life forever. My current goal is to bag a C# Web Application Developer job in the USA, and I hope very soon will succeed.
i program in php all day for web and C# in the evening for personal desktop apps, I'm also using C++ for some heavy lifting. Programmers should see languages at tools, you don't pick just one to do everything, the right tool for the job. I don't care what language i'm coding in, so long as it's easiest way to get the job done. It's all just code, some languages are just better at certain things.
C# only has two characters in its name, whereas Java has four. Obviously C# is faster to type. Java on the other hand takes up more of your life, two characters more to be precise, every time you need to mention it in an email or doc, etc... Of course, I only ever use C.
the c# reads two characters, but it actually needs 3 keyboard strokes , the c , the shift and the 3 ;p)
@@yasirhantoush Yes, so?
I respectfully disagree; I think C# shows more character 😁
C is a bit flat in comparison, but is the base and generally the more major of the two! 🎶
You use C? What a waste of time! I exclusively use
you forget about async-await. one of the most important think that java doesn't have till now and c# was one of the first languages to introduce async-await.
We have futures in java
They meant the syntactic sugar comes with multitasking in c#, the syntax make asynchronous code looks like synchronous code and avoid callback hell
C# was in fact the very first to implement async await
C# will weep once Java Continuations arrive via Project Loom.
@@ImaginaryNumb3r and other hilarious jokes you can keep telling yourself
Microsoft sacrificed backwards compatibility by implementing generics from the ground up the right way. Java maintained backward compatibility by utilizing type erasure. However, there are more implications than just Reflection. The vast majority of generic programming surrounds the collection types, which use an array as their backing store, and the difference is particularly evident for primitive value types. If you wanted a Java List and the bools have to be converted to objects (boxed), they're taking significantly more space on the heap and getting scattered (your array now holds references to other heap locations). A .NET List uses an actual concrete array of bool behind the scenes, should hold the data in a contiguous block of memory, and doesn't suffer from the same inefficiencies.
@@ThiagoPagogna Java programs don't run for long enough to cause a BSOD, they consume all system memory and freeze up long before that happens. Cope.
"should hold the data in a contiguous block of memory"
And does.
Thank God for the competition created by Java. Otherwise, there would not be such a shining and powerfull language called c#. For more than 20 years I have been coming across such comparisons. In the beginning, it was "c vs java". C# takes features from java (vm, open-source philosophy), java takes features from kotlin (records) , c# (lambdas, virtual-threads), javascript (promises, declarative programming, reactive)(and golang latest version supports generics at last). The thing you have chosen is not only the language itself, it 's also the open-source community behind the scenes. Long live open-source, even the companies have been funding foundations to drive the open-source community.
Love your view on this, very well put.
Makes me happy when a language adopts features from another language.
Kotlin/Swift/Typescript front ends with a C# backend, and I have to say, languages are in a good place at the moment. All of the native front ends do a great job of not getting in the way while providing great developer experiences. C# and .NET are great as well, with batteries included. If I had to use the JVM, I would go with Kotlin over Java.
I like java because it's simple. When I program in C++, it looks a lot like java, and is easier to read in my opinion than C++ code I read on the internet that makes use of all C++'s special features.
c++ is diferente from C#
String-variable Interpolation is a nice syntax feature in C#
Generics not accepting primitive types was one of the things I was shocked by when I started using Java.
I'm still waiting for the time I can use Generics. I didn't see any use case for them🥲
This isn’t true, you can use the wrapper classes
@@NOTturke wrapper classes are classes, not primitive types. Integer and int are not the same thing.
@Jan Krynicky true, it is pretty annoying to have to have an entire object with methods just for a single value
4:55 C# dynamic is not a tuple. its a proper dynamic type, like a dynamic type in java script.
The video is full of errors and knowledge gaps; pretty much every single section has one.
Thank you for this Chuck. As someone trained on Java and C++ I'd been wondering for some time what exactly the difference was in C#. After watching this and your C++ vs C# video, I now have a much better appreciation of the differences.
Going to see if you've made any videos on Kotlin now, as I'm learning that language on the side for funsies atm.
Cheers.
Thanks!
As non programmer I enjoyed this content!
I believe in C# supremacy ! It feels more modern and Microsoft is upgrading it a lot since NET5 open-source. Anyway, I'll always respect Java and we'll still see it around for a while, but working with C# and Typescript for frontend (also Microsoft) is a great combination!
you forgot that C# gives you the option to write low level code. So i can just write my Application using all of C#s benefits and only write the performance critical parts in a unsafe way without having to write them in a whole other language.
I also like how C# adopts so many functional features, combining the best of both worlds
Also people forget how great C# interops with native libraries. Java on the other side often requires some kind of overhead
Amazing comparison! My main language is C# and I recently learned Java and... I don't hate Java per say, but it just seems inferior to C# in every way, especially since C# is now multiplatform (though I've only ever used Windows anyway).
My typical workflow relies heavily on things like properties, events, nullables, and LINQ, so whenever I use Java I'm constantly bumping into inconvenience after inconvenience. Even if they're minor, they add up to frustrate me quite a bit, so this video kind of validates those feelings lol.
Thank you so much!
My only comment is: you didn't mention database integration. I'm still a bit of a programmer newb but all my coder friends are clear: if you're going to build an application that is tied a database, go with C#. And I can't argue with that. I've done the integration in Java and it is annoying but I've seen it in C# and it was seamless.
Idk man, with spring boot and hibernate it's never been easier
Generic classes being generated for each generic type doesn't just matter for reflection. It also matters for performance and static fields. Java uses type erasure, which means generics are fake. Every value type is boxed to an object. C# uses real generics where value types are not boxed and can be accessed directly. C# generics are closer to C++ templates, but not exactly the same.
Yes, but C# doesn't use type-erasure, which inflates application sizes.
@@fnamelname9077 That's only true for AOT compiled applications, which most are not (native AOT is still in preview). The JIT creates the types on the fly at runtime so the application size can remain small. That's part of why AOT uses stripping to remove unused code to reduce application size.
@@protox4 True, but that's just changing a memory pressure for a computation pressure.
@@fnamelname9077 Well that's just the nature of software. There are always trade-offs.
@@protox4 One of the tradeoffs, is reducing the efficiency of coding in order to obtain the same computational result for a lower operating cost.
This is one of the best comparison videos i have ever come across. it cleared up lots of my doubts. Thank You
Glad it was helpful!
In Java i could not access Memory Mapped Files, also there is no unsigned,
I tried c# and it was super good.
Thank you.
@obeid_s In Java you can leverage memory mapped files using the RandomAccessFile class. I use it heavily for streaming in world data in my game engine.
Small clarification: Both Java and C# offer features through classes, but C# simply offers syntax aliases for these classes, which are sometimes structs. Like with the nullable example, the question mark is removed in CL and becomes a reference to the generic Nullable struct. You may use the struct like any other and the values are interchangable with variables defined using the nullable syntax, but IDEs may detect the use of the struct and suggest the designated syntax.
This also extends to LINQ for which the query syntax shown is an alias for a chain of LINQ extension method calls. This doesn't mean the lack of extension methods is preventing Java from having something comparabie to LINQ. In reality, you could always use method calls inside method calls just like you can in C# through the static Enumerable class. The reason LINQ is based on extension methods in the first place was to simplify the syntax when calling the methods. The query syntax was only added later to further, making it ressemble SQL.
As for checked exceptions, although there is no way to signal potential exceptions that will have an impact on the assembly, C# does support signaling of potential exceptions through XML documentation that references the assembly. This allows for an IDE to read the documentation file and show context-sensitive documentation including possible exception at the programmer's request.
I love syntactic sugar, makes it easier to write and read the codes.
Thanks for making this video, I was curious on the differences between these languages and you explained those differences very well!
learning C# for over 2 Years now and im loving it, for me, it is better as Java.
Newer languages stand on the shoulders of the great languages that preceded them. Java is great and we would not be here in software programming without Java. There would definitely be no C#. Microsoft took a lot of ideas from Java and added their own stuff to make it better and that's how C# was born. Initially, the languages were very similar but they are quite different now because of the effort put into developing it by Microsoft. It doesn't feel like there was enough effort and innovation put into the language after Java gained popularity. For this reason, Java feels quite outdated to me despite being a great language.
The only feature that Oracle cares about is backwards compatibility. The newest JVM will still run java applications from a lifetime ago. (Sometimes re-configuration is required.)
If that wasn't true, Java would already have moved beyond type-erasure. For that matter, look at how long Lombok has been around, before Oracle added records to java.
@Jan Krynicky Java's highly-regular syntax is one of its strengths. It's easy to parse - which is why it has such a rich ecosystem of automatic code-generating tools, why it's so easy for syntax-highlighters and debuggers to interpret, why it's always had great linting support. And more than anything - why it's so easy to work on collaboratively, at scale.
@Jan Krynicky That doesn't make any sense. The JVM is powerful and useful, but Java as a language is a value unto itself.
The greatest strength of "scripting" languages are that they "just run" - usually incorrectly. But they protect small minds from the psychic violence of being able to tell WTF they've programmed and how incorrect it is.
C# is pure comfort, compared to Java...
And also MS Visual Studio is the ultimate best editor by far!
I really wouldn't want to use anything else ever again.
Visual Studio does have some very comfortable features, but to me it felt cumbersome how many times it tried to incorrectly predict what I wanted to write. I could probably tweak it if I wanted to spend time with it, but I mainly use Java and IntelliJ has to be my #1 choice, i never had problems like I do with VS.
@@martinsandor707 bruh. You're talking about intellicode which is a copilot assistant. Just turn it off if you don't like it. "I don't like this car because there was a pack of bad tasting chocolates in the glove box".
@@martinsandor707Jetbrains makes Rider for C# which is almost the exact same IDE as intelliJ. You’d feel right at home with it.
Both are good, for me it depends on what I'm doing, but I do lean toward java, thers a Order about it that helps me remember more of my code for those big projects
The way Java handles generics has been a frustrating experience for me for many years.
No worries, Oracle is re-working on generics, maybe in 1-2 years it will be less frustrating
@@alessioantinoro5713 I'm afraid you are being overly optimistic on the timeline. Project Valhalla has yet to finish even "phase 1" (value types), and from there it's still a long way towards specialized generics. An inofficial estimate I've read on that is around 2025. And even that sounds optimistic to me.
@@cod3r1337 🤷
Thanks for the video Chuck. I'm starting a new position at work and have a flexible manager willing to put me on teams that either work with java or C#. I don't have much industry experience or experience with those languges outside of a few projects. This video helped me understand things differently and has me leaning towards joining the C# developers more than I already was. Thanks again
Chuck - great work, great content. Thank you for sharing your experience, your wisdom. I really like your level-headed language comparisons.
Having worked with software development for 40 yrs I cherish a valuable source when I see one. You earned my subscription after just one video.
I appreciate that!
Having to be a ‘soft’ engineer, this is what I realized. From a C/C++ bg I moved to php and C# in a month for some projects, after a year I started Java and what exactly what you say now is what I got to know after .net5 was being realized. What I can simply say is that Csharp is clean Java.
Pretty good summary. I think one historical difference had been start-up time. With Red Hat's Quarkus and using GraalVM, this issue has been fairly addressed. I think one area not covered may be library SDK Ecosystem in relation to Cloud Providers. If using Azure, both are covered fully, with edge to C# (broader functionality). If one is talking Google Compute Cloud or AWS, they may or may not be as fully comprehensive for C# as they are for Java. As for speed, as long as one follows standard best practices, either are adequate and you are correct, absolute speed really means another choice (C++, Rust, or even Golang depending on specific coding requirements).
i'm definitely in the C# camp... the last time i TRIED to do anything in Java I got totally lost just installing the tools. TO BE FAIR, it's very possible a Java guru would have the same reaction to getting started with C#.
I used to believe the same things about performance... and for the desktop you're right. it's fast enough -- and when it's not, optimize the hot path and move on. in the cloud however, performance can affect the bill you get at the end of the month -- so performance needs to be a higher priority.
anyway -- excellent and fair comparison of these languages without insulting anybody's mother ;)
With C# you can do so much! Dot net alone is huge add to that unity in your free time. Just so warm all around
Don't get worried if people say one language is better than the other. Learn whatever language that is most in demand in your area and after you land a job and gather enough experience and knowledge you can easily jump to any other language as you please
Pro tip: Start with BrainFuck ... then become a barista :D
C#/.NET has delegates (type-safe function pointers) whereas Java doesn't. Java's generics depend on Type Erasure, where a type parameter is essentially stripped when compiled, but .NET is completely aware of what type a parameter is at runtime. A List is a List at runtime.
This man deserves more subscribers.
"Is C# better than Java?"
Yes. I stand by how I describe it, that being: "C# is what Java would have been, if Java creators, before creating it, stopped to think: 'How do we design this language so that it makes sense and it's not shit?' "
Sounds very salty from someone enjoying a copy paste langage version of Java 🤣
lol this is some thick material. Awesome comparison. I work in both, and I greatly greatly prefer C# and .NET. I could go on for hours why - it's just everything is already packaged for you, from a single source really - Microsoft. In Java, you, the programmer, has to sit there and configure third-party tools - it's a major nightmare! Version matching is horrendous. Yes, there is Maven, etc. But it's another thing you have to waste time and effort on, just to make it work! And any issues with that - you are on your own, good luck lol!
"a single source really - Microsoft"
That exactly what kills C# for me. Being dependent on a single source is never a good idea. Especially if that source is Microsoft.
Sun's Java, like the referent one, has been running generational GC since late nineties. Technically speaking, GC is not mandatory part of JVM, and varius JVM implementations have completly different GC algorithms at any point of time. Being "generational" is also not a significat benefit or a failure, as implementation details are far more important than "generational", "copy", "segmented", "precise", "stop-the-world", "realtime" or whatever else comes.. Also for running server code, the most important aspect of GC, is ability of allocator to reuse unused "holes" within memoryspace as not using those leads to memory leak because of fragmentation. A classic C problem. The remedy for that is usually "copy collector", or in modern times, segmented one. Many "generational" GC algorithms are often also "copy collectors", but they don't have to be.
I have a feeling, that Chuck maybe was confused by G1GC because it is complicated and it was in development for a very long time, or maybe by J2ME due to it's difference in memory management or maybe by difference between "server" and "desktop" versions of JIT compilers (I actually don't know where else that "desktop" idea could came from)... But anyway, this part of the video could be better: I work with Java and I see evolution of the GCs: first it was CMS, then G1GC and now Shenandoah so I'm curious how it's going in the .Net world, especially after seeing the failure of Go's GCs, but eh...
The best video on this war between C# and Java.
Hey you should have warned me… That slap got me by surprise.
I know this is probably a horrible analogy, but it almost feels like when you compare C# and Java. It sounds like the same arguments the C and C++ camps debate over. But to be honest? If I had to choose, I think I would go with C# and .NET for the simple fact everything you need is all together under the .NET framework. Java feels all over the place. Don't get me wrong? I like Java as well; they feel like the same language even though they aren't. Basically, finding learning material for C# seems to be so far easier to find in comparison to Java. For example, for Java to set up my environment was such a difficult task. I had to download from Oracle I think they call it an SDK. Next, I forgot what they call it I had to download some file. finally, I downloaded IntelliJ which is a cool IDE and finally when I tried to run Java on VSCode, my code wouldn't run. I found the C# ecosystem a little bit easier to find material to learn from. Also, there are different versions of Java which isn't recommended to use? I found this confusing. For example, what is Java FX? With C# I downloaded Visual Studio and I quickly found lots of material for how to get started and had an easier time figuring things out. At the moment I stopped this, and I am purely focused on JavaScript. But after I learned React, I will pick up most likely Java because of the huge job market. I am in NYC, and I can tell you that from indeed.com there were only 237 jobs post for C# and .NET and over 1,227 jobs post for Java. Despite what my personal feelings are if you want to find your first job you have to go where everyone fishing to catch fish. Sorry for the horrible analogies but I hope you get the point. This is from a newbie's perspective I am not a professional. This was my struggle as a newbie so far.
Also, I would like to thank everyone for providing me with such insightful advice throughout my learning path. It has given me much needed guidance throughout these past couple of months.
A very interesting explanation. I also noticed that C# seems to be more adapted for Virtual & Augmented reality developer.
Miss anonymous classes in C# which has been in Java from the beginning. C# supports anonymous methods (delegates and lambda expressions) and types (properties) but for some reason not full classes.
Anonymous classes are supported in C# albeit most programmers will use them just to bunch together a set of properties. However an astute observer may notice that a property can be in fact a lambda. These classes are extremely useful in Linq, especially in fluent form when results from previous method calls are chained in the next call as anonymous objects.
You cannot compare the two because C# is one of the most advanced programming languages and has one of the best compilers on the planet and Java is so far down the list as far as performance, syntax, and popularity is concerned that it just cannot compare.
For sane and comfy ecosystem: c#
For more jobs: Java.
I go with Java... I need that job
If It wasn't for Java I probably would have gave up programming as I hated C at Uni. Then Java doing android games got me interested in game engines so Unity and C# never looked back since! A sprinkle of Html/css/js, tiny bit of python but don't get the hype and I use some C++/Blueprints on UE4/5, but C# is my fav language...so far will take something special to beat C# for me anyway. ✌
Python is the worst language, it's like a worst version of Javascript and Javascript has gotten much better in recent years. The whole point of the language is to be needlessly complicated so academic types can pretend they are smarter then everyone because they write unreadable code.
@@FilipCordas I agree JS has gotten better especially after ES5/6, I like flow but prefer Typescript obviously coming from C/C++/Java/C# background. I made a Django ecommerce project and I just did not get where things were coming from and I just felt why do people Love Python? Because it has less code? Ì think as well def__init__(self) I just don't think is very intuitive coming from a different language, not a fan of looking at __init__ calling a function def and having(self). There are parts of Python I like others I dont, Var everywhere can lead to problems fast and Django I just can't see me using it again, I did however like the built in admin. I really have yet to come across my no.1 server side framework. I'm toying with Express, made some simple asp. Net sites nothing large. I have done some simple php stuff too but not yet full done a full laravel project, I will after express. Ive read some Golang its interesting. I might even do a Spring project as well. ROR I just feel it will be a mix of Python/JS, could be wrong and might try that as well, but my main thing is games so only do web now and again mobile not so much anymore. But yeah I hear you with Python, the scripters love it fir automation on Unix systems along with bash. Thats prob why its popular plus its recommended as starting language and a lot never leave it.
If a developer asked me which the learn, one of my first questions would be what kinds of companies do you want to work for? If you want to work on line of business apps in established companies, C#. If you want to work in west coast startups or big tech, Java. I definitely like the C# language and tool stack better, but because C# started out life as Windows-dependent, Java ended up dominant in cultures that didn’t want to depend on Windows. Thankfully the dependency went away, but the inertia from that history remains
C# every day and twice on Sunday.
in my opinion, with java the difference between theory and implementation is minimal as compared to C#. What i mean is that if the theory has 3 components in a concept, then the implementation of that concept in Java would also have 3 components in code. But, in C# the implementation would have 5-10 extra components that we would have to understand. Example, like, in this video you see that java uses existing concepts to implement new functionality, but c# has introduced a separate standard/princple/concept just to add a new feature. that is why there are more than twice as many keywords in C#.
Java class library is more natural, while with C# it seems like every different concept has been implemented by a very different person. Although, with .NET Core things are getting better.
After many years of C#, I thought it would be a cakewalk to work in Java. After all, they are virtually identical languages aren't they?? NO!!! I had a very tough time trying to actually work in Java. There were numerous technical quirks and annoyances that were difficult for me to surmount. I gave up!!
You Can make pretty blazing fast applications in C#, but it's no magic bullet you'll need to put in the same effort into the code and algorithms as you would in a lower level language to achieve it.
Just a correction, Java recently added records.
Yeah, we produced this prior to J18 release
@@McCulloughAssociates I suspected as much, and that is totally fine. Both languages are still evolving allot so a statement that was true a moment ago is not necessarily true now. Anyway I found your video to be very informative and provides a good overview of either language. Keep up the good work.
It might be something from one of the newest versions but java actually has Record classes. (With a record keyword instead of class)
I wouldn't mind a deep explanation of checked exceptions and why they are an anti pattern.
Think of it this way - exceptions (c++) replaced return codes. Return codes required each function on the call stack between the error and the handler to recognize and propagate the error. Lots of points of failure. Exceptions allow the thrower and the catcher to be the only code to be exception aware - everything else is exception illiterate. Forcing each method to declare a throw puts us back into the return code paradigm.
In practice, error conditions are usually considered in later iterations. An error detection would occur in lower level code whilst handling in application layer code. One would have to modify all of the code inbetween with the throw declarations. Take HttpServlet as an example. The doXxx methods all throw Servlet and IO exceptions. A subclass probably invokes other methods that might throw SQL exceptions. The override can only throw the declared exceptions. Many developers make the mistake of catching and dumping the SQL exception. The right answer is to catch and rethrow one of the declared exceptions or runtime exception. This is just more code where mistakes can be made. If the exception were just a runtime (unchecked) to start with, maintenance would be much easier because the middle code wouldn't have to deal with it. This is why the DispatcherServlet in Spring catches checked exceptions and rethrows runtime exceptions - so that the application code doesn't have to get boxed into throw decls.
Stroustrup cites a similar scenario to justify the change in C++ 11 to have the compiler ignore exception declarations. It looked good on paper, but in reality, exception declarations on function signatures caused more harm than good.
@@McCulloughAssociates wow. Thanks!
@@McCulloughAssociates great explanation! I recall the war between proponents and opponents of checked exceptions when they were introduced
You were actually helpful. I took no offense to the fact Java is slow. It blocking IO vs Node.js Non-blocking IO is something I knew. C# being faster then Java is not something I am surprised at even though I have been in Java for 27 years.
I got a book out of the library on Java once. The librarian said she had been there and highly recommended it.
Hi McCullough, I know Java and C# are both OOP languages but the language I am learning at the moment JavaScript isn't? JavaScript is prototypically written. I find this very confusing. What exactly is prototypical? Would this hinder my learning or understanding of what real OOP is in comparison to Java or C#? Which is real OOP? I am at the stage where I understand the fundamentals and I am trying to learn more advance topics with JavaScript like recursive functions and gain a better understanding of pure functions versus class-based functions. Eventually I will migrate to either Java or C# for a back-end language. I am trying to learn JavaScript on a deep level so that I am able to better understand other languages with better ease when I move onto the next one. Or would it be best if I gained a deeper knowledge of languages like C# and Java versus learning from a prototypical language like JavaScript since Java and C# are true OOP languages? What would be your recommendations? Thanks McCullough most appreciative.
Great question. But the answer is a little tough to elaborate in a comment! For basic stuff like loops, conditionals and functions, conceptually similar. I think strongly typed vs untyped JavaScript is as big a hump as perhaps the object oriented features. Remember, ultimately everything executes machine code using memory, cpu, and IO.
I have several videos on SOLID design- take a look. They might shine some light on OOP concepts
@@McCulloughAssociates OK, I will check out your videos on solid design. I think I may have heard of solid design with C#, sounds interesting, thank you for the direction.
Java doesn’t support unsigned numeric types which can be a rather significant omission depending on the application requirements
To be honest, yes it's not buildt in, but you can easily get them using an "extended" std library such as Guava or Apache Commons
Java was designed for Internet Applets. The Windows Team wanted it for Business Apps. It catches errors better than C++.
5:17
❤
Issues with running .NET anywhere? Been developing in Windows .NET that run in a Linux server. Never had any issue during deployment. That comment confused me.
i think java's remained current thank to spring, spring is used in a lot of big companies and it's a great framework, i would say the best in the industry
Great video, but there is one thing missing here - comparing the project structure. In modern C# you have 5 lines in a csproj for, and you already are able to build, run and debug the program both by running "dotnet build" command, and in Visual studio.
For Java, at least in templates, it's by far way more complicated. First of of all, you need to know me syntax, groovy (while everyone knows basic XML). Secondly, you cannot use javac, if you want to have any maven dependency, you need Gradle to compile.
Please, correct me if I'm wrong, but I tried to replicate few programs in Java to compare them myself and got stuck at the setup part - I just wanted single Java file with ability to add dependencies and to be able to F5 debug in InteliJ. Never got there, either in Java nor Kotlin, just a simple console app. I admit, it was only one evening of trying, but in other evenings I managed to setup Zig, Rust, node.js, Go without any issues
@@ThiagoPagogna What's the point in wasting time on that?
Thanks for the video sir, great explanation!, i want to move into C# .NET environment from Java, and found this video and i could get an overview about C# development
C# allows C++ inside the code (with the proper compiler settings). I prefer C# over Java, and recently played around with Kotlin for the first time (Android relies on it heavily). They both work, but I found C# just prettier, feels better, makes more sense to me. Java feels like it's somewhere between C++ and C# and with all the 3rd party libraries, I often find myself lost in the maze of different (and often terrible) naming conventions and bad documentation. Kotlin doesn't have that problem (as much), but that's probably for the same reason C# doesn't have that problem (as much); A big and solid enough foundation, support and use by others for the time and effort put into making great documentation. I'm not against Java by any means, but it just doesn't work for me 😅
WHAT?? C++ inside the code? Who ever made you believe that?
You probably just mean unsafe programming with pointers, however that's still far from C and C++. And it's not even a real subset of these languages, since there are multiple fundamental differences as well.
@@jongeduard experience made me believe that 🤣
@@rolandtennapel5058 Well then you need some more experience, because there are fundamental differences. 😂😂
C# target multiple platforms, write once execute everywhere like web, Windows, Android, Mac
.Net MAUI uses c# will point to Windows, Android, and Mac. if you are a C# developer then I can say that you are an android developer, IOS developer and😁 windows app developer and web developer😃😃
Xamarin has been around for well over a decade many companies have apps developed in it. Dotnet MAUI is a new push to simplify and clean up Xamarin. It's early days for it but looks promising, so more inroads. Flutter/ReactNative/Ionic there are no cross platform winners.
Is your benchmark with our without warm-up? (That the JVM is slow before warm-up would not be that surprising, I think.)
Hi, great question. Ran the code just as it appears. However, since the code iterates thousands of loops, the respective vm''s "warmed up."
I also ran the C# code marked as *unsafe* which disables the runtime safety checks. It did not make a huge difference.
In order to _warm up_ the VM, I think one would have to write an additional layer to run the code shown several times within a single execution.
Homework!
@@McCulloughAssociates Did you use tools like JMH which has warmup included as a separate feature. It would be interesting to see how quick each VM is when they had warmups included.
I wonder why chacked exceptions are a bad Idea? Because without being a Java Dev, it sounds really great. It always bothered me in C# that you never know when a method could throw.
It is good in theory, but in practice it can be a problem.
Think about the HttpServlet class in Java. To create a servlet, one must subclass and override doGet, doPost, etc. The superclass methods declare throws ServletException and IOException. These must be replicated in the override. However, most developers will access a database that throws SqlExceptions. Now the developer must try/catch those. A common programming error is to simply ignore the error, leaving the application in a 'good' state even though the operation failed. The correct move is to rethrow a runtime or servlet exception with the original nested. This clutters up the code and doesn't add any value.
Code that can really handle the exception probably doesn't care what the problem is. It will simply log the error and redirect the user to a sanitary error page. Having all the layers of code in between have to be exception aware defeats the purpose (essentially becoming a return code that has to be propagated)!
Bjarne Stroustrup explains the reasoning for dropping the feature in C++ 11 by saying after decades of use, most applications handle all exceptions the same way near or in main and all the exception declaring just made everything more cumbersome and error prone.
The best thing Java has going for it is how relatively easy it is to port to C# ;)
It seems like you are doing this comparison with an old version of Java. There is another type specifier that you said is only in C#, Record. BTW Enums in Java are much better than in C#. And when mentioning Linq, you could have also shown Streams. The way it is done seems a tiny bit biased.
Thanks for your comment!
Yes, latest version of Java 18 has records. The video was produced before the release of J18 in March 2022.
Our original script included a mention of Streams in the Linq topic, however, it was cut because Streams only apply to collections and files while Linq can also operate on data sources (relational databases) and includes a query language.
@@McCulloughAssociates Thank you for finding time to answer. I like the video, I just wanted to point out a few inacuracies I noticed.
About the Records thing, Records were part of the Java 14 release in 2020 as a preview feature and then released fully in Java 16 a year later. Java is releasing new versions very often these days so I understand that it is easy to miss new features. It's probably a good idea to use the current LTS version for these kind of videos.
@@McCulloughAssociates plus there is no syntactic sugar for streams. In addition Linq will operate on any IEnumerable or IQueryable. Plus there is now IAsyncEnumerable also a target for Linq. I am not aware of anything similar in Java
Great video, could you recommend a beginner book for both Java & C#? Thanks!
There are so many books for each. Everyone has a different learning style, so hard to recommend a specific book.
Take a look at my intro C# playlist also.
ua-cam.com/play/PLXd94bZTzZ-QaMgLp41ZUb_w0sjLBGjUp.html
I have a lot more content coming soon!
I would be interested on you take on Swift. Maybe in comparison to C#, which is relatively close.
I am a C# fan. Easy to learn syntaxes. Programmers are well 'spoonfeeded' with built-in algorithms and data structures through its rich libraries, which helps speed up function implementations of the app.
which also results in the programmers becoming code monkeys rather than actual software engineers xD
As the world moves to quick implementation, it is better to "package" the backbones and focus on solving business problem!
@@kevinstefanov2841 programming is just assembling legos, some like to do it piece by piece not using anything prefabricated, others wants to make it fast. Thinking of programmers becoming "code monkeys" because they use stuff that has been normalized and simplified to make debugging and writing efficient and readable code more easy is as stupid as saying "people nowadays are stupid prefab users, back in the days I would have built my pc entirely myself"
@@quelqunderandom6143 and how is that stupid? that's literally what engineering is about - building stuff yourself from scratch. They can call themselves anything they want but not software ENGINEERS if all they do is use prefabricated ready-to-use bs lol
@@kevinstefanov2841 then go ahead and build your own computer from bottom up, component by component since you are an engineer. Elitism is idiotic, of course as things go on we are gonna move away from low level code, because there is no real need for it 90% of the time
C# > Java
(oops forgot.. subjective warning applied)
when .net runs faster than java, java says 'hey, speed does not matter'; when java's mvc runs faster than webform/.net mvc, java says 'hey, .net sucks'
Webforms have been dead for a while now
That's a strawman. No one said that speed does not matter. Performance is just a much more complicated topic than raw number crunching throughput (which may or may not matter, depending on usage scenario).
That said, I believe everyone with a minimum of professional attitude can agree that both .NET and Java offer good enough baseline performance for the jobs they were designed to do, and both have their strengths and shortcomings in specific scenarios. Everything else is just noise coming from childish amateurs.
This is the first Java v C# video that is up to date, and does a wonderful comparison of the two languages. Too bad it doesn't mention async await.
What Does async & await Really Do in C#? Learn all about Async Await in C#
ua-cam.com/video/uhNVM_7CXu4/v-deo.html
Or ExecutorService class and Future Interface in java
Please post a video between Java vs C# vs Python. It's my humble request.
So why are very large systems such as core banking software, stock market and very large financial software implemented with Java, I have seen companies that still use Spring and ejb for banking software development.
Workforce - inertia, and most of those efforts began in the late 90's looking for a COBOL replacement. Java was blessed by everyone, including MS. Oddly enough, Java was designed as a desktop or applet development tool (hence lazy GC), not long running server applications. .Net was designed for server based apps (windows server, of course) and the marketplace used them exactly the opposite.
Not saying the banks made the _wrong_ choice, but that they made an arbitrary choice. Also, the choices then weren't the same as the choices today.
@@McCulloughAssociates As far as I know, before .NET Core, .NET depended on Windows Server and was also paid.
For this reason, companies are moving towards open source technologies such as Java.
Do you think that .NET Core market is good?
I want to learn new technology and I am very interested in .NET Core and C#.
@@shahramamiri6790 Well, the market doesn't always do what we want, but I am seeing a very strong demand for C# & ASP.Net developers. Without question, it is easier than Java _IF_ you already know it. In any case, knowing more than one language and platform makes you better at all of them.
Does the dotnet vm take less time to spin up than the jvm?
Yes dotnet is faster. Also when compiled with AOT you get instant startup times like in C++
No se trata si uno es mejor que el otro, se trata que si es empleable una persona que sabe del lenguaje... al final todo se reduce a la empleabilidad, si existe o no trabajo....
I am really missing async/await in Java
Only seen the start of the video so far but it seems a tad harsh to include type names as keywords since they are really not at all keywords.
Simple (although crude) way to demonstrate feature implementation as core language vs library.
To me, eventhough c# seems nice to write, it seems alot more difficult to maneuver. Like where does things live, where are implementations etc? Things are splitted into multiple files with partials, ide seem to be not helptful at all you are trying to look up sourcefile implementations for an interface or an abstract class.
Well it s the symptom of a stranger in a strange land. The same could be argued for any toolset over language. Maven is not easy, nodejs makes you want to pull your hair, etc...
@@eugenpaval Not really. If you write java your idee will help you alot with finding implementations. That does not seem to be possible with c# sourcefiles, atleast not without alot of extra work.
I don't agree with maven not being easy, it is pretty straight forward, and node js doesn't have a difficult classhiarchy to manouver in, as it is not class based/oop-based.
@Nein, not only Visual Studio finds the implementation but you can even see implementations of libraries you are using. Plus you can even set breakpoints in said libraries to help you understand why your call to a specific function does not perform the way you imagined.
the fact i can do this similar to js/ts makes me pick c#:
var foo = new {
// Some object props
}
Thats just one thing without a LinQs example or any of that and C# 12 is on another level.
Absolute the best video, thats what i needed thanks Chuck
C# is clearly the better language; Java is the worst language on the JVM which seems to be a lot of what you're comparing. Compare C# to a modern jvm language like kotlin and it's a whole lot closer.
Java is the price you pay to get onto a platform: jvm, android, etc. Java the language is rarely chosen for technical reasons, usually its things like finding devs who know it, supporting legacy code bases, vendor integration, etc.
Agree 100%!!!
If Java worst as you said then explane me why the most enterprise applications prefer Java instead of C# ?
@@aliksargsyan2782 Technical merit is a small part of language success. Most DEVS would prefer C#, most CTOs wouldn't.
Java came out during a time when people were charging for compilers, when there wasn't a portable class library etc. The 'free' java stuff created one of the largest and most vibrant OSS ecosystems in software. Remember, java was a loss leader for a hardware company Sunn.
C# has a notorious vendor, bad blood from their fake java they were sued and lost over, closed source and not cross platform (its changed a lot over the decades)
I mean. On a core, fundamental principle i hate OOP enforcing languages but this is besides the point. If it wasnt for the fact that in the market i am, like out of 10 companies 8 will use java as backend, you have the odd one using Python and the remining one does use C# i would, in a Heartbeat, go with C# without even thinking about it. Modern C# might not be gods grace to programmers in terms of what a beautiful language can be like, but its more than acceptable and you are avoiding the JVM.
Your video helped narrow it down a bit more, thank you. I never touched C# but I played with Java for 3 weeks. At the moment I am 4 months into learning JavaScript. I have time to think about this but I figured in 8 to 12 months from now I would like to learn either C# or Java.
From what you mentioned in this video could it be said that Java is light weight where C# is overly complex?
My end goal is to learn one of these languages for backend and mobile. But I don’t want to spend years learning to many technologies or something overly complex, what is your opinion? Thank-you.
In my opinion, C# has more features built in, sure. But it does not make it more complex. Moreover, in professional Java development you will likely search for them, but it will be then some third party package implementation or your own boilerplate or even there will be no substitute. You just have more possibilities built in, but core is of the same complexity. Problem is different - I personally like C# much more but there more jobs on Java usually)
If I had to start learning a full language again, from scratch - I would go with C#. So many reasons why! Documentation on C# is FANTASTIC - Microsoft supported official doc.Microsoft site is just everything you could dream of. Visual Studio has all the reference information already built into it - you can quickly look up classes, interfaces and methods you are pulling, directly from within VS. Vast majority of C# programmers are American/Western, so there is massive amount of English speaking forums, and help. While Java is dominated by Indian guys, and so you won't find any good forums in english, at all lol Everything is 3rd party in Java - literally NO documentation, of any sort lolol Maybe some support on the CURRENT versions only, but anything 1-2 years older+, you are totally on your own. Go with C#, if you are in doubt. Javascript by the way, might give you incorrect perception of real programming - JS is not really a full language. So I would advise to quickly move into a good enterprise language, or you might get wrong ideas. Cheers, GL
@@victorbukowsky7496 I really appreciate the wisdom. Also, documentation is very important I noticed, perfect example React has really good documentation. Originally I was thinking about Vue but a lot of the documentation is decent. I felt React had better documentation which is why I decided to use this library. Also, I see where your going with learning JavaScript, its a complicated language. Class system is prototypical? it isn't like Java or C#, a class is a class.
At the moment I had learned the fundamentals and I am learning to work with the DOM now. Once I have a handle on the DOM, CSS- flex-box, and high array functions. I will move onto React. After I have a good handle on React. Finally I will choose C#. Just want to make sure I know the tool kit well before adopting another tool set. But I appreciate your invaluable insight it is much appreciated. I am strongly considering C#. I will revue the documentation for C#, thank you once again.
@@DevlogBill yes, classes in Javascript are just syntactic sugar - meaning they just look like classes, but aren't'. For many reason, because there is no even compilation in Javascript anyway, it's all just interpreted runtime. DOM is great - this your foundation, for entire front end. What DOM really is just the browser object, that you are allowed to work with, using Javascript. But DOM is just an object, written in C++ or Swift for Apple or whatever a particular browser is written in. React - I would advise to wait with it. I know it, it's pretty confusing. If you want to learn front end framework - go with Angular, you won't miss out on that. Much better choice than React. Yes, React is hot, but it's weird, and has very limited niche - it's for highly reactive quick websites. You shouldn't clog your mind with that stuff right now. My advise - finish up with Javascript, maybe go into Angular, and then quickly move into C#. This is where the real programming is, and REAL MONEY is. Job market for C# is very hot, specially in the USA, Canada, etc. I don't know where you are. Skip Vue as well, don't waste time on it. It's junk anyway, I kinda know it - just skip it. Good luck, friend! lol you have a quite a road ahead of you, but it's massively fun. I enjoyed my trip. And money is ridiculous lol Plus freelancing/consulting possibility down the road.
@@victorbukowsky7496 I really appreciate your insight, you give a different perspective on things. What I think is confusing with React is JSX. It looks like JavaScript with HTML plugged into the code break. I hear from some developers that you could learn JSX and React first then jump into the fundamentals. But me personally? I figured it would be much smarter to get a strong grasp on the fundamentals since these libraries and frameworks are constructed for JavaScript.
I will begin a framework around mid-May. What is the best approach to learn Angular?
I believe the best approach is to take the entire framework Angular and learn the syntax first. Next learn about the modules and components next. What was your approach with learning Angular? Today I will download the documentation and visit the website to gain a better understanding of Angular.
Also, I live in NYC so there is a strong market for C#, JavaScript, Java, etc. etc.
When I check indeed I see jobs for C# but I keep on running into so many jobs for Java. But I noticed something. Most of those jobs from what it looks like I am not sure but it seems they are looking for people to update their back-end or maintain it. I don't see anything mentioned about creating new products using Java.
Also, I downloaded some plugins for C# into my visual studio code, soon I will look into what is C#.
im pretty sure they ve added records in later versions of the jdk
Can you make a video on JavaFX vs WPF ?
Absolutely! Will put that in the hopper. Look for it soon!
The funny thing is all that semantic abstraction turns out to be just bytes that were put in memory in a logical arrangement wich are sequentially read by the CPU wich reacts to them in a certain manner depending on their values and, in turn, outputs signals in certain ways as to control devices such as video cards, sound cards etc. so that we can see or hear the result of all that and use it to our advantage. LOL.
It's sad to see the comparison between Java and C# usually boiling down to syntax. This is the uninteresting part.
Both, the Java and C# virtual machines are fascinating pieces of technology with wildly different approaches. C# goes all-out on static optimization, while the Java Virtual Machine is very dynamic and unmatched in terms of runtime analysis and dynamic optimizations. And each philosophies have their merit and use-cases.
There's also performance implications in using async-await vs. Java Futures etc.
Also, the actively developed parts of C# and Java are very different, trying to make up for what each language is lacking. With Java having unified generics and value types or Continuations and C# being more modular and portable, making it applicable in more use cases (WASM support, MAUI, .net core, etc.).
Sure, syntax is the shiny thing that newcomers are fascinated by, but there is too much interesting technologies and investments being made. It's a shame not to see this being mentioned.
Syntax is the most important part of the language though because it's the core of the human/machine interface. Like Python isn't popular because it's fast it's popular because it's readable and LISP is unpopular because it's not.
@@abebuckingham8198
Of course syntax is the shiny thing that attracts novice programmers, but it tells you fairly little about the underlying semantics.
On a syntax level, you would think that Properties are a clear advantage.
But given the modern mentality of more immutability, they only let you do the wrong thing easier.
You might also think that delegates are a cleaner approach to working with functions as data.
But with functional interfaces, Java has function pointers directly integrated into the type system and all the advantages that come with it.
Don't get me wrong, there are areas in which C# is the best de-facto choice. Blazor and WASM support just to name one unique advantage which is derived from its technology.
@@ImaginaryNumb3r The engineering problems are easy to solve, the social and communication challenges, not so much. Python isn't popular because it's fast, it's popular because it's readable and that's the advantage of clean syntax. Technical considerations are typically of lesser importance.
@@abebuckingham8198 if you say something like this then I can only assume that your major business semantics are basic IO operations, mathematical operations or data analysis where frameworks do all the heavy lifting.
I come from Enterprise Software Engineering and Cloud where demands are very different.
@@ImaginaryNumb3r I have to write code that will be maintained by other people and I have to answer the phone if they call me because they can't figure out what I did. Most of these people do all of their programming in Excel. I'm told this is Dante's forgotten 10th circle of hell.
C# developer for 5 years. My company wants me to learn Java for new projects and I have 0 interest coding in Java smh. I feel like thats going backwards for my career
Unless some specific scenarios, I'd always choose C#. Your video gave me the impression that java tried to do more with less, which is an interesting idea for the implementation, but not for the programmer.
There is one point I think you forgot to mention: the IDE you work with. I mean, if a new language pops up, one factor that will help it spread is having a good IDE. And I think C# in Eclipse would be way less usable.
I’m a complete beginner and about to start school for a bachelors in software engineering. I have the option to choose a Java or c# route. Anyone wanna help me on what to choose? I’m so torn about which one!
Either. Learn both, and c++. The language isn’t the issue. Languages come and go. Be above it.
@@kirkshammett94 if you are new then just choose the one that has mlre job offerings in your market, it would be too confusing studying two or mlre la guages at the same time when you're new, just pick one and master it, on the I dustri you will have to learn other la guages but you can just learn them on demand
I think it would be more useful if you kept both the C# and Java syntax on screen at once so you can visually compare them. Instead of "transforming" the code into the different language, so you have to rewind to check the previous syntax.
Thank goodness for pause and rewind!
@@McCulloughAssociates "Thank goodness for crutches, now you don't need that leg surgery".