区分大小写与不区分大小写的语言?
Visual basic.net 不区分大小写,因此它允许编码人员在编写时无需关心或记住变量的大小写。如果您在声明中使用的变量之外的另一种情况下使用该变量,它还可以缓解“未声明的变量”错误。事实上,它的行终止是换行符,这使得它更具可读性,这与 C# 或 C++ 不同,C# 或 C++ 需要小心地进行大小写和连续的战争,跟踪 {},匹配它们并找出哪个是哪个。
我的问题是 C# 相对于 VB 有什么优势,因为两者都被编译为 MSIL,所以两种语言之间几乎没有性能差异?
visual basic.net is case insensitive so it allows the coder to write without caring or remembering the casing of variables. it also relieves from the 'undeclared variable' errors if you use the variable in another case than the one used in declaration. The fact that its line termination is a line feed makes it even more readable unlike C# or c++ that need good care in the casing and contineous war with following up with the {}, matching them and figuring out which is for which.
my question is what are the advantages of c# over vb knowing that both get compiled to MSIL so there is almost no performance difference between the two languages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
外壳并不让我兴奋;特别是对于任何像样的 IDE,您都会拥有智能感知、自动完成、自动更正等功能。最坏的情况:编译器会为您找到它。而且我真的不认为强制使用特定的行空间模式是一件好事(是的,我使用 VB 多年)。
确实,c# 和 VB.net 有很多融合,特别是现在有了动态(这有助于填补 c# 与 VB.net 之间唯一的真正差距)。
对于强大的 C# 功能:迭代器块(又名yield return)。还; lambda 语法更完整/更通用。
但有一个不太具体的论点:广泛使用两者后,我发现 c# 更具表现力,更易于阅读/维护,而且更干净。简而言之:我非常喜欢它;)
还有一种情况是,以 java/c/c++/JavaScript 熟悉的语法开始可以使传输更容易。
Casing doesn't excite me; especially with any decent IDE you'll have intellisense, auto-complete, auto-correct, etc. Worst case: the compiler finds it for you. And I really don't buy that being forced into a specific line-space pattern is a good thing (and yes, I used VB for years).
It is true that c# and VB.net have a lot of convergence, especially now with dynamic (which helps plug the only real gap in c# bs VB.net).
For a powerful c# feature: iterator blocks (aka yield return). Also; the lambda syntax is more complete/versatile.
But a less-specific argument: having used both extensively, I find c# more expressive, simpler to read/maintain, and cleaner. In short: I like it lots ;)
There is also the case that starting witha syntax familiar to java/c/c++/JavaScript makes transfer easier.
首先,C# 社区要大得多。
绝大多数代码示例位于 http://www.codeproject.com/ 采用 C# 语言。
我的建议当然是选择 C#,如果只是因为这个原因的话。
For one, the community for C# is much larger.
The vast majority of code samples on for example a site like http://www.codeproject.com/ is in C#.
My advise would certainly be to go for C#, if only for this reason.
我有 Delphi 背景,几年前我对区分大小写的看法和你一样。但是,当我使用 C#(学习大小写约定)几天后,我注意到它的错误源比预期小得多。
静态类型语言中的大小写敏感性并不重要。
对于区分大小写的语言,即使在没有 IDE 的情况下编程,也不会经常出错,因为您知道大小写不是任意的,但是遵循惯例(有些语言如 Cobra 甚至强迫你遵循惯例)。对于 IDE,这甚至不那么重要,因为智能感知正在为您修复它。
IMO 强迫你在任何地方都遵循约定会导致更好的可读代码。当我在 Delphi(不区分大小写)中编程时,我的大小写非常不一致。但是,用于不区分大小写的语言的现代 IDE 应该具有格式文档功能,该功能使标识符的大小写与声明标识符时使用的大小写相同。因此,这对于现代 IDE 技术来说已经过时了。
对于某些动态类型语言,区分大小写至关重要
虽然这不适用于 VB 与 C#,但某些动态类型语言(lua、javascript)只能在区分大小写的情况下正常工作。这是因为其中字典中的
string
键和成员名称几乎相同。区分大小写的字典比不区分大小写的字典更强大。I come from a Delphi background and felt like you about case-sensitivity a few years ago. But once I worked with C#(learning the casing convention) for a few days I noticed that's it's a much smaller error-source than anticipated.
Case sensitivity in statically typed languages doesn't matter much.
In case sensitive languages, you don't get it wrong that often even when programming without an IDE since you know the casing isn't arbitrary, but follows from the convention(Some languages such as Cobra even force you to follow the convention). And with an IDE it's even less important, since intellisense is fixing it for you.
IMO forcing you to follow the convention everywhere leads to better readable code. When I programmed in Delphi(case-insensitive) my casing was quite inconsistent. But modern IDEs for case insensitive languages should have a Format-Document feature which makes the casing on identifiert use the same as the identifier was declared with. So again that's obsolete with modern IDE technology.
For some dynamically typed languages case-sensitivity is essential
While this doesn't apply to VB vs C# some dynamically typed languages(lua, javascript) work only well with case sensitivity. This is because in them
string
keys into a dictionary and member-names are almost the same. And case sensitive dictionaries are much more powerful that case insensitive ones.基本上没有。
VB.NET 的创建是为了吸引现有的 Visual Basic / Office 程序员,C# 的创建是为了吸引那些喜欢 Java / C++ 的人。
Essentially none.
VB.NET was created to lure existing Visual Basic / Office programmers, C# to lure the ones preferring Java / C++.