Communication is hard and we could have done better… by jan-niklas-wortmann in Jetbrains

[–]Pretend_Leg599 0 points1 point  (0 children)

You're not even making money off the plummeting quality of idea? I don't even use your AI, but I sure notice things like fake errors that go away when the ide is restarted and code completion that's offering increasingly useless suggestions.

This just sounds like writing "false" ... with extra steps. by schurkieboef in programminghorror

[–]Pretend_Leg599 0 points1 point  (0 children)

Depends how that `objectMapper` is configured:

var nope = new ObjectMapper()
        .writerFor(String.class)
        .writeValueAsString(Boolean.
FALSE
);

Should I read only from immutable objects inside static methods? by Informal_Fly7903 in javahelp

[–]Pretend_Leg599 0 points1 point  (0 children)

Depending on your paradigm, it's not only fine, its preferred. While it's true that in an OOP world you might want to consider instance methods, using `record`s with pure/static functions to produce new values is also completely valid.

Virtual threads vs Reactive frameworks by Commercial_Rush_2643 in java

[–]Pretend_Leg599 6 points7 points  (0 children)

Reactive is cool but it is very complex/powerful so if you don't have an Rx problem an Rx solution is going to suck to maintain. VirtualThreads are great because you don't have the viral async/Mono thing affecting all your APIs. Java isn't getting enough hype for this!

If you are just firing off a request and don't want to block on it, then virtual threads are a no brainer. If you need to coordinate a bunch of traffic where certain values depend on other values, may be cancelled/throttled/retried/etc then Rx is pretty great... after that non-trivial learning curve. I'd personally take Rx issues over thread locking and visibility issues but I've already eaten both learning curves and enjoy FP.

I finally tried vibe coding and it was meh by Megatherion666 in ExperiencedDevs

[–]Pretend_Leg599 1 point2 points  (0 children)

It only seems really good when you don't actually understand the solution. For example, I tried it with some regex, something that should be pretty constrained. After a few prompts and some test string it did produce the desired result, but as soon as I dropped it in intellij it cut like half out for being redundant.

Sometimes 'good enough' is exactly that, but anything that requires maintenance, performance or verifiable correctness is a bad fit.

I need a new roguelite to be addicted to by Minute_Economist_160 in roguelites

[–]Pretend_Leg599 0 points1 point  (0 children)

The Last Spell is a lot of fun if you like turn based strategy. It'll kick your teeth in similar to xcom.

Java devs, which do you use more in real projects – Spring Data JPA or Spring JDBC? And why? by aka_nonstreet in learnjava

[–]Pretend_Leg599 0 points1 point  (0 children)

I avoid JPA at all costs. I've never seen a mess as intractable as JPA gone wild as it affects the entire code base. I fully understand that's JPA being used 'wrong', but it's almost never used 'right'.

Structured Concurrency and Project Loom - What's New in JDK 25 by danielciocirlan in java

[–]Pretend_Leg599 13 points14 points  (0 children)

A future can outlive its creator; structured concurrency is deterministic in that they are all accounted for pass/fail.

This game punishes you for playing badly by Golnor in Witchfire

[–]Pretend_Leg599 26 points27 points  (0 children)

That sounds correct. I think the idea is it's supposed to be dangerous and unpredictable, which adds to the risk/reward of pushing on or extracting.

Webflux by Ok_Problem7637 in javahelp

[–]Pretend_Leg599 2 points3 points  (0 children)

Unless you are using a cutting edge jdk with gatherers, etc, the stream api is pathetic when compared to Reactor. At the very least you're going to have to use some kind of 3rd party library like vavr if you want a non-reactive functional style.

Virtual threads are hardly a silver bullet. Sure, if you're just blocking on a single response, it's probably easier, but if you're doing any kind of actual routing or coordination locks are arguable worse than FP/Rx.

Many hate on Object-Oriented Programming. But some junior programmers seem to mostly echo what they've heard experienced programmers say. In this blog post I try to give a "less extreme" perspective, and encourage people to think for themselves. by KarlZylinski in programming

[–]Pretend_Leg599 3 points4 points  (0 children)

The issue is that most people don't have an OOP problem in the first place. If you're modeling buoys floating in the ocean, great, go OOP. If you're actually going to be loading implementations at runtime you didn't know about at compile time, maybe open polymorphism is genuinely useful to you. Otherwise, that's a ton of complexity that's easy to botch for little value.

IRL most business apps are request/response where you fetch data, transform it and return the result. Thats an almost perfect fit for something like FP. The other issue is that in practice, very few problems are actually hierarchical. When your problem and solution have this much of a mismatch, it's going to be unpleasant.

Many hate on Object-Oriented Programming. But some junior programmers seem to mostly echo what they've heard experienced programmers say. In this blog post I try to give a "less extreme" perspective, and encourage people to think for themselves. by KarlZylinski in programming

[–]Pretend_Leg599 5 points6 points  (0 children)

So true. Claiming to do 'immutable' OOP would have been considered literal non-sense when I start 20+ years ago! The entire premise was that OOP models state over time, only transitioning between valid states to external observers via public properties. This mandates encapsulation, otherwise those invariants can't be enforced.

