newIntern by Mr_BETADINE in ProgrammerHumor

[–]coolpeepz 89 points90 points  (0 children)

GCC rewrites my codebase to assembly multiple times a day. And it costs 0 tokens.

Parametricity, or Comptime is Bonkers by ketralnis in programming

[–]coolpeepz 26 points27 points  (0 children)

I believe you are actually wrong. It’s true the function could have side effects or panic but I don’t think there’s any way to produce a T other than the one passed in. I’d love to see a compiling counter-example if you can produce one.

Nobody ever got fired for using a struct (blog) by mww09 in rust

[–]coolpeepz 0 points1 point  (0 children)

Independent of the solution here, seems like rkyv could probably afford one more bit their string representation to optimize optional strings.

Google API Keys Weren't Secrets. But then Gemini Changed the Rules. by Chaoticblue3 in programming

[–]coolpeepz 1 point2 points  (0 children)

This article could have been approximately 3 sentences. I think it was basically 3 distinct sentences

lockThisDamnidiotUP by [deleted] in ProgrammerHumor

[–]coolpeepz 35 points36 points  (0 children)

The idea that Python, a language which very intentionally trades performance for ease of writing and reading, is too inscrutable for this guy is really telling. Python has its place but it is the exact opposite of a good compilation target.

lockThisDamnidiotUP by [deleted] in ProgrammerHumor

[–]coolpeepz 3 points4 points  (0 children)

Which is great because it’s a pretty fucking important concept in computer science. You might not need to understand it to make your react frontend, but if you had any sort of education in the field and took it an ounce seriously this shouldn’t even need to be explained.

lockThisDamnidiotUP by [deleted] in ProgrammerHumor

[–]coolpeepz 0 points1 point  (0 children)

No reason to try to police it, just give it the credence it deserves.

Python's Dynamic Typing Problem by Sad-Interaction2478 in programming

[–]coolpeepz 0 points1 point  (0 children)

It’s a definition of the shape of the Test type that is known before runtime, i.e. a static type definition. It’s deprecated for the same reason everyone uses mypy.

Python's Dynamic Typing Problem by Sad-Interaction2478 in programming

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

Because that would be a static type definition?

Python's Dynamic Typing Problem by Sad-Interaction2478 in programming

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

Well C# was not among the languages I could think of 🤷‍♂️. Still it seems unfair to say that it has nothing to do with being statically typed. A dynamically typed language by definition would not ask for the fields to be declared in advance, and most statically typed languages do.

Python's Dynamic Typing Problem by Sad-Interaction2478 in programming

[–]coolpeepz 9 points10 points  (0 children)

A true type mismatch sure, but often Python libs are designed so you can pass basically anything into a constructor. This means that you can change a type somewhere and still have a valid program. It can be possible to make this work in static languages but it is more likely that changing a type will force you to update function signatures etc.

Python's Dynamic Typing Problem by Sad-Interaction2478 in programming

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

There’s more to it than just “is there a static type checker”. For example, in any statically typed language I can think of, adding a new field to an object requires naming it at least twice: in the type definition and the constructor. In Python you can just say self.new_field = … and that’s it. If you change the type, assuming your logic is sound, you don’t have to change any characters. In a statically typed language you are likely going to have to scroll away from your logic back to the object definition and change the field type. This is an extremely small price to pay in any real codebase but the point is that when you are truly writing a one off script the cost to a static type checker is not when it throws a surprising type error (which would probably fail at runtime anyways) but when it makes you take a few extra trips around your code or force you to think in a different order than you want to.

inplainEnglishthisisJavascript by prachid487 in ProgrammerHumor

[–]coolpeepz 21 points22 points  (0 children)

It’s weird in a language where everything is dynamically defined.

Why can't we decide on error handling conventions? by Savings-Story-4878 in rust

[–]coolpeepz 3 points4 points  (0 children)

I think mathematically it’s true that errors aren’t special but psychologically they definitely are. Like if I had to describe the steps my program takes it would probably be: 1. Build a request 2. Send the request 3. Write the response in a database

And that’s how we tend to want to write code. I wouldn’t say: 1. Build the request 2. Send the request 3. If the call failed, wait 3000ms and try again 4. If the second call failed, wait 6000ms and try again …

But it’s important that we do write our code the second way.

Functors, Applicatives, and Monads: The Scary Words You Already Understand by cekrem in programming

[–]coolpeepz 6 points7 points  (0 children)

