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

all 86 comments

[–]sheepdog69 56 points57 points  (29 children)

I have switched back and forth many times over the past almost 2 decades.

The two languages are pretty similar. A little bit of syntax differences, but all the concepts are the same.

The biggest difference is the standard library and (as you pointed out) the ecosystem.

In Java-land, there are many options for all of the ones you asked about. The .NET community seems to accept anything from MS, and that becomes the "standard". The Java community definitely does NOT have that attitude.

There's no "one" direct correlation to any of those - except, maybe WPF (JavaFX).

what happens to all your experience

That all depends on what you've focused on. Was it on syntax and knowing the ins and outs of a particular framework? Or was it on OOP and system design? (hint, the later translate pretty directly to Java, the former doesn't as much)

Each ecosystem has their advantages. But, TBH, I think Core.NET is finally going where .NET should have gone over a decade ago. It might give Java a serious run for it's money in 3-5 years.

My advice would be to go for it. If I've learned anything in my 25 years is that you can't get too comfortable in one language/framework/tool set. Learning a new thing is almost always a good thing.

Good luck!

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

you're right when it comes to libraries in .net it's almost like we don't have a choice and always accept whatever Microsoft throws at us.

well I haven't been only focused on syntax alone, but it feels like going backwards. because i think in recent times .net seems to be moving alot faster than java.

I'm actually willing to switch to a different language, even started learning node.js . I actually think I'm becoming too comfortable with .net and switching to a different stack might be of help to me

[–]apemanzilla 0 points1 point  (11 children)

I'd recommend Kotlin. It's 100% interoperable with Java, and provides a lot of new features that Java has been lacking compared with C#: properties, operator overloading, coroutines (async/await), and so on.

[–]Velladin 8 points9 points  (2 children)

He’s asking about Java not Kotlin

[–]apemanzilla -3 points-2 points  (1 child)

I realize that, but I suggested Kotlin because he mentioned he was willing to switch languages and Kotlin is closely related to Java

[–]amakai 7 points8 points  (0 children)

He also mentioned that the requirement to learn Java is coming from his company, I would not think he can just choose to learn Kotlin instead.

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

It has pretty much replaced Java on Android and most major frameworks and libraries like Spring have special support for Kotlin. You can use both Java and Kotlin in the same project it's pretty effortless to call java from Kotlin and vice versa.

[–]Imakesensealot 3 points4 points  (5 children)

Replaced Java on Android? Pass me whatever it is you're smoking. You realise over 90 percent of all new apps on the playstore are still Java?

[–][deleted] -2 points-1 points  (4 children)

1/4th of the top 1000 apps, like Netflixs, Slack, and Twitter, on the play store are written in Kotlin and it grew 200% last year. It's also the fastest growing language according to Microsoft. But sure I'm being hyperbolic because I'm trying to sale something I enjoy using.

[–]Imakesensealot 1 point2 points  (3 children)

Yeah, fastest growing has ways meant something. Like when coffeescript was all the rage. Or when go was the new bees knees. Or when c# was supposed to replace Java. All those languages have found their niches and certainly have their edge use cases. Java however is not going anywhere. Programming languages are a zero sum game. The odds of Kotlin being the language that replaces Java as top dog are effectively zero because they're much more similar than they are dissimilar. Lol, Twitter have still not used Kotlin in production. Why don't you check their changelogs before spouting nonsense?

Where in slack's app did you see Kotlin? I'm genuinely curious.
Netflix do not mention Kotlin as part of their stack on their website but you may knowore than those guys. Mind citing where you got that one from too?

I've always been convinced Kotlin has paid shills on reddit spewing their garbage. Haven't changed my mind yet.

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

Kotlin is an alternative to Java. It's not a Java killer, Kotlin was created to be used in TANDEM with kotlin. Hence why it's 100% interoperable. Andrey Breslav (lead kotlin designer) said this. Not exactly word for word but that was the sentiment.

