Celebrity Deathmatch (VB.NET vs C#)
-
Yeah, the "C way" is better. It's much more flexible. See here for an example.[^] Also, several times I have changed an
if
to awhile
-- in VB you have to change both ends. X| Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.modified on Monday, March 28, 2011 11:52 PM
PIEBALDconsult wrote:
in VB to have to change both ends
I forgot about that! I ran into that today, actually. The most annoying one for me is "Function"/"Sub". Why the heck should I have to annotate that difference? They're both methods. Let the bloody compiler figure out if it returns something or not. I find it strange that VB.NET doesn't have "Begin Grouping" and "End Grouping" rather than parentheses. :rolleyes:
PIEBALDconsult wrote:
Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.
Good point!
-
Which ain't the same thing.
-
Which ain't the same thing.
IsToo... IsNot... rofl... :laugh:
Reminiscing just isn't what it used to be!! If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!
-
Nemanja Trifunovic wrote:
You write code once and read it many times.
By that same reasoning, you learn a language once (well, can take a while for things to sink in) and you can develop software for many years based on that knowledge. It is faster to read "{}" than "Then End If", so why not go for the faster version since it is the one that will lead to the least overall time spent reading if-statements?
AspDotNetDev wrote:
It is faster to read "{}" than "Then End If",
Kind of.
End If
closes the block afterIf
and that's it. To get what}
does you need to be aware of the scope - sometimes even to scroll up a couple of pages. Sure, a good editor helps, but as far as a language goes I likeEnd If
better. -
Yeah, the "C way" is better. It's much more flexible. See here for an example.[^] Also, several times I have changed an
if
to awhile
-- in VB you have to change both ends. X| Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.modified on Monday, March 28, 2011 11:52 PM
PIEBALDconsult wrote:
Would you double-check that link? I saw nothing related to your arguments there (using Chrome 10 on Fedora Linux).
PIEBALDconsult wrote:
Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.
Meh, as a Cyrillic-writing Serbian I'll take Anglo-centric any time over cryptic symbols. In fact, my ideal language would have no operators at all - not even mathematical ones.
-
AspDotNetDev wrote:
It is faster to read "{}" than "Then End If",
Kind of.
End If
closes the block afterIf
and that's it. To get what}
does you need to be aware of the scope - sometimes even to scroll up a couple of pages. Sure, a good editor helps, but as far as a language goes I likeEnd If
better.Very good point. Though, if the code is written in small enough methods and the editor is good enough (like Visual Studio), clicking on a closing curly brace will highlight the corresponding opening curly brace and you can see it without scrolling. If the code is not small enough, then you'd have to scroll anyway in either language and you could easily get lost. Come to think if it, would be a neat IDE feature if you could right click on "}" or "End If" and select "Go To Start".
-
Which ain't the same thing.
Ah. Right you are.
-
PIEBALDconsult wrote:
Would you double-check that link? I saw nothing related to your arguments there (using Chrome 10 on Fedora Linux).
PIEBALDconsult wrote:
Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.
Meh, as a Cyrillic-writing Serbian I'll take Anglo-centric any time over cryptic symbols. In fact, my ideal language would have no operators at all - not even mathematical ones.
Nemanja Trifunovic wrote:
my ideal language would have no operators at all - not even mathematical ones
-
PIEBALDconsult wrote:
Would you double-check that link? I saw nothing related to your arguments there (using Chrome 10 on Fedora Linux).
PIEBALDconsult wrote:
Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.
Meh, as a Cyrillic-writing Serbian I'll take Anglo-centric any time over cryptic symbols. In fact, my ideal language would have no operators at all - not even mathematical ones.
Fixed, thanks.
-
PIEBALDconsult wrote:
in VB to have to change both ends
I forgot about that! I ran into that today, actually. The most annoying one for me is "Function"/"Sub". Why the heck should I have to annotate that difference? They're both methods. Let the bloody compiler figure out if it returns something or not. I find it strange that VB.NET doesn't have "Begin Grouping" and "End Grouping" rather than parentheses. :rolleyes:
PIEBALDconsult wrote:
Plus, using more symbols and fewer keywords makes C somewhat less Anglo-centric.
Good point!
AspDotNetDev wrote:
"Function"/"Sub".
Yeah, and class/module too.
-
this would be a linq version
(from f in new List<Func<bool>>() { Step1, Step2, Step3 } where !f() select 0).FirstOrDefault();
but you are still limited to the same function signature in the vb version it could be
case step1(mystring)
case step2(myint, mystring)
.....modified on Monday, March 28, 2011 6:56 PM
I figured out a shorter version that makes use of LINQ. I posted a tip/trick about it.
-
VB.NET supports by-ref extension methods. As of 4.0, C# does not.
Regards, Nish
Are you addicted to CP? If so, check this out: The Code Project Forum Analyzer : Find out how much of a life you don't have! My technology blog: voidnish.wordpress.com
Well the VB designers got Extension Methods right, the C# designers really screwed up big time. Extension Methods should be by attribute in both languages.
-
Fixed, thanks.
Doesn't look fixed to me. Methinks you need to get the permalink from whatever message you are linking to.
-
AspDotNetDev wrote:
Maybe "End Sub" makes the code easier to read to somebody not initiated with the language, but it doesn't make the code any easier to write
Which is a reasonable trade-off. You write code once and read it many times. Besides, with any decent editor, it is a non-issue.
AspDotNetDev wrote:
if (true)
{I see unnecessary and confusing symbols here. For instance in Go, it would be something like:
if true {
Or (even better) in ML:
if true then
Nemanja Trifunovic wrote:
AspDotNetDev wrote:
if (true)
{If I had my way (and I don't), the braces would be mandatory and the parentheses would be optional.
-
AspDotNetDev wrote:
It is faster to read "{}" than "Then End If",
Kind of.
End If
closes the block afterIf
and that's it. To get what}
does you need to be aware of the scope - sometimes even to scroll up a couple of pages. Sure, a good editor helps, but as far as a language goes I likeEnd If
better.See what happens when you remove all the newlines. Readable?
-
Doesn't look fixed to me. Methinks you need to get the permalink from whatever message you are linking to.
My post "Here's something else VB can't do".
-
My post "Here's something else VB can't do".
-
There hasn't been a good "why language X sucks and language Y is better" thread in a good while, so I thought I'd start one. Unlike most, however, this one has rules. I will post a reason C# is better than VB.NET and somebody reply with a reason VB.NET is better than C#. I (or somebody else) will then reply to that message stating another reason C# is better. And so on. Also, you must show code examples (when appropriate). I'll start. C# Is Less Verbose
Public Sub Something()
' VB.NET...
End Subpublic void Something()
{
// C#...
}You're turn (post why VB.NET is better than C#). :)
VB is better because I use it more often, and have more experience with it than C#. Do I get points for honesty?
-
There hasn't been a good "why language X sucks and language Y is better" thread in a good while, so I thought I'd start one. Unlike most, however, this one has rules. I will post a reason C# is better than VB.NET and somebody reply with a reason VB.NET is better than C#. I (or somebody else) will then reply to that message stating another reason C# is better. And so on. Also, you must show code examples (when appropriate). I'll start. C# Is Less Verbose
Public Sub Something()
' VB.NET...
End Subpublic void Something()
{
// C#...
}You're turn (post why VB.NET is better than C#). :)
AspDotNetDev wrote:
You're turn
Am I? ;P
-
That's pretty neat! But you can actually get pretty close to that in C#:
var steps = new List<Func<bool>> { Step1, Step2, Step3 };
foreach (var step in steps)
{
if (!step()) break;
}And if you create this helper function:
void DoEach(params Func<bool>[] steps)
{
foreach (var step in steps)
{
if (!step()) break;
}
}You can shorten that code even further:
DoEach(new Func<bool>[] {
Step1,
Step2,
Step3
});Got to love delegate inference! Not sure, but I think there's something in LINQ that does something like this as well. Can't be bothered to try and find it now though.