top | item 39331126

Spark – A web micro framework for Java and Kotlin

64 points| znpy | 2 years ago |sparkjava.com

37 comments

order
[+] bborud|2 years ago|reply
I'd recommend Javalin (https://javalin.io/) instead. Same idea, only executed better and it is actively maintained.
[+] pritambarhate|2 years ago|reply
Unfortunately it's not being properly maintained anymore. Last maven release was in Jul 10, 2022. It's maven dependencies have security issues and need to be updated to latest version. So if you want to use it you will need to do that.
[+] topspin|2 years ago|reply
SparkJava has an actively developed fork/successor called Javalin[1]. It's straightforward to convert from SparkJava to Javalin. The latter is written in Kotlin but fully supports ordinary Java.

While the rest of the Java world was devolving into annotation hell, AOP and other nightmares, these microframeworks showcased what happens when you leverage modern Java language features. A small but enthusiastic following has developed and they pop up now and then.

[1] https://javalin.io/

[+] AndrewSChapman|2 years ago|reply
I could be wrong, but I think Vertx would be a better choice? https://vertx.io/

It's actively maintained with full time developers, performant, supports Kotlin out of the box, and has more features?

[+] amarant|2 years ago|reply
I've used vert.x in a big project once. I don't ever want to do that again. Performance is pretty good, but the developer experience is beyond clunky.

My current favourite Java server framework is Micronaut.

Great performance and easy to develop for!

https://micronaut.io/

[+] selimco|2 years ago|reply
I’d say Javalin is more of a successor. Vert.x is too focused on reactive programming to qualify as a successor IMO.
[+] p2detar|2 years ago|reply
The community of vert.x is quite active. There’s a Discord server where discussions, releases info and help questions are being published in live chat.

Vert.x has already adopted VTs and in general its documentation is still one of the best I‘ve seen.

Really impressive work on the toolkit all these years. I love working with it.

[+] jillesvangurp|2 years ago|reply
If you are on Kotlin, ktor is a nice framework. And it works outside the JVM too. Ktor client works in the browser, on native, wasm, and on the jvm. Ktor server is mainly for the jvm but also works on native.

There are actually two ways to use ktor-server with native.

1) you can use Graal and compile your jvm project with that.

2) you can use kotlin-native and produce native code directly.

And I would not be surprised to see some wasm support come together either when the kotlin wasm compiler has had a chance to mature a bit.

But short term, targeting the jvm is the easiest. Either way, ktor is a nice framework.

[+] tfsh|2 years ago|reply
I've been working on a framework built on top of Ktor for a while now with the intention of providing SSR capabilities with the HTML and CSS DSL and auto generated bindings to generate JavaScript from Kotlin multiplatform code in order to provide interactivity.

The only stumbling block I've encountered is the hot reloading support, for whatever reason only half the application is reloaded (some classes are and others aren't). This has been enough of an enigma for me to plan a switch to vertx.io.

Massive shame because I think the general Ktor framework is brilliant and I especially appreciate their adoption of the Kotlin Multiplatform.

[+] aussieguy1234|2 years ago|reply
I've inherited an old legacy spark project. I find the developer experience and tooling of Spring Boot to be much better and it's well suited to building microservices.
[+] ysleepy|2 years ago|reply
Spark is nice, I switched to usinh jersey+jetty though, you get the mature API of jax-rs and everything in under 6MiB of dependencies. you can even use the jdk http server to be even smaller.

I'm very happy with that setup.

[+] grishka|2 years ago|reply
My ActivityPub project, Smithereen, is built on this. Though I had to fork it to add the ability to stream responses. By default it really insists on rendering everything fully into a string and only then serving it to the client. I also updated its dependencies and added support for Java 21 virtual threads.

https://github.com/grishka/Smithereen

My fork of Spark: https://github.com/grishka/spark

[+] debarshri|2 years ago|reply
So many memories of this library. They were early movers of Sinatra style web framework in java before spring boot.

Have deployed 10s of services into production build on java spark. Still works like charm.

[+] sidcool|2 years ago|reply
Last update was 2 years ago. I think this should be avoided for production use. Unless is so stable it need not be used.
[+] fnord77|2 years ago|reply
looks nice, but it has a name collision with apache spark
[+] ph4te|2 years ago|reply
SparkJava has been around since just about the time that Spark became Apache Spark. 10 years ago-ish.
[+] knvlt|2 years ago|reply
What‘s rubbing me the wrong way is the author pitting against NodeJS/Typescript on the front page without real arguments. You can pit your framework against another, but show me how it makes my life easier in comparison. Argue with features and developer experience, not with personal opinions.

„and unlike a lot of JavaScript web frameworks, Spark won’t be deprecated tomorrow.“

Especially if you can’t hold your promise. Deprecations are a normal thing in every software driven by individuals. We lose interest, get kids, etc.

[+] zackify|2 years ago|reply
I came here to say this too.

The funniest part is comparing it to expressJS, which hasn’t changed much in 10 years, and saying unlike JS frameworks, it won’t be deprecated tomorrow.

[+] hit8run|2 years ago|reply
I remember stumbling upon it like 10 years ago. IIRC Per took a year off work (parental leave?) and built it as a fun project. A very thin layer on top of the java standard. I used it for a few side projects and also hosted the official javadocs back in the day on one of my servers. If you need something tiny and simple on the JVM spark is still a valid choice although there are tons of alternatives nowadays.
[+] Sytten|2 years ago|reply
How is sprint boot + java thèse days? I have a client that wants to pick it up for a suite of services (and Java) but my experience with it 5+ years ago was that it was an overengineered painful thing to use. I would much prefer they use a Kotlin + ktor/vertx + jooq combo but I have a hard time convincing them.
[+] TeaVMFan|2 years ago|reply
This appears to be a server-side web framework only.

If your interest is one language (Java or Kotlin) full-stack for a single-page app, you will be interested in my Flavour book: https://frequal.com/Flavour/book.html

[+] arthur_sav|2 years ago|reply
At my company we dropped Spark in favor of Ktor since it's not properly maintained.
[+] Copenjin|2 years ago|reply
I've been using this for years, simple and gets the job done. Perfect when you just want to add an http endpoint to an existing java application quickly without including tons of libraries.
[+] jknoepfler|2 years ago|reply
It might be prudent to avoid name collision with an ubiquitous open source technology also in the jvm ecosystem.
[+] brazzy|2 years ago|reply
This framework is older than that "ubiquitous" technology.
[+] blacklite|2 years ago|reply
and we already have a bunch of these.
[+] winrid|2 years ago|reply
it's been around for a long time.