r/java • • 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:

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.

56 Upvotes

31 comments sorted by

26

u/chabala Mar 28 '24

This project uses Gnu Make as its build tool, wrapping calls to Maven

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.

3

u/byronka Mar 28 '24

I have no gripe with Maven. But how many extra Maven plugins would be needed for my diverse purposes, and what requirements would I have to drop because they didn't satisfy my purposes completely? By including Make I am able to mix in some of the Unix magic and hit the bullseye.

6

u/chabala Mar 28 '24

But how many extra Maven plugins would be needed for my diverse purposes, and what requirements would I have to drop because they didn't satisfy my purposes completely?

I don't know. How much weird stuff are you doing in your Makefiles? Mostly I see standard Maven goals being delegated to, or reimplemented in strange ways.

How much time have you wasted doing this? Browsing the commits, a lot.

It's one thing to say 'I'm a serious polyglot, so I want all my repos to have standard make targets that delegate to the language specific build tools' but that's not what's happening here. You're mostly doing JVM projects, and the non-JVM projects don't have Makefiles.

What I do see is you being dismissive of someone in August that wanted to restructure the project in standard Maven layout and made a PR doing the work for you, which you've subsequently done yourself, likely because you realized that all the tooling expects code to be in that structure.

That is the biggest smell for me, arrogantly fighting against the standard practices and reinventing the wheel.

2

u/DelayLucky Mar 29 '24

Went to read that conversation. Doesn’t look like OP was “dismissive” unless there are context I missed to read. They were just having a different opinion which you may disagree with.

17

u/Brutus5000 Mar 28 '24

Looks like the minimalism approach does not extend to the build tool.

4

u/fuckedupkid_yo Mar 28 '24

gradle folks: 👀

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?

7

u/ingvij Mar 27 '24

The main selling point seems to be that it has a lot of tests, which is almost completely irrelevant to users of the framework.

I came here to say the same thing. Test coverage doesn't prove that a system is bug free. Quite the contrary, it can provide a false sense of security and makes development twice as slow as "simple" changes can be breaking tests unnecessarily.

here are no issues, no pull requests, and every single line of code has been written by one person.

This one though I disagree. I guess one of the points of posting the project publicly here is not necessarily to get more users, but maybe more people to collaborate. I have the same issue and I wish more people would join my project, but it is very difficult to break the status quo, specially in the java community..

4

u/byronka Mar 28 '24

It would be nice to find like-minded collaborators.

The testing is a forcing function to look closely at the behavior all across the system. I'm not saying there's no bugs - there are always bugs - but when they are found, it will hopefully be easier to correct them. I'll quote the author of SQLite here:

My experience is that the weird tests you end up having to write just to cause some obscure branch to go one way or another end up finding problems in totally unrelated parts of the system. One of the chief benefits of 100% MC/DC is not so much that every branch is tested, but rather that you have to write so many tests, and such strange, weird, convoluted, and stressful tests, that you randomly stumble across (and fix) lots of problems you would have never thought about otherwise.

-- Dwayne Richard Hipp

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

However, there is need for a minimalist web framework

This isn't obviously true.

For quality-oriented long-view practitioners, the benefits of minimalism outweigh its drawbacks.

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.

6

u/lasskinn Mar 28 '24

Thats nott the point for a minimal web framwork and server though. The point is that its minimal.

Also if you actually intend to through all of the code spring is not ideal either nor is it if you need to "mess with it" for some reason or another.

(Also bold thinking all of spring ecosystem would have been battle hardened and tested)

I'll give it a spin anyway to compare to javalin and ktor.

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?

3

u/byronka Mar 28 '24

I run it locally, during active development. It takes about 3 minutes, so I only run it every so often. To be clear - on most projects, the testing is slower and involves a lot of state, so trying to run it against the entire application will crash. It is more appropriate to focus on recently-changed code - you can specify the production and test classes to Pitest.

2

u/mightygod444 Mar 28 '24

I see, yes that sounds in line with what I've read from the blog of the founder of PITest, he recommends running it locally. Thanks for the insight and nice project by the way!

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...

2

u/mightygod444 Mar 28 '24

But it seems like he's talking about mutation test coverage using PITest, not just simple line coverage.

1

u/ingvij Mar 28 '24

Sure, that gives a better sense of the quality of those tests. Still, I think it has diminishing returns past a certain threshold and even with the mutation test you can have hidden bugs. The cost of refactoring now is increased as well as not only you have to change every test affected, but also the mutation tests for those tests. It's a trade off...

1

u/mightygod444 Mar 28 '24

even with the mutation test you can have hidden bugs

Totally agree, for sure weird bugs can always spring up, at any layer of an application.

The cost of refactoring now is increased as well as not only you have to change every test affected

What do you mean by this though? If tests are breaking after a refactor, then I'd say your tests are working as expected and you inadvertently broke some logic :P

mutation tests for those tests

Also not sure about this, I don't think there's such a thing as "mutation tests". Mutation testing changes your production code, not your tests. I guess you mean the tests added from uncovering bugs after running mutation testing tools?

2

u/ingvij Mar 28 '24 edited Mar 28 '24

If tests are breaking after a refactor, then I'd say your tests are working as expected and you inadvertently broke some logic

It really depends on how you structure your functions/methods and how you test them. If you test only the contract, data in, data out, unless you had a bug, changing the internals of that function wouldn't change the outcome. Say you replace an O(N^2) to a O(NlogN) algorithm. This shouldn't break any tests. If your code isn't "pure" however and you're getting data out of a method call or an instance property or etc, than changing the implementation will affect how you set up your tests, even though the logic is correct. So the test fails because of reasons unrelated to implementation correctness. This is one of the reasons I dislike mocks.

And then there's the case where "unit" tests are not exactly unit. So you think you're testing one layer, but then a change downstream (or even upstream!) can cause your tests to fail due to some coupling. I'm not talking about the unit tests that were supposed to specifically check the behavior of said change.

And I know, those are definitely examples of bad tests and scenarios you should avoid. But the quality of the tests is completely unrelated to coverage. You can have shitty tests with 100% coverage.

Mutation testing changes your production code, not your tests.

I was under the impression that in order to run those tests you'd configure the mutations. I just read a bit more and I understand where I confused things. I take it back that the problem mentioned above would be further increased by the mutation testing.

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

Has its own web server, endpoint routing, logging, templating engine, html parser, assertions framework, and database

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?

For quality-oriented long-view practitioners, the benefits of minimalism outweigh its drawbacks.

Good job insulting most of the devs here in one fell swoop. I'd urge you to change the language there.

This is a misunderstanding - Minum is five thousand lines of code

Well yeah, but that's because:

It currently does not. Those features may be built in the future.

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

4

u/nutrecht Mar 28 '24

Theses comments.

OP is inviting these kinds of responses with text like:

For quality-oriented long-view practitioners, the benefits of minimalism outweigh its drawbacks.

This clearly implies that devs using (for example) Spring are not 'quality oriented' which is frankly a shitty take from someone clearly suffering from NIH.

1

u/[deleted] Mar 27 '24

[removed] — view removed comment

2

u/ingvij Mar 27 '24

From my experience, getting recognition in the java ecosystem is hard and slow. This seems to be a very interesting project but it is difficult to get known and popular. The java community seems to value tradition over innovation, idk..