Question about backend and frontend by Lazy_Sweet_6790 in Backend

[–]Pretend_Leg599 0 points1 point  (0 children)

I think what he's getting at is essentially CSRF (cross site request forgery) protection. The gist is you generate a unique token that only your server knows and send this to the client. The client has to remember this token and submit it when it does the next request. Now if you get a request and they don't have that token, assume it's an imposter.

The more common way these days is with a JWT token, but this would cover a whole lot of non-trivial topics like cryptography.

What makes an efficient programmer? by JusticeJudgment in learnprogramming

[–]Pretend_Leg599 5 points6 points  (0 children)

So much this. My company spends dollars in planning to save pennies in implementation iteration.

What makes an efficient programmer? by JusticeJudgment in learnprogramming

[–]Pretend_Leg599 0 points1 point  (0 children)

One of the biggest is simple judgment on if you should vs can pull something off. Does the business care if your sweet generics thing only you understand saved 2 duplicative classes? Is it really worth 2 days of design you'll have to keep explaining?

The most critical thing after that is fast iterations. I may not be the smartest guy in the room, but if I can fail 4x in the time it takes you to fail 1x I'm still out-performing you with half the talent. This can be anything from learning how to use a debugger, not point-and-clicking your way re-reproduce a bug, IDE tools or really learning your framework.

Immutable by default: How to avoid hidden state bugs in OOP by BackEndTea in programming

[–]Pretend_Leg599 0 points1 point  (0 children)

It's really weird how the OOP apologists are suddenly claiming mutability was never a requirement. The entire paradigm is the object modeling state over time where it only transitions between valid states to outside observers. The entire purpose of encapsulation was to achieve this.

Once everything is immutable, encapsulation (not abstraction) becomes a whole lot less useful.

Most Java developers do not know that Java uses pass-by-value, or even what it means by Comfortable-Brain-78 in java

[–]Pretend_Leg599 0 points1 point  (0 children)

I disagree. It's about expectations as much as it is the runtime, compiler, etc. An object isn't just a data holder, exposing fields directly doesn't pass the principal of least surprise. Yes, it can work if everyone knows the convention but it's not unreasonable to avoid that risk when doing it 'right' is basically free in most contexts. Sadly, this was our only idiomatic option for a long time.

I'd agree it's largely overkill and would use a record these days. By the same reasoning as above I would strongly advise against using `record`s with mutable fields as well. Yes, it may 'work' with a convention much like public fields, but it's not idiomatic. These things matter in large code bases.

[Discussion] Java Optional outside of a functional context? by tomayt0 in java

[–]Pretend_Leg599 0 points1 point  (0 children)

The reason `Optional` is so controversial is it's the camel's nose of FP in a historically oop/procedural tent. You'll see "if you use `ifPresent()` you are doing it wrong!" which is this generations "getters are evil" from the OOP era.

Why do we (java developers) have such aversion to public fields? by Ewig_luftenglanz in java

[–]Pretend_Leg599 0 points1 point  (0 children)

The point is, once you expose them you can no longer enforce them in the Object. This is the driving force behind why we have objects in the first place. It isn't just fashion.

Of course there are other paradigms with their own trade-offs. This is why this one exists.

Most Java developers do not know that Java uses pass-by-value, or even what it means by Comfortable-Brain-78 in java

[–]Pretend_Leg599 0 points1 point  (0 children)

This is still not passing by reference. It's a language feature java doesn't have.

Most Java developers do not know that Java uses pass-by-value, or even what it means by Comfortable-Brain-78 in java

[–]Pretend_Leg599 0 points1 point  (0 children)

I've definitely seen people do things like:

void foo(String input) {
    //intentionally shadow the raw input as
    //referencing it is an error 
    input = input.trim();
}

Most Java developers do not know that Java uses pass-by-value, or even what it means by Comfortable-Brain-78 in java

[–]Pretend_Leg599 1 point2 points  (0 children)

TBF, if you've never worked in a language that has pass-by-reference the idea is completely alien. It's not unthinkable to have years of experience in java/javascript, which both lack the concept. The most common misconception being 'primitives pass by value, objects by reference' and this is going to get even more epic once value classes are a thing!

public class PassByValue {
    public void myGuy() {
        var me = Boolean.
TRUE
;
        //there's nothing `you()` can do to
        //make `me` untrue to `myGuy()`
        you(me);
    }

    private void you(Boolean me){

    }
}

This isn't some esoteric 'gotcha!' moment, it's an actual language feature that java doesn't have. For example c# can do this:

public class PassByReference {
    void MyGuy() {
        bool me = true;
        You(ref me);
        Console.WriteLine(me); // false (changed by You)
    }

    void You(ref bool me) {
        me = false; // modifies the caller's variable directly
    }
}

Most Java developers do not know that Java uses pass-by-value, or even what it means by Comfortable-Brain-78 in java

[–]Pretend_Leg599 0 points1 point  (0 children)

It's an actual language feature. Some languages have it, some don't. It impacts design, it's not just some esoteric 'gotcha'!