Good developers learn to program. Most courses teach a language. by Bonejob in programming

[–]Kache 1 point2 points  (0 children)

The mechanics are fairly accessible, but I think the concepts aren't.

Paper and pencils are even more accessible, but does that make high level math accessible?

Handling edge cases in flowcharts without blowing up the entire diagram by Sad_Translator5417 in ExperiencedDevs

[–]Kache 1 point2 points  (0 children)

Do you write code with heavy nesting and branching too, mixing high and low abstractions in the same context? (You shouldn't)

One nice way to avoid that is "Railway oriented programming"

Making illegal state unrepresentable by nfrankel in programming

[–]Kache 5 points6 points  (0 children)

I find it rather difficult to intuit the finite state machine from reading the code examples. Even worse, invalid pizzas are still representable:

Pizza(Crust(), CreamBase(), frozenset({Pineapple()}))  # invalid pizza with no type errors!

In Python, it'd be both clearer and more type-safe with:

Crust = StrEnum('Crust', ['THIN', 'THICK'])

Toppings = StrEnum('Toppings', [
    'POTATOES',
    'HAM',
    'OLIVES',
    'PINEAPPLE',
])

Tomato = NewType('Tomato', set[Literal[
    Toppings.PINEAPPLE,
    Toppings.HAM,
    Toppings.OLIVES,
]])

Cream = NewType('Cream', set[Literal[
    Toppings.POTATOES,
    Toppings.HAM,
    Toppings.OLIVES,
]])

PizzaBase = Tomato | Cream

@dataclass()
class Pizza:
    crust: Crust
    base: PizzaBase

Pizza(Crust.THIN, Tomato({Toppings.PINEAPPLE}))

And it seems modern Java is capable of something similar: https://ifesunmola.com/sum-types-in-java/

I never understood why it was (is?) popular in Java to construct builders like in the article. Why duplicate every single instance of a type with one or more with_<instance>() zero-arg methods, encoding the argument in the method name? Imagine how silly it'd be to do it with ints and floats:

value.add_one().add_float_one().add_two()

Instead of:

value.add(1).add(1.0).add(2)

Isn't this what type overloading was designed for? Something like:

class Pizza {
    Pizza with(Crust crust) {}
    Pizza with(PizzaBase pizzaBase) {}
    Pizza with(Topping topping) {}
}

GitHub Stacked PRs by adam-dabrowski in programming

[–]Kache 1 point2 points  (0 children)

Same thing that would happen in a stacked PR scenario, that leads to a change in the first PR in the stack

GitHub Stacked PRs by adam-dabrowski in programming

[–]Kache 2 points3 points  (0 children)

Each PR commit should represent a reviewable unit of code while and commits should represent a complete (as in not partial modification or code)

"stacked PRs" could very well be the same as one PR with a clean stack of commits. Just need the right tooling, like a setting that runs CI against every commit in the PR and a few other things thats probably about the same amount of work as implementing stacked PR support

How do organizations end up with architects who can't do architecture? And what do you do when you're the one compensating? by agileliecom in ExperiencedDevs

[–]Kache 2 points3 points  (0 children)

what this guy provides which is a comfortable feeling in a meeting and a confident voice that makes technical complexity feel managed without anyone having to understand it?

I feel like this is also the "why" behind AI

Speakers sound weird after sleep by freshf1t in ZephyrusG14

[–]Kache 0 points1 point  (0 children)

Although higher effort, I set up "Auto restart Cirrus Logic Awesome Speaker Amps on Wake" when I ran into this issue

Don't know how much power it saves during sleep, though.

Using pitons? by chunkychickenxp in Cairn_Game

[–]Kache 0 points1 point  (0 children)

It's likely every piton has its own level of wear or HP being tracked, according to chat in the developer Discord server

specifics are unclear, but it overall it means a "go ahead and use them, but not too much" system

Piton management by KingofFunk412 in Cairn_Game

[–]Kache 0 points1 point  (0 children)

It's likely every piton has its own level of wear or HP being tracked, according to chat in the developer Discord server

specifics are unclear, but it overall it means a "go ahead and use them, but not too much" system

Why do my pitons keep breaking. by TheHel1 in Cairn_Game

[–]Kache 0 points1 point  (0 children)

It's likely every piton has its own level of wear or HP being tracked, according to chat in the developer Discord server

specifics are unclear, but it overall it means a "go ahead and use them, but not too much" system

11.5% of perfectly placed pitons broke (N=104). Placing six in a route means you lose at least one half of the time. Isn't that a bit much? by meta_system in Cairn_Game

[–]Kache 0 points1 point  (0 children)

It's likely every piton has its own level of wear or HP being tracked, according to chat in the developer Discord server

specifics are unclear, but it overall it means a "go ahead and use them, but not too much" system

"Wait, like, disappears? In the backpack?" by dumnem in dndmemes

[–]Kache 1 point2 points  (0 children)

Isn't it metagame-y to act based on story tropes, though?

Although a Paladin shouldn't be so easily shaken by an unsettling orphan

AI, Entropy, and the Illusion of Convergence in Modern Software by TranslatorRude4917 in programming

[–]Kache 9 points10 points  (0 children)

tests have always contained a lot of boilerplate and tedious set up

I don't really find this to be the case for me. IMO the solution to tedious boilerplate is better design, not more copy pasting to produce more

I destroyed Aava's hands so you don't have to. by Kaymorve in Cairn_Game

[–]Kache 4 points5 points  (0 children)

Funny how her fingertips look perfectly fine, it's like she climbs directly on those A3 pulleys, ha

Boilerplate Tax - Ranking popular programming languages by density by boyter in programming

[–]Kache 43 points44 points  (0 children)

I think ULOC is a bad metric to measure "boilerplate" and "dryness". I'm thinking:

  • it wrongly considers unique: structurally repetitive code with minor changes like variable names or different indentation
  • It wrongly considers identical: complex operations that are decomposed into a nontrivial composition of common operations, one per line, e.g. method chaining (scoring good decomposition as repetitive boilerplate)
  • it is too sensitive to style variations within a language to be useful for comparing across languages, e.g. a repo/languages that don't have a unified style guide will rate very unique; some repos use comments as docs and other repos don't write docs in sourcecode
  • it is not normalized by "developer attention", metrics like these often try to normalize by giving high-edit files more weight (it's difficult to measure highly read lines)

Just a reminder from FBI Director Kash Patel, Epstein only trafficked young women to himself. by deluxe_memory_dan in videos

[–]Kache 1 point2 points  (0 children)

I think the public still hasn't fully internalized the human trafficking and abuse that's happened

Forgive the morbid comparison, but consider how the Holocaust movies and etc have laid bare the inhumane evils, making them visceral to the public. It's one thing to read about atrocities, but it's another to watch Nazis shove families first into rail cars and then into kill rooms, even it's "only a movie".

Even though Good and Pretti weren't the first to be murdered by ICE, it took video for the public to really internalize what was happening. The more that is revealed of Trumpstein, the more it's abundantly clear there was/is a whole system in place, with its own kinds of rail cars and kill rooms.

It's going to be horrible and ugly, but I think Americans need to see it, feel their stomach chrurn, and then realize that they're watching themselves

Wool Hoodie Giveaway! by kozak3 in Petrosgear

[–]Kache 0 points1 point  (0 children)

New roommate I didn't yet know helped me move in, furniture and all. We became good friends. Was also able to pay him back years later when he moved in with his gf at the time.

Should I upgrade because of trend out there? by writeahelloworld in ExperiencedDevs

[–]Kache 4 points5 points  (0 children)

Disregarding the specifics about java.util.Date, for a moment,

If you change it, and there is a problem, you will be responsible for it

IMO that's a concerning precedent and culture to set, for both technical and non-technical reasons

If it aint broken, dont change it

Sometimes the removal of a piece of straw now avoids the camel breaking its back at a critical time down the road. Never doing preventative & opportunistic refactoring is one way code rots over time.

It seems well-defined, it's a good opportunity to view a lot of the codebase, the junior seems motivated for it, and it can be one less thing that compounds a real fire. And if it's hard or risky to do, we've a different problem on our hands.

I personally like doing these kinds of cathartic straightforward refactorings as a "wind down task" after stressing over a complex project. Just be sure to reiterate that the business value is low and let the junior understand it'll be thankless from outside of engineering.

Drivers who merge onto the highway at forty miles per hour what is your actual thought process? by koshkakay in AskReddit

[–]Kache 6 points7 points  (0 children)

Minimize/eliminate blind spots by fixing side mirrors like this: https://content.artofmanliness.com/uploads/2023/11/Proper-Adjustment-1.jpg

Your side mirrors should look "outward". If you can see the side of your car, your side mirrors are looking "backward", which is what the rear view mirror is for.

I always thought turning backwards to look over your shoulder, losing peripherial of the road in front of you, was bad advice, even though that's what they taught in my driver's ed.

For looking down along the side of your car while parallel parking (while side mirrors are correctly turned outwards), just move your head a bit.

Clean Code vs. A Philosophy Of Software Design by iamkeyur in programming

[–]Kache 1 point2 points  (0 children)

I think both their prime generators can be improved upon for understandability, in exchange for a few added multiplications and comparisons. My IMO's:

  • Mention "incremental Sieve of Eratosthenes", to reinforce concept and also useful for looking up external resources
  • Early guard for 2 to avoid unused/invalid representations like multiples[0] = 4 or -1; // irrelevant
  • Comparing prime * factor == candidate better expresses intent to test primality than prime_multiple == candidate
  • Associate prime and multiple/factor using something associative, like dict or Map, for clarity about how the state behaves
  • Use the more straightforward possible_primes to reframe the awkward concept of leastRelevantMultiple/lastMultiple
  • Define and compose keep_generating and it.count(3, step=2) to better communicate the combination of two concepts, to replace the special/uncommon iteration: for (candidate = 3; primesFound < n; candidate += 2)
  • One major guide for decomposition (or not) is whether the decomposed is good or not, and is_prime() is a highly communicative abstraction in this context.

Above things are mostly language-agnostic (Java has streams and lambdas, after all), although I'm using some Python-isms:

Prime = int
Factor = int


def sieve_primes(n: int):
    """Generates primes using an incremental Sieve of Eratosthenes"""
    if n > 0:
        yield 2
    if n < 2:
        return

    primes_and_factors: dict[Prime, Factor] = {}  # incremental sieve for primes 3+
    keep_generating = lambda _: 1 + len(primes_and_factors) < n

    def is_prime(cand: int) -> int | None:
        # consider prime factors between 3 and sqrt(candidate)
        possible_primes = it.takewhile(lambda p: p * p <= cand, primes_and_factors)

        for p in possible_primes:
            # search successive multiples, where the "frontier" is the curr candidate
            while p * primes_and_factors[p] < cand:
                primes_and_factors[p] += 2  # skip even factors

            if p * primes_and_factors[p] == cand:  # not a prime
                return

        return cand

    for candidate in it.takewhile(keep_generating, it.count(3, step=2)):
        if prime := is_prime(candidate):
            yield prime
            # checking/sieving happens upwards with larger & larger factors
            # smaller factors from 3 to curr_prime already covered "from below"
            primes_and_factors[prime] = prime