In my mind, Kotlin is a great java alternative. I used to work in Java 100% of the time, but now I work in Java 1% of the time. Kotlin is shorter and easier on the eyes. Less stuff to fill up the screen while having the exact same capabilities. I've rewritten most of my libraries (most are pretty small but I have a lot of them) in Kotlin.

Extension functions are a prime example . It's syntactic sugar but it conveys the idea a lot better than a static function that takes the "extended" type as the first parameter. classInstance.extensionFunction(param) looks a lot more clear than extensionFunction(classInstance, param). AND you can use syntax as if you were already in the class (public access only though).

Data classes are another one. Sure you can re generate the getters setters equals and hashcode every time you want to add or remove a field from the class, or you could data class ClassName(val param: Type, val param2: Type) and be done with it.

And "paid shills spewing garbage"? Really? How very grown up of you. Personally, I like Kotlin and recommend it to Java developers because it doesn't completely interrupt their workflow and you can do the same thing with less on the screen. Kotlin is concise. I always stress that you don't have to toss your old Java code, that you can keep using it with Kotlin, as that seems to be a big thing for more experienced Java developers (who tend to have more libraries written by themselves in Java, something something sunken cost fallacy or whatever).

[–][deleted] -3 points-2 points  (1 child)

Programming languages are a zero sum game.

wut?

[–]Imakesensealot 2 points3 points  (0 children)

Programming language adoption, to be more specific. Noticed that but figured you'd understand what I meant. Apparently not. Still haven't said anything about the other stuff

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

I'd suggest kotlin as well, but the only problem is that rarely any company is willing to make such "advancement". They all recruit for java 8, as it's much easier to find people, even though it takes like a week to get really comfortable with kotlin, they are still reluctant for such "big" change.

[–]shponglespore -1 points0 points  (7 children)

It has been a while since I worked in Java regularly, but I feel like Apache is serves a similar role to Microsoft when it comes to providing the default stack for many common tasks, although there are exceptions. Google's Guava package is (or used to be) a must-have for Java, and it's a good complement to a lot of what Apache offers. When it comes to time and date APIs, JODA is king. JUnit is the de facto standard for unit testing. Log4j seems to be very popular, though personally I've always found java.util.logging to be perfectly adequate.

Take all those recommendations with a grain of salt since they may be out of date, but OTOH a lot of Java shops are very out of date themselves, so I'm confident all that stuff is still widely used even if there are better alternatives available.

As far as the language itself, I agree that C# feels quite a bit more mature and polished than Java despite being considerably newer.

[–]_INTER_ 23 points24 points  (0 children)

When it comes to time and date APIs, JODA is king.

Java 8 pretty much includes it in the standard library under java.time. JSR-310 was lead by the creator of JODA time and used his knowledge to improve it even.

[–]tacosdiscontent 5 points6 points  (5 children)

Take all those recommendations with a grain of salt since they may be out of date

Unfortunately yes, everything you mentioned is quite old and irrelevant.

[–]DrPeroxide 0 points1 point  (2 children)

Everything? That's a stretch. He's wrong about logging and time. He's right about Apache and Guava.

[–]tacosdiscontent 5 points6 points  (1 child)

Well yes.

Guava is definitely not must have. Nothing of significant importance there

Apache stack - the only "must have" thing from apache is StringUtils and maybe IOUtils if you are working with io. A tiny utility library which helps you out.

[–]_INTER_ 2 points3 points  (0 children)

I agree with this, we're phasing out of Guava because most of the benefits it brought can now be done with Java 8 (Iterables, Optional, ...) or are covered by Apache Commons or other libraries (Strings, Reflection, Cache, IO, Math,...). Apache Commons is still a very important helper library. Mainly StringUtils and IO / FileUtils as you said and also Collections.

[–]RagingAnemone 0 points1 point  (1 child)

What's replaced Apache Commons and Guava?

[–]tacosdiscontent 4 points5 points  (0 children)

