ProgrammerHumor

cursedCsharp

cursedCsharp

Old photo of mine, tried my best to do most cursed hello world in C#

https://i.redd.it/jew9forvmpdf1.jpeg
Reddit

Discussion

stillalone

I think your C# caught an STD.

22 hours ago
Evangeder OP
:cs:

r/angryupvote

14 hours ago
FACastello
:c::cp::cs::j::js::ts:

This is r/programminghorror material actually

1 day ago
sambarjo
:cp: :cs:

I had no idea most of this stuff existed in C#. Cool post. Could have been a screenshot though.

1 day ago
capinredbeard22

That’s part of the curse: you lose the Print Screen key on your keyboard!

22 hours ago
BoBoBearDev

I have no idea you can do << in c#

21 hours ago
setibeings
:rust::cp::js::ru::ts::j:

I don't know csharp, but I'm 95% sure that's a bitwise shift.

19 hours ago
ThatOneCSL

I don't know if this is a joke or not, but in the event it isn't...

Ohhhhh boy is C stream IO going to be an eye opener for you.

19 hours ago
DoNotMakeEmpty
:c::lua:

Isn't this C++ stream IO instead of C? C has (f/s)printf, which are much tamer than iostream.

17 hours ago
ThatOneCSL

Ah yep, you're right.

I don't wrastle with either, I just remembered that from playing around with both... 20+ years ago? Wrongly attributed. Thanks for the correction!

12 hours ago
setibeings
:rust::cp::js::ru::ts::j:

Just because operator<<() is overloaded in C++ doesn't mean it's overloaded elsewhere.

11 hours ago
Ludricio
:c::p::cs::ts:

