On http4s, minimalism, and 1.0 #7386
Replies: 3 comments 4 replies
-
I strongly agree with a minimal With regards to uri, this exists, and may be a way forward. I would also express the need for the entity model such as it is in the main branch. This greatly improves the netty implementation and I think the perceived complexity is worth it. One might look at the entity model still as streams as a user, but will allow a more efficient implementation. However, we might accomplish the same with only providing an interface for |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting this conversation started :)
💯
This is me! Among a few others. But let me clarify: the desire is not just to make it part of toolkit, but to generally reduce the friction for any user of http4s to hit the ground running. Having a default client available (and possibly a default server) on some top-level imports can take us a long way. See discussion in #6696.
You could say the same thing about In fact, if I know my history, didn't CE originally start as just a kernel? I'm curious what the path to a concrete My vision of a minimal http4s is very inspired by Cats Effect:
I think (1) and (2) are more-or-less straightforward (I agree with your scoping above). Admittedly what does or doesn't go into (3) and what it should look like is a much harder conversation that treads on a slippery path back to the http4s we have today. However, I think it's important to acknowledge there is stuff that does fall in this category and, when done well, a high-quality stdlib is a major asset. (1) is essential for unblocking http4s 1.0. (2) isn't necessary but I think would be prudent. (3) trails further behind: many of the prospective candidates for an http4s stdlib have not had sufficient time to mature. |
Beta Was this translation helpful? Give feedback.
-
Should we keep doing 1.0 milestones as this takes shape? An 0.23 patch is imminent. I don't want to leave people high and dry, but the final product is going to look substantially different. |
Beta Was this translation helpful? Give feedback.
-
On http4s, minimalism, and 1.0
http4s has been binary stable for 939 days, which warms my enterprise
staff engineer's heart. It has also been 0ver for 4,050 days, a more
dubious accomplishment.
How big is it, anyway?
The GitHub description for the project has long read:
Let's check the
cloc
.This is after The Great Schism, which split off a significant number
of modules.
By way of comparison, this is bigger than cats-effect:
It's also bigger than fs2.
Why it matters
More code, more liability, more bikeshedding, more 0ver.
What is minimalism?
The original spirit of the project is neatly described by our Rack
cousins. Let's indulge our Scalatra roots, and substitute Scala for
Ruby:
A revised strategy for 1.0
Let's extract a kernel from core. The kernel should be just enough to
serve as the sole dependency of a server and a client implementation.
It should also be enough to serve as a target for "front ends" like
Smithy, Endpoints4s, and our trusty old extractor-based DSL.
In scope
The base is a
Request
andResponse
in compliance with RFC9110.This likely pulls into scope:
Uri
: a blight on http4s-0.23. This may be best manifested incats-uri, though that project is not currently maintained and would
add to the "import tax" that plagues http4s-0.x.
Headers
: calledfields
in the spec.Entity
: calledcontent
in the spec. A minimal definition isan
fs2.Stream[F, Byte]
, but one of the significant divergencesbetween the main branch and series/0.23 today is the Entity
sum type with strict and streamed implementations. There are
performance benefits to this, and it represents some tension we'll
need to resolve in the definition of "minimalism".
Methods
andStatus
: now, is it minimalist to imbue them withsemantics like
isIdempotent
orisClientError
?Version
: there can only be 100 of them. At least this is solid!Out of scope
These features are important parts of http4s, but they're also subject
to bikeshedding.
HttpRoutes
andHttpApp
: as much as I will miss the demagogueryaround monad transformers, up to and including being blamed for
climate change,
Request[F] => Resource[F, Response[F]]
is enoughto implement a server and a client. And Kleisli composition will
always be available for those of us who understand that the network
is their bottleneck.
ported to MTL. They're also not kernel. This includes supporting
features like auth and metrics algebrae.
became the de facto backend. It's still quite useful, and
eliminating it would be traumatic. But it's definitely not the
kernel.
underlying model is already a
(CIString, String)
product. Leavethese to the front ends.
EntityEncoder
andEntityDecoder
: http4s was designed whentypeclass codecs were en vogue, but implicits fall apart when
there is no canonical instance. Is a
String
plain text or a JSONstring?
need to exist, but HTTP != JSON.
staticcontent
services: not core!Open questions
Attributes
I have long regretted the attributes. But how do we support extended
functionality, like web sockets and servlet sessions, without a way to
smuggle information through?
HTTP/2 and HTTP/3
Perhaps related to the above, do we have everything we need to
support HTTP/2 in full? HTTP/3? We have to get this right now. Our
WAI cousins created an HTTP/2 application for push support.
An implementation versioned with the kernel
There is a stated desire to make a default configuration part of the
Typelevel toolkit. I think Ember is a fine starting point for that,
and tactically it makes sense to compile it against the kernel as the
kernel is defined. I see no reason it has to be versioned together
with the kernel, or why a toolkit couldn't depend directly on it.
One thing that could persuade me is that if the kernel model can be
made safer if a codec appears in its companion objects, but this
substantially increases the size of the kernel.
Beta Was this translation helpful? Give feedback.
All reactions