chchrutuch
Further, purity is about expectations, not scope. Expecting something to be pure means I can reliably call it with the same arguments and always get the same result, with the additional expectation that it will change nothing about the world. A function that accepts no arguments can be pure but must always return the same thing. If the person's name is indeed immutable, then person.getName(), provided it performs no side effects, is perfectly pure.
In concept, other than brevity, invoking a constructor on an immutable object is not much different than the function returned by a higher order function such as this:
(defn name-getter [{name :name}] (fn [] name)) (def get-name (name-getter {:name "John"})) (get-name)
"If you write Java code that has no side-effects, that doesn't read or change the local object's state, you'll be called a Bad Programmer."
No you won't.
"Java thinks that localised side-effects are cornerstone of good code"
Java doesn't think anything. It's a tool.
"Unfortunately, in practice Java doesn't just try to encapsulate side-effects; it mandates them"
No, it doesn't.
I will say I've worked in Java shops and seen the language used in this way. I've also worked in Java shops and seen people who have read and internalized the messages in Effective Java, especially with regard to handling state, and the codebase looked nothing like what is described in this article. I recommend the author take some time to read that book and keep reminding himself that Java is a generalized tool that can be used in many ways.
person.getName() is the same as getName(person). In the former it's an implicit parameter, in the latter it's explicit. Or, looking at it differently, one is a syntax for functional calls that prepends the first argument as a target, and one is a syntax that accepts the target as the first argument.
With Java 8 method references, you can see this a bit more clearly. You could, for instance, do this to get a function without the implicit this:
Function<Person, String> getName = Person::getName; getName.apply(new Person());