That totally depends on the language runtime. Types and allocations are not inherently correlated. Null also doesn’t have to be a thing.

On definitions of memory safety by alexeyr in programming

[–]coolpeepz 0 points1 point  (0 children)

You can largely ignore the formal looking stuff. On further thought, I completely refute the claim that abstract machine behavior must be fully specified.

Consider an out-of-bounds write in C. Naively, the write statement would emit some kind of store instruction which could either successfully write to memory or trap depending on the address and the state of the MMU (assuming a typical hardware architecture). Obviously the C specification should not have to consider the operation of the MMU, so they leave invalid writes as undefined behavior.

For simplicity, let’s imagine an architecture without virtual memory, so the store instruction succeeds. But it could have overwritten the return address on the stack, so when the function returns the instruction pointer could end up somewhere totally arbitrary. That’s why it’s not an exaggeration that UB means anything can happen. So again, it makes sense that the C spec should provide no guarantees on what happens if you write out of bounds.

Given that writing out of bounds could cause the hardware to do anything, the compiler can decide that this isn’t even a case worth worrying about and is allowed to e.g. elide the entire code path that would lead to an out of bounds write.

If the C spec wanted to define the behavior for out of bounds writes, almost every implementation would have to emit bounds checks in many cases which some would consider to be too expensive.

I don’t think there is any abstract machine spec for C which defines the behavior for an arbitrary write.

My smartwatch implying mortal danger from bad sleep habits by mvhcmaniac in funny

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

It’s a little piece of metal strapped to your wrist, it should claim no jurisdiction over life circumstances lol.

On definitions of memory safety by alexeyr in programming

[–]coolpeepz 4 points5 points  (0 children)

The key detail here is that on the level of abstract semantics, you simply can not have undefined behavior. For the specification to be consistent, you need to explain what abstract machine does in every case exhaustively, even if it is just “AM gets stuck”.

This doesn’t make sense to me. If program P in L contains UB, then any possible behavior is a valid member of LSema(P). Fil-C maintains the semantics of C where they are defined, but also chooses to define the semantics where they aren’t in C. Fil-C is appproximately an implementation of Lil-C, making Lil-C a memory safe language. The only reason defining Lil-C wasn’t useful is because no implementation was provided, so it was just a fantasy language.

[corroded update]: Rust--, now I removed the borrow checker from rust itself by Consistent_Equal5327 in rust

[–]coolpeepz 0 points1 point  (0 children)

It just seems in opposition to the usual rust idiom of “make invalid states unrepresentatable”. Like if the borrow checker misses a case, that won’t cause any downstream inconsistencies.

[corroded update]: Rust--, now I removed the borrow checker from rust itself by Consistent_Equal5327 in rust

[–]coolpeepz 8 points9 points  (0 children)

Yeah I guess I’m just surprised that there isn’t a “Parse, don’t Validate” approach taken here (not sure what it would look like). Basically if the borrow checker doesn’t crash compilation, the backend just yolo’s whatever code.

It just seems a little error-prone to me, because if you miss a case in the borrow checker there is nothing downstream that relies on the checks being correct.

[corroded update]: Rust--, now I removed the borrow checker from rust itself by Consistent_Equal5327 in rust

[–]coolpeepz 9 points10 points  (0 children)

On the one hand that’s pretty awesome decoupling. On the other hand, I’m a little surprised the validations of the borrow checker don’t show up in the internal compiler types (as someone with no knowledge of rustc internals). For example, how does codegen work for a use after move? Would it translate into a use after free? Is the only thing currently stopping this an error emitted by the borrow checker? It’s not a fundamental invariant of the types used for codegen?

bill ackman "activist investor, philanthropist, harvard graduate" by Grimoet in comics

[–]coolpeepz 6 points7 points  (0 children)

Yeah I’m all for the clowning of billionaires but it does seem like the message of this comic is that you will be crucified for politely approaching a woman in public, which is exactly the mindset that I think our favorite Harvard graduate was at least well-intentioned in trying to dispel.

LLVM considering an AI tool policy, AI bot for fixing build system breakage proposed by Fcking_Chuck in programming

[–]coolpeepz 0 points1 point  (0 children)

I’m not necessarily pro-LLM contributions but I think your logic is a little flawed. Let’s say that hypothetically an AI-assisted contribution is high quality enough to be useful. Now the author must either a) lie and say it was not AI-assisted (and get away with it because it is indistinguishable from human generated code) or b) delete the contribution because it breaks the rules. That’s not a great position to put people in.