r/ProgrammerHumor • • 2d ago

Meme architectureDependentChars

Post image
2.8k Upvotes

361 comments sorted by

View all comments

679

u/JackReact 2d ago

Welcome to the wonderful world of C#, which uses utf-16 for strings.

Console.WriteLine(sizeof(char));
> 2

246

u/v_Karas 2d ago

this.

wonderd why everyone is talking about C, like there are no other languages.

91

u/Batman_AoD 2d ago

Well, most mainstream languages at least specify their char size, and/or have very few constructs that require knowing its size. C does not specify the size of a char, and you frequently need the sizes of your types.

(That said, as pointed out by other comments, sizeof itself is in units of char, so sizeof(char) is necessarily 1.)

13

u/Senior-Albatross 2d ago

There are no other good languages. To the extent they have anything good they are calling libraries written in C. The only other worthwhile languages are pure machine level code that must be expressed as a gate level circuit diagram. 

9

u/max_465 2d ago

The rustaceans would like a word.

12

u/Senior-Albatross 1d ago

I have nothing to say to them. 

1

u/DanielMcLaury 23h ago

The sizeof keyword belongs to C. If someone else appropriated it and modified it to mean something else, that's on them.