i really dont like the {'s and }'s...if u have complex code with many if's inside other if's that makes the code get really really big.. =\...and in some cases it's hard to see whom are the {'s parents..damn
Printable View
i really dont like the {'s and }'s...if u have complex code with many if's inside other if's that makes the code get really really big.. =\...and in some cases it's hard to see whom are the {'s parents..damn
Same can be said about the End If or Loop words in VB.
Have you ever read the Linus Torvald code formatting standard?
Code needs to be indented, then it's very easy to find what belongs to what. Very complex code should be subdivided into functions (except if it's time critical, then it shouldn't be C# ;)).
In general the braces of C/Pascal derived languages (C, C++, Pascal, Delphi, JavaScript, PHP, PERL, C#, Java, ...) are more readable than the End * statements of Basic-derived languages (like VB, Lingo, ...).
nop, loops and ends in VB are really easy to understand and in C# and all that langs with braces its in some cases ****ty...i remember doing a program in C# which the end of the file had about 8 or 9 closing braces! LOL
I have done VB programs that had 8 or 9 End If's...lol.
It is all the way you think about it. We all understand you don't like it. That is fine, no one said you had to, but all it is is substituting the End If with a }. Seems pretty easy to understand to me. I know there are a lot of others besides me that can comprehend it also.
If you hate C#, C++, Java, JavaScript, and all the other languages that use this format, then don't use them. It is pretty simple. You have a choice. Just remember that your choice won't be everyones.
I personally don't care about the {} in C# or the End If's in VB.Net. It just doesn't make a difference to me. I can program just the same with either. I don't let little hangups about a language get in the way of learning new things.
lol i dont hate that langs but i hate the braces when they get really "big" LOL
and VB has the difference that has End If End Loop End Class End function etc...u know what u're ending and with braces u have to check ^^;;; -_^;
Q: Why did MS create C# when VB now has OO?
A: C# has been designed specifically for .NET. C# has fully managed code (which C++ doesn't have). The intent was to give everyone something in between C++ and VB.
BTW: VS.NET was written in C#!!!
Regarding the "slowness" of .NET apps... I blame it on the JIT. At the moment, it seems to me that the .NET JITter is immature. IT will get better.
One of the nice things about .NET is the interoperability of components written from different languages. Let's say I'm building an app inC# and I need to do something, if I know how to do itin VB, I can switch over to VB.NET, write code, then pop back into C# hook it up and call it.
To anyone who is "afraid" of having to learn a new language.... get over it... be thankful things are easier than they were from a few years ago. Here's my take on languages: With a couple of exceptions, all languages are essentially the same. Every one has an IF statement. And that IF statement has the same 3 components in it:
1) Test condition
2) Statements for condition TRUE
3) Optional alternate statements for condition FALSE.
The syntax varies, but essentialy they are the same. It just looks different. I'm NOT saying that all languages are created equal, because they are clearly not (how long did it take to get true OOP in VB???). And the tools used to create the programs vary in their ability to "hide" certain things from the developer. In VB, you double click a control and pop into the event code of the control; In C++, you (in very basic terms) create a message, then hook a function to that message event.
What I like about the braces is that you can distinguish an end-of-block from a line of code with a short look.
yea thats true
...and this new tab technology makes it even easier :D :p
That's not too hard to understand!? And by my calculation, "}" is faster to type than "end if". But, you can check my math yourself if you don't believe me.Code:class ...
{
if (...)
{
for (...)
{
}
}
}
VB Code:
if lol = true then if lol = false then for y = 0 to 1000 for i = 0 to 1000 loop while ... end loop next i next y end if end if
now look to C# code:
which is harder to read? in vb i know what im closing and in C# u dont..PHP Code:<same thing>
}
}
}
}
}
}
i want to see ur math calculations when u'r really stressed catching a damn bug to ur work and u get confused because u dont know where da hell are the damn closing braces u're looking for :p
Very easy. Go to the opening statement and place the caret at the start, then press the down key until there is a brace right next to the caret. It doesn't take long, and you'd have to do the same if you da multiple End Ifs.Quote:
Originally posted by PT Exorcist
i want to see ur math calculations when u'r really stressed catching a damn bug to ur work and u get confused because u dont know where da hell are the damn closing braces u're looking for :p
And Visual Studio.NET has this new wonderful code hiding function...
Never let bugs stress you.
well in vb we dont havve to do that **** about going to the open and that thing..lol..we simply look and understand right away where it is starting,...
I agree with CornedBee. Also, if you use plenty of comments throughout your code, you shouldn't have a hard time figuring out whats going on anyway.
What are some comments about C# as opposed to Java?
I want to develop apps that link across platforms... Java is already interoperable and becoming more supported. I have programmed in C and VB but I want to change to something that will be more useful to the future of my company!!
btw doesnt J# sucks? if the big point of java is work under any plataform and J# needs the framework then i see no point in using J#...
There isn't. J# is a transitional language. It's basically C# with some keywords changed to accomodate Java programmers (e.g. I think using is replaced by the Java import). I expect it to always be the least maintained .NET language. My recommendation is not to use it.
C# currently is only for windows, because only windows has a functional CLR framework. But there are several projects that plan to port the CLR to other platforms (like the mono project). When they are finished C# will be as interoperable as Java. But Java has a several year advantage.
Oh, PT:
Linus Torvalds would kill you for that. His coding guidelines explicitly state that every function with more than three indents is crap. Create helper functions, which will make your code more readable without having to type 'End If'. Linus also says that the indentation should be 8 chars, then it's even easier to read.Quote:
Code:
}
}
}
}
}
}
The bottom line: the advantage of End If stems from bad coding style ;)
CornedBee, what is the coding standard in C# when it comes down to naming your variables?
In VB, for example, with hungarian notation, a string would be declared using:
I haven't noticed any pattern in C#.Code:Dim strMessage As String
Thanks
Although I agree with the information, Linus Torvalds isn't the God of programming. That is his style, not everyones. Just cause he does it, doesn't mean I have to. He is a good programmer, don't get me wrong. I can learn a lot from what he has to say, but we are getting into the 'style' part of programming. What makes us comfortable is what we should do....unless working with a team, then you all come up with standards together.Quote:
Linus Torvalds would kill you for that. His coding guidelines explicitly state that every function with more than three indents is crap. Create helper functions, which will make your code more readable without having to type 'End If'. Linus also says that the indentation should be 8 chars, then it's even easier to read.
To Lethal, this is all I could find on the MSDN site:
http://msdn.microsoft.com/library/de...techniques.asp
Of course you are right hellswraith. We can all choose our own style (I use a very strange mix of Hungarian and K&R) unless we work on a team.
But that was exactly the situation Linus wanted to point out. Having 6 or 7 levels of nesting makes your code hard to read, no matter if you use } or End XX to delimit it.
Lethal: You can still use Hungarian in C# if you like it. Naming conventions are independent of the language.
Looking at the .NET framework it seems as if it's convention would be this:
All identifiers start with an upper case letter.
Don't use _ in the identifiers.
The type is not encoded into the identifier.
A multi-word identifier has an upper case letter for each word start (like 'DoSomeWeirdThing').
No prefixes are used for static members or normal members.
Classes don't have a prefix.
I think code is most readable if it adheres to the convention of the framework it uses. But there are arguments both for and against this. It's really up to your personal preference. Think of it this way: code that you'll still be able to read in a year is good. Everything else is bad.
That's exactly how I feel. You need to write it so you can come back and read it again.Quote:
Think of it this way: code that you'll still be able to read in a year is good. Everything else is bad.