I'd say it is the same thing in some contexts, but we focus on a slightly different aspects.
When people say that "stateless" means it has no state, it makes me laugh. Of course it has some state from some point of view, e.g. stateless service can be backed by complex graph of objects (dependency injection). The thing is network protocol has slightly different meaning of the "state": it is something that depends on previous request/response. But immutable service doesn't depend on previous calls too, by definition.
"Stateless" doesn't always related to HTTP-protocol, the same term we can use to argue setters in service objects in your shiny OOP code. And here you can see that these two terms are same in fact: immutable service is a stateless service and vice versa.
However, it's awkward for me to call a value object "stateless object". It sounds terrible.
Recap: in case of services (network or OOP, doesn't matter) I'd say these terms are interchangeable.
Just example:
interface Logger
{
public function logWarning(string $message);
public function logError(string $message);
}
It doesn't matter how many times we called logWarning
or logError
and order of calls doesn't matter too. Thus, we can call it "stateless service".
But this service is also has no setters and any mutators like changeFileName()
-> it is an immutable service/object.
Mutability makes object stateful.
Stateful makes object mutable.
These terms are interdependent in context of services.