4 ms·
A part of the inefficiency is that business-logic oriented applications (a) often use stateful object models to organize their code and services, which are (b)
by bordercases 6y ago
A part of the inefficiency is that business-logic oriented applications (a) often use stateful object models to organize their code and services, which are (b) extremely difficult to reason about mathematically, both due to the pseudo-mathematical nature of mutable state, and due to no canonical formal representation of what an "object" is mathematically, nor what an "object" ought to be in software engineering.
The situation may be improving: more programming is moving over to the functional style which at the very least gets you algebraic concepts like combinators as the method for code reuse, and types + monoids as formal stand-ins for objects. In other words programming moves towards math when it makes functions really functions.
Category Theory and Linear Logic also provide models for data-transformation locales (objects) as well as resource consumption (mutation); but they are still heavyweight formalisms which have yet to make full penetration towards applications which quite frankly might not need them to do useful work.
- amw-zero 6y agoWhat makes state hard to reason about mathematically? TLA+ has a very formal definition of state and time that can be model checked or used for proofs. I think the reason that this is such a common statement is exactly because people don’t even know that state can be reasoned about mathematically, they just assume that it can’t be. The biggest thing that TLA+ showed me is that there’s no difference between functional and imperative programming from an algorithm standpoint. You can implement the exact same algorithm in both paradigms, and while the functional one has no explicit state, it can have a tremendous amount of implicit state. Recursion where a new state parameter is passed as argument to the next call is just as difficult to reason about as mutable state, it’s just less efficient from a processor standpoint.
- bordercases 6y agoI have no experience using TLA+, just secondhand knowledge, so you might very well be right. From my understanding, everything I said is true when restricted to classical logic. Otherwise, there are multiple approaches to objects and time, all of which are non-classical logics, and so are not commonly taught nor have they yet been embedded in many languages. TLA+ has been getting more traction, which might signal some kind of convergence since I last looked into it? I guess Rust would be another example where state is checked against using ownership signals, which uses non-classical concepts. Defending myself against the second claim, yes these algorithms have implicit state because the machines we're operating on are fundamentally stateful. But that's meant to be abstracted away at the language level and left for the interpreter/compiler to resolve. This still leaves problems for how to modularize code at the domain layer using functional idioms, which primarily express behavior over properties. OOP can be restricted in a way which makes this simple to bridge towards using the Actor model but that's still a step away from habitually structuring your code using modules monoids and combinators. TLA+ doesn't quite address this, since (IIRC) you don't implement your final system in TLA+.