Advertisement

C#

Started by August 19, 2000 08:11 AM
125 comments, last by Lucas DG 24 years, 4 months ago
I have been looking into this C# thing and as far as I can see its mostly a web language like java. C/C++ as far as I can tell is still going to be here for a long time as one of the best languages maybe even for ever who knowes. I hope so its got so much power but I am not a Game programer for nothing so if it ever does change Im ready just like the next Game Programmer.
Check this out.

And trust me, those guys at Microsoft aren''t amateur developers, having several million lines of code already is no small feat. This is web and office development though, it still has little to do with games.


Give me one more medicated peaceful moment.
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important social functions will be disabled from now on.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Advertisement
I haven''t had time to read all of the C# language reference (277 pages!) yet, but when I was skimming through it, I noticed this:

"For developers who are generally content with automatic memory management but sometimes need fine-grained control or that extra iota of performance, C# provides the ability to write ''unsafe'' code. Such code can deal directly with pointer types, and fix objects to temporarily prevent the garbage collector from moving them. This ''unsafe'' code feature is in fact ''safe'' feature from the perspective of both developers and users. Unsafe code must be clearly marked in the code with the modifier unsafe, so developers can''t possibly use unsafe features accidentally, and the C# compiler and the execution engine work together to ensure that unsafe code cannot masquerade as safe code.

The example
    using System;class Test{	unsafe static void WriteLocations(byte[] arr) {		fixed (byte *p_arr = arr) {			byte *p_elem = p_arr;			for (int i = 0; i < arr.Length; i++) {				byte value = *p_elem;				string addr = int.Format((int) p_elem, "X");				Console.WriteLine("arr[{0}] at 0x{1} is {2}", i,  addr, value);				p_elem++;			}		}	}	static void Main() {		byte[] arr = new byte[] {1, 2, 3, 4, 5};		WriteLocations(arr);	}}    

shows an unsafe method named WriteLocations that fixes an array instance and uses pointer manipulation to iterate over the elements and write out the index, value, and location of each. One possible output of the program is:
arr[0] at 0x8E0360 is 1
arr[1] at 0x8E0361 is 2
arr[2] at 0x8E0362 is 3
arr[3] at 0x8E0363 is 4
arr[4] at 0x8E0364 is 5
but of course the exact memory locations are subject to change."

Can someone who knows more about C# enlighten me on this "unsafe" keyword? How much of a performance gain are we talking about?
unsafe means garbage collection is disabled for that block of code, and you can use pointers. Exactly how much extra performance the garbage collection will cost you, I''m not sure, but there''ll be a slight improvement.


Give me one more medicated peaceful moment.
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important social functions will be disabled from now on.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
quote: Original post by Vlion

