Going From Java to C# - Advice?

Hey guys, I’d consider myself a bit of a Java nerd, but due to my current role I’m being forced to work with the MS stack, thus I need to learn C#. I’m currently going through a bunch of online courses (LinkedIn learning, Pluralsight, etc.) but do you guys have any solid suggestions?

I.e. What’s the C# equivalent of Java magazine? What’s the C# equivalent of a Java champion? Could you suggest any C# wizards that I should look up? What’s the C# equivalent of Java’s Optional class? etc. I’d also highly appreciate any input on the infrastructure level, traditionally I’m used to the Linux & open source kinda environment, but I need to learn more about IIS servers & whatnot… Any suggestions would be much appreciated! :slightly_smiling_face:

Tooling wise… I assume that NuGet is the C# equal of Maven?.. Is there a C# version of Jacoco?.. I am basically super duper junior level with C#! :joy:

Yep.

It would not be a bad idea to learn PowerShell as well as C#. Powershell can access all of the dotnet functions that C# can, and can even import some C# liberaries, so there is a bunch of overlap. And PowerShell is the management tool on the infrastructure side.

1 Like

One of the things about being in the MS ecosystem is that they make this rather easy. I’ve only ever used cloud in the projects that I’ve worked in, but from what I’ve seen (Colleagues spinning up IIS on their machine to get us to test internally) it’s pretty easy.

Usually this is built into IDE’s. Visual Studio and rider both have code coverage tools built in.

Just put a ? at the end of the datatype
private int? thisIsNullable;

Also I can’t stress this enough. Stop reading and start coding!

Too many times I see people learning a new language by reading books and stepping through coding tutorials, write the damn code man! Pick a little idea you think is cool and roll with it.

5 Likes

only advice I have is: good luck!

never used any of them professionally but had my quarrels with java, I think you’ll be fine

I love the props thingy and the lack of getters and setters

only the beautiful

public string MyVar { get; set; }

or something

Coming from Java I’ve been spoiled with the likes of Lombok

Personally I freaking hate this syntax… Ughh…

I mean I appreciate your input, but duh… It’s all well & good doing your homework but without applying it you’ll soon fall behind! :stuck_out_tongue_winking_eye: … I guess that’s why they call it R&D?

1 Like

You don’t need Lombok because c# has it all built in! I write in java and c# and I prefer c#. It’s got more features overall.

Also you need to try reflection and generics in c#, so much better than java. Javas type erasure annoys me so much. LET ME KNOW WHAT T IS GODDAMMIT. (https://stackoverflow.com/questions/12989825/type-erasure-java-vs-c-sharp)

Totally fair, I mean I’m currently preferring Java, purely because that’s what I’m used to more than anything… I’m trying to enjoy C#, but so far it’s not going so well! :joy: … Even something as small as the C# way of implementing an interface, I’m not a fan… I know it’s stupid, I’m trying to like it because it’s used so much in my part of the world, like if you’re a C# wizard you’d have an endless number of jobs available! :stuck_out_tongue:

So naturally it makes sense to try & get into C#, not to mention that my current role requires me to be confident with C#, Java & front end development, not to mention the infrastructure & devops side of things… I’m also trying to master things like Chef atm… I have a lot to try & learn atm, if I pull it of I’ll basically end up being one of those nerds that can do it all, I mean I like to think I can do a fair bit on my own, but when it comes to the nitty, gritty details with networking & whatnot, eh, it’s not my strongest point! :joy:

You’ll get used to it. Honestly, I find it much easier than Java to get into. Since as far as ‘the ecosystem’ goes it is pretty easy to figure out what will work and get the job done. Meanwhile in Javaland you have a bajillion options (it has its upsides, but simplicity being not one of them). If it where the other way around I asure you you would be much more lost. Lets learn how I can create a project today. Shall I use ant, maven or gradle? Hm? Thats how it starts out already.

IIS you dont really need to learn if you develope with .net core. IIS is the big fat windows only server. .net core introduces kerstel. Which does do very little compared to IIS. But it is smaller, faster and cross platform. In production you’d deploy it behind an nginx proxy to do things kerstel wont do.

Because you asked about optional types. There is an option in the newer c# versions that you can enable that makes everything that you dont explicitly define as nullable non-nullable. https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/nullable-reference-types