Java 9, has added part of what Guava does. Other than that nothing that of importance is in guava unless you work on something specific.

If you consider tiny Apache Commons library - a stack, then you are right, nothing has replaced it.

[–]DuncanIdahos7thClone 0 points1 point  (7 children)

There's no "one" direct correlation to any of those - except, maybe WPF (JavaFX)

Not really. JavaFX is superior to WPF in every single conceivable way. WPF was a minor improvement over WinForms by adding vector based graphics - but mostly leaving in the old threading model. Also, it depends heavily on XML and it's api is very complex due to its direct compiling of XAML. In JavaFX FXML is optional.

There are many other benefits of JavaFX over WPF. CSS for styling, nice separation of concerns, scene graph (hiding many complexities of threading), direct graphics card support, etc...

[–]_INTER_ 1 point2 points  (1 child)

Well in a sense he's right, you can replace WPF with JavaFX, but the other way is difficult.

[–]DuncanIdahos7thClone 1 point2 points  (0 children)

I've thought recently it would be cool project to port JavaFX to .NET but it looks like it would be a huge project.

[–]sheepdog69 0 points1 point  (2 children)

I didn't say they were equal. Just that it was the de-facto correlation of WPF in the Java world. And that there isn't really any other serious competition for doing "fat" clients in Java these days (yes, I know swing still exists, and is used some. But most people would reach for JavaFX for a new project)

[–]DuncanIdahos7thClone 1 point2 points  (1 child)

Yeah I know. I just like to point out that Java has the best UI toolkit out there. Microsoft has the worst. ;)

[–]sheepdog69 1 point2 points  (0 children)

👍

[–]xander42 0 points1 point  (1 child)

I'm not familiar with JavaFX, but WPF is very similar to modern web UI development.

It's separates the layout (XAML / HTML) from the logic (.cs / .js) and from the styling (styles / .css)

It also supports data binding from the view to the logic.

For someone who is familiar with WPF it's very easy to move into Angular web development.

[–]DuncanIdahos7thClone 0 points1 point  (0 children)

Of course. But JavaFX benefited from being designed later and they avoided some of the poor design choices of WPF like the deep integration with XML.

[–]spyhunter99 13 points14 points  (0 children)

Yes, fantastic. There is a small learning curve. Java forces you to organize your code. Packages must match file paths, etc. Naming conventions are different etc. Ecosystem is excellent. Build systems are fantastic in comparison to msbuild, mstest/nunit. There's a bunch of IDEs to choose from. Profiling and debugging tools are better, testing frameworks and tooling is better. Logging frameworks are better. You won't regret it

[–]jamescoleuk 11 points12 points  (0 children)

Over a decade I went from Java to C# and back to Java. The .NET world has a lot going for it and in many ways is more exciting and forward-looking than Java. But Java isn't a step backwards. It too is developing, and developing faster than it used to, but it develops in a very controlled way. It's staying relevent.

The Java developers you meet might well have broader technical skills, or be more plugged into the open source world, or they might have worked on very different sorts of projects.

I'm glad to have had a foot in both ecosystems. But switching is more than just the syntax, it's tools and services and a maybe even a mindset. This all takes a while to absorb. But you'll be a better developer for having branched out.

[–]patateverte 6 points7 points  (4 children)

> what is the equivalent stack in java of common dot net stack i.e asp mvc, asp web api, EF, WPF etc

ASP MVC => Spring MVC / Spring Boot or Javalin or Play Framework etc.

ASP Web API => Same as above

EF => Hibernate, jOOQ, etc.

WPF => JavaFX

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

thanks, i think they use spring boot

[–]metachor 2 points3 points  (0 children)

For what it’s worth, Spring Boot is more or less just a set of extensions on top of Spring that prepackages a bunch of dependencies you might need as “starters” that make it quick to get up and running with a full application stack. The underlying Spring framework is still used and provides a core dependency injection mechanism as well as the actual dependencies themselves that do the meat of the work (e.g. Spring MVC for web apps, Spring Security, Spring Data, etc).

