Last Updated:

C# through the eyes of Java

There are two approaches to comparing programming languages: religious warfare and "we don't care." I'll try to squeeze in between and start with the commonalities. A key feature of both Java and C# is automatic memory management. Of course, because of this, both languages are completely unsuitable for writing the operating system kernel, but they greatly simplify the development of application programs, because:

  • there are fewer opportunities for memory leak;
  • No need to write code to free up memory.
  • you can write f(g(x)) and not think about freeing memory from the result g(x).

So, we have two mass platforms for software development, each of which employs millions of programmers; behind each are the world's software giants, but none has revolutionary advantages.

Microsoft Impact

Historically, Java appeared before .NET and slowly captured the market not only for server software, but also for GUI applications for corporate clients, because C++ is difficult to draw molds, Visual Basic is not like a language for cool developers, and Borland has invested in Java more than in Delphi.

But the more Java applications, the less need for Windows, so Microsoft decided not to support Java, but to create .NET to stimulate the development of programs for Windows. Of course, there is some cross-platform .NET, but from a Windows perspective, .NET aims to become part of an operating system like Internet Explorer. Career NET-developer assumes a close partnership with Microsoft, including the use of the Visual Studio development environment, MS SQL database and the Visual SourceSafe version control system.

To the credit of Microsoft's marketing, many companies prefer to think about software without going beyond Microsoft's vision. Sometimes because of this, you have to put aside your favorite Java and pick up C#. The good news is that the Java experience helps in .NET as well, and the development of .NET drives Java's progress.

CVS vs. VSS

Most Java developers are accustomed to CVS, after which the transition to Visual SourceSafe, combined with the implementation of integration with it in Visual Studio and the concept of solutions-projects, is perceived very painfully. In fairness, it is worth noting that the transition to CVS in a large project is theoretically possible, but will cause an extremely negative reaction from people who are accustomed to VSS.

At this point, you could wave your fists a bit about "why CVS is better than VSS", but I won't do that because CVS isn't perfect either, and there's a project like Subversion that's openly positioned as a replacement for CVS. Microsoft also does not consider VSS its flagship product and is preparing a replacement for it in the form of Visual Studio 2005 Team System.

Influence of VB.NET

Programs in many languages can be compiled into bytecode for the JVM, but almost all software for the Java platform is written in Java. For .NET, it is approximately equally likely that a project can be developed in both C# and VB.NET, and very often both languages are used at once.

It is clear that C# and VB.NET have almost no differences with each other, except for syntax, but they bring fragmentation to the developer community. Even if you use only C#, documentation search results will always confuse content related to VB.NET. In the desktop version of MSDN, you can set up a filter by programming language, but still, for my taste, the Java documentation is much more convenient and understandable.

GUI development

C# GUI development is a typical example of a RAD like Delphi. In Java, the GUI is usually done using Swing. Although Swing is very voluminous and complex, good thoughtfulness and extensibility of the architecture in combination with the available source code allows you to develop a GUI of any complexity.

Web Application Development

I ate a dog developing web applications in Java, but never used ASP.NET; however, I fully admit that ASP.NET has certain and very significant advantages when creating small sites. However, these advantages separate web applications into a separate segment, very many . NET developers specialize in either the GUI only or the web only. In Java, web applications can be created without using any specific technologies like JSP, JSTL or Struts: — and go! extends HttpServlet

Of course, the Java website development market will not give up without a fight, you can expect news from JavaServer Faces or from Fabrique. In any case, making web pages is not the most difficult class of tasks for modern programming languages.

Is everything object?

In Java, the slogan "Everything is object" is very popular, in C# this is not the case. The first thing that catches your eye is the presence of structures in C#. Obviously, there are incentives to use structures to improve performance, but it seems to me that modern computers are productive enough not to add another essence to the language.

Also, instead of anonymous classes in C#, delegates are used, this is the idea that if a method has a certain set of arguments and a given type of return value, then it does not matter what it is called, whether it is static and other nonsense - you can pull it.

If we are talking about , then it is necessary to mention about - they really reduce the size of the code in the development of the GUI, although at the cost of deviating from the ideas of OOP. delegateevent

To a certain extent, C# is less concise, without going into details, I will limit myself to mentioning the keywords , , , , which have no analogues in Java. virtualoverriderefoutparam

The influence of the platform on the self-awareness of programmers

Of course, most of all the quality of the software is affected by the quality of the developers themselves, and not by the programming language. However, my experience is that the vast majority of Java projects use Ant for build management, and in .NET, builds are often done with built-in Visual Studio tools, although similar tools exist for .NET. In addition, C# does not have clear rules for naming classes and placing them on disk, which often introduces additional confusion (of course, qualified programmers successfully deal with this problem).

There are no checked exceptions in C#, there is even an explanation why. Such a solution has its own reasons, but if the compiler does not control the processing of checked exception, then you need to talk more about error handling through other communication channels, otherwise there will be programmers who will not know what an exception is at all.

Tigers rush forward

There are areas in which Java dominates unconditionally, such as mobile phone games or JavaCard technology. However, the struggle between C# and Java for market share will continue for a long time, both platforms will be improved, for example, in Java 5 and .NET 2.0 there will be support for generics.

Obviously, the success of each particular project depends not on the programming language, but on the understanding of the task, the ability to give the methods understandable names, the ability to avoid duplication of code and other universal values.