I assume that in the screenshot the << operator for cstr is indeed overloaded and is longer bitshifting (there's a lot of overloadable operators in C#). I would think cstr contains a lot of unforgivable things

4 hours ago
otac0n
:cs::ts::js::powershell::re::lua:

It's overloadable, just like in C++

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/operator-overloading#overloadable-operators

42 minutes ago
jeremj22

Pretty sure you can overload that. However, the operator overloading doc says to not overdo it and specifically calls out shift operators on streams

8 hours ago
Temporary_Equal_1821

Many languages support operator overloading, a form of polymorphism. I've never worked with C# (thankfully), but that's how << works with output streams (e.g., cout) in C++.

18 hours ago
joske79

What is it you don't like about C#?

14 hours ago
CreepyDadd

I agree, too many C# haters. From someone who has coded in, Java, C, C++, ObjectiveC++, Swift, JS and C#. C++ and C# are tied first for my favorite languages to code in

13 hours ago
Narfi1

If you do enterprise software, there is nothing better than modern C#

8 hours ago
RiceBroad4552
:s:

That must be the reason why almost all enterprise software runs on the JVM…

(Yes, there are some companies very deep in M$ ass who in fact use C# for their internal Sharepoint / ASP development, but that's thankfully the big exception by now.)

7 hours ago
Narfi1

Right, because enterprises are known for low inertia and always make sure to refactor the codebase and not have a bunch of legacy projects

Also, Php is the best web backend language since it powers most of the web

7 hours ago
Dealiner
:cs:

That must be the reason why almost all enterprise software runs on the JVM…

"Almost all" being a huge stretch here.

5 hours ago
cherrycode420

You should try C# if you have some use case and you'd like a pleasant development experience, assuming you can use Visual Studio or Rider. the Language itself is really great, it's just some frameworks and projects that are not fun to use or work at, but to be fair, every language has those

9 hours ago
TheShatteredSky

That's actually one of my favorite parts of C#, that you can be writing in SQL, C++ or Python in the same language

10 hours ago
RestInProcess

It's clear enough to see it, so I won't complain this time. Some screenshots are terrible though.

9 hours ago
tmstksbk

My hat is off to you and I'm not letting you near my computer.

22 hours ago
Spill_the_Tea

C♭

18 hours ago
jeckles96

Fuck I just made the same joke

18 hours ago
hongooi
:r::cp:

C Blunt

22 hours ago
IllWelder4571

.... I've been doing c# programming for 5 years. I didn't even know you could do half of this shit.

Cool to know, but do I want my c# to look like c++? Hell no.

Side note... I'd never let you touch my computer. There's a certain point where your job changes from healer to necromancer. This is definitely the latter.

19 hours ago
RiceBroad4552
:s:

I've been doing c# programming for 5 years. I didn't even know you could do half of this shit.

I've used C# once a little bit in a side project.

I knew all the stuff shown in this screenshot (and I know quite some more).

So I'm wondering: What do people actually do when they claim to "learn" a language?

Not even once skimming the docs? (Especially as C# docs aren't even such bad. Had to work with orders of magnitude worse stuff in the past.)

7 hours ago
IllWelder4571

They learn what a language is best at, and in c#'s case it's absolutely not this. If I needed to use the functionality depicted by the op I'd use c++ instead. As that sort of thing is exactly what it's best at.

C# shines at being simplistic and non-cryptic. If you used it once in a side project and ended up doing stuff like the op.... You were using it in a way that goes against its strengths.

7 hours ago
PLEXT0RA
:cs::cp::js:

C# is actually a pretty good option for working with lower level stuff, but its not as flexible as C++

6 hours ago
bluekeys7

Shouldn’t it be sizeof(char) * 12 because of the null terminating character at the end of the string?

21 hours ago
hongooi
:r::cp:

C# strings aren't null terminated

20 hours ago
Etiennera

If you're allocating native memory and using this std, are they still C# strings?

16 hours ago
hongooi
:r::cp:

Hmm you may be right, this isn't a regular string but an object of class cstr

15 hours ago
Evangeder OP
:cs:

string is never native/unmanaged in c#, cstr here is just a wrapper for char pointers, don’t remember how I did the bitshift operator overload but prob some pointer logic shenanigans. I might still have the code at my pc, I can check for it at Monday.

14 hours ago
RamonaZero

You’re null terminated

20 hours ago
hongooi
:r::cp:

YOUR MOM™ is null terminated

20 hours ago
faculty_for_failure
:cs::c::ru::py::ts:

They are actually null terminated in memory. You just don’t have to deal with the null terminator from code.

12 hours ago
faculty_for_failure
:cs::c::ru::py::ts:

They are actually null terminated in memory. You just don’t have to deal with the null terminator from code.

12 hours ago
Zombekas

Well sizeof(char) is 2 in C# because Unicode, so this is wrong either way

9 hours ago
RiceBroad4552
:s:

This would allocate too much memory in the worst case. Allocating too much is not a real problem, besides being inefficient. Not allocating enough would be an issue.

7 hours ago
savevidio

hold on that's C#??? I thought that was C++ WHY DID YOU DO THAT

22 hours ago
amidescent

They used to forbid the shift operator from being overloaded with types other than int until one or two years ago, exactly for this reason. Maybe it wasn't such a dumb restriction after all...

btw you should repost this on r/csharp.

18 hours ago
uberDoward
:cs::cp::py::ts::powershell::asm:

You should see the C# code I wrote for handling image alterations.  Unsafe, blazing fast DMA lol

22 hours ago
Isogash

Well this is gross, congratulations

21 hours ago
7374616e74

This should be called C#++

19 hours ago
jeckles96

I think more like Cb

18 hours ago
dexter2011412
:cp::py::rust:

You should look at C++/CLI lmao it's even more cursed

17 hours ago
Antlool
:cp::c::rust::asm:
#include <stdio.h>
#include <stdlib.h>
const __uint8_t b[13] = {0x48, (6<<4)+5, 0x6c, 108, 0x6f, 0x2c, (1<<5),
                             0x77, 111, 0x72, (6<<4)+12, (3<<5)+4, 33};
__SLONG32_TYPE main(void) {
  __uint8_t* str = (__uint8_t*)malloc(13);
  __u_char i = *str^*str;
  void** poi = (void*)malloc(16);
  *poi = &&is;
  *(poi+1) = &&not;
  is: *(str+i) = *(b+i);
  goto **(poi+(!(++i^13)));
  not: puts((const char*)str); free((void*)str); free(poi);
  return 0xe&(1<<0x1b);
}

tested it and works (C)
edit: probably made it gcc-only but it's even more cursed now (thanks goto)

10 hours ago
RiceBroad4552
:s:

Dear kids reading that, don't do that at home.

7 hours ago
Electronic-Bat-1830
:cs::cp::ts::powershell:

My most normal C# looks something like this

(Not my repo, but the pattern is the same)

20 hours ago
LazyItem

I once in the days of old got an assignment to work on a CRM system. Initial info was that it was slow but ok… The ”system” was basically implemented in one class with 7000 rows that did interop towards old COM ADODB for every request. I threw everything and started over from scratch…

18 hours ago
FirstIdChoiceWasPaul

The machine spirit wails.

17 hours ago
mrwishart
:cs:

I feel like this is the coding equivalent of that tape from the Ring

12 hours ago
SokkaHaikuBot

Sokka-Haiku by mrwishart:

I feel like this is

The coding equivalent

Of that tape from the Ring


Remember that one time Sokka accidentally used an extra syllable in that Haiku Battle in Ba Sing Se? That was a Sokka Haiku and you just made one.

12 hours ago
mrwishart
:cs:

There is no haiku in Ba Sing Se 👀

12 hours ago
RiceBroad4552
:s:

For reference:

https://www.imdb.com/title/tt0298130/

(It doesn't have the best ratings but it got some cult status.)

7 hours ago
mrwishart
:cs:

...urgh, 23 years ago? Just reminded me how old I am 😢

7 hours ago
robinredbrain

CBlunt

11 hours ago
Livid_Boysenberry_58

You gotta check if memory was successfully allocated

Unless the code already does that

9 hours ago
HieuNguyen990616

just when i thought i was out ...

19 hours ago
Gigibesi

who wants to play with fire?

13 hours ago
Casperious

Did you guys know C# is called that because it’s C++ ++ but the extra pluses are placed under the first two, making a #

7 hours ago
Nathan2222234
:unity::cs:

Heh I got one somewhere on my pc that mimics c++ a bit more than this. I’ll post a link once I’m home

4 hours ago
AndreasMelone

Hey I did this in java before!

18 hours ago
RiceBroad4552
:s:

I want to see that.

7 hours ago
AndreasMelone

It consisted of multiple files, one for wrapping Unsafe and one for wrapping System.out to be compatible with pointers and C-style strings. I can make a github repo if you like

7 hours ago
RiceBroad4552
:s:

👀 Seeing this would be in fact interesting! 👻 Sounds scary.

34 minutes ago