Walnut356

joined 1 year ago
[–] Walnut356 4 points 1 year ago* (last edited 1 year ago) (5 children)

the ergonomics expected of modern languages.

As someone learning c# right now, can we get some of those "modern ergonomics" for switch statements πŸ’€

I cant believe it works the way it does. "Fallthrough logic is a dumb footgun, so those have to be explicit rather than the default. But C programmers might get confused somehow, so break has to be explicit too"

I miss fallthrough logic in languages that dont have it, and the "goto case" feature is really sick but like... Cmon, there's clearly a correct way here and it isnt "there is no default behavior"

[–] Walnut356 1 points 1 year ago* (last edited 1 year ago)

60fps doesn't matter

60fps feels smooth, less than 60fps doesnt feel smooth. Even in non-shooters. I dont like the jittery look when i pan the camera or do anything. Computers are more than capable of it. I say this as a programmer who focuses on low level optimization. Almost all software runs like shit because devs dont care about performance and people are just used to it. I still have my mind blown on a near daily basis on how much I can squeeze out of my cpu. Not because i'm doing anything crazy or complicated, but because 90% of software has visible latency for clicking a button and eats tons of ram for no good reason.

RAM should be used. For gaming it would be wasteful not to use it. If you aren't using all your ram then you're loading textures, shaders, and everything from disk, which is thousands of times slower and that would lead to .. you guessed it, gamers bitching about lag

That's... Not really how it works at all. Using all of your ram is actually pretty bad. Because then if your computer needs more ram, something is getting dumped to the page file. On your hard drive. There's no easier way to make your PC crawl than to make your cpu have to keep swapping shit to and from the page file.

It's entirely possible to have a better system for when to have those textures loaded to decrease overall ram usage, better/less wasteful data structures, culling techniques to decrease the number of things that have to be loaded and directly handled (e.g. in factorio if you have a belt with only 1 type of item on it, it wont track every individual item. It just averages the throughput to save on processing power.)

I have 32 gigs. I want them to use it.

The average consumer still has 8, i have 16 and run into problems with some modern games. I also shouldnt have to close other applications on my computer because your shit game cant handle its memory properly.

[–] Walnut356 8 points 1 year ago (4 children)

Generators probably. It's the one thing i genuinely miss about python when i work in rust.

[–] Walnut356 1 points 1 year ago

Ick. At the very least, i've seen it a LOT less in VSC. The fact that something as simple as rainbow brackets uses the freemium model in intellij sucks. I mean the fact that it's not a builtin setting is dumb too but that's beside the point

[–] Walnut356 5 points 1 year ago* (last edited 1 year ago)

I feel like it's like pointers.

"Variable" refers to the label, i.e. a box that can contain anything (like *ptr is a pointer to [something we dont know anything about])

Immutable describes the contents, i.e. the stuff in the box cant change. (like int* ptr describes that the pointer points to an int)

Rust makes it very obvious that there's a difference between constants and immutable variables, mainly because constants must be compile time constants.

What do you call it when a variable cant change after its definition, but isnt guaranteed to be the same on each function call? (E.g. x is an array that's passed in, and we're just checking if element y exists)

It's not a constant, the contents of that label are "changing", but the label's contents cant be modified inside the scope of that function. So it's a variable, but immutable.

[–] Walnut356 9 points 1 year ago (1 children)

Saying "non negotiable" doesnt actually hold up in small claims, nor against basic resistance in most cases.

Look up your local laws, in some places carpets must be replaced at the expense of the landlord every X years, or if there is any kind of damage (caused by regular wear and tear) that could be a trip hazard. Pictures from move-in, carpets not being replaced when you moved in, etc. all help your case.

Last place i lived, I spent 30 minutes arguing on the phone with my previous landlord over flooring and got my 700 dollars back. Turns out most of the time they only vaguely know the laws they're quoting, so if you come with confidence, prep, and a willingness to take it to small claims, they'll fold to save themselves the effort.

[–] Walnut356 -1 points 1 year ago (2 children)

The freemium and constant "are you sure you dont want to pay?" from some intellij plugins is insulting enough that it's hard to believe any developer would praise it. Presumably this doesnt happen in vscode because it cant happen in vscode, not because people arent shameless enough to do it there.

[–] Walnut356 44 points 1 year ago* (last edited 1 year ago) (14 children)

That depends on your definition of correct lmao. Rust explicitly counts utf-8 scalar values, because that's the length of the raw bytes contained in the string. There are many times where that value is more useful than the grapheme count.

[–] Walnut356 1 points 1 year ago (1 children)

I think it was this issue. Looks like maybe it got fixed some time this year? Iunno, i'll look into it at some point

[–] Walnut356 6 points 1 year ago (4 children)

code that's been written today has been made obsolete by a language feature in the latest nightly build

I mean couldnt you say that about any language? There's lots of old C code that's obsoleted by features in C11. There's lots of stuff written in python today that's obsoleted by stuff in the 3.13 alpha. It's just kinda how things go.

Doesnt the edition system prevent this from being too big of an issue anyway?

[–] Walnut356 1 points 1 year ago* (last edited 1 year ago) (1 children)

I did not dismiss it, I said measure the performance yourself.

Then why does anyone ask anything? Just figure it out yourself. Oh you read a book or went to college? Why? Should have just reinvented computers yourself man. Taking advantage of collective knowledge is for suckers /s

This means that the code performance is highly dependent on runtime conditions, and needs to be measured in the place where it's used.

How is that helpful for OP? For example, if his question was about rust i'd say "options 1 or 2 should be identical for speed", but if it's python i'd say "match statements are just chained if/else chains, so a direct array index would be faster". For another example, in python attribute access is a function call. x.y in a loop is slower than assigning z = x.y outside of the loop and calling z in the loop.

You can absolutely generalize and have rules of thumb for performance.

If they already measured, then they would know which one is faster, because they measured it.

Measurements can have unintuitive results based on the dataset used (which, for benchmarks, usually end up being artificial datasets). OP's measurements may not have been consistent with their working understanding, thus they ask outside sources to confirm the truth. Idk why you cant just give them the benefit of the doubt and like... answer the question they actually asked? The explanations for "why" that accompany that answer can also be incredibly helpful.

And all of these optimizations are just as effective after you measure them to see if they're needed, and they're no longer premature.

That implies that these optimizations are harder than doing it the "mundane" way. They're not.

Here's a fun micro optimization for compiled languages: on modern CPUs

x = x * (arr[0] * arr[1]) in a loop has better performance characteristics than

x = (x * arr[0]) * arr[1]

even though they do the same thing (in short, it's because of the data dependencies for out-of-order execution - compilers wont make this optimization automatically for floats). How much harder is it to write the first one compared to the second one? How much harder to read is the first compared to the second?

So why would you not just make the first one your default? Now all your future uses of that pattern will perform better, for no extra effort except the amortized cognitive fee of changing your default option.

Look at OPs question. Could the answer fall under a rule of thumb that they can apply as their default option for a scenario? I'm pretty sure it can. So who cares about "premature" or not?

The particular question asked by the OP is very very unlikely to have any significant performance impact at all, unless it's in an extremely hot loop running millions of times per frame

So instead of answering their question, you assume it isnt impacting performance and they're just asking for no reason?

I literally had this exact question about python like 8 months ago. I had a file parser that needed to process different chunks based on a tag. Performance was critical, several thousand files, each ~3mb), the tag dispatch happened about 100,000-300,000 times per file. The original was implemented with if/else. I switched it to match because i thought it was faster, it wasnt. I looked at a lot of threads with answers like yours until stumbling upon dictionary dispatch (i.e. key = tag, value = first class function to call on the tag's data) and array dispatch.

That change alone was a 15% performance improvement.

You have no idea how their program works, what their hot loop is, if they're just asking out of curiosity, whatever. Just answer their fuckin question my dude. Platitudes are a waste of everyone's time.

[–] Walnut356 8 points 1 year ago* (last edited 1 year ago) (3 children)

Rule number 2: stop dismissing performance questions just because of something some guy said decades ago. Performance matters, learning about performance matters, and answers like yours dont help anyone.

Did they ask if they should optimize, or did they ask which one generates more performant assembly? Which one of those questions did you answer?

Maybe they already measured and already knows this is a bottleneck. Maybe they are curious if match statements are a slow abstraction (e.g. in python, it's essentially a chain of if/else. In rust it's often compiled to an indexable table). Maybe the given example code is only partially representative of the actual code this is being applied to.

It's so irritating to look up performance-related questions when this answer is at the top (and middle, and bottom) of every thread. I swear half the reason every piece of modern software runs like shit is because nobody bothered to learn how to optimize and now everyone just parrots that phrase instead of saying "i dont know".

There's tons of little "premature" optimizations that you can do that arent evil. Choosing the right data structure (how random is the access? Are you using keys? Does it need to be sorted?). Estimating time complexity and load size (e.g. "i'm parsing [11 million | 2] files, i should probably [keep time complexity in mind | ignore time complexity completely]"). Structuring loops in a way that's easy for compilers to auto-vectorize - usually it's not any harder to read what the loop is doing, so why not do it right away?

Yes i'm bitter =(

view more: β€Ή prev next β€Ί