|
|
Contents
This article explains the benefits of a Microsoft .NET application development organization coding in C# versus coding in VB.
It's common knowledge that VB.NET and C# are functionally equivalent. Hence a frequently-heard argument for choosing one or another is that because they are functionally equivalent, neither poses a clear advantage. This argument has merit, but because it attempts to be diplomatic and avoids subjective opinion, it fails to get to the heart of the matter.
This article does not simply consider objective arguments. Rather, I attempt to explore some of the highly subjective factors which influence developers working in VB versus C#. These subjective factors taken collectively over time contribute to a certain culture. The VB culture is different from the C# culture.
By examining the history of the two cultures and their current trends, we can make predictions about how the choice of one language or another might influence the production of quality code in a production shop.
The purpose of Visual Basic was to create a mass market for software development tools. Prior to Visual Basic, application development languages were viewed as complex and restricted to the domain of skilled programmers. Visual Basic was syntactically simple, and it enabled virtually anyone with a few hours of time to learn how to create simple applications. In the days when software development was seen as more of a black art than an engineering discipline, the ability to be able to join the ranks of “software developers” was a powerful aphrodisiac for many computer users.
And join they did. Millions of “power users” of computers became millions of “software developers”. It happened that Visual Basic came along just as the demand for new software applications was escalating rapidly, driving demand and hence higher salaries for software developers.
The fact that Visual Basic was lacking in the fundamental building blocks of object oriented programming didn’t matter much at the time. Software was still relatively simple. Distributed application development was client-server at best. The web was so new that application development models for it had barely started to evolve—the business world didn’t even know where the web was going, so how could developers possibly know how to program for it? Web applications were hacked together, and it didn’t matter. To compound the hacking methodology, the sheer demand for web applications began to accelerate at a pace that exceeded even the wildest expectations by an order of magnitude. Application developer salaries skyrocketed, demand continued to increase, and the perceived need for a sane, sustainable application development model was left trailing far behind.
The peak of this trend coincided with the peak of the Internet boom. Vast armies of grossly under skilled developers were paid enormous sums of money and elevated to cult-like status to hack together anything that would even remotely resemble a software application. And Visual Basic, with its lack of formality and constraints that might slow down the hacking process, was just the right food for the frenzy.
Visual Basic was launched in March of 1991. In 2000 Microsoft announced .NET. in a move that swept the slate clean and replaced Visual Basic with what was in effect an entirely new development paradigm. The underlying classes against which programmers developed were completely replaced by the .NET Framework. The kludgy third party tools were swept aside and replaced by a clean third party tool model. The lack of inheritance and the limited implementation of polymorphism enforced for so many years by the underlying limitations of the Visual Basic engine architecture was overcome by throwing the old engine out completely.
With these changes, Visual Basic was reborn as a powerful new development platform, functionally equivalent to C#, J# and Java. In fact, of the Visual Basic of the 90’s, only two things remain today; the culture and the syntax. The culture of Visual Basic is the culture of the 90’s: build it fast, hype it up, sell it, and don’t worry about whether the story will hold together tomorrow, or even hold together at all.
To grasp how this culture affected trends in software development, it’s instructive to hear what Niklaus Wirth had to say about it in 1997. Niklaus Wirth is one of the most influential thinkers in the software world. A professor at ETH Institute in Zurich, Wirth designed Pascal, Modula 2 and Oberon. In the early 1970s, he was one of the people who proposed program development by stepwise refinement. He's the author of many important books, including "Algorithms + Data Structures = Programs" (Prentice Hall, 1975) and "Systematic Programming" (Prentice Hall, 1973) He was awarded the Turing Prize in 1984, and has also received five honorary doctorates and several other awards.
In a well known interview with Dr. Carlo Pescio, published in Software Development, June 1997, Pescio asks Wirth:
You probably know about the 'good enough software' concept popularized by Yourdon. In many senses, it's just a rationalization of what's happening in the software world: the first company hitting the market with a feature-rich product is more likely to win the battle than the careful, quality-seeking company. Do you think there is anything developers and software organizations can do about that? I guess many developers would be happy to be given more time to develop better software, but at the same time they are rushed in the name of corporate survival. 'Educating the users' seems more a wild dream than a possibility.
to which Wirth replies:
'Good enough software' is rarely good enough. It is a sad manifestation of the spirit of modern times, in which an individual's pride in his/her work has become rare. The idea that one might derive satisfaction from his or her successful work, because that work is ingenious, beautiful, or just pleasing, has become ridiculed. Nothing but economic success and monetary reward is acceptable. Hence our occupations have become mere jobs. But quality of work can be expected only through personal satisfaction, dedication and enjoyment. In our profession, precision and perfection are not a dispensable luxury, but a simple necessity.
Recently I read a final report of a research project funded by the Swiss National Science Foundation. The project's naive goals were identified as follows: First, how can easy programming be achieved (in particular, for non-experts)? Second, how can a mechanism be realized that allows hiding the difficult parts of parallel programming? After more than 30 years of programming we ought to know that the design of complex software is inherently difficult. This despite of the fact that, for decades, the industry has been advertising programmers' positions by claiming that programming is easy. Later on, when doubts arose even to the advertisers, they switched to promising a wide variety of tools to facilitate the arduous tasks. Tools became the slogan; the right tools, paired with clever tricks and serious management methods, would work wonders. Then Edsger Dijkstra called Software Engineering 'Programming in spite of the fact that you can't'.
Indeed, the woes of Software Engineering are not due to lack of tools, or proper management, but largely due to lack of sufficient technical competence. A good designer must rely on experience, on precise, logical thinking, and on pedantic exactness. No magic will do. In the light of all this it is particularly sad that in many informatics curricula, programming in the large is badly neglected. Design has become a non-topic. As a result, software engineering has become the El Dorado for hackers. The more chaotic a program looks, the smaller the danger that someone will take the trouble of inspecting and debunking it."
In a minute, we’ll look at how the culture of Visual Basic affects the quality of code produced, even today, and how the last remaining vestige of Visual Basic, the syntax, unfortunately continues to reinforce the culture.
But first, let’s review the culture of C#.
To understand the culture of C# is to understand the story of Anders Hejlsberg, its chief architect. Hejlsberg deeply admired Niklaus Wirth. Wirth created the Pascal language from Algol, the first high-level language with a readable, structured and systematically defined syntax. Hejlsberg created the world’s first compiler for Pascal, and extended the language to include object-oriented capabilities (Object Pascal). Both were focused on the language’s elegance, at least in part because the language was designed as a teaching tool for students of programming languages to learn structured, and later object-oriented, development techniques.
Pascal was first embedded in a commercial development environment by Borland, with the release in November 1983 of Turbo Pascal, which employed Hejlsberg’s compiler on a licensing arrangement. Hejlsberg worked for Borland for thirteen years from 1983 to 1996 during which time he was the chief architect of Turbo Pascal and later Delphi.
Delphi, a direct competitor to Visual Basic, was regarded as vastly superior technically, even by Microsoft, who routinely plundered its inventions. To preview some of the features of each successive version of Visual Basic, it was generally recognized that one only had to look at the current version of Delphi.
Delphi, however, was hampered by a relatively insignificant development and advertising budget. While Microsoft plowed hundreds of millions of dollars into promoting Visual Basic, Borland had to rely primarily on technical excellence to drive usage through word of mouth. Hejlsberg knew his work would never achieve mainstream adoption while he remained at Borland. At the same time, Microsoft gradually came to realize that Visual Basic would never achieve the technical excellence of Delphi without Hejlsberg.
About the time when these two forces were starting to draw Hejlsberg and Microsoft together, a thunderbolt hit that would dramatically accelerate the fusion. That thunderbolt was Marc Andreessen’s endorsement of a brand new language (or at least one with a brand new name): Java.
Java’s precursor was developed by Sun’s Patrick Naughton, Mike Sheridan, and James Gosling in 1990-92, who had the far-reaching notion of connecting together small devices, such as video recorders and televisions, in cyberspace with a common programming language. The first version of Java was called “Oak” and was architecture-neutral, distributed, portable, object-oriented and secure. Although these qualities turned out to be just the qualities needed to develop applications for the web, the adoption of Oak for the web would have to wait until 1994. But the fact that Oak’s true potential would take several years to recognize was much less important than the culture in which it was born. For in 1990, Naughton, annoyed with the disparate directions in which Sun was heading, nearly quit and took his work to the more idealistic and focused neXT, owned by Steve Jobs. It was only because Sun’s CEO, Scott McNealy, solicited a report on the failings of Sun from Naughton, and heeded the report, that Naughton stayed. McNealy agreed Naughton would be allowed to create a small team of engineers outside of mainstream Sun in order to “do fewer things better."
Designed by a small team dedicated to technical excellence, Oak/Java was the antithesis of Visual Basic. Yes, it was more difficult to learn, but it was more powerful. And the proof was in the pudding. Java applications, when architected and built by skilled Java developers, were more powerful and feature-rich than the vast majority of Visual Basic applications.
Marc Andreessen, CEO of Netscape and therefore the “God of the Internet” at the time, was one of those who saw the potential of this new language. In 1994 he told the San Jose Mercury News: "What these guys are doing is undeniably, absolutely new. It's great stuff."
Coming from most people, such an endorsement would have been just another spark. Coming from Andreessen, it was the thunderbolt that shocked the world into a near-frenzied adoption of Java, and ultimately brought Microsoft and Hejlsberg together.
For Java was not perfect either, and by then the brilliant Hejlsberg was envisioning the next generation of application development language. Hejlsberg envisioned a language which would fully embrace the emerging component model for application development by making the three key constructs of component development—properties, methods and events—first class elements of the language.
In Java, for instance, properties don’t really exist. They’re “faked” by using the get xxx and set xxx syntax. In a property inspector they show up as “xxx” and you have to know that you put the get and set in the right places. This and other anomalies made Hejlsberg the perfectionist uncomfortable. He felt that the ideal language would require no such kludges or workarounds, but should instead roll all of the core constructs right into the syntax, giving the programmer a “one stop” experience. The problem was that this would require fundamental rewiring of the compiler, and significant research and development expense.
With Java rapidly gaining ground, by 1996 Microsoft was getting very concerned. They were taken off guard by the fact that an elegant, precise language that required a significant degree of programming skill and dedication to use effectively was making headway against Visual Basic. They also recognized that they needed more than just some reworking of the Visual Basic engine. They needed fundamental change. They made Hejlsberg an offer he couldn’t refuse. If he would come to Microsoft, he would be given a clean slate and a massive budget to create a “perfect” version of Java. In 1996 Hejlsberg began work on Microsoft’s J++ 6.0 and WFC, the Windows Foundation Classes for Java, as chief architect of both.
Microsoft J++ 6.0 and the WFC, born out of intense desire by the world’s most qualified software architect to make the very good Java even better, were the successors to Object Pascal and the Delphi Visual Component Library. And soon they would become the precursors to C# and the .NET Framework.
For in 1997, Sun sued Microsoft over the changes it was making to Java, stopping the work cold.
Undeterred, with massive financial reserves, and wanting to get even with Sun, Microsoft upped the ante. It gave Hejlsberg an even cleaner slate, the mandate to write a new language that would be better than Java, and backed by a programming toolkit that would be better than Java’s.
The result, born in a culture that puts technical excellence first, unfettered by prior constraints and guided by the wisdom not only of Hejlsberg’s years of experience with Turbo Pascal and Delphi, but also by the wisdom gleaned from Java, is the C# language.
We've seen that the cultures of VB and C# are very different. And we've seen that this is no fault of the programmers who use them. Rather this is a product of the combination of factors that collectively could be called their upbringing—business environment, target market, integrity and background of the original language developers, and a myriad other factors.
One factor, however, that seems to have a greater effect on the culture than others, is the syntax and semantics of the language.
To what extent do syntax and semantics play a part in the culture that builds up around a language and to what extent, vice versa, do the syntax and semantics depend on the culture in which the language was created?
The truth is, both—just as spoken languages both grow out of culture and influence culture. For instance, in the far north the language syntax has evolved several words for the different types of snow. Interactions then use the language to express nuances of snow, creating a more snow-centric culture.
So in Visual Basic, the decision to include in the syntax and semantics the ability to assign numbers directly to strings and vice versa was a result of the designers’ desire to attract a broad base of developers who would probably not understand the notions of strongly typed variables. Once the syntax permitted it, such assignment became widespread, reinforcing the designers’ original premise.
Once this cycle of self-reinforcement begins, the cultural habits quickly become entrenched and widespread, and are extremely resistant to change. Minds tend to gravitate to like minds. User groups tend to attract homogenous followings. Visual Basic instructors tend to propagate what their instructors taught them.
This awareness of the immense inertia of embedded culture is precisely the brilliant insight that caused Microsoft to keep Visual Basic and to make it nearly 100% backward compatible at the syntax level. They recognized that trying to get legions of developers to abandon their old cultural norms and adopt new ways was foolhardy.
The brilliant insight Microsoft had was not to support multiple languages—if this was the case then surely it would not have bothered with J#, which is syntactically so close to C# that support for language’s sake alone would be ridiculous. The insight Microsoft had was to support multiple cultures.
What does this mean in concrete terms? What impact does this have on today’s application development? How does the decision to adopt Visual Basic or C# affect programs written today and tomorrow?
- 80% of C# programmers are good, while 80% of VB programmers are not good. This is not to say that everyone who programs in VB is less skilled than everyone who programs in C#. This is to say that:
- the VB syntax and semantics is designed to attract less skilled programmers and, in combination with other factors examined above, this has created a culture that is populated with less skilled programmers.
- and because VB syntax and semantics make it more difficult to avoid common programming errors and hence to program well.
- Hiring a good C# programmer is easier than hiring a good VB programmer. This is because of (1).
- Hiring the average C# programmer costs more than hiring the average VB programmer. This is because the average C# programmer is a better programmer than the average VB programmer, and this is because of (1).
- Hiring a good VB programmer costs the same as hiring a good C# programmer. There are many good VB programmers, and some of them are much better than some C# programmers. However this is the exception, not the rule.
- A good programmer accomplishes two to ten times what an average programmer accomplishes, and causes 90% less bugs and headaches.
- At the time of writing there are probably almost as many good VB programmers as there are C# programmers. This is because there are many more VB programmers than C# programmers. The 20% of VB programmers who are good is about same number as the 80% of C# programmers who are good.
- In the near future, there will be less good VB programmers than C# programmers. This is because many of the good VB programmers are switching to C#. This is partly because they like the language better, but mostly because they like the culture better. As the cultural separation becomes more evident and self-reinforcing, it will accelerate until there are very few good VB programmers left.
- VB programmers, on the average, know less about good object-oriented, distributed, loosely coupled application design and development than C# programmers, on average. This is because their language has not supported these notions, so their culture has grown without them. Although these notions are supported now in VB, they are more slowly being adopted than in the C# culture because of cultural inertia.
Under .NET, the VB language retains constructs that support the existing (old) VB culture. This was done, of course, in order to avoid alienating the culture’s members. Many of these constructs are still used by VB programmers, even though they should be avoided. Others are not harmful except in as much as they continue to provide cultural reinforcement of habits, including those that are harmful. Examples of key differences are listed below. These are simply examples and not an exhaustive list:
- VB by default allows support for late binding. Although it can be turned off with
Option strict, the culture is such that it’s usually left on. This leads to numerous difficulty to catch errors. C# binding is always early.
- VB still supports the old
On error goto construct. This leads to sloppy or non-existent error handling. C# supports only the superior try…catch error handling.
- VB supports optional parameters. Although VB developers often list this as an advantage, it is a disadvantage because the use of optional parameters weakens the contract between the caller and the method, allowing the developer to slacken his analysis and get away with it until bugs creep in. [Note: C# param array construct is not the same as optional params]
- VB supports the legacy VB functions, with reference to Microsoft.VisualBasic.dll. Many of these functions are slow and they should all be avoided in favor of the .NET Framework. However many VB programmers still use them. In new VB projects, this dangerous namespace is included by default.
- VB allows implementation of interfaces with methods of different names, making it confusing and difficult to find the implementation. C# does not.
- VB supports background compilation. While this speeds the development cycle for small projects, it slows down the IDE in large projects, contributing at least in part to the culture tending to gravitate toward small projects.
- C# namespaces are managed in way that makes programmers aware of namespaces and their importance. VB namespaces are managed in a way that hides them from the programmers by default. Careful attention to namespace management is a fundamental tenet of strong application design and its importance cannot be overestimated.
Conventional arguments between Visual Basic and C# focus on the functionality differences. Since these differences are minimal, it is argued that the choice of VB or C# should remain a matter of personal preference.
These arguments fail to take into account the deep cultural differences between the VB and C# camps.
The truth is that while there are some exceptional VB teams that write exceptional quality code, this is the exception, not the rule. Most VB teams have trouble writing high quality code, and this trait is ingrained deeply into their culture by environmental factors beyond their control, and continues to be propagated by the VB syntax and semantics in Microsoft .NET.
Therefore:
- If an organization is content to write average quality software and has average VB developers, there may be no benefit in switching to C#.
- If an organization has an exceptional VB team and wants to continue to improve, there is a real danger in continuing in VB. The danger is that the programmers will leave for opportunities in C#. Once even one top developer does this, the polarization of the group towards the old VB culture may accelerate, thus accelerating the attrition.
- An organization with an exceptional VB team should switch to C#. The exceptional VB team will have no problem learning the new syntax, so there is no danger. The team will then reap the benefits of the C# syntax, semantics and culture for years to come.
- April 19th, 2005: Minor grammar fixed and removed reference to an internal project in our shop that is meaningless to the broader audience. Clarified several sections that might be taken to be slights against VB developers to indicate that it's not VB developers that are the problem. It's the upbringing of the language in the context of the environment... i.e. its culture. Removed section of additional benefits of C# since it's orthogonal to the point.
- April 19th, 2005. I apologize to anyone who is or was offended by this article. Please read it carefully. If after reading it carefully you think that it slights good VB developers, please let me know exactly where/how and I'll fix up the article. My intention is not to slight any good developer, or even a bad one who's trying. Criticizing the factors that lead to a culture that makes it difficult for developers to be good... now that I have no problem doing.
- April 22nd, 2005: I'm getting so many comments about how I say that C# is a better language than VB (even though I never say this) that I edited paragraph 2 to reflect that they are functionally equivalent.
- May 10th, 2005: DotNetRocks' Carl Franklin read my article and commented on it in a recent issue of DotNetRocks, which you can download here: .NET Rocks! - Kimberly Tripp on SQL Server 2005. Being pro-VB, Carl was pretty negative on the article. I would have no problem with that except that I thought that he also missed the point and tried to ridicule the article by taking excerpts out of context. But you be the judge. I've transcribed his comments word for word in a comment slot below, so you can read them, comment, and, of course, rate his comments.
- May 20th, 2005: Some posters have asked me to indicate that this article, and in particular the 80/20 comment, are based on my opinion and not on empirical or statistical data. They are my opinion.
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 396 (Total in Forum: 396) (Refresh) | FirstPrevNext |
|
|
 |
|
|
Yes, I admit it. I am a BASIC programmer. I always have been, from the time I was six years old and used my Atari 800 BASIC cartridge to do my math homework problems for me. From there I learned to do simple coding in GW-BASIC and BASICA in my early teens, and I started learning some of the advanced IO and system functions in QBASIC when I was in high school. Afterwards I wrote crude and simple games and utilities in Visual Basic 5 and 6, and learned Access Basic and VBA for some database work in a few jobs I had.
And then I found C++, and everything changed.
I knew VB had its limits. There were things I wanted to do that I couldn't do, because the language had no terminology, no understanding of those things. I had to learn C++ because it was closer to the system, it gave me access to those things in Windows that VB chose to hide away.
C++ is hard, and reasonably so. A computer is so unimaginably complex, and while BASIC kept me safe from that complexity, it also kept me from expanding my mind and understanding. Byval used to be just a silly meaningless keyword to me; it slowed down my program, drove up my memory overhead, and all it did was make sure that my function wouldn't overwrite the parameters it was given. Surely I was careful enough I could keep my program from doing that myself, right? But C++ taught me what byval and byref really meant, and what they did to the system hardware, and why my memory overhead grew, and why I couldn't overwrite a byval parameter.
It took me a long time to learn what pointers were and what they were used for. I learned OOP, and constructors/destructors, and the correct way to instantiate new objects. I had been writing code nearly my whole life in BASIC... but C++ taught me how to program.
I wholeheartedly agree with this article. Most VB programmers come from a purely BASIC background. Their idea of OOP is encapsulated in VB classes, and polymorphism is something you have to declare with Implements Interface. They link to 3rd party libraries through some mysterious art called COM, without really knowing what COM is or what it does in secret, underneath the compiler. Many VB programmers have never dreamt of a constructor that could take parameters. API calls are an option of last resort, and the average VB programmer considers it a form of blackest voodoo.
Unfortunately, many of those VB programmers who have migrated to .NET treat it like it's just a bigger, more confusing VB6. A project I migrated from .NET 1.1 to .NET 2.0 had about 60 compile errors because every MessageBox statement used a hard coded number value for the button argument instead of using the enumeration. I couldn't count the number of warnings I got from converting numbers to strings and vice versa.
The long and short of this is that C# is familiar and appealing to C++ and Java developers. The reason most C# developers are better than their VB.NET counterparts is because most of those C# developers came from a background that tought them what their hardware did with the code they compiled. A lot of VB programmers don't have that background - they just know that the program acts the way they tell it to act without knowing why it acts that way.
I still program in VB.NET at work, not by choice, but because that's what most of the people I work with use. But even so, I still tend to think in C#, because now I know how to program... instead of just writing code like I have been for all those years.
Please don't bother me... I'm hacking code right now. You remember what "hacking" really means, right?
|
| Sign In·View Thread·PermaLink | 3.00/5 (3 votes) |
|
|
|
 |
|
|
If you search for VB vs C# in internet you will find a lot of articles saying "It's all about the framework", "both compile to MSIL anyway". While this is true, this makes C# and VB compatibles, not equal. At the end all the language run over binary code and they are not equal. As written in the article C# is designed to be excellent, while VB is designed to be the quick and dirty language on .Net. Some clear examples:
- Option Strinct off by default, allowing small mistakes and stupid patterns (misuse of interfaces).
- Option Explicit, while false by default, is a horrible feature that dramatically decrease the code quality and increase the hours debugging.
- Variable declaration: The Dim syntax makes natural splitting the declaration and the initialization of a variable. This is error prone and harder to read. Having the type first in the declaration makes more comfortable declaring variables on the fly, therefore in the correct scope. (Even more clear in for's and foreach's, where the variable should be declared in the middle between the inside and the outside of the loop)
- Variable initialization: While C# initializes fields automatically, it forces you to initialize a local variable before using to avoid mistakes. This is also more useful combined with out parameters where the contract is clearer.
- Casting: CType is uncomfortable, and also option strict is off by default, so almost all the VB code has random conversion between types. That means worst understanding of data types and precision of numbers (shot, int, long, float, double, decimal …).
- Nothing semantics: VB fakes Nothing semantics on structures (ZeroMemory’ing) making more difficult to differentiate between value types and reference types (a lot of VB programmers thing DateTime is a class, and string a struct). This is also bad to understand boxing and unboxing and makes it more confusing why Generics are so good. - Variables by reference: There´s four horrible things about that . First, you have either to write ByVal or ByRef on any single parameter declaration. That makes ByRef harder to spot than in C# where you only have to write ref if is necessary. Second, when calling you don’t need to write ref again as in C#, making the contract clearer in the client code. Third, allows you to pass properties ByRef, that doesn’t make sense, so is faked dirtily creating a invisible temp variable causing unexpected behavior if you expect your set method to be called more than once. Fourth, allows (in option strict false) to have some kind of polymorphism over ByRef parameters. This will compile:
Sub Main() Dim q As Dog SetCat(q) Console.WriteLine(q.GetType()) End Sub
Sub SetCat(ByRef an As Animal) an = New Cat() End Sub
Class Animal End Class
Class Dog Inherits Animal End Class
Class Cat Inherits Animal End Class
This just hurts my mind.
- Hides delegates: That makes events harder to understand. An event is a delegate property. How many VB programers know that? Very few. That also makes is harder to find patters where delegates alone are useful, like comparison methods for sorting, or the whole Linq project!
- Shared methods: Visual basic allows using shared members through instance variables. That makes confusion, creating stupid questions like: It’s a shared method overrideable?. Nevertheless shared is a better keyword than static in my opinion.
- WithEvents: While it’s a good idea, needs to be faked by hiding the field to the public eyes and creating a property instead to make the work dealing with the events. This is even funnier combined with the odd ByRef behavior on properties.
- Modules vs Static clases: Modules exposes all the members freely. So a lot of people just don't use modules to avoid dirty the intelisense. Also modules feel not very object oriented. C# coders use static classes without problems.
- VB hides namespaces: The imported namespaces and the namespace of all the classes is centrally managed in the project settings. Ok, this is optional, but everybody does this way. Also imported namespaces can be completed from one of the branches already imported. And also there’s no refactoring to quickly find a type and add the namespace import to the top, so nobody takes care of the namespace and is a mess.
- Returns policy: Even with Option Strict On, Vb allows to get out a method without returning any value, returning the default value for you. Dear VB compiler, I appreciate your help, but returning 0 or Nothing doesn’t solve anything.
- Array syntax: VB don’t use squared brackets for arrays so it´s harder to diferenciate between an array access (or indexer) and a function (that also can omit parameters). Even more, VB has a very odd syntax for declaring arrays. Compare:
int[] a; int[] b = new int[2]; object c = new int[2]; Over
Dim a() As Integer Dim b(2 - 1) As Integer() Dim c As Object = New Integer(2 - 1) {}
Declaration and initialization are mixed in the two first examples, so understanding where arrays are allocated is harder (in the heap) and the syntax is really ugly when creating an array over a non-array variable. Also, .Net arrays are zero-based, but VB try to hide this declaring one element more at the end (so 0 is commonly not used). This creates trubles with buffers.
- Backgroun compiler: Works great with small projects, but creates a lot of troubles with a large codebase, during big refactorings (just crash VS) and proyect reference issues (impossible to issolate the erros compiling only subset of the solution).
Conclusion, VB is a clear example of HHH (Holes hidden with hacks) compared with C#, whenever there's a tradeoff in the design of the language between “First day fun” and “Long term maintainability” the VB language designers go for the former. Maybe it can be as fast as C#, but only if the code is done by a C# programmer that knows how to avoid these holes. 
Olmo del Corral
|
| Sign In·View Thread·PermaLink | 2.33/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
At last, at long last, I'm getting out of VB. I have dealt with the kind of slipshod thinking described in the article above for many years now, but I have finally managed to land a job in a c# shop. No more VB for me!! It's really true, the syntax and culture of VB lulls people into a false sense of potency, they forget to use namespaces properly, they end up writing the most god-awful spaghetti code(particularly in a lot of web apps I have seen) and typing and naming conventions simply go out the window, simply because it has been made too easy for people.
It's not rocket science, this business, but you're not supposed to pick it up off of Sesame Street either.
I can't wait. End of the month, I'm off. I just had to share that again.
All the dude ever wanted... was his rug back.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Just 2 years ago, ads looking for .NET programmers, were fine with VB. Today, 95% of the ads looking for .NET programmers, state C# as required. I wonder why?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Great article that is very thoughtful. I am a VB guy and in the "not so good" category. Your article is motivational. thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I read this article as part of my research to see if I should switch from VB to C#. I keep running into program samples and ideas on the web that are written only in C#. So I asked myself, should I be programming in C#?
I agree COMPLETELY with this article!
I AM one of those people who started hacking out code in VB because it was quick and easy. But suddenly, I found that I had to 'grow up' and design applications.
I use to use the analogy of writing 'scripts' instead of code. I could always solve a small problem with a quick snippet of code. My programs were the result of many snippets all grouped together.
The advent of VB.NET and the Object Oriented model made me grow up. I first had to rethink everything I knew about coding. I had to remove my hands from the keyboard and go to the whiteboard. And I don't mean just a few flowcharts. I mean I had to re-imagine the design. I had to trash my procedural 'scripting' mentality and think carefully about what belongs to what object. It was a most challenging and rewarding experience!
I SHOULD have switched to C# back then. I was making a change in culture, and I was ready for C#. Alas, I did not switch.
But I keep reading articles with solutions to my code issues that are written in C#. It seems that like-minded programmers are C# programmers - at least to me. I find myself translating code from C# to VB to better understand the solutions. That alone told me something was wrong.
I am ready to switch.
All I can say is thank you for the affirmation.
Terry O'Boyle
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
What is the purpose of programming anyway? If OOP design was the true goal, then your article makes more sense. With your narrow premise, you ignore the point that programming is simply a tool for implementing an automated solution. Few lovers of art care about the methodology used to create the art, but focus on the quality of the output. Users of software are probably in that boat as well.
I am not understating the importance of quality design and I do adhere to OOP design principals as appropriate. However, you make a huge assumption that programmers skilled using OOP such as those in the C# arena, are automatically 'better' than those who don't. That is narrow and elitist.
OOP can be easily over-engineered and cloogy...and maybe even as harmful to a project as spaghetti code. In my view, convention is every bit as important as methodology if not more so. And that any methodology chosen is only valuable if it makes economic sense to the organization. You ignore that point. Too many programmers such are yourself get hung up trying to create the eloquent while the core issues are ignored. That is, can the application be delivered on time, on budget, within spec and be easy to use and easy to maintain.
With a special emphasis on readability and maintainability...VB has a clear advantage. Whether or not VB allows you to use a 'Goto' is a speck of dust compared to core issues.
I will agree that there are probably more untrained hobbyist in the VB realm. At the same time, I would also assert--using your proclivity for generalizations--that VB 'ers because of their experience probably have a greater understanding of user interface, usability and maintenance issues.
Your notion that C#, because of its complexity compared to VB, has created a litmus test to identify highly skilled programmers, only underscores your narrow understanding of the true role of programming. Propetuating this myth is doing your readers a disservice.
-- modified at 17:48 Wednesday 23rd May, 2007
|
| Sign In·View Thread·PermaLink | 2.23/5 (4 votes) |
|
|
|
 |
|
|
Mr Nigel Shaw. Your article is pretty much biased towards C# when you talked about 'skills'. In my view "skills of a programmer cannot be judged by the culture he embraces--whether he embraces C#,J#,VB.Net or Java".
You wouldnot have written this article if you were a VB.Net programmer.
X
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
I have been in this industry for quite a few years, and I have coded in a wide variety of languages: C/C++, C#, VB, VB.NET, VFP, Clipper, Pascal, Delphi, and the list goes on. I am always amazed at the religious wars people have about the different technologies in this industry. In my early years, I participated in these religious wars. Luckily, I have matured quite a bit. Today, if I can give the younger programmers a word of advice, it is this. It is all about using the right tool.
I agree with everything said in this article. I believe it is 100% on the mark. The reader just needs to read it with an open mind, weigh out what is important to them, and choose the right tool for them.
Recently, I had the opportunity to contract my services at a VB shop to work on an ASP.NET project. The first time I opened up the source code from this company, the whole floor heard be belt out the words "Are you kidding me?" After I realized I said that out loud, I quickly contemplated what this meant, especially after the team lead for this project bragged about this being his baby. I won't go into the details of what I saw, but it was bad. Let's just say that many VB shops can be paramount to walking into the twilight zone. It can be an experience where the basic rules of software engineering that are usually second nature to many experienced programmers are avoided, and interestingly, one in which this rogue VB culture will often swear that their way is right, that everyone else is wrong. Don't get me wrong, though. As this article implies, there are decent VB shops, but unfortunately, they are becoming increasingly hard to find.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Since I wrote the article I did quite a bit of thinking. I think the single biggest failing of VB is putting the type after the object. In good languages, we're trained to think of the class first, the type second:
Employee bob = new Employee();
In VB, the type is an afterthought:
Dim bob
Whoops!, I meant
Dim bob as Employee
See, because the type is an afterthought, VB developers think of things as instances first, and think of their classification second, if at all.
Now, in my personal opinion, the single most important thing in application development is object classification. This is why we created layered applications in beautiful hierarchies, with each layer having its own responsiblity, and only objects of certain classifications going in there.
In my experience working with developers that move from VB to C#, this is the biggest "light" that goes on... the realization that everything has a classification, and that development is all about the classification of things.
Nigel
Nigel
|
| Sign In·View Thread·PermaLink | 1.80/5 (2 votes) |
|
|
|
 |
|
|
great thanks to mr. shaw for contributing to the development society by raising awareness about the OO culture. i have read a lot of articles on vb.net & c# differences, mostly technical, but nothing has made me more conscious about OO practices than this one.
the only drawback is that it did so by some degree of generalization at the expense of the die-hard vb community, both OO and non-OO followers alike. the stereotyping has obviously some potential to demoralize and discriminate people in this particular group, whether intended or not.
the approach seems to be: "you have a hole in your boat, i suggest you switch to ours."
when it could have been: "you have a hole in your boat, let's fix it."
here's an article that does the latter, done so by teaching:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/interinher.asp[^]
"This puts Visual Basic .NET on equal footing with all the Microsoft .NET languages and breaks down the barriers that have isolated Visual Basic programmers in the past."
may mr. shaw's ambition of raising OO awareness be achieved across the board. wouldn't that be cool?!
respectfully, rael (c, c++, c#, vb6, vb.net)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 Man, I love you...
I'm a VB programmer in past, as I learned BASIC programming during my school time, so VB is more natural and hot on the market that time.
Now I'm onto C#, and pls don't ask me to go back VB or VB.Net. Why learn so many different type of programming syntax, while the C are the holy grail for all. you name them: Pascal, Delphi, Java, JavaScript, bla bla bla...
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
I recently had reason to refer back to this article and re-read it. I made a blog entry that refers to it: http://community.tigranetworks.co.uk/blogs/tim_long/archive/2005/11/14/110.aspx[^] I still think this is a really insightful article. Many of the comments posted so far tend to miss the point somewhat. I think most now accept implicitly that it's possible to write good and bad code in any language; that good teams are made of good people; that VB.Net is not the same as VB6 - but I still think it holds true that the history and culture of a language affects its developmment and vice versa. Ultimately, the cultures may converge but that is not the situation today. Further, a lot of people I know are still using VB6 and choose (for whatever reason) not even to adopt VB.Net - because of that 'filtering' effect we may start to see the overall quality of VB.Net programmers increasing.
One of the points I make in my blog entry is that if you are a new programmer, starting with a clean slate and no prejudice, then the best favour you can do yourself is to learn best practice right from the outset. It is far easier to do that than to learn sloppy ad-hoc techniques then go back and try to unlearn them later. Computer languages are merely different forms of notation to achieve largely the same end, but some notations lend themselves to the expression of different concepts. In picking a language that affords easier expression of best practice, one can become a better programmer and side-step the risk of being drawn into a 'shoot from the hip' culture.
I congratulate the author in tackling an emotive subject in a thought-provoking and interesting way.
Tim Long Technology Consultant TiGra Networks
|
| Sign In· | | | | | |