I’ve noticed that Java, Python, Perl, and Haskell/Clojure have distinctively different treatment of static functions. In particular,
1) What are the idiomatic differences in the way static functions are implemented and utilized in different languages.
2) Do some of these languages have “more complete” separation and support of static vs statefull methods than others?
For example :
In clojure, all functions are, essentially, static – allowing for extreme modular composability , not associated with any thing in the object-ether. Clojure-functional programming can be described to java programmers as similar to static functions.
Meanwhile, in traditional idiomatic Java, there is often a mixture, where object-oriented features maintain internal state, relying on external static methods for certain, often stateless transformational operations.
Then, there is the scripting world : I’ve noticed in Perl and Python that the concepts of differentiating static vs stateful code are not stressed quite as much (UPDATE:As per comment – maybe this is due to the multi-paradigm nature).
And finally, we have the object-oriented breed of PHP-5 developers, who seem to code similarly to java developers in its their treatment of static vs stateful (object scoped) functions.
Any other insights into the differences in how different programmers, from different backgrounds, treat static functionality would really help me to review code with a few PHP/Perl developers that I work with.
The relevant distinction may be the programming paradigm emphasized by language. Functional languages such as Haskell & Clojure aim to eliminate side effects and emphasize determinism; encapsulating mutability or state in thinks like monads. This is in contrast to Imperative languages. Perl & PHP are multi-paradigm languages, so it is possible to implement imperative styles such as procedural and object oriented coding, or even emulate functional styles.
In collaborating with imperative programmers it might be worth focusing on loose coupling and side effect free design patterns such as Dependency Injection.