Skip to content

Hi, My Name is Ben

  • About

From C# to Java

December 23, 2018 by Benjamen

I made a switch recently in my professional life.  I’ve been doing some for of C# and Microsoft development since about 2005 with sprinklings in of Objective-C, Swift and JavaScript/Node.js but C# has always been my primary backend, get things done language.  However, I recently took a new role back fully dedicated to Healthcare and Patient care and our primary backend stack is in the world of JVM languages.  The below is nothing more than just my initial takes, learnings and optimistic thoughts as I look to really ramp up in 2019.  Total opinion piece but if you agree or disagree with anything, feel free to comment below !

The Languages

Most people I know when asked the difference between the two will generally say, “They are both similar and both are compiled down to bytecode to be interpreted by their runtimes (CLR or JVM)”.   I’d agree with that on the surface as well.  Both have

  • Strings, Floats, Doubles, Ints etc
  • HashMap or Dictionary and any flavor in between
  • Same for lists and Arrays
  • As of Java 8, support for streams and chained expressions as you do with LINQ.  One could argue the robustness of one vs the other, but so far, I’ve found streams to be as much as I need
  • Logical and functionality grouping with Namespaces vs Packages
  • Solid testing frameworks in XUnit/MSTest vs JUnit
  • Asynchronous and concurrency constructs such as async/await, Futures and Tasks and CompletableFuture and TaskCompletionSources.  Additionally, both languages threading support has everything you’d expect from a tried and true language

I could go on a little longer as there are more similarities or 1:1 copies of functionality in 1 vs the other but you get the idea.  Both languages have the tools and constructs you need to get the job done .

The spot that I’ve spent the most time reading and doing trial and error sandboxes has been in the concurrency and stream space.  PLINQ vs Streams in Java is fairly comparable but learning the different thread pool managers have taken me sometime.  However my biggest source of learning has been in the frameworks. I’ve spent a large portion of those years in C# doing ASP.NET and even more specifically ASP.NET MVC and most recently in ASP.NET Core.  The Java world in my take has had many more years of community collaboration (MSFT has made great strides in the last 1/2 dozen years or so) and therefore has a ton of choice where it comes to libraries and packages to chose from.  Which is where I’ve spent most of my time learning

Spring Boot vs ASP.NET MVC

I couldn’t possibly compare these two in detail in a summary article such as this but my initial and early impressions are that Spring Boot is a joy to work with.  It is sometimes tough to figure out dependencies in Maven (which is probably my fault) but the libraries themselves are robust and easy to plug in.  Again though, most of my time has been figuring out how Spring Boot does what I’m expecting to do from an Enterprise Development standpoint.  All the things I need, I’m still figuring out how they apply.

  • Dependency injection (configuring Unity vs @Autowired)
  • The concept of Beans, Components and Services
  • Transaction management
  • Hibernate.  Before EF I used NHibernate pretty seriously but that’s been 10 years ago.  Hibernate has a learning curve
  • Aspect and Cross cutting filters and interceptors
  • The Pipeline — which gets called first, second, third and so forth
  • Jackson vs NewtonSoft for JSON Serialization/Deserialization
  • Different return types OkObjectResult vs ResponseEntity
  • Configuration … application.properties vs appsettings.json and so forth

I could literally go on for a while on just the figuring out of what I know I need and the places I did to locate that information.  (This resource has been incredible http://baeldung.com ).  But bottom line, both frameworks are just fine and it’s a matter of figuring out where things are to accomplish the tried and true OOP, DDD and other 3 letter abbreviations for good quality systems design.

Wrap up

I’m sure there have been so many articles written about this topic and many strongly contested debates but for me the transition has been just fine.  End of the day, I like delivering and helping teams delivery product that people find usable.  You can do this in either.  I love C#, I really do.  And sure, I miss properties, LINQ, async/await and a couple of other things, but I’ll adapt and get used to the nuances of Java just like I did the same for C# and life will go on.  One thing that I’m still doing a lot of is AWS so expect more content driven that direction.  I’m interested to diving into Microservice architecture here and how the patterns and guidance can be applied using Spring Boot, AWS and occasionally some third party tools.

And last but not least, Jetbrains has been there with me through it all.  IntelliJ feels just like Rider so it more feels like I’ve changed appliances/hand tools vs moving into a new home.

facebooktwittergoogle_plusredditpinterestlinkedinmail

Post navigation

Previous Post:

Time series data in MongoDB

Next Post:

Covariant Method Return Types in Java

2 Commments

  1. Mike Graf says:
    December 24, 2018 at 3:38 am

    Hey Ben,

    I enjoyed the write-up! I’m curious if you have spent any time playing with Kotlin as an alternative/complement to Java. I find it provides a lot of the nice C# features (properties, extension methods, declarative collection filtering) along with a lot of really powerful features C# has yet to implement (data classes, enforced null-safety, pattern matching etc). The two biggest selling points for me were the IDE support and the Java interoperability. Since Kotlin is developed by Jetbrains, it’s a first-class citizen in IntelliJ. It’s also really easy to introduce Kotlin classes into existing Java code-bases without the need to rewrite the entire project in Java. Then again, I’ve only used it toy projects (<100 classes), although it seems to be gaining traction in the enterprise space.

    Anyway, I'll be interested to hear how your foray in the JVM ecosystem comes along in future posts.

    Reply
  2. Benjamen says:
    December 24, 2018 at 4:07 am

    Hey Mike – I’ve only spent surface level time with Kotlin. That plus Scala is high on my list of things to evaluate in 2019 to see if they make sense to bring into our ecosystem. I do miss properties, var declarations and declarative collection filtering. To be honest, I’ve never like extension methods. Feels a lot like monkey patching to me but I totally get the appeal.

    I love Jetbrains’ products. Like I mentioned, being able to build .NET Core natively on my Mac with Rider was awesome and then IntelliJ + DataGrip is nice combination.

    I appreciate you reading the blog. I’ll do my best to keep the content coming 🙂

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Spring Boot, Logback and Logstash
  • Covariant Method Return Types in Java
  • From C# to Java
  • Time series data in MongoDB
  • Documenting your ASP.NET Core Web API with Swashbuckle

Recent Comments

  • Benjamen on From C# to Java
  • Mike Graf on From C# to Java
  • DJ on Takeaways from my First Analytics Conference

Archives

  • March 2019
  • December 2018
  • September 2018
  • August 2018
  • December 2017
  • November 2017
  • October 2017
  • March 2016
  • February 2016
  • November 2015

Categories

  • Agile
  • AWS
  • Data
  • Java
  • Life
  • Programming
  • Tech
  • Uncategorized

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© 2021 Hi, My Name is Ben | WordPress Theme by SuperbThemes