Why .net Sucks Ass

Posted by blackhole on May 3, 2010, 11:47 p.m.

I have had it with this stupid, fucking, piece of shit language that is supposedly the future of code. I have had it with people laughing at my supposedly immature and baseless hatred of managed languages.

TEMPLATES SHOULD BE INCLUDED IN C#.

You know why? Because if you want to mimic the same behavior with generics, it is a TOTAL BITCH to do and is astoundingly inefficient. The primary issue is that generics are resolved at runtime. This is useful for somethings and very-not-useful for a whole lot of other things. Lets take a basic 2D coordinate class. A 2D coordinate class has to do a lot of things, like normalizing, getting length, defining operators, etc. It is the bedrock of your entire graphics engine or game, and it needs to be stupid, stupid fast. If you have templates, making this 2D coordinate class work with any value type you want is trivial. template<typename T> and your done. The compiler generates a separate class for each type, all properly optimized and ready to go.

What about Generics? Well first of all, there isn't any possible way to define an inherited class type as an integral value, so where(type) is useless. Then there's the whole problem of it getting resolved at runtime, which in terms of speed is like trying to walk along a goddamn freeway. But the truly terrifying problem is that T is considered to be an object by default, and objects do not have any basic operators.

None.

Zero.

How do you get around this? You create a bunch of static methods, of course! Add(), Subtract(), Multiply(). You know, all the methods that operators were specifically invented to replace because they were stupid and redundant. Oh, but it gets even worse. Because your type is resolved at RUNTIME, there is no possible way for the compiler to optimize the code. Every time you want to add something, it actually calls that add function, copies all the information over, adds it, copies the return value back, and then finally returns it. Think about doing that thousands of times a second.

Yeah, .net generics are way better then templates. I don't know why you'd ever need templates!

Fuck.

That.

Shit.

If anyone ever tells me that C++ is inferior to C# ever again I'm going to kick them in the face and burn them alive.

As a disclaimer I decided to solve the problem by using a #define to manually generate all the classes for me. This is, of course, extremely bad code practice. Too bad I don't have a choice.

Comments

Scott_AW 14 years ago

You should try GLBasic, less stress.

sirxemic 14 years ago

By your logic 1 annoyance makes a language suck ass…

C# is superior to C++ in terms of overall user friendliness for a start. If you fail to realize that, you suck. Of course optimal performance suffers from this, but if performance is an issue you don't use C#…

Also, apparently you completely misunderstand the point of templates. T considered to be an object? Damn right! Templates are mostly used for datastructures, and it's kinda obvious you don't need basic operations on the elements then…

DSG 14 years ago

I want to agree with you. But, I don't understand anything.

blackhole 14 years ago

sir_Xemic: No, by my logic a long string of things that piss me off about C# makes the language suck ass (although its really the CLI, not C# specifically). The complete lack of template support is simply one in a long line of things. The .net framework has some of the most ridiculous implementations of basic data structures I have ever seen.

This isn't an issue of "Oh if you don't like it don't use it." The point isn't that I'm trying to use templates in C# (you can't), its that I'm trying to take a graphics engine written in C++ and port it to CLI so its usable in C# because someone wants to use my graphics engine and they only work with C#.

Your definition of a template is inherently flawed because many data structures must work with integral value types as well as objects. This is why the standard C++ library has an entire technique dealing with passing reference types versus value types. Beyond that, templates in C# don't consider T to be an object because, as I just explained, there are no templates in C#. There are Generics. They are fundamentally different, and yet we are expected to use generics in place of templates anyway, which is exactly where the problem lies. In the context of a generic, where things are resolved at runtime, it makes sense to consider T to be an object because as you mentioned generics are not designed for value types and were never intended for such things.

Templates, however, were designed for that and do a very good job at it.

C# is easier to develop in than C++ (and I am not debating that) mostly only because of vastly superior intellisense and development tools combined with a ridiculously huge function library. Both of these come at the price of only working on windows.

Juju 14 years ago

Don't use .net for graphics I think is the moral here.

sirxemic 14 years ago

Yeah I shouted things a bit too quickly. Most of my comment holds though. I was confused by the difference between templates and generics. I think C# never intended to use template metaprogramming since it isn't exactly compiled.

What I found most annoying about this blog was that you state your opinion, then only use one argument to support that opinion. That just sounds silly.

Oh and my username is sir Xemic, without the underscore =P

Juju 14 years ago

Stating your opinion and then backing it up is… you know… accepted argumentative technique.

blackhole 14 years ago

Again, you aren't making sense. C# *is* compiled, into bytecode, and then compiled all the way down into assembly. Generics were made so it could be done at runtime instead of being resolved in compile time, since C# hates things like #define or anything of the sort. There is nothing in the C# language stopping templates from being supported, they just didn't want to support them. C# absolutely hates anything having to do with metaprogramming, which I find very bizarre and is another reason why it sucks.

You do realize this was just a gigantic rant, right? I stated my opinion and then ranted on about a very specific thing that was pissing me off and only bothered to back up that very specific thing. This isn't a PhD dissertation, its a goddamn journal entry.

Your username looks like it has an underscore when its underlined as a link.

Kaz 14 years ago

From what I've seen and used, .net is just a simplified version of another language, which caters to a wider audience who don't want to learn the details of every minute thing.

C++ and C# both have their advantages, although I agree that C# should have generics, if it is true that it doesn't support them. I've only made generics in PHP thus far and they are incredibly useful.

GearGOD 14 years ago

"Why .net Sucks Ass"

"TEMPLATES SHOULD BE INCLUDED IN C#."

C# and .net are about as similar as oranges and helicopters. You liberally using and switching these terms around provides a good setting for evaluating the worth of your opinion: 0.

If you want to know why there's no templates, you only have to think a centimeter ahead of your worthless fucking around and consider real world issues such as how templates would interact with reflection. How about what happens when you try to use your imaginary template with an embedded type? Oops.

All in all, just stick to C++. The more people like you, the bigger my salary will be.