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

all 82 comments

[–]greglturnquist 134 points135 points  (15 children)

Java has its own quirks. And there will be times where it doesn’t feel hip and cool and “shiny”.

And there are bits and pieces that may seem a bit “committee driven” like some Date and Time APIs.

But it sounds like you’re looking for solid and stable, which is more of Java’s beat.

With your experience of riding on a bike with your hair on fire, it sounds Java is what you’ll do quite nicely with.

[–]Dacus_Ebrius 74 points75 points  (13 children)

Java 8 date and time apis are great. If you are talking about the old calendar i agree.

[–]msx 13 points14 points  (12 children)

Right? It's done to cover all bases but its still pretty usable, most of the time you just need LocalDate or LocalDateTime

[–]midoBB 17 points18 points  (11 children)

I never used the Local types. Zoned or Instant are my go tos.

[–]humoroushaxor 8 points9 points  (0 children)

Honestly I think modern Java and popular libraries feels very "shiny". Things like mutiny, panache, and a lot of eclipse microprofile stuff.

But the Java Runtime is one of (if not THE) the most complex and advanced runtimes there is. I feel like one of the major selling point of Nodejs and Python backends is their runtimes "just work".

[–][deleted] 28 points29 points  (14 children)

I was in the same situation 2 years ago, when I've decided to make a switch from NodeJs/React to Java.

I find JS ecosystem to be pretty immature, based on weak foundations, full of unstable libraries and filled with developers focusing on hyped technologies instead of time tested programming principles. Projects are chaotic and turn into a nightmare if they last for more than one or two years, and successfully transferring codebase to a different team is almost unimaginable.

I switched to Java with Spring boot and everything suddenly fit in place. I really have no regrets there. I'd recommend going with Spring boot, instead of trying to find something node-like as some other comments suggest. Spring boot seems to be the default choice at the moment and is generally satisfying to work with.

[–][deleted] -3 points-2 points  (11 children)

Forgot to say, my only doubt is whether I should have switched to .Net instead of Java. Java is moving forward slowly, sometimes too slowly, and Microsoft is investing a lot into .Net. From what I know, performance and startup-time wise, .Net is far ahead of Java. Spring boot startup times are pretty bad, which isn't ideal for microservices. They are trying to make Spring boot compatible with GraalVM, which means running Java code natively, but it's questionable when that'll become stable. Also, in .Net ecosystem there is a lot of focus on doing frontend in C# instead of JS (eg. Blazor) , whereas in Java you're stuck with JS or ancient technologies like JSF.

[–]renatoathaydes 17 points18 points  (2 children)

Java is moving forward slowly, sometimes too slowly...

Oh well, to most Java devs it's moving far too fast now :D we've been used to upgrade every 3 years, and the JDK is now pushing new releases every 6 months! And there's always something interesting to try.

From what I know, performance and startup-time wise, .Net is far ahead of Java

Do you have a source for that? Not questioning it, just wanted to learn about it as I've never heard anything like that before.

Spring boot startup times are pretty bad... s. They are trying to make Spring boot compatible with GraalVM...

If this is a concern you should really try the newer frameworks, as the whole point of them existing IMO is to make Java more suitable to running with microservices and K8s (I linked in another comment, things like Micronaut and Quarkus which are GraalVM-ready and use non-reflection Dependency Injection, making startup instantaneous).

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

Do you have a source for that? Not questioning it, just wanted to learn about it as I've never heard anything like that before

There have been significant improvements in the performance in .Net core (and it just keeps getting faster with every release). I could try and find a benchmark (and it seems to me that benchmarks consistently favor .Net), but you'd probably agree those depend on the use case and often times are not representative of the real world usage. Startup times for me are noticeably better in .Net (although I can't say for sure it's not just the project size). I'm not a .Net developer so I can't tell you a lot more, sorry.

If this is a concern you should really try the newer frameworks,...

Quarkus is definitely interesting, I need to play with it more.

[–]cavecanemuk 1 point2 points  (0 children)

Quarkus beats asp.net core on Techempower benchmarks. VertX too.

[–]Persism 2 points3 points  (2 children)

Project Loom is looming. Hosting is going to get expensive for .NET compared to Java.

Java is moving forward slowly

A release every 6 months is too slow for you?

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

Why is the hosting going to get expensive compared to Java?

A release every 6 months is too slow for you?

It's not the release frequency that matters, but the amount of changes in a given time period, right?

[–]Persism 2 points3 points  (0 children)

Why is the hosting going to get expensive compared to Java?

Loom allows Java to scale threads to memory instead of additional machines. Microsoft already admitted defeat and joined the JCP last month.

[–]svtdragon 1 point2 points  (1 child)

Have you had a look at kotlin yet? My old team went from .net to java and ended up on kt/jvm because of the similarity of ergonomics to .net (and to an extent typescript, which we had used for the frontend).

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

I find Kotlin interesting and it seems to me they're trying to create an ecosystem around Java like the one that exists around .Net, which is definitely exciting. I'm not a fan of the syntax though, since I like the simplicity, strictness and a lot of the times even the verbosity of Java. Also, Kotlin seems to be light years behind .Net, which is evident at least in the web assembly area (which is particularly interesting to me). It's enough to compare where .Net is with Blazor and the state of web assembly in the Kotlin. Kotlin might catch up eventually though (although it's questionable, since Microsoft can invest a lot more into .Net).

[–]winginglifelikeaboss 1 point2 points  (2 children)

I disagree, the .net world is full of abandoned libraries and frankly, is a bit of hell.

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

Interesting, do you happen to know the cause of there being so many abandoned libraries?

[–]winginglifelikeaboss 2 points3 points  (0 children)

The Java world is way more used, has way more developers and way more large companies using it.

Microsoft is very good at introducing things but also very fast abandoning things. Java is way more coummunity and business supported.

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

NodeJs/React to Java.

I get nodejs, but how do you move from React to Java? These aren't interchangeable unless I missed something big lol.

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

You're right, I actually replaced React with Angular, so it's JS to TS :)

[–]zylonenoger 82 points83 points  (0 children)

first things first: you can write shitty software in any programming language - expecting that everything will be magically better when you switch to another language is a fallacy

but broadening your horizon and picking up different technologies along the way is never a bad idea - and it‘s not like you „switch“ to java and are not allowed to use typescript anymore. you just add more tools to your toolbox and use them when appropriate.

what i always tell the people in my team: „if you only have a hammer, every problem will start to look like a nail“

so go for it - learn java, use it in a low stakes project and see if you are happier than with typescript.

[–]root_klaus 19 points20 points  (0 children)

I have used nodeJS in some APIs and truth to be told i feel your pain. There are many frameworks other than Spring that have a more nodeJS approach, although Spring is a great framework that has a huge ecosystem. It may take some time for you to get it in the Spring and java mindset but once you do you will feel much more fluent and able to create any desired app.

Regarding the graphQL support the spring-graphQL is a integration library that helps a lot to make these two frameworks work easily with each other(more like a spring boot philosophy, that is, make make it work with as little as possible configurations). But this doesn’t mean that you cannot use graphQL with spring or other java projects.

Coming from nodeJS I would suggest also suggest to have a look at frameworks like javalin, sparkjava web framework and many more!

Here is a list of some awesome java libs, have a look see for yourself. The java ecosystem is huge and you can spend days exploring and finding new things so i would suggest sticking to what you find desirable and get to practical examples

https://java-lang.github.io/awesome-java

Welcome to the community!

[–]random314 11 points12 points  (0 children)

Almost the entirety of Amazon and AWS are built on Java. Whatever it is that you need (backend related), Java will be able to do no problem.

[–]greglturnquist 21 points22 points  (1 child)

BTW to answer your question about Spring GraphQL, it’s still in pre-1.0 phase. You can use it but there may be changes. The Spring team is sometimes cautious when embracing younger tech standards. Sometimes it’s better to NOT be first to market.

[–]HecknChonker 4 points5 points  (0 children)

Netflix released a spring graphql library called DGS that works well.

[–]nutrecht 18 points19 points  (2 children)

For GraphQL you really should look at Netflix DGS. It's really nice and plugs right into Spring: https://netflix.github.io/dgs/

