News for hackers. Stuff that matters.
Re:Microservices and the First Law of Distributed Objects by dragonwriter on Wednesday August 13, 2014 @05:12PM (#8175045)
> If you read that post again you'll see that Fowler's admonition about "not distributing objects" is really about "not distributing method calls", and method calls aren't that different from function calls so far as his argument is concerned in that (1) the latency of distributed function calls is 10^3-10^6 greater than local function calls, and (2) distributed function calls often fail for reasons inherit to the network and not the application itself.

The expense of distributed method calls comes from the fact that you are dealing with objects -- that is, containers of mutable state -- where you either need to synchronize copies across the network (expensive in terms of traffic/latency) or run all method calls on the place where the object lives (likewise expensive in terms of latency).

Pure function calls don't depend on mutable state, and so don't have those issues (further, to the extent that you do set up a system that requires a remote call to execute them, once you've executed a given pure function with a given set of arguments, you don't need to do it again, as the result is cacheable and guaranteed good forever.) You still have to distribute the calls that actually depend on mutable state, but if your language starts out with a clean distinction between pure functions and operations whose result might depend on mutable state, you start out miles ahead when it comes to dealing with distribution compared to working with a language which provides no language level distinction between pure and impure code, requiring either manual segregation or treat-everything-as-state-dependent-and-pay-the-cost approaches.

Re:Microservices and the First Law of Distributed Objects by bunderbunder on Wednesday August 13, 2014 @09:08PM (#8175647)
Practically speaking, function calls over a network are by definition impure.

Any function that is capable of returning varying results for the same arguments is impure. And a function call across the network could return anything - a correct response, a corrupt response, no response - depending on what the network's having for lunch at that moment. We do have clever tools like the I/O monad, yes. But the I/O monad doesn't take I/O and make it pure; it takes I/O and wraps it up in a clever facade that (usually) lets you pretend that it's pure.

Re:Microservices and the First Law of Distributed Objects by dragonwriter on Wednesday August 13, 2014 @09:40PM (#8175724)
Whether a function is logically pure or not precedes the decision to implement via a network call and, in the event that a pure function is for some reason implemented via a network call, shapes how you implement it as a network call (as it affects cacheability, etc.)

Obviously, the medium of a network call is inherently impure -- but in the same way that anything implemented in an any physical device is (including internal computations in an electronic computer without network communication.)

Re:Microservices and the First Law of Distributed Objects by bunderbunder on Wednesday August 13, 2014 @10:06PM (#8175759)
Technically, yes, you can follow that reductio all the way down the rabbit hole. Practically speaking, though, it's not generally considered problematic that there's no way to set a timeout before issuing the CALL instruction.
Re:Microservices and the First Law of Distributed Objects by dllthomas on Thursday August 14, 2014 @11:08AM (#8177837)
There are ways to set a timeout before issuing (a particular) CALL instruction. Occasionally these are important.
Re:Microservices and the First Law of Distributed Objects by twic on Wednesday August 13, 2014 @06:37PM (#8175329)
> The expense of distributed method calls comes from the [need to] run all method calls on the place where the object lives

Which is exactly the same in functional as OO languages. If service A has some data, and service B needs to make use of that data, then service B needs to make a call to service A.

The OO/functional axis is orthogonal to the monolithic/distributed axis.

Re:Microservices and the First Law of Distributed Objects by lmm on Thursday August 14, 2014 @08:33AM (#8177104)
What's expensive is shared mutable state. Isolated mutable state is fine - it can live in the place where it's used. Shared immutable state is also fine, as it can be distributed once and then reused as much as you like, and there's no need to worry about keeping all the copies in sync.

Functional programming is all about avoiding shared mutable state, so it does have an advantage here.