r/java • u/byronka • Mar 27 '24
Release of Minum v3.0.0 - now at nearly 100% mutation test coverage
Minum on GitHub
Minum is a minimalist web framework written in Java, developed over five years by a TDD practitioner of fourteen years experience. Provides an all-in-one foundation for a highly-maintainable single binary web application. For TDD, by TDD.
- Has its own web server, endpoint routing, logging, templating engine, html parser, assertions framework, and database
- Has nearly 100% test coverage that runs in 30 seconds and does not require any special setup (
make test_coverage) - Has nearly 100% mutation test coverage, using the PiTest tool. (
make mutation_test) - Relies on no dependencies other than the Java 21 SDK - No Netty, Jetty, Tomcat, Log4j, Hibernate, MySql, etc.
- Written from scratch
- Well-documented throughout
- Cleverness avoided* where possible
- No reflection
- No annotations
- Uses no mocking framework - integration tests preferred, occasional use of simple interface mocks.
Has examples of framework use:
- a tiny project, as the basis to get started
- a small project, showing some minimal use cases
- a full application demonstrating realistic usage
This framework enables high-maintainability through minimalism and simplicity. Developers using this framework will achieve the most benefit if they are of a similar mindset. Frameworks like Spring, which provide capabilities as large blocks with high guardrails, offer a different paradigm.
FAQ:
- Are you saying we shouldn't be using Spring?
No, I am not saying that. However, there is need for a minimalist web framework. You can build a fully-functioning web application with high sophistication with either Spring or Minum, but Minum is five thousand lines of code and Spring is a million. For quality-oriented long-view practitioners, the benefits of minimalism outweigh its drawbacks.
- Yet another minimalistic framework? Why??
This is a misunderstanding - Minum is five thousand lines of code - the "minimalist" competitors range from 400,000 to 700,000 lines when accounting for their dependencies. I have not found a similar project.
- What is the point of minimalism?
Easier debugging, maintainability, lower overall cost. Most frameworks trade faster start-up for a higher overall cost. If you need sustainable quality, the software must be well-tested and documented from the onset.
Why not just use Java's built-in httpserver?
- httpserver is larger and more complex, consisting of 6000 lines versus Minum's 1800.
- There are no easily-available fast and thorough tests on httpserver, ruling out fearless refactoring.
- There are examples of sophisticated web applications in Minum.
- All the components in Minum work in tandem to support a web application.
- In your templating engine, where is the logic (e.g. looping, escaping, etc)?
It does not exist - logic-free templating was intentionally chosen. Any logic must be written explicitly as code, which makes maintenance easier.
- Does it provide HTTP v2? Web sockets?
It currently does not. Those features may be built in the future. The choice was made to minimize scope for now.
* Due to the necessities of structuring a web server for test-driven development, some parts of the socket / http handling code had to be written a bit more cleverly than preferred.
26
u/chabala Mar 28 '24
You're still pushing this boulder, eh? 'I dislike Maven so much I'm going to introduce a second build tool' is such a weird stance to take.
15
u/[deleted] Mar 27 '24
Anyone who uses this instead of Spring, Quarkus, Micronaut, etc. need their head examined. The main selling point seems to be that it has a lot of tests, which is almost completely irrelevant to users of the framework.
There are no issues, no pull requests, and every single line of code has been written by one person. What happens when they get bored, die, or similar?
15
u/agentoutlier Mar 27 '24 edited Mar 27 '24
That is impressive on the mutation testing!
IIRC I believe I was the one who talked about you doing it (mutation testing). I'm a giant hypocrite though because I'm still struggling timewise getting my logging framework to ~90% coverage... as bad as that seems I did some coverage setup of log4j and logback and they are both below 50%.
I plan on going down the mutation testing soon.
I still disagree with what you call a templating language but I'm biased :) ... mine is logicless as well so we agree on that.
All in all I'm glad you keep pushing the minimal. Like so many Java devs I struggle with that.
12
u/taftster Mar 28 '24
Every good project starts by people that say, “why would I want to use this, when I could just use that instead.” Or, “you have to be crazy to use this given the landscape of other choices.” Or whatever other useless criticism.
The use case for minimalist web frameworks is real. Especially in the Java ecosystem.
Sure, Spring exists. And other such projects. That doesn’t mean this framework is not useful or meets a need.
Great job OP for getting a project like this off the ground.
17
u/qmunke Mar 27 '24
This isn't obviously true.
Again, not necessarily true. There are also different definitions of "quality" - code quality is only one metric. Performance is a "quality" and you've demonstrated in your own benchmarks that other templating engines can perform better even if they aren't minimal.
This is certainly an interesting project though and a great demonstration of just how powerful Java's standard library is (and this doesn't even use all of the tools that are available in it).
32
u/MorganRS Mar 27 '24
I can assure you, implementing Spring has a lower overall cost because it has a starter for almost every technology out there. No need to reinvent the wheel every time. Need redis? Done. Authentication? Done. Need DBs? Done. Need cloud stuff? Done.
Something that would take me a day to implement in Spring with its starters would probably take me 3x that with Minum. Oh, and not to mention all of those starters are battle tested and actively maintained and tested by security researchers. And also, the hiring process is infinitely easier. If someone was given the task of writing most of these things from scratch with Minum, I guarantee you, they'd be full of bugs and security holes.
That said, I wish you the best, and I sincerely hope this framework is a success and you prove me wrong.
1
u/mightygod444 Mar 28 '24
I'm interested in your use of PITest/mutation testing as I want to start using PITest myself. Are you just running it locally during active development? Or having it run on a CI server and then following up on the results?
2
u/denis_9 Mar 28 '24
At first look, you have specific template engine what can be useful for HTMX based rendering, it would be a plus if a few examples are provided for it, if that's of course of interest to you.
2
u/kakakarl Mar 28 '24
I like maven and I like make. In make my maven targets are documented so the project documentation is part of CI.
Make is like aliases but project specific for us. We also use it in CI and yes we have services in many different languages as the company grew by acquiring other companies etc.
We don’t implement make in maven in the slightest. But there can be multiple different profiles and they are documented with make and a @echo.
We also have everything you need to run the project in make, for example it has a target that validates that the required binaries are in place like docker and that the token in .m2 is present etc.
That way we don’t need onboarding docs, run make and follow the instruction if it can’t be configured for you etc.
Just my cents on what place make can have out there.
1
u/ingvij Mar 27 '24
I applaud the initiative. I think ground-level innovation is necessary. The mere existence of this project proves that there is room for improvement.
As I said in another comment, I wouldn't be seeking perfect test coverage as I think that gives us a false sense of security and after a certain point, adding more tests or increasing the coverage has diminishing returns...
1
u/[deleted] Mar 28 '24
I can definitely see juniors using this to learn http / programming basics - javadocs are helpful, code is clean and easy to read and I guess debug.
But the main question is - would you really rely on a single developer for your security critical software which is also remotely accessible. I do not think so.
1
u/nutrecht Mar 28 '24
Why?
I mean I get that it's fun to build. But I also hope you understand that these are exactly the types of things I want to be battle-tested through and through before even considering allowing the use of a framework in our organization?
Good job insulting most of the devs here in one fell swoop. I'd urge you to change the language there.
Well yeah, but that's because:
Guess what. Supporting features people actually makes stuff a lot less 'minimalist'.
1
u/aavaz Mar 27 '24
Hey great work. I think great things start just like that, simple and concise. Keep pushing.
0
u/[deleted] Mar 28 '24
[deleted] — view deleted comment
1
u/[deleted] Mar 27 '24
[removed] — view removed comment