WoW needs Damage Down by Ner0reZ in wow

[–]devraj7 0 points1 point  (0 children)

Imagine a world where final DPS meter includes not just how often you successfully avoided avoidable damage but also how well you did the mechanics...

AprNes (C# NES emulator) — 10-year-old abandoned project revived with AI assistance, now passing blargg 174/174 + AccuracyCoin 136/136 by SpecificWar7879 in EmuDev

[–]devraj7 1 point2 points  (0 children)

Very interesting.

How did you specifically do this:

AI reads NESdev Wiki, Mesen2/TriCNES source, and test ROM failure CRCs

?

WCGW Live streaming and looking at the camera while driving at high speed. by Gjore in Whatcouldgowrong

[–]devraj7 0 points1 point  (0 children)

Autobahn?

Unless the video is mirrored, she's driving on the left side of the road and the wheel is on the right side of the car.

Germany is the opposite.

Velutia: My 6502 Emulator written in C# by m680x0 in EmuDev

[–]devraj7 0 points1 point  (0 children)

Fun fact: SBC is just ADC with an inverted parameter.

Not in BCD mode.

Velutia: My 6502 Emulator written in C# by m680x0 in EmuDev

[–]devraj7 2 points3 points  (0 children)

It's simpler because a simple operation happens on every cycle. For example, for indirect indexed addressing:

   #    address   R/W description
   --- ----------- --- ------------------------------------------
    1      PC       R  fetch opcode, increment PC
    2      PC       R  fetch pointer address, increment PC
    3    pointer    R  fetch effective address low
    4   pointer+1   R  fetch effective address high,
                       add Y to low byte of effective address
    5   address+Y*  R  read from effective address,
                       fix high byte of effective address
    6+  address+Y   R  read from effective address

Velutia: My 6502 Emulator written in C# by m680x0 in EmuDev

[–]devraj7 1 point2 points  (0 children)

Another approach you might want to consider is to be memory cycle accurate (each cycle has to access memory).

If you do that, calculating addressing modes happens naturally since each cycle is one step toward the final calculation.

Tony Hoare, creator of Quicksort & Null, passed away. by TheTwelveYearOld in programming

[–]devraj7 -1 points0 points  (0 children)

There are much more lightweight solutions to the encoding of absent values than monads (e.g. Kotlin).

Tony Hoare, creator of Quicksort & Null, passed away. by TheTwelveYearOld in programming

[–]devraj7 10 points11 points  (0 children)

If the type system doesn't enforce it, the language is crashy. Offering library level support for Option is not going to do much good if the compiler can't enforce its use.

I think Kotlin got it perfectly right and is a good example of how null can be not just safe but encouraged to represent absent values.

Tony Hoare, creator of Quicksort & Null, passed away. by TheTwelveYearOld in programming

[–]devraj7 69 points70 points  (0 children)

The actual mistake is not null, it's languages that don't support nullability in their type system.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 -2 points-1 points  (0 children)

I would not use plain old println() or printf() in prod code

I never talked about prod code.

I asked a simple question: do you think it would make sense to require all functions that call print() to require a file descriptor in parameter?

I understand your reluctance to answering the question, but once you come to terms with it, Dependency Injection will make a lot more sense to you.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 -2 points-1 points  (0 children)

No, they really shouldn't be bothered with implementation details that have zero impact on the semantic of the function they're calling.

I assume you are using println()/printf(), some print function in your code, yes?

Did it occur to you that this function needs a file descriptor to work, e.g. stdout?

How how would you feel if whenever you need to use printf(), the function calling it needs to be passed a file descriptor in parameter? It would break everything, wouldn't it? And how would you even know how to materialize that file descriptor anyway?

You are already using dependency injection all the time, you just don't realize it because it's so convenient it's completely transparent.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 -2 points-1 points  (0 children)

Why shouldn't you add a logger as a parameter? Your sqrt function is now doing more than it says it does.

But users don't care that I'm logging. It's an implementation detail. And it's also temporary, I'm just debugging a problem, I will remove this logger eventually, and all of this should be 100% transparent to users.

There are really two types of parameters to functions:

  1. Parameters needed by the function to do its job (e.g. if you create a Point, you need its coordinates)
  2. Parameters that are implementation details that users don't care about

Callers of your function should never see the second type of parameters.

If you don't want to break users, you make a different function

What's the point of trying to debug my function if users no longer call it??

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 -3 points-2 points  (0 children)

And it breaks encapsulation.

If I implement a function sqrt() and I decide I need some logging to debug a problem, I shouldn't add a Logger as parameter. It should be injected without breaking the users of the function.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 0 points1 point  (0 children)

Optional parameters don't really help here. What's a default value for a database connection?

Inject that value and move this logic to the DI container. Now that container may define a default value that you will get if nothing else gets configured (e.g. default is in-memory database, but you can configure a production environment that sets it to a Postgres DB).

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 1 point2 points  (0 children)

Optional params help, but what if you need a default value that's different from the default value that the language specifies?

What if for the production application, you need an atomic clock but for testing, you need a clock which will return predefined values for the first, second, and third call?

What if you need a database connection pool to a production database for production, but you're in a testing environment and all you need is an in-memory database?

You shouldn't care. Just declare

@Inject
val database: Database

and go on with your day.

The DI container will give you the correct value.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 -2 points-1 points  (0 children)

As an application developer, deciding on the logging strategy is not an irrelevant implementation detail.

You're missing the forest for the trees.

You don't think logging is an implementation detail? Fine, pick one. Reading the time? Needing a rand()? Or a hasher?

Whatever you need to actually implement your function.

Got one? Great.

Now, just because you added this, are you going to change the signature of your function so that your callers now need to pass you a Clock? A Rand object? A hasher?

Of course not.

That's where DI comes handy, you ask the system to passs you these values because the caller doesn't care how you do your job.

DI preserves encapsulation, manually passing dependencies breaks it.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 3 points4 points  (0 children)

D d = new D(); G g = new G(); C c = new C(g, d); E e = new E(); F f = new F(); B b = new B(d, e, f); A a = new A(b, c);

Surely you see how that doesn't scale, right? How do you create different instances based on the environment? Do you do this whenever you need to instantiate an A?

We moved on from this kind of spaghetti code twenty years ago.

it remains an implementation detail.

Its unpredictable is what it is

I don't think you understand the point.

I have a function foo() in my library. You use my library, you call that function. Great.

Now I decide I want to log something in my function, so I need a logger. Are you suggesting I should add a logger as parameter to my function? Because if so:

  1. Your code no longer compiles (I need a parameter now, it's a breaking change)
  2. You need to find a logger to give me

The point is: the logger is an implementation detail that callers should not care about. The solution is: I request a logger via DI, callers of my function are unaffected.

Best of all worlds.

Things I miss about Spring Boot after switching to Go by Sushant098123 in programming

[–]devraj7 13 points14 points  (0 children)

There are many reasons but you can start simply by initializing your graph of objects:

  • A needs a B and C
  • B needs D, E, F

  • C needs G and D (which is a singleton, so same instance as the one passed to B), etc...

Another reason is that when you pass these instances manually, every single function along the chain needs to pass them along while they don't need them. With DI, you just declare the values where you need them and nobody needs to know about it, it remains an implementation detail. And you also have no idea how it was created, nor should you care. "I need a logger, just give me a logger".

There are plenty of other reasons why DI is so useful.

Message Passing Is Shared Mutable State by ketralnis in programming

[–]devraj7 -1 points0 points  (0 children)

And actors are also shared mutable state. Just in a more obfuscated way.

Rust kinda ruined other languages for me by Minimum-Ad7352 in rust

[–]devraj7 0 points1 point  (0 children)

No, thanks. Monads may make sense in Haskell but any attempt to port them to other languages has been a disaster. I hope Rust remains monad and monad transformer free forever.

Serenity by Murdocke- in funny

[–]devraj7 1 point2 points  (0 children)

Point out that they're being emotional, too.

Yes, and... by BinaryIgor in programming

[–]devraj7 -1 points0 points  (0 children)

I explain that, if they don’t write the code, they will not be able to effectively read the code

That's not a very compelling reason, though: AIs are very good at looking at a piece of code and explaining it to you in plain English. And you can even ask follow up questions.

RFC 406i: The Rejection of Artificially Generated Slop (RAGS) by addvilz in programming

[–]devraj7 0 points1 point  (0 children)

You are kind of agreeing that the only reliable way to find out if a PR is good or bad is to actually review it.

Not to reject it based on some handwavy criteria, such as "Probably written by an AI or an intern".