Editor's Note

On the Benefits of Learning Multiple Languages

Developers of VB and C# can learn a lot from the similarities -- and differences -- between the two.

I recollect that the Polish sci-fi novelist Stanislaw Lem once joked that everyone in the world, wherever they lived, could read Spanish. The same might be said to be true of Visual Basic (at least for English speakers), with its natural language syntax. And if you can read VB, reading C# typically isn't much harder. C# and VB.NET share a common framework and many common features; they are far more alike than different, and likely to become more alike than different going forward, according to some of the details released by Microsoft at its latest Professional Developers Conference.

This is no great insight, of course. The languages are similar enough that you can write code in one language and run that code through a translator to get usable code in the other language. I highlight this similarity partly to highlight something that gets less attention: the languages' differences.

In fact, the similarities and differences of C# and VB aren't unlike those of written and spoken languages. Citizens of the United States are notorious for speaking only our native English. Sure, it's possible to get by doing this, as long as you don't leave the country's borders, and even then (outside of Paris) you can probably get by quite well relying on the kindness of strangers. But the advantages of speaking another language are compelling. Apart from the gratification that comes with speaking another language fluently, one of the most important advantages of learning another language is that it tends to teach you much about your native tongue.

The same is true of programming languages. Learning other programming languages can make you more fluent and give you a better understanding of the language you depend on primarily. This is true even of languages as similar to each other as VB and C#.

This is significant because it's not uncommon for developers who use primarily VB or C# to find themselves using the other language for a special project, and sometimes the subtle differences between the two languages can trip developers up. Think of it as the programming-language equivalent of the "false cognate." A false cognate is a word that's similar on the surface to a word in another language, but means something decidedly different. For example, an English speaker might hear the Spanish word embarazo and conclude the speaker was referring to embarrassment; in fact, the speaker would be referring to pregnancy. Or, turn it around and imagine telling someone how pregnant you are when your intent is to describe your embarrassment. In the right (or wrong) circumstances, the miscommunication could be funny or potentially worse.

Such examples abound, whether you're referring to programming languages or spoken and written ones. This issue features a departure from our usual practice where the articles exist independently of one another: Kathleen Dollard and Bill Wagner both touch on the similarities and differences you encounter when programming in VB as a C# developer, and vice versa.

Kathleen Dollard writes about the programming-language equivalents of false cognates in her Ask Kathleen column, when she says:

"There are some annoying inconsistencies between VB and C# in recent features. VB propagates nulls in nullable comparisons the same way TSQL does, while C# returns a non-nullable Boolean type and considers a comparison of something else with null false. Immutability of anonymous types is also different with VB's Key keyword."

In a similar vein, Bill Wagner writes about the differences in how C# and VB.NET enact and support lambdas and closures in his column.

As Dollard and Wagner explored the similarities and differences worth noting in C# and VB, they found enough information to fill out not just their columns for this month, but enough information for follow-up columns, as well. Be sure to check out this month's columns on tips and suggestions for getting the most out of C# and VB, and to watch for future columns that revisit this topic.

Talk Back: What do you think of the announcements related to Visual Studio 2010? Tell me at vsmedit@1105media.com or ednote@1105media.com.

About the Author

Patrick Meader is editor in chief of Visual Studio Magazine.

comments powered by Disqus

Featured

  • VS Code v1.99 Is All About Copilot Chat AI, Including Agent Mode

    Agent Mode provides an autonomous editing experience where Copilot plans and executes tasks to fulfill requests. It determines relevant files, applies code changes, suggests terminal commands, and iterates to resolve issues, all while keeping users in control to review and confirm actions.

  • Windows Community Toolkit v8.2 Adds Native AOT Support

    Microsoft shipped Windows Community Toolkit v8.2, an incremental update to the open-source collection of helper functions and other resources designed to simplify the development of Windows applications. The main new feature is support for native ahead-of-time (AOT) compilation.

  • New 'Visual Studio Hub' 1-Stop-Shop for GitHub Copilot Resources, More

    Unsurprisingly, GitHub Copilot resources are front-and-center in Microsoft's new Visual Studio Hub, a one-stop-shop for all things concerning your favorite IDE.

  • Mastering Blazor Authentication and Authorization

    At the Visual Studio Live! @ Microsoft HQ developer conference set for August, Rockford Lhotka will explain the ins and outs of authentication across Blazor Server, WebAssembly, and .NET MAUI Hybrid apps, and show how to use identity and claims to customize application behavior through fine-grained authorization.

  • Linear Support Vector Regression from Scratch Using C# with Evolutionary Training

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the linear support vector regression (linear SVR) technique, where the goal is to predict a single numeric value. A linear SVR model uses an unusual error/loss function and cannot be trained using standard simple techniques, and so evolutionary optimization training is used.

Subscribe on YouTube