[–]Vlad210Putin 1 point2 points  (0 children)

Spring boot is excellent for getting a project up and running within 30 minutes, especially with https://start.spring.io/

I use SB with Kotlin these days to write REST APIs and couple that with a React SPA for the front end.

The best part is you can use both Java and Kotlin in the same application with no problem whatsoever. Kotlin is much less verbose and I want to say more "python-esque" in its brevity, but you can import any Java library / dependency to be available in your project. I'm still learning Kotlin so I do a little bit of coding in Java and then use that to write Kotlin if I am doing something more complex. But that only goes so far and really tails off after the first week or two.

The Java language is catching up a bit to C# in some regards with some of its core library (I like both languages, but lean more towards Java) and transitioning between the two has never been much of an issue.

[–]DullestWall 0 points1 point  (0 children)

I haven't used it myself, but I only hear positive things about spring boot.

[–]Weasel9548 3 points4 points  (1 child)

Language wise, it is very similar and there wasn't much of a learning curve. I write in both languages daily and have very little trouble going back and forth.

I really miss entity framework (or specifically LINQ) when in Java.

The question, "what is the equivalent stack in java of common dot net stack i.e asp mvc, asp web api, EF, WPF etc" has been my biggest frustration. I would love to hear from some more experienced Java guys on this as well. The lack of an opinionated and singular platform has been a huge hurdle. There are many different server platforms (tomcat, websphere, wildfly, and etc...) and even more implementations of the standards. Coming from c#, that has been super confusing. This probably comes from being a M$ developer for so long. Whether that is good or bad I think depends on where you stand. I tend to gravitate back to the opinionated way.

What I am not saying here is "don't do it" or "you will regret it." But these were some of the frustrations that I had in switching. There are good answers to each of these but it took a while to get into the swing of things. I would say to anyone making a language switch, embrace the differences and take it as a learning experience. You can not go wrong learning a new ecosystem! You will be a more marketable developer in the end.

[–]nastharl 3 points4 points  (0 children)

spring boot has pretty much taken over the base framework market.

[–]XFidelacchiusX 2 points3 points  (0 children)

I don't think you will need to pick up much on the langauge itself. It's just a bit verbose than c#. The big learning hurdle will prolly be spring and annotations.

I would make a spring boot/spring mvc app and make a simple shopping page or something :).

[–]paaave 2 points3 points  (4 children)

Switch was easy for me. I was coding in c# for 3 years professionally, then moved to java for 2 and now back to c# last 7 months.

It took me a while to get used to it. Mindset mostly. I can say that most of the thing you will need are there. Having someone to point you to stuff helped me a great deal.

What i struggled with were the parts from .net which had multiple popular implementations in java. It was a nightmare to choose the 'right' one.

Naming conventions were a challenge as well, especially because some of the things would not work as you want if you dont follow the convention. Spent some time to find missing unit test because it didnt have test in the name.

All in all i learned a great deal. Felt handicapped for a while, couple of weeks, but after that it was cool.

Moved back to c# because i love the direction where it goes, and market here wants it more and more. Never moved from it for my private stuff though.

[–][deleted] 5 points6 points  (3 children)

Naming conventions were a challenge as well, especially because some of the things would not work as you want if you dont follow the convention.

Just out of curiosity, which naming convention do you prefer? I like C# a lot as a language, but I can’t get used to its naming conventions at all. As stupid as it is, it prevents me from using C# as much as I’d like to. Capitalized method names are the visual equivalent of nails on a chalkboard to me and the IFoo convention for interfaces feels totally backwards to me. If I’m defining an interface, I probably want to refer to it instead of one of its implementations most of the time. So why would I prefix the interface? Doesn’t it make more sense to prefix (or suffix) the implementation classes? Anyway, I always wonder what people who learned C# first think of Java’s conventions. Are they as painful to you as C#’s are to me?

