Old photo of mine, tried my best to do most cursed hello world in C#
I had no idea most of this stuff existed in C#. Cool post. Could have been a screenshot though.
That’s part of the curse: you lose the Print Screen key on your keyboard!
I have no idea you can do << in c#
I don't know csharp, but I'm 95% sure that's a bitwise shift.
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.
Isn't this C++ stream IO instead of C? C has (f/s)printf, which are much tamer than iostream.
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!
Just because operator<<() is overloaded in C++ doesn't mean it's overloaded elsewhere.
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
It's overloadable, just like in C++
Pretty sure you can overload that. However, the operator overloading doc says to not overdo it and specifically calls out shift operators on streams
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++.
What is it you don't like about C#?
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
If you do enterprise software, there is nothing better than modern C#
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.)
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
That must be the reason why almost all enterprise software runs on the JVM…
"Almost all" being a huge stretch here.
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
That's actually one of my favorite parts of C#, that you can be writing in SQL, C++ or Python in the same language
It's clear enough to see it, so I won't complain this time. Some screenshots are terrible though.
My hat is off to you and I'm not letting you near my computer.
C♭
Fuck I just made the same joke
C Blunt
.... 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.
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.)
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.
C# is actually a pretty good option for working with lower level stuff, but its not as flexible as C++
Shouldn’t it be sizeof(char) * 12 because of the null terminating character at the end of the string?
C# strings aren't null terminated
If you're allocating native memory and using this std, are they still C# strings?
Hmm you may be right, this isn't a regular string but an object of class cstr
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.
You’re null terminated
YOUR MOM™ is null terminated
They are actually null terminated in memory. You just don’t have to deal with the null terminator from code.
They are actually null terminated in memory. You just don’t have to deal with the null terminator from code.
Well sizeof(char) is 2 in C# because Unicode, so this is wrong either way
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.
hold on that's C#??? I thought that was C++ WHY DID YOU DO THAT
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.
You should see the C# code I wrote for handling image alterations. Unsafe, blazing fast DMA lol
Well this is gross, congratulations
This should be called C#++
I think more like Cb
You should look at C++/CLI lmao it's even more cursed
#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) = &¬
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)
Dear kids reading that, don't do that at home.
My most normal C# looks something like this
(Not my repo, but the pattern is the same)
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…
The machine spirit wails.
I feel like this is the coding equivalent of that tape from the Ring
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.
There is no haiku in Ba Sing Se 👀
For reference:
https://www.imdb.com/title/tt0298130/
(It doesn't have the best ratings but it got some cult status.)
...urgh, 23 years ago? Just reminded me how old I am 😢
CBlunt
You gotta check if memory was successfully allocated
Unless the code already does that
just when i thought i was out ...
who wants to play with fire?
Did you guys know C# is called that because it’s C++ ++ but the extra pluses are placed under the first two, making a #
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
Hey I did this in java before!
I want to see that.
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
👀 Seeing this would be in fact interesting! 👻 Sounds scary.
I think your C# caught an STD.
r/angryupvote