Lamdas/Linq in c# are very important for many things. Its effectively the equivalent of the streaming api in java. So there are two id say main important interfaces for that IQueryable and IEnumerable. IEnumerable is for local lists. Most things are evaluted lazily when either looping threw the result of lets say .Where(x => x>3) or when calling a terminal expression such as .ToList() that will materialize the actual result. IQueryable inherits from IEnumerable. Its intended for query builders for databses. So you can expect these to not run locally. Thats also one of the reason Id say its important since effectively JPA is replaced by them too.

that sucks ass :face_vomiting:

I’d understand either java and frontend or c# and frontend but… putting you to dominate two similar technologies seems to be pretty dumb in a business focused practice

might be better to find someone for c# and get double the performance

I find it funny the number of annotations on a java program

@Getter
@Setter
@EverythingElse
@GetMapping
@Entity

xD

True, you don’t need to learn about IIS in order to just write code, but I’m one of those full stack devs that deals with nearly the entire stack, underlying infrastructure is actually a big part of my responsibility right now. That’s why I asked about it, like with Java you need to have some of an idea about the underlying application server whether that’s JBoss or WebSphere, just those two alone are very different beasts.

I’ve developed that impression also! :joy: - But thanks for the input on the distinction between IEnumerable & IQueryable .

Yep, full on full stack… So that includes front end, middle tier, back end, DB & infrastructure, I’m surprised I’m being thrown this much to look at to be honest…

I’d imagine that would only apply in very niché scenarios? I mean if developing something relatively simplistic/typical you may see some bits & pieces that are nicer than if a non C# guy were to do it. But as long as you know your elbow from your a** hole, you should realistically be fine for the most part? … I mean these days it’s hard to f**k up to the extent where you’ve written some API & it runs dog slow, unless you’re a cowboy dev & you’ve just not applied best practices & proper principles… I.e. TDD, defensive coding, design patterns, etc…

Personally I like using annotations, if it can simplify my code base, why the f**k not? :stuck_out_tongue:

Fair, enough. What I ment if you develope in .net core IIS might not be part of your infrastructure. Neither in developement nor in production. If you are using .net however you don´t have a choice it´s IIS or nothing. If you use kerstel in production, you don´t need to learn kerstel you need to learn nginx. On windows you can still choose IIS with .net core if you prefer it.

Also a fair point! But I currently work with a lot of legacy systems, I work in the financial sector & things move at a snails pace! :joy: - Unfortunately we’re not using .NET core quite yet…

1 Like

Not sure why this just popped into my head. But about that. I’ve spent a fair time in kotlin (well… still working on that devember project every now and then from I believe it was 2 years ago when I started it T_T). It works for me now, but it’s still not really playstore worthy I think. Not easy to develope something in your free time while having a full time job at all.

Kotlin has the exact same syntax for nullable types. It also has Optional, since it aims to be fully compatible with java. Whatever exists in Java you (can) use. However, I find the null in kotlin to be much nicer than Optional in kotlin. I’ve played with Optional for a bit. And considered using it. But at the end of the day I decided against it.
Reason being that when you use Optional you are kinda on your own as far as the compiler is concerned. It does not care wether or not you check for isPresent or not. Meanwhile null in kotlin is checked at compile time more often than not (ofc it can’t always be since it must remain compatible with java… and then some edge cases where it just can’t figure it out). But it’s a lot better than not doing it at all. Also unboxes itself to a non-nullable type when you check if it’s not null in an if.

So… I don’t actually think Javas Optional is all that great. It’s OK in Java, because it does not have better language tools available to express intent of what should be nullable and what should not (so they made a class… which seems like the cheap way of doing it to me). Surely, kotlin at a bytecode level does not actually know either. But at a language level it solves this pretty well as it will just refuse to compile. As long as you either work with only kotlin code, or java code with a bunch of annotations to make kotlin happy lul.

1 Like

I guess it really is just a matter of personal opinion on this one to be fair? I mean clearly my opinion of thinking it looks right up nasty can’t be too popular… And I for one love the Optional class, I think it’s genuinely a great little tool, I mean while it’s possible to do it without, I’ve found it a nice help for writing my own DSL’s…

But I can also see your point that it was a bit of an ‘easy’ option to create a class rather than implement some syntax to handle null checking & whatnot… I can totally appreciate that point! :slightly_smiling_face: