Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
abraham linksys
Sep 6, 2010

:darksouls:
I've started dipping my toe into writing web apps in Kotlin on the JVM. I'm a front-end engineer at my day job, but I occasionally poke around at the backend for fun (or when I can't pull in a backend engineer for a trivial change). We use Dropwizard at work for all our services (with a mixture of Java and Kotlin depending on the age of the service), and I've been pretty happy with writing in it, so I've started looking into using Kotlin for the API in a personal project (which was previously Express/TypeScript, which is just an absolute mess in practical usage).

One thing I'm still figuring out is what libraries I should pick and choose from the ecosystem. I picked up JDBI as my database layer, since it seems well-regarded and I don't really like traditional ORMs - we use it at work, though we've been experimenting with JOOQ in newer things (which I put aside for now purely because it seemed harder to set up and configure).

The actual web framework part is where I'm kinda lost. I've been building on this library I found called Javalin, which is one of those web frameworks that's very much One Dude's Neat Project. Like a lot of those, it's fairly minimal, but has a decent set of batteries included for things like validation and JSON serialization, as well as a lot of guides and tutorials. It's fun to write in, but before I go too much further with it, I figured I should look at the rest of the ecosystem.

Problem is, the ecosystem is huge, and while there's many things that Java does better than Node, open source marketing sites isn't one of them. I've been trying to sort through everything from Spring Boot, to Quarkus, to Micronaut, to JHipster, to Dropwizard, to Ktor, to Vertx, to like eighteen other things, trying to figure out what the best options are.

My guess, from what I've seen so far, is that Spring Boot probably is the framework with the most users and support. Mostly, I figure this from the number of times I've googled "how to do X in java" and gotten an answer that is specifically tailored for Spring Boot. On one hand, that makes me think it's something I could easily Google may way to production with; on the other, I worry that it has a lot of its own special complexities compared to other frameworks. Like, when I've started poking into what Spring actually looks like in practice, I've read about stuff like its @Transactional annotation, which requires using your DB library with a special TransactionAwareDataSourceProxy, and then somehow magically binds DB usage within service objects to a specific transaction - which simultaneously sounds awesome and terrifying. It seems like Spring also has its own DI that has some Rails-style "analyze all your poo poo and hook it up," which is kind of weird to me - I've been doing what could be charitably described as "manual DI" in my app (re: a root function that creates all of the objects in my app and passes them to each other's constructors as needed), since DI in general seems like a huge can of worms to figure out.

All that aside, one other thing I don't really get is where Spring Boot stops and where Spring itself begins. Spring Boot kind of markets itself as "pre-configured Spring," but its user guide seems to describe an entire framework unto itself, and just about every library you can use with it has a package used to configure it specially for Spring, not to mention that it has a "project initializer" with approximately 50 different checkboxes for these libraries. It's daunting in a way I thought it was specifically made to avoid being.

So I have few questions:

a) Are there other frameworks worth investigating for small to medium scale projects beyond Spring Boot? Since I've found Javalin to Suit My Needs so far, should I probably just stick with it?

b) Is Spring Boot the closest the JVM has to a recommended happy path for building new web apps? Is it still a big ecosystem, or are people moving to other frameworks, scared off by the dislike people have for Spring in general? And is it reasonably learnable for developers with no experience with Spring before?

c) I noticed that "Spring WebFlux" (which I guess you can use from Spring Boot?) seems to be one of the few web frameworks that supports Kotlin coroutines (outside of Ktor and I think Vertx?). Has anyone used it? Is it mature/supported/"production-ready," or more of an experimental thing? I don't really need to worry about handling a whole lotta connections at once in my little personal project anyways, but one thing that I liked about Node was async-by-default I/O, so you didn't need to change your programming model as you scaled. It seems like that's still very much not the case in most JVM frameworks (though I guess having an I/O thread pool means a lot of devs never have to think about it?) so I'm curious if WebFlux is anywhere near being a "default" recommendation yet.

Adbot
ADBOT LOVES YOU

abraham linksys
Sep 6, 2010

:darksouls:

Objective Action posted:

I think the problem in my mind is in trying to disambiguate what we are talking about when we talk web apps. You mention front end but then all the projects listed are geared towards service applications serving REST endpoints. To be fair I don't think that's your fault at all since searching for Java + Web anything is going to flood out the results with those these days. Of the ones listed I would say stick with Boot and only open the Spring can of worms one piece at a time when you want to add a new feature they already have into your code. Don't try to eat the whale whole.


Sorry for the lack of clarity of here - my project's frontend is a Vue app that consumes a REST API, so I'm looking for an HTTP API framework specifically. I don't need, e.g., server side templating.

I know some frameworks are focused more on the "internal services communicating between each other" use case instead of the "API consumed by a web app" use case, so I wanted to mention this is in the context of a web app just to filter out anything that is, say, GRPC-first.

abraham linksys
Sep 6, 2010

:darksouls:
I absolutely would not be writing Java or Kotlin without IDEA. I feel a little weird about having a language so reliant on the IDE (especially with Kotlin, since unsurprisingly there isn't much alternative tooling out there), but it is a tool that makes everything about the language make more sense to me.

On the other hand, I don't think you need to crack a book open and learn your whole IDE front to back before continuing. I'd run through a hello world in your IDE so you learn some of the basics, and then just learn incrementally. You should be trying to build and run apps and tests through your IDE (which is easy with IDEA's Maven/Gradle integration) and be comfortable with the debugger (which, if you've used a browser debugger before, you would be familiar with). The refactor tools are helpful but situational; you'll probably discover them when you need them.

In addition, as a full-stack developer, I would not go overboard trying to use IDEA for everything, since (a) that actually is where you get into the part of IDEA that costs money and (b) trying to integrate things like your frontend builds into IDEA will require a lot more overhead than you'd probably want. I just keep VS Code and IntelliJ running simultaneously (and did grab the uber-basic VSCode Kotlin plugin just so I could take a peek at backend code without opening IntellIJ when I'm focusing on frontend).

abraham linksys
Sep 6, 2010

:darksouls:
grafana cloud is free to start and i think pretty price competitive. i will say the ui for actually getting to the logs with loki is kind of weird compared to other dedicated logging systems (you basically have to "define a query" every time), but once you figure that out it's pretty nice (and ui improvements for this are at least on their roadmap). integrates well with metrics/traces if you decide to do that through grafana too

depending on how simple your logging is you might be best off with just papertrail though, we use it at work to handle a ton of logs that are too inconsistent to do anything structured with and we're pretty happy with it (tried to move to new relic logs at one point to get the integrations with their APM stuff and holy poo poo that was an awful nightmare of a product)

e: after writing this i reread your post and realized you were specifically asking for open source options, whoops. still, if you're okay with something paid and hosted, i think these are decent options

abraham linksys fucked around with this message at 22:07 on Jan 11, 2022

abraham linksys
Sep 6, 2010

:darksouls:

Submarine Sandpaper posted:

I told my boss that a mid level engineer cannot be expected to fix this, so they promoted me :toot:

truly the most good news/bad news thing ive ever read in this thread

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply