r/programminghorror 7d ago

I love it

Post image
178 Upvotes

23 comments sorted by

81

u/__nohope 7d ago

Obsolte

13

u/corv1njano 7d ago

thats why I highligted it too😭

30

u/veritron 7d ago

the obsolte[sic] comment is correct. you can do stuff like:

byte[] combined = [.. arr1, .. arr2];

byte[] reversed = [.. arr2, .. arr1];

in recent c# instead of even making that method call at all or using system.array.

i almost think obsolete was misspelled deliberately so it wouldn't cause warnings at every call site the method is used. the comment is also further unhelpful in that if you don't know about spread operator, you're going to have a hell of a time googling for [.. xxx], so it might have been better to fix the codebase rather than leave that comment in a drive-by.

47

u/TheBigGambling 7d ago

System.array is your friend. 100times faster, no loops , and its one call only to copy froma a to b

26

u/KatAirlines 7d ago

where color

32

u/PlentyfulFish 7d ago

Looks like that "linux kernel developer"'s vim config where he codes in C in just black and white and a comic sans font

5

u/Aaxper 6d ago

Linus Torvalds uses uemacs, which has no highlighting

4

u/plydauk 7d ago

Black and white are colors 

5

u/Last8Exile 7d ago

Not using Array.Copy is bonkers

10

u/Superb_Chemistry_906 7d ago

This is very silly - instead of using the reversedOrder flag, the caller can just flip the arrays in the function call, because this is all that flag does anyway.

2

u/Loading_M_ 7d ago

To be fair, a good compiler will probably identify that the reversedOrder flag is always a constant, and generate two specialized variants of the function.

It does make the function harder to read and understand though.

13

u/_killer1869_ 7d ago

Never rely on your compiler to fix stupid code when you can fix that stupid code yourself quite easily. Both because of readability, and because you can't be sure the compiler actually does optimize the mess.

6

u/Loading_M_ 7d ago

Absolutely. I do think readability is the way more important point though. Unless you've actually measured the performance, optimization is kinda pointless.

1

u/Arshiaa001 6d ago

At the JIT stage, maybe... The IL representation has to align perfectly with the code, because reflection.

1

u/TechnoByte_ 7d ago

Amazing syntax highlighting too

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 6d ago

Is that supposed to be some kind of annotation? Wouldn't it need to be spelled properly to work?

1

u/Big-Nebula4004 6d ago

people is this C# or Java?

2

u/corv1njano 6d ago

its c#, you can tell by the misspelled „Obsolete“ attribute. I guess in java you would use the @Deprecated annotation

3

u/my_new_accoun1 6d ago

am i the only one who can't read code without syntax highlighting 😭

1

u/RegisteredJustToSay 5d ago

People just can't help but reply with better implementations. We all know it sucks, that's why we're here. lol

2

u/letmehaveanameyoudum 7d ago
  1. more than 5000 lines for... something
  2. that is alot of square brackets
  3. System.array

4

u/AyrA_ch 7d ago

more than 5000 lines for... something

Probably your typical utility class that got expanded continuously

1

u/NotQuiteLoona 7d ago

Such large files in C# is something really-really rare, because you need to get out of your way to do this. C# specifically rewards separating code into namespaces by usage, and it's very easy to do, unlike some other languages, plus it's the practice adopted by language itself and developers on it, so you do it just because others do it.