Visual Basic.net or C #
- How to choose .NET language
In .NET, how to choose VB or C #? This seems to have been arguing for a long time. Many people have blindly selected and have produced many rumors and errors. This article will guide you from the following aspects you choose the correct development language.
Functional consideration
Many people think that C #'s function is powerful than VB.NET, or C # is more suitable for .NET, etc. In fact, this is not a matter of one or two sentences. C # does have VB unable to complete, but VB also has a function of C # unable to complete. In general, there is 100% compatible with CLS for .NET development, VB and C #. The following is different from their language function, which is just a problem with language implementation, and does not affect the generated code. The content of the * is not compatible with CLS.
C # has a function of VB:
1, operator overload. *
2, unsafe code (pointer and fixed memory area). *
3, no symbol integer. *
4, shift operation.
VB has functions with C #
1, instant compilation.
2, static event binding.
3, the condition is abnormal capture.
4, COM compatible class. *
5, loose type check and variable declaration.
6, Visual Basic runtime library.
7. Optional parameters, with parameter properties, modules and other languages. *
8, dynamic array. *
It can be seen that in fact, more powerful is VB instead of C #. However, most of them are not the same as a tight feature. Overall, VB or C # should not be selected from the function, because they don't have any specific difference.
Performance consideration
Performance is the most concerned issue of programmers. VB and C # generate the same IL, so there is no performance difference in theory. But why do Many people say that C # performance is higher than VB.NET? This is because VB.NET supports instant compilation, which is compiled while writing code. This can immediately discover the syntax errors, making debugging easier. However, in this way, VB needs to browse throughout the code file and store the temporary data. This causes a redundancy in the code generated by VB.NET. But you can't say that the VB is slow, and when the user chooses to open optimization and compile the project in the Release mode, you can get the same short and fast code as C #.
Difficulty in learning
This part is not only for beginners to consider, but developers who transfer from existing development tools to .NET also need to consider. First, VB and C # are very simple. For beginners, VB provides a stronger space, so it is easier to accept than C #. But this is only relatively, C # will not have too many difficulties for beginners.
For programmers using Visual Basic6 or other versions. VB.NET's grammar is obviously more close to VB6 than C #, and the VB and VB.NET differentiated on the Internet are exaggerated, so that some programmers retract. In fact, VB.NET has increased just object-oriented ideas. Many VB programmers do not have perfect object-oriented programming experience, so I feel that VB.NET is difficult to accept, which is easy to overcome. Think about it, even if you want to use C #, do you have to learn other objects? As for people with C / C / Java experience, C # is a snatch. I just said that C # and VB are actually very simple, so I don't see VB programmers to learn C # is more difficult than C / C programmers, and vice versa, people with C / C experience can also decisively select VB.
Transplant existing code
This part is the most headache of the programmer. However, the language selection has decisive significance.
Programmer from VB6 transplant code, the best choice is VB.NET because there is no one in other .NET language is similar to VB. And even if the VB6 engineering transplants are very difficult, there is also a transplant guide to help you do most of your work. If handmade transplanted him to C #, it takes a lot of time. And the VB programmers who have just started using C # usually have a headache for C # lacking their familiar functions. VB.NET does not happen. Transplant from ASP to ASP.NET, the preferred language is still VB.NET, because most programmers use the ASP language that is VBScript, only VB.NET is close to this language.
C # to the transplant code seems to have no effect, understanding the C #, it understands that the existing C / C code is put in C # is almost 100% can't pass. So, if you need to transplant C / C code, it is best to use Visual C . Net. He did the best new and old combination. C # is only used to write new .NET applications.
If you need to transplant code from Java, C # can choose. There is also a conversion tool provided by J # and some other MS.
Documents and resources considerations
In the MSDN document, C # and VB are similar. All documents and examples are both VB and C #. Therefore, you don't have to worry about seeking resources. Resources on the Internet, C # should be more than VB, especially domestic, and tend to C #. However, ASP.NET has more resource VB. The lack of VB.NET resources in China is an important reason for impacting VB.NET promotion. But there are many very mature VB technology abroad, such as the development technology of the handheld equipment.
Code style and miscellaneous issues
C # written code is 20% shorter than VB, and many people don't like the keywords in VB. Of course they can choose C #. However, in the development environment, VB automatic completion functions are more perfect than C #, in fact, 30% of the code is automatically supplemented. Therefore, in fact, VB programmers will not play more words than C #. However, VB language is more troublesome than C #, if you need to write a lot of complicated and long code, it is best to choose C #. The VB code is close to the complete English, more readily read than C #. If beginners may wish to choose VB.