1,356 karma · joined Jun 19, 2017 (9y ago) · 591 submissions
comment 6y ago · link · parent
A purely functional approach would involve a core of functions taking in a current state and returning an updated state and a list of canvas actions to take.
Functions might include "select ellipse tool" and "set pen width to 5" and "click on canvas at point (3,15)" and return canvas primitives like "render ellipsis from (3,15) to (47,99) with stroke width 5, stroke colour black, and no fill".
Unit testing of the core should obviously be quite simple to do, being totally independent of the GUI system.
comment 6y ago · link · parent
I had trouble believing he'd diagnosed it when he glanced at the ultrasound and calmly said what it was. Given I'd had medical practitioners send me for neurological studies to check it wasn't all in my head, suggest fusing my wrist to stop the pain, tell me there was nothing visible in X-ray, MRI, or the same ultrasound report the surgeon diagnosed me from... It seemed unlikely anyone could do an apparently simple diagnosis like that.
comment 6y ago · link · parent
It turned out to be a benign tumour. Surgery was my answer, but it's only a partial one. It's a soft tissue tumour, the surgeon didn't expect to get all of it, and it's growing back now. It's been about seven years, and I expect I'll need surgery again within seven more years to be able to do simple tasks like lift objects with that hand still.
Sometimes it's not diet - but it's like the old climate change joke. What if I switched to a better diet and a healthier lifestyle, for no good reason?
comment 6y ago · link · parent
Two very common machines from the era were the ZX spectrum and the TRS-80. But there were dozens - Kaypro, Osborne, MSX, the Nintendo Gameboy... the Z80 was used in lots of machines. Chips based on the Z80 are still used in embedded systems today.
I built a retro-computer this year using a Z180, which is a Z80 (minus undocumented behaviours) core with a handful of useful peripherals built in. They're still actively manufactured and sold.
comment 6y ago · link · parent
It's easy for us as developers to think that source code is valuable - but this leads to problems like never removing code "in case it's needed", or with an in-house dev team developing systems you could get off the shelf.
If code is an asset, then it makes a lot more sense to write stuff yourself: you not only get the artefact, you also get the source.
If it's a liability, then it makes a lot more sense to let someone else bear the costs of that liability, especially if they have economies of scale, except where you can't get your desired outcome other than writing code.
This is of course technically incorrect. It's perhaps more accurate to say that source code requires upkeep and is expensive to maintain. That tends to draw less interest and discussion, because it's "obvious." Except as an industry we're overall pretty lousy at paying the required upkeep on code.
comment 6y ago · link · parent
Unless you happen to be one of the very rare companies that sells source code and not built artefacts, your asset is the built artefact and your code is the expense you take on to get it.
Having less code to get the business outcome only makes sense when you see the code as a cost, not a thing of value itself.
comment 6y ago · link · parent
Bad type systems need you to use the escape hatches frequently - you can't write much C without using casts.
I haven't yet used a language with no need at all for an escape hatch - but some languages need them far less often than others.
Java's type system is better than it was. The main places it still has weaknesses are around exceptions (you will need to wrap checked exceptions in runtime exceptions in places you'd have preferred to specify an exception type via generics, eg) and the occasional cast after an instance type check.
You can phrase good development practices in business terms: what are the risks to the business due to sloppy code? Are they greater than the risk of being slow to market?
Sloppy code has accumulating costs. A good type system can help greatly with refactoring to address those costs, but it cannot help with the attitude that those costs aren't real and don't need to be paid.
comment 6y ago · link · parent
comment 6y ago · link · parent
The "output monad" described is usually called the Writer monad - you can append to a log, but you can't do anything based on what was in it. It can be generalised from strings to any monoid - a domain that has an empty value and an associative concatenation function.
The IO monad, as another commenter said, is a kind of state monad where the state is something ineffable from within the computing environment: it's the state of the world outside the program. But there's no need to rush to trying to fit the IO monad to this model - we can start with the "reader monad".
An element of D* for the reader monad is a function from an element of some specified domain R to an element of D. The mapping from D to D* is a constant function that produces D no matter what the argument to the function in D* is. D's elements are functions from R to D* so the collapse is function composition and therefore associative. Likewise, f* from D* to E* is function composition, which composes, obeys the embedding of D into D* and since both collapse and embedding functions is function composition f* * (s')V == f* (s'V).
The reader monad is sometimes called the environment monad, because there's some environment (the value from R) that is available to all computation. The key thing it gives us for this article's model of monads is that elements of D* don't have to just be pairs, they can be functions.
Sort of combining the Reader and Writer monads gives us a monad where an element of D* is a function from an element of the domain S to a pair from (D, S). The embedding from D to D* is the function that copies its input state to its output pair. The collapse from D is composition with application. An element of D* * is a function S -> (D* , S), or S -> (S -> (D, S), S); apply the function in the pair to the state in the pair and you get S -> (D, S). D* * * is the further nesting of this structure, S -> (S -> (S -> (D, S), S), S). Evaluating this is associative: either way you will pass the initial state through each function in the same order to get the final output state. Embedding a function also satisfies the laws; effectively it will transform the final output D and leave the state S alone.
The collapsing of State to ensure its functions are always evaluated in the same order is how the IO monad provides sequentiality of effects. The state is "everything outside the program" - the user, the keyboard, the network, the operating system, even parts of the interpreter state that are not typically open to program inspection, perhaps allocations or bit-level representations.
An element of D* for the IO monad can read from the state of "everything outside", seeing whether the operating system has a character in its console input buffer perhaps. It can modify the state of "everything outside" by writing a character to the OS console buffer. And it preserves the order of these things because of how collapse is defined.
It also needs a magic interpreter that can provide the initial state of the world and maintain it as the program updates that state, along with magic primitives that can make changes to an ineffable "real world" state.
comment 6y ago · link · parent
I blog my work activities on an internal wiki for similar reasons. Major decisions need to be gathered in project documentation but small decisions and daily challenges are good to have written down.
comment 6y ago · link · parent
These sorts of details will typically wind up in an implementation report document. It's rare that an IETF protocol specification document will attempt to pre-determine the solution to all such implementation details up front, and IMO, not good when they do.
In some contexts, it may be much better to require the application to re-obtain resource owner authorisation than to allow a replay of a refresh token. In others, it may be much better to avoid requiring resource owner authorisation. What you see as a bug, others would see as a critical feature.
comment 6y ago · link · parent
Here is my program:
def fool(input):
while input:
pass
The input given to the program is your answer as to whether it halts given that input.That's the gist of the proof that the halting problem is unsolvable. Whatever the algorithm or method is used to answer the problem, you can take that method and "embed" it into the program to be verified, and invert the answer.
The halting program doesn't say you can't answer for many or even most programs and inputs, it just says there'll be at least one counter-example.
comment 6y ago · link · parent
def foo(o):
if (b := o.a()) is not None:
b()
Because the original interface indicates that all "o"s must know about the link between "a" and "b", there's no loss of generality, but now there's a statically inferable structure: "o" must support an "a" that returns None or a callable.If you do a tiny modification to "def foo(o, a): ..." then this doesn't apply any more, and you're outside the realm of structural types and into the realm of dependent types, which means you must drink deeply of the static typing kool-aid and want to write type signatures that run the risk of being more complex than the code they describe.
(But I like to quote Conor McBride: "if you're not going to write types your type system has to be stupid enough a computer can do it", from https://www.youtube.com/watch?v=3U3lV5VPmOU&feature=youtu.be...).
comment 6y ago · link · parent
Do you think it's easier for a consumer to discover and vet certification organisations than it is for them to discover and vet transportation organisations?
The price signal you mention is the strongest one, which is why pigovian taxes are often the most effective approach to tackling negative externalities. It's a good example of the sort of government regulation that is many orders of magnitude more effective than individual action.
comment 6y ago · link · parent
We buy our toothbrushes from a retail store, many transactions removed from the manufacture of the toothbrush, and every organisation in that chain would have to voluntarily agree to honestly report its transportation details. This is unlikely.
Even if it did happen, the onus would then be on consumers to interpret these details, perform a comparison between a number of available brands, and determine the most conscientious choice. And then review this decision periodically, because transportation contracts come and go. This is a substantial amount of work.
Even if consumers were able to do that amount of work, they'd then have to replicate that work for every single product, because everything goes through a similar transportation process. There is absolutely no way that any individual has enough time in their lives to research the transportation details of even a reasonable sampling of products used.
And that's not even considering the transportation issues in the supply chain!
As you observe, individual organisations also cannot act, because doing so makes them less competitive.
This is basically the same reason why individuals can't effectively tackle climate change. There is far too much information that's hidden, and far too much time required to effectively assess information, for individuals to influence anything.
Like with climate change, there is a solution, and it's regulation. The problem would vanish overnight if the EU, the US, and I guess now the UK all refused to allow docking of ships with flags of convenience, or even just ones flying flags from countries that don't ratify the maritime treaties.
And like with climate change, the solution is hampered not because of technical difficulties or cost, it's hampered by lack of will to spend a relatively small amount of money on something that only has a social good and not an economic good.