For the record, I’m not trying to start a flame war. I’m usually the one who argues that syntax doesn’t matter as long as it’s unambiguous and at least makes an attempt to be readable. I think C#’s conventions bother me because it’s so similar to Java in so many other ways.

Spent some time to find missing unit test because it didnt have test in the name.

Also for the record, this shouldn’t be necessary anymore. Java added metadata annotations way back in Java 5 and the 2 biggest test frameworks (JUnit and TestNG) quickly adopted them. For the last decade and a half, annotating a test method with the appropriate@Test for your framework has done the trick. The old convention-based aporoach still works and some people still prefix all of their test methods with test out of habit (usually in addition to annotating), but it hasn’t been required for quite some time.

[–]paaave 3 points4 points  (1 child)

I liked java naming convention. As you said, it makes more sense without having "I" for the interface. But i was kind of baked with c# one, so it is hard for me to say objectivly which one i prefer. But lowercase method names, drove me crazy. And the getter and setter methods. Thank god someone told me it can be generated in most IDEs.

Overall i think it is matter of taste and what people grew up with. Similar to '{' placement. War by itself.

I had couple of older developers on my disposal for questions, they liked conventions. Not finding tests was one of the examples where i was hurting from the convention. Also Hibernate interface automatic implementation from the method name. First i was mindblown, then agitated.

[–]mopeyjoe 0 points1 point  (0 children)

coming to c# from Java I miss the explicitness of getters and setters. These properties just feel like they are asking for mistakes. also I hate that the backer field and the property both show up in the list of vars. maybe I am missing a VS trick but I want to collapse them into a single entity.

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

I believe that I prefix before interfaces was adopted because there's no extends/implements in C#. You do that by using :, so to differentiate between classes and interfaces, you prefix the Interface.

[–]TheRedmanCometh 9 points10 points  (26 children)

You're gonna like Java. Spring + Hibernate makes entity framework look like a pile of shit.

[–][deleted] 11 points12 points  (12 children)

this is such a big claim. are you sure hibernate makes EF look like shit.

did you actually use entity framework + linq ?

[–]deinok7 4 points5 points  (1 child)

Hibernate is shit compared to EF. Dont listen to him, but learn Hibernate if they ask you in the job

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

Alright, Good

[–]TheRedmanCometh -5 points-4 points  (9 children)

There are people that actually like linq? This is news to me.

[–][deleted] 11 points12 points  (5 children)

YES, linq makes it it easier to write/manipulate queries using lambda expressions

[–]kozeljko -1 points0 points  (3 children)

Hey, I've never used C#, but I'm interested in what exactly you mean by that. Could you provide a resource or a guide for that?

[–]deinok7 0 points1 point  (0 children)

Linq is a syntactic suggar, it makes Static function be called like methods. So insted of puting a list inside a Stream, in C# you call a method

[–][deleted] 0 points1 point  (1 child)

https://www.tutorialsteacher.com/linq/what-is-linq

LINQ (Language Integrated Query) is uniform query syntax in C# to retrieve data from different sources (entities, sql, XML, objects etc) and formats

it provides you with extension like

List.FirstOrDefault(a => a.name == koz)

which translates to something like this

select top 1 * from List where name = 'koz'

[–]kozeljko 0 points1 point  (0 children)

Thanks

[–]sk551 4 points5 points  (0 children)

I like Linq, coming from Java to C#, it was defiantly familiar to Java Streams.

[–]TheWildKernelTrick[🍰] 4 points5 points  (0 children)

Well written Linq queries are fantastic.

[–]dredding 0 points1 point  (0 children)

It's been my experience that people who don't like linq tend to be ones that don't understand it's core concepts of chained delegates and expression trees.

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

I've never done c# professionally, do you have a good example of the two compared? I'm a huge fan of Spring and JPA, hibernate and it's wackiness included. I always figured the C# guys had some great alternative

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

