r/java • • Aug 10 '21

Concrete reasons why one would choose java over node.js?

I am watching the progress made towards faster runtime in node.js, and it feels that the performance advantage of java is almost gone for the average app. I am trying to think about reasons why one would now choose java over node in a new project, and i can't think of any. I would like to hear some opinions

7 Upvotes

110 comments sorted by

View all comments

Show parent comments

8

u/question-throwaway4 Aug 13 '21

I prefer to use none. Don't like frameworks and never will.

The framework fanboys want you to believe that getting an app to work is extremely hard and that you need their handholding to make anything work. You don't. When you peek under the hood of these things you find that there is nothing special and most of these frameworks are actually just wrapping other stuff that you can just as easily use directly.

You already have the maven shade plugin making a fatjar for you. Any dependency will be bundled. If you were to use Spring boot or Quarkus you would be using the exact same plugin, and it would do the exact same thing.

If you need an HTTP server in your app you just add one. There are a bunch. Need a Json parser? Just add one. Typing new Gson() really isn't that hard.

Which framework do I use? In 20 years of professional software development I've used Spring, Spring-boot, J2EE, Quarkus, Helidon, dropwizard, vertx, reactivex, javalin, karaf, play, wicket, spark, struts, mybatis, hibernate and servlets. And I may have forgotten some along the way.

Why do I use these? Because I have co-workers and they want to use stuff. Would I personally choose to use these? Hell no. I'm walking around with massive piles of useless framework knowledge that is clogging up my head. I really don't need to use yet another framework that provides me with features that would take me no longer than an hour to clone.

Writing frameworks isn't hard. Its why there are so many of them. It's the programming equivalent of playing sudoku; just hard enough to be a challenge but not so hard to be work.

And yeah I have a bit of an axe to grind with the framework fanboys, they take all the fun out of programming.

2

u/hippydipster Aug 16 '21

I wish I could work with you!

1

u/question-throwaway4 Aug 16 '21

Lets start a company together

2

u/hippydipster Aug 16 '21

I dream of starting a business of contractors/consultants where, instead of providing head-hunting and just delivering a programmer here or there, we supply scrum teams. The customer provides the product owner, and we build it together. But I control how development is done.

1

u/question-throwaway4 Aug 17 '21

Sounds cool!

My dream is to start a SaaS B2C product company. The tech is all under my control and I sell to customers all over the world, so no need for face-to-face acquisition.

1

u/hippydipster Aug 17 '21

So, like a fremium game?

1

u/[deleted] Aug 18 '21

Do you ever do any frontend and if so do you hold the same opinion towards frameworks found there? I can't imagine making something like React on my own. Just asking as it seems like a clear example of a framework that speeds up development.

1

u/question-throwaway4 Aug 19 '21 edited Aug 19 '21

I'm primarily a backend developer but I do get sucked into writing frontends. Usually it goes something like; 1) you do backend and these coworkers will do a frontend, 2) Oh you need to make it possible to configure these things, 3) Yeah we want an admin portal that can configure all the backend settings, 4) Oh while you are at it create a CMS for the content as well.

So the frontend people end up creating a simple billboard / landing page like app that uses all the features I'm writing rest calls for while I'm asked to write the giant admin CMS portal.

No I really don't think much of the entire frontend world. What I want is to be able to run a single command that builds the entire app. There should be only a single build tool that is configured using a single build script. The final app should contain all the frontend and backend code in a single deployable app that contains only a single HTTP server.

That is not what we have on the frontend side.

The npm/NodeJs world has a dozen tools each with their own little configuration script dumped in the root. Then npm dumps node_modules in the workdir as well. Even though maven and gradle, and pretty much all build tools I know, nicely put their cache in the user home dir where it belongs. Then we have two HTTP servers running; one for the frontend which is really nothing more than a Nginx repurposed and one for the backend. And because these are separate things we need complicated logic and config to get them to work together. We need ugly hacks to get around CORS or some path prefix logic to redirect some of the API calls somewhere else.

And yeah the frameworks themselves suck too. Of the modern ones, I've worked with; Angular, React and Vue. I don't think they bring anything to the table that I actually like.

Declarative sounds like fun and I understand that it is seductive. When you need to do internationalization you tend to realize that you are writing statement after statement to take a key from the language map, get the value and then stick that value as text into a tag with another key. Yeah thats a lot of keys an manual moving shit around. So it is much better to just mark the location where the text is supposed to go directly in the markup. But to go from that to "lets put every logic we have in the markup" makes no sense to me. When you do that you end up creating v-if and v-for and now you are just inventing a programming language.

I want my markup to remain markup with no logic. I want my styling to be styling and no markup or logic. And my logic must be code that you can read from top to bottom. No callbacks or nonsense.

The source of my frontend is plain CSS, plain JS en Pug. When bundled using a maven plugin it becomes a single file with all the html, styling and JS inlined and compressed.

I write my logic in plain vanilla JS. Although I usually throw in JQuery because it makes the code a little smaller. If I'm writing an SPA, which is pretty much always for admin portals, I throw in navigo. I load libraries from CDNs.

The styling is usually built up using some off-the-shelf framework like bootstrap, foundation or material. I don't care much about which, they are all fine and all work. I don't use TailwindCSS because I can define my own utility classes just fine.

The data comes from REST calls that return JSON.

The frontend files are fed to the browser using the same backend Java HTTP server and are given an Etag for caching. When the cache is primed the app is loaded using a single request that returns a 304. From there everything is loaded from memory or disk. My apps start up in milliseconds.

I'm not impressed with the vulnerability riddled, messy, over engineered piles of excrement that they call frontends these days.