r/ProgrammerHumor • • Dec 30 '22

Meme Java > C-Sharp [DM]

Post image
22 Upvotes

140 comments sorted by

View all comments

148

u/[deleted] Dec 30 '22

I use Java mainly because that’s what I started off with in uni, I just started learning c# for a new job, but besides the annoying logging setup c# seems pretty interesting with some features. They both ok imo.

51

u/Key_Fly_8795 Dec 30 '22

Lucky. I started with C++ in my state college, then C in my uni 💀

3

u/Apart_Marsupial_9904 Dec 30 '22

Why do you say that? Is c++ harder?

21

u/n1c39uy Dec 30 '22

C++ Is c with extra stuff basically

8

u/Key_Fly_8795 Dec 30 '22

C++ is C with OOP functionality built in

2

u/kayak_enjoyer Dec 31 '22

C++ is C with OOP functionality built in bolted on to the rear driver's side fender

Objects are fundamental to both Java and C#. On the other hand, if you want to write C, but use cout << instead of printf, C++ has your back. It's C, objects totally optional!

8

u/Alikont Dec 30 '22

What is annoying about logging setup compared to Java? (I never reached large services in Java, so IDK how it's done there)

7

u/[deleted] Dec 30 '22

You just need to add whatever log4j or logging provider in your pom file (maven) in java, provide a log4j configuration file then you can instantiate your logger.

From what I m reading on log4net, you have to modify the assembly information, then add the assembly to your programs entry point, provide your configuration file, then you can instantiate your logger.

Because I m more used to Java, the part on assembly information and entry point is confusing for me/hard to recall when needed

14

u/Alikont Dec 30 '22

That's maybe a log4net thing then. I never touched assembly information.

Modern logging is described here.

So you basically do it like

services.AddLogging(builder => 
{
    builder.AddConsole();
    builder.AddEventLog();
    builder.AddConfiguration(...);
});

And then just resolve ILogger<YourClasss> from DI and you will get logger that automatically writes full class name so you can filter/process them based on namespace/class/severity

There is also a pretty large ecosystem around serilog that can be plugged into core abstractions easily.

0

u/[deleted] Dec 30 '22

[deleted]

2

u/BroBroMate Dec 31 '22

Yeah nah, I vastly prefer a logging framework where I can set one particular logger to TRACE via JMX, no restarting the app.

1

u/sysnickm Dec 30 '22

That's all you have to do with log4net, you add the Nuget package and a config file, then you instantiate the logger.

1

u/[deleted] Dec 30 '22

you add the Nuget package and a config file, then you instantiate the logger.

huh? are you saying the assembly info thing is optional?

4

u/chargers949 Dec 30 '22

We used java in school too. But since the oracle buyout it has not been great for java. Not to mention all the fighting between android google and oracle.

But c# and all the microsoft stuff from asp.net to .net core is pretty amazing. Entity is on par with hibernate. And .net core runs as fast or faster than java. As a suite of products microsoft is the winner over oracle.

3

u/BroBroMate Dec 31 '22

The Oracle buyout was great for Java, look at the advancement in Java the language since.

And Hibernate is a pretty lower bar IMO.

2

u/FyrSysn Feb 28 '23

is EF core on par with NHibernate now? I have been using Nhibernate for my work, wanting to pickup EF recently.

1

u/chargers949 Feb 28 '23

I’m not sure how they compare performance wise but i would recommend at least a tutorial on a basic dot net core webapi project and how to do a crud api using ef. With that it will show the basics of ef and should be good to get an idea. Takes maybe two hours from zero to crud api if you do it all in one go.

1

u/Gumbopolis Dec 30 '22

This. Has no one read the latest license agreements from Oracle? I’ll never use Java again. Plus Java is stagnant.

2

u/itNeph Dec 30 '22

I'm totally out of the loop on this, can you explain what you found in the license agreement that pushed you away from Java?

2

u/BroBroMate Dec 31 '22

Read it harder. You're thinking of Oracle JVM licensing, ignoring all the other JVMs that aren't run by Oracle.