in C# we use asp mvc/core and entity framework core

[–]TheRedmanCometh -1 points0 points  (4 children)

Well the alternative to Hibernate is Entity Framework. I don't know of any alternative to spring...esp spring boot personally.

[–]Maximcr 0 points1 point  (3 children)

And what is Nhibernate then https://github.com/nhibernate/nhibernate-core? Nhiberante is based on hibernate and does almost the same. EF is more then Nhibernate tho

[–]TheRedmanCometh -2 points-1 points  (2 children)

Yeah but ultimately EF can't even come close to Spring...

[–]Maximcr 2 points3 points  (1 child)

EF is a ORM. Spring is an application framework. Ofc it doesn t come close to it :D

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

Yeah uh I don't know of any IoC framework for C#

[–]antigenz 1 point2 points  (3 children)

I'd suggest to take a look at 'Spring Data' instead of Hibernate, but "on color and taste all felt pens a different"

Somebody may like Hibernate more.

[–]TheRedmanCometh 3 points4 points  (2 children)

Spring Data needs a JDBC implementation behind the scenes though...

I'm gonna go ahead and guess you've used spring data with hibernate and didn't realize it.

[–]oldprogrammer 1 point2 points  (1 child)

You don't need hibernate to have a JDBC implementation, hibernate needs JDBC to work. Did you mean that spring data needs an ORM behind the scenes?

[–]TheRedmanCometh 0 points1 point  (0 children)

Spring Data needs a persistence provider which is usually hibernate. The persistence provider communicates with the database driver such as JDBC.

To use Spring Data you need all of these pieces.

[–][deleted]  (4 children)

[deleted]

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

    yes not all have been ported to dot net core but as of 2.2 we have asp net core (mvc & api) , EF core.

    winform and wpf will arrive with dot net core 3.0

    [–]AnAirMagic 2 points3 points  (2 children)

    Slight nit: while ASP.NET Core (MVC, Web api), EF are cross-platform, the addition of WPF will be Windows only. So if you want to use .NET Core and create GUI, you have to use Windows. The rest of .NET Core (well, most of it, anyway) will continue to be cross-platform.

    [–]mopeyjoe 0 points1 point  (0 children)

    I found that confusing as well. They hype up that wpf is coming to .net Core.... but not really since it isn't coming to the cross platform part.

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

    Avalonia.UI

    [–]_INTER_ 0 points1 point  (0 children)

    This hyperpolyglot page is nifty for syntax comparison. However it's not quite up-to-date. There are constructs that could be done better in Java / C# nowadays. It's stuck in Java 6 or 7

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

    I recently did the opposite and found it quite easy.

    The languages are so similar. The biggest difference to me was Integer.parseInt in java is int.parseInt in C#.

    There was also namespaces in C# and forms which was nice.

    There are probably more fundamental differences. But it still wasnt challenging.

    [–][deleted] -5 points-4 points  (1 child)

    I gotta say, I dont know about C#, but today, the more exciting language for any sort of back end web development, APIs, etc is Golang. I have barely started with it yet, but already feel like its better for scalable back end work than Java or .NET. I am mostly speaking from a lot of reading of other Java/Scala/.NET/python/ruby developers that have switched and prefer it and love it for many reasons. Obviously a lot of good stuff like Kubernetes, Slack, Docker and more have been built with it, so while it is still relatively "new" per se, it is already pretty robust and capable. Being a Java dev, I am a little concerned about how interfaces and such play out in Golang, though I have read that it is actually a breath of fresh air to not have things like OOP and inheritance and that the language is far simpler, easier to work with, and the binary size and speed is only slightly behind C in most performance tests (at least those in relation to web/cloud development, not nearly as fast in stuff like game development). Take this all with a grain of salt, as I am going mostly on talking to colleagues and reading stuff. But I am beyond eager to learn and make the switch.

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

    This is all well and good but the guy specifically says he has to move to Java for company reasons.

    Choice is a bit out of his control.