And I would use Linux if it had a really and reliable M$ OS compatibleity: all my games are for DOS/W9x and a few progs are for W3.1. So then, its not really practical for me to use Linux.
Now, if I was starting a server, I`d find a copy of ole RedHat.


I'm pretty sure you could find equivalents (sp?) of your Windows software for Linux... But if you're happy with Windows, then there's no reason for you to install Linux (if you don't feel like playing around with it, like I do ).

quote:
4. I have a dual boot Win98/SuSE Linux6.4, soon to be a quadruple Win2k, WinNT, Win98, SuSE Linux6.4. I'm not an average user.


I'm just curious: what's the reason to have both WinNT, Win2k and Win98 on the same machine? I can understand Win2k and Win98 (since not all 98 software is compatible with 2k), but why WinNT too?

Edited by - Muzzafarath on August 21, 2000 11:00:38 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
I have WinNT4.0 for mainly for testing purposes, so I can try out anything I write on every platform. I can tell you, you run into the strangest quirks sometimes!


Give me one more medicated peaceful moment.
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important social functions will be disabled from now on.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Advertisement
MY GOSH!!!! HAVE YOU ACTUALLY READ WHAT THOSE SICKOS ARE DOING TO THE BEAUTY OF THE C++ LANGUAGE!!! IT''S DISGUSTING!!! I HAD TO STOP BECAUSE IT MADE ME SICK!!!

I decided to cut and paste the section of the code that I read into this thing. I hope that you feel the same amount of disgust that I do...

quote:
What''s one of the most annoying things about working in C++? It''s gotta be remembering when to use the -> pointer indicator, when to use the :: for a class member, and when to use the dot. And the compiler knows when you get it wrong, doesn''t it? It even tells you that you got it wrong! If there''s a reason for that beyond out-and out taunting, I fail to see it.
C# recognizes this irksome little fixture of the C++ programming life and simplifies it. In C#, everything is represented by a dot. Whether you''re looking at members, classes, name-spaces, references, or what have you, you don''t need to track which operator to use.


Does anyone see the problem with this? The reason that the C++ language did this is for you, the programmer, to be able to tell the difference between when the variable is a pointer and when it is not! Gosh, didn''t those idiots think about that?


Okay, so what''s the second most annoying thing about working in C and C++? It''s figuring out exactly what type of data type to use. In C#, a Unicode character is no longer a wchar_t, it''s a char. A 64-bit integer is a long, not an __int64. And a char is a char is a char. There''s no more char, unsigned char, signed char, and wchar_t to track. I''ll talk more about data types later in this article.


Once again Microsoft assumes that you are a boneheaded idiot who can''t think for yourself. This guy who wrote it has probably not programmed C++ too much, and probably has a sub-100 IQ.
DUHH!!! With the "unsigned" keyword, you have the ability to gain twice as many results without using one more byte of memory!

And secondly, Microsoft is destroying the current variable integrity! A 64-bit long? A 16-bit char? That''s going to make it all the harder to do anything that is data-specific. It also will slow down the system because 64-bits will take 2X or more time to process on a 32-bit system!


The third most annoying problem that you run across in C and C++ is integers being used as Booleans, causing assignment errors when you confuse = and ==. C# separates these two types, providing a separate bool type that solves this problem. A bool can be true or false, and can''t be converted into other types. Similarly, an integer or object reference can''t be tested to be true or false—it must be compared to zero (or to null in the case of the reference). If you wrote code like this in C++:
int i;
if (i) . . .


You need to convert that into something like this for C#:
int i;
if (i != 0) . . .


Great, "programmer-friendly" devices that take more time to code and really add no improvement in the code. If you really want to see if(i!=0) in a program you write, then write it! Duh!!! I don''t need Microsoft to force me to get carpal tunnel faster then I might!


Another programmer-friendly feature is the improvement over C++ in the way switch statements work. In C++, you could write a switch statement that fell through from case to case. For example, this code
switch (i)
{
case 1:
FunctionA();

case 2:
FunctionB();
Break;
}


would call both FunctionA and FunctionB if i was equal to 1. C# works like Visual Basic, putting an implied break before each case statement. If you really do want the case statement to fall through, you can rewrite the switch block like this in C#:
switch (i)
{
case 1:
FunctionA();
goto case 2;

case 2:
FunctionB();
Break;
}


I don''t think any explanation is needed here.

I hope the rest of you have gotten sick now...
*getting extremely sick*

*mouth hanging open in disbelief*

All those "annoying" things are features I LIKE!!!!!!!!!

*slumps forward in chair, falls on keyboarddddddddddddddddddddddddddddddddddddddd*
quote: The same goes for almost all versions of Windows - except they still work when you do it badly...for a while... THEN the shit hits the fan. Ask any WindowsNT tech support person.
[ What do you mean, the user had rights to delete their home directory? WHOOPS! ]


Sometimes I wake up screaming , what do you mean you never made repair disks Anyway you guys are beginning to sound like my grandma''s bridge club at a bunjie jumping resort , I smell a lot of fear . Technology is dyanamic , and as programmers you guys should be able to adjust if it comes to that. Personally I cant stomach the idea of not having intimate knowledge about any new programming language or os ........... N-way , I''m rumbling , but my point is , we do not have enough data to substantiate the implied capability for c# to revolutionalize the programming industry.
I was influenced by the Ghetto you ruined.
The dot thing is fine by me, I don''t really care.

The boolean thing is just annoying. IF you can''t tell that

if (i) is checking to see if i is true, you should stick your head in the toilet and flush.

The goto thing is just ridiculous, some of us programmers can claim to count the number of goto''s we''ve used on one hand. I can understand destroying the fall-trough-ness, with I kind of like, but fall through with goto? no way
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt

This topic is closed to new replies.

Advertisement