• 0 Posts
  • 36 Comments
Joined 2 years ago
cake
Cake day: August 14th, 2023

help-circle
  • Kache@lemm.eetoProgrammer Humor@programming.devstop
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    3 days ago

    It’s a container with certain behaviors and guarantees making them easy and reliable to manipulate and compose. A practical example is a generic List, that behaves like:

    • List[1, 2, 3], i.e. (“new”, “unit”, “wrap”) to create, containing obj(s)
    • map(func) to transform objs inside, List[A] -> List[B]
    • first(), i.e. (“unwrap”, “value”) to get back the obj
    • flat_map(func), i.e. (“bind”) to un-nest one level when func(a) itself produces another List, e.g. [3, 4].flat_map(get_divisors) == flatten_once([[1, 3], [1, 2, 4]]) == [1, 3, 1, 2, 4]

    Consider the code to do these things using for loops – the “business logic” func() would be embedded and interlaced with flow control.

    The same is true of Maybe, a monad to represent something or nothing, i.e. a “list” of at most one, i.e. a way to avoid “null”.

    Consider how quickly things get messy when there are multiple functions and multiple edge cases like empty lists or "null"s to deal with. In those cases, monads like List and Maybe really help clean things up.

    IMO the composability really can’t be understated. “Composing” ten for loops via interlacing and if checks and nesting sounds like a nightmare, whereas a few LazyList and Maybe monads will be much cleaner.

    Also, the distinction monads make with what’s “inside” and what’s “outside” make it useful to represent and compartmentalize scope and lifetimes, which makes it useful for monads like IO and Async.


  • First suggestion is impractical. Not going to be able to memorize 100 names to look up and research later

    Second suggestion should already be happening, but doesn’t capture the desired use case.

    The use case is this: in physical life, there is a gradient of “boundaries/leashes” to match maturity and development. For example, the gradient of movie ratings, or:

    • Very young - stay within arms reach/sight
    • Young - stay in the yard/park/neighborhood
    • Child - stick with what’s familiar, I’ll be nearby
    • Pre-teen - go and try it, I can be right there
    • Teen - go and try it yourself, call me if needed

    We could argue about whether a gradient is too steep or shallow, but the point is that one exists.

    In contrast, digital in many ways is very often all-or-nothing

    Not saying digital should be “gradient-ed” in all cases, that leads to tone-deaf rules and bad security practices. Just trying to show what the problem is


  • I think there is a difference. Because software is so flexible and quick to build, it’s orders of magnitude easier to build something known and understood.

    A promising startup with its systems in a knot, but their initial team is still on retainer? Brains can be picked, abstraction boundaries placed, surgical rewrites deployed. Despite the mess, they still understand it, and development can expand.

    It remains to be seen if AI-generated code is recoverable, if any existing strategies can be applied so humans can contribute, or if the company is forever beholden to AI providers to release a better AI to manage/improve what they’ve already got.










  • If you used good objects, you’ll only have to make the change in one place

    IMO that’s generally a retroactive statement because in practice have to be lucky for that to be true. An abstraction along one dimension – even a good one, will limit flexibility in some other dimension.

    Occasionally, everything comes into alignment and an opportunity appears to reliably-ish predict the correct abstraction the future will need.

    Most every other time, you’re better off avoiding the possibility of the really costly bad abstraction by resisting the urge to abstract preemptively.








  • wanted to add something to the end of a for-loop, but had too little indentation

    To address this, I prefer reducing length & depth of nested code, so the for/while is rarely ever not visible along with everything inside it. Others have success with editors that draw indentation lines.

    opening up new/anonymous scopes

    I occasionally use Python nested functions for this purpose


  • I find it’s possible to operate Python as a statically typed language if you wanted, though it takes some setup with external tooling. It wasn’t hard, but had to set up pyright, editor integration, configuration to type check strictly and along with tests, and CI.

    I even find the type system to be far more powerful than how I remembered Java’s to be (though I’m not familiar with the newest Java versions).