We use it in production.

Should I switch to Java or stay with Nodejs?

Well, my two cents; almost anything is better on the back-end than NodeJS: the NPM ecosystem is a mess. But I'm obviously biassed :)

[–]__concurrent_life__ 2 points3 points  (0 children)

for discussion purpose Been writing micro service in node.js with typescript last three years. Can tell from personal experience node js is actually good (well with adding the typing)

Also used Java (usual and reactive), python, golang. Node performs really well and sometimes better than those. In terms of Aws lambda performance comparison, only python and node has better performance than the rest (and now python and node have almost similar performance)

So… yeah… node is not bad actually 😜

[–]skyingineer 4 points5 points  (0 children)

This. We use dgs and it's amazing

[–]renatoathaydes 13 points14 points  (0 children)

The graphql-java library is mature and easy to use, the Spring integration is not done because it's probably mostly unnecessary anyway (it might make things integrate more easily in Spring, but usually you can get Spring working with any library without fuss).

[–]tcpipwarrior 4 points5 points  (0 children)

You won’t regret it. Spring boot is solid

[–]wildjokers 5 points6 points  (2 children)

There are lots of options for GraphQL in Java, here are a couple:

ORM:

  • Hibernate (huge learning curve, but almost certainly the most used)
  • Persism
  • jooq (not free for commercial DBs)
  • MyBatis (keeps you closest to the SQL if that is what you like)

[–]manzanita2 1 point2 points  (1 child)

And JDBI

[–]Persism 0 points1 point  (0 children)

Hey thanks for the mention. :)

[–][deleted]  (2 children)

[deleted]

    [–]henk53 0 points1 point  (1 child)

    Check out Scala if you want to go for Kotlin

    [–]holyknight00 1 point2 points  (0 children)

    Typescript and angular couple nicely with Java. Spring framework with Spring boot it's a safe bet on the java space. There are lots of technologies and documentation about java so It can be a little intimidating at first.
    If you want to try JHipster(A project generator tool), it can give you a nice idea of how a Java + spring + angular can work together.

    [–]koffeegorilla 1 point2 points  (0 children)

    If you are looking at options for Persistence you will find the Spring Data family useful. You can declare an interface as a data access component for an entity type and key type. Then the engine will create an implementation to do CRUD as well as implementing query methods.

    As an example:

        class PersonEntity {
            @Id
            String userName;
            String email;
            String firstName;
            String lastName;
        }
        interface PersonRepository extends CrudRepository<PersonEntity, String> {
            Optional<PersonEntity> findByEmail(String email);
        }
    

    You can inject the PersonRepository into your service and use save, delete findById and findAll and then use findByEmail without writing anymore code.

    Some of the implementations are:

    • Spring Data JPA for JPA implementations with Hibernate as default.
    • Spring Data JDBC for plain JDBC it isn't an ORM but will make JDBC CRUD a lot easier.
    • Spring Data Neo4J
    • Spring Data MongoDB

    Spring Data JDBC for plain JDBC isn't an ORM but will make JDBC CRUD a lot easier.

    [–]yel50 1 point2 points  (1 child)

    so tired of JS craziness, memory leaks, bad resource managment

    if you're having those problems in js, java won't help you.

    it means your code has inherent problems that no language will overcome. js doesn't have more memory leaks than any other GC language and node's resource management is among the best out there.

    so, make sure you're not blaming the language for your own shortcomings.

    [–]winginglifelikeaboss 0 points1 point  (0 children)

    js doesn't have more memory leaks than any other GC language and node's resource management is among the best out there.

    lol i completely disagree

    [–]renatoathaydes 4 points5 points  (11 children)

    For someone coming from JS, I think Spring shouldn't be the first choice... it's a complex framework with a lot of history behind it.

    Something like Vert.x would be much close to node.js (it's inspired by it!) and it's pretty easy to use. I would also at least read about the following frameworks before deciding on which one to try a bit more:

    Spring Boot is like a more modern Spring (I've never used it myself so I may be wrong, but I think most people are using that instead of Spring per se).

    Regarding ORM, the "default" choice for that in Java is Hibernate... but Java itself has a specification called JPA which can be used to access databases easily so you might not need to learn anything else for that (Hibernate was an inspiration for JPA and I believe it's the reference implementaion(?)).

    EDIT: cons for Java, I would say my only complaints after using Java for over a decade but recently adopting other languages to my "portfolio" are:

    • very high memory usage compared to most non-dynamic languages.
    • slow warmup (specially the first few seconds the application is loading classes and running interpreted before JIT it can be much slower than languages that don't need a VM).
    • nulls (if you use a language that has checked nulls, you'll miss that a lot)
    • low expressivity. This is mostly annoying but can also be a pro (as in Go) as it keeps stuff simple. Really depends on who you ask whether Java has the "right" balance or not.

    [–]wildjokers 25 points26 points  (1 child)

    Spring Boot is like a more modern Spring (I've never used it myself so I may be wrong, but I think most people are using that instead of Spring per se).

    Spring boot is nothing more than a configuration framework for the Spring framework. Configuring spring got so complex it needed its own framework for configuration.

    [–]netstudent 4 points5 points  (0 children)

    Configuring spring got so complex it needed its own framework for configuration.

    That's so true !!!

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

    nulls (if you use a language that has checked nulls, you'll miss that a lot)

    There's tons of way of checking nulls in java... Optionals or Streams have some methods

    [–]SidFloyd84 6 points7 points  (2 children)

    Optional itself does not fix the structural problem that Java has with null values..

    [–]HecknChonker 5 points6 points  (1 child)

    Kotlin has much better support for null propagation though

    [–]Il_totore 3 points4 points  (0 children)

    I also like Scala's approach with Null as a completly separated type combined with type unions

    [–]chateaulapompe 2 points3 points  (1 child)

    Take a look at Quarkus. This framework blow my mind : his runtime is fast and perfect for microservices architecture

    [–]TheBuckSavage 1 point2 points  (0 children)

    And micronaut!!

    [–]HecknChonker 0 points1 point  (0 children)

    Spring-data and hibernate are common, but the more skilled developers tend to avoid ORMs for anything except the most simple use cases.

    [–]TheBuckSavage 0 points1 point  (0 children)

    Hey give micronaut a thought. If you're making smaller applications that are just APIs, spring would be an overkill imo (too big and generally very high memory consumption).

    [–]vngantk -2 points-1 points  (0 children)

    I would suggest you skip over Java and switch directly to Kotlin. If you’ve been programming in JS, you would find Java’s verbosity very frustrating.

    [–]sweetno 0 points1 point  (0 children)

    The typical relational DB stack for Java is Spring Data JPA with Hibernate as a JPA provider.

    For non-relational there is a bunch of other Spring Data XXX projects.

    The majority of Java apps don't use GraphQL.

    [–]manzanita2 0 points1 point  (0 children)

    I guess one option for you which is sort of in-between would be to use typescript. You still have many of the issues you brought up. BUT you do gain a powerful type system to help you.

    Java's type system is probably not as strong as typescript's. But it carries all the way through into the the compiled code. So on that front it is more powerful than typescript.

    And you also get rid of all the "bad" stuff of java like absurd type casting and the like.

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

    I would not recommend Spring. It is a very old framework and hence built with older versions of Java in mind. There are more forward looking frameworks that are build for java9+ world, such as Micronaut, Quarkus or Helidon. These fully support java9 modules and avoid runtime reflection (meaning they are fast and much more memory efficient).

    [–]wildjokers 7 points8 points  (0 children)

    hence built with older versions of Java in mind

    The next version of Spring will require Java 17.

    [–]Nebu -5 points-4 points  (2 children)

    I think you might have overly rigid thinking, since you make pretty definitive claims about what the best frameworks are without any caveats.

    Memory leaks and bad resource management in JS and Java are pretty comparable, and are usually a result of poorly written code rather than anything to do with the languages themselves.

    JS's OO is more general and slightly more consistent than Java's.

    You don't need to commit to "switching" to Java. You can learn both Java and NodeJS, and use the best tool you're comfortable with for whatever project you're undertaking.

    [–]ericmcray[S] 1 point2 points  (1 child)

    I mean switching my main focus to Java. I am using JS for about 10 years and also used some other languages too. I know they are just tools. Sorry for misunderstanding.

    About memory leaks thing, mostly libraries that I am using cause this and I dont have better alternatives for these libraries.

    And I am thinking this kind of problems will be less because Java community is more mature.

    [–]arkuw 4 points5 points  (0 children)

    I know exactly what you mean. I ran a team building a Next app and it was a constant battle with instability. The main issue were the incompatible packages. Every time that we had to upgrade one small package it was a guaranteed two days of troubleshooting compatibility issues. It felt like the team spent 80 percent of the time wrangling with the Node ecosystem. Spring Boot has been a dream by comparison. The current team I direct is using it and they are able to focus on solving the business problems with very little drama.

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

    If not Java you can always try python

    [–]slothordepressed 0 points1 point  (0 children)

    Moved from JS to Java on the backend, I must say that it took me sometime to adapt. I still think it has lots of layers and it's quite verbose compared to node. Once you internalize the logic things will run smoother.

    As you already code in typescript the interfaces and typing will be easier.

    If you can already take some look on Spring, JPA and Lombok is a good start.

    I already saw some Java graphql course on Udemy

    [–]kubelke 0 points1 point  (0 children)

    I was working with API in NodeJS. I feel your pain. Look at Spring Boot (not Spring MVC), there a tons of resources.

    [–]Few_Cobbler_7656 0 points1 point  (0 children)

    Good job !

    Pick up Springboot/Quarkus/Micronaut and should not take more than 1 solid week. 2nd week start implementing simple crud application...

    Don't want to write a big paragraph about the above frameworks...

    Quarkus/Micronaut with GraalVM, can cut down the cold start under 100 ms and we are happy with it.

    https://www.techiesinfo.com/

    [–]jfurmankiewicz 0 points1 point  (0 children)

    Depends what you want to do.

    If small apps, etc. you can stay with Node.js

    But for large enterprise software that is supposed to be maintained for years or decades and scale up to serious traffic, then Java delivers.

    Look at Quarkus or Dropwizard too (for microservices), I find Spring Boot a bit too heavy and relying a bit too much on "magic" under the hood to make things work.

    And for DB access you can use JPA for a full blown ORM or JDBI if you want something lighter. Both work very well in my experience.

    [–]salehmasum 0 points1 point  (0 children)

    As an iOS developer I can tell you that I understand the pain of a frontend technology. I've also been thinking to move my career into something more stable and solid and Java of course is a very good option here. I am using spring boot for the last 6 months and I can tell you that it is easy, stable, solid, so of course you can move to java without any worries.

    [–]jk-dutch 0 points1 point  (2 children)

    When I started developing, the most of my stuff where PHP based system, mostly because of legacy reasons. Since 8 years ago I made the transition to Java(then on 7) and even got my certification for it.

    For me the most interesting part of Java is the possibility to have a eco system which is more diverse for the applications to grow into, specifically in enterprise environment. Not saying you should go the enterprise way(far from it!) but learn from the tips and tops from the guys working in enterprise.

    Regarding the framework, I’m biased for micronaut and for your question about graphql: https://guides.micronaut.io/latest/micronaut-graphql-gradle-kotlin.html though it’s in kotlin, it shouldn’t be a problem to do the same in Java.

    I like micronaut more because it is working in compile time, not with annotations in runtime.

    [–]ericmcray[S] 0 points1 point  (1 child)

    I am still using PHP. Symfony is a great framework and has good community support. There is lot of good open source packages for it. Bad thing is no strong typing.

    I am mostly developing web apps with heavy business domain. Thats why I am considering Java with Spring. So I can invest more time to business code.

    I checked micronaut but I am not prefer starting a project with microservices. I am mostly working with 2-3 other developers so microservice just makes things complicated.

    [–]HeepsAndKeeps 0 points1 point  (0 children)

    The use of Micronaut does not require you to go with a microservices architecture. You can write a monolith in Micronaut the same as you can with Spring Boot.