分享
 
 
 

JAVA程序员眼里的C#(转)

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Java developer's view of C#.September 03, 2004

There are two ways to compare programming languages: a religious war and a "we just don't care" type of attitude. I will try to find the middle ground and start with generalities. The key feature of both Java and C# is automated memory management. Of course this makes both languages useless for writing an operating system kernel, but it makes application development significantly easier because

Chances of a memory leak are minimized

We don't have to write code to free up memory

We can write f(g(x)) and not worry about freeing up memory used by the return value of g(x).

So, we have two popular software development platforms. Each of the two is used by millions of software developers and is backed by a world famous software giant, but neither one carries any revolutionary advantages.

Influence of Microsoft

Historically Java came about earlier than .NET and slowly captured not only the server-side software market, but also the market of corporate client oriented GUI applications. The reasons were that C++ is too complex for making forms, Visual Basic doesn't feel like a cool developer's language, and Borland invested more into Java than into Delphi.

However, the more Java applications there are, the smaller the demand for Windows. So Microsoft decided not to support Java, and to create .NET in order to stimulate the development of software designed to run on Windows. Of course .NET has some cross-platform compatibility, but from the point of view of Windows, .NET is trying to become a part of the operating system like Internet Explorer. The career of a .NET developer supposes a close partnership with Microsoft including the use of the Visual Studio Development Environment, MS SQL database, and the versioning control system Visual SourceSafe.

Microsoft marketing deserves a lot of credit for the fact that many software development companies tend to think about software entirely within the Microsoft framework. Because of that, sometimes we have to put aside beloved Java, and make use of C#. The good news is, the experience gained while working with Java is helpful with .NET, and development of .NET is motivating progress of Java.

CVS vs. VSS

The majority of Java developers have gotten used to CVS, after which a move to Visual SourceSafe combined with its integration into Visual Studio and the solutions-projects concept is perceived as quite painful. To be fair we must note that the use of CVS in a large project is theoretically possible, but triggers a negative reaction of people, used to working with VSS.

Here I could throw some punches on the subject of "why is CVS better than VSS", but I will not do that because CVS isn't perfect either. Then there is a project called "Subversion" which is openly positioned as the replacement for CVS. Neither does Microsoft consider VSS as its flagship product, and is working on a replacement for it in the form of the Visual Studio 2005 Team System.

The influence of VB.NET

Many languages can be compiled into byte code for JVM, but practically all the software for the Java platform is written in Java itself. A project for .NET can equally likely be written in either C# or VB.NET, and quite often both languages are used.

Clearly C# and VB.NET have very few differences, except for the syntax, but create a divide in the community of developers. Even if you write exclusively in C#, in the results of a support documentation search you will always find material related to VB.NET. In a desktop version of MSDN one can filter the content by programming language, yet I still find the Java documentation much more convenient and helpful.

GUI development

GUI development in C# is a typical example of RAD, like Delphi. In Java the GUI is usually done with Swing. Even though Swing is quite large and complex, the fact that the architecture is well thought out and scalable combined with the availability of the source code allows for development of GUI of any complexity.

Web application development

I have a lot of experience in web application development in Java, and never have I worked with ASP.NET. However I readily accept ASP.NET having some minor advantages when it comes to creating small scale web sites. However these advantages separate web-applications into a distinct segment of software. Many developers specialize in either web development or GUI development. In Java web-applications can easily be created without the use of special technologies like JSP, JSTL or Struts. All you have to say is extends HttpServlet.

Of course Java will not easily give up the market of web development. We can expect more news from JavaServer Faces and Fabrique. In any case web page development is not among the most complicated problems for a modern programming language.

Is everything object?

In Java there is a popular slogan "Everything is object", in C# this would not be true. The first thing that stands out is the existence of structures in C#. Obviously we are motivated to use structures to increase productivity, but I think modern computers are productive enough not to require the addition of another entity in a programming language.

Also anonymous classes are replaced by delegates in C#. This is the idea that if a method has a definite set of arguments and a given return type, it is absolutely unimportant what its name is and whether or not it is static, or any other nonsense. You can just call it.

While we are on the subject of delegates, we should also mention events. They really do decrease the code volume in GUI development. However this comes at a price of going against OOP principles.

In addition C# has some added abilities, which are not present in Java. Without going into much detail, I will mention operator overloading, and keywords such as virtual, override, ref, out and param.

The influence of the development platform on the programmer's self-consciousness

Without a doubt, the one thing that influences the quality of software is the quality of software developers, and not the programming language. Nevertheless, my experience tells me that in the majority of Java projects Ant is used for build management. On the other hand in .NET, builds are often done with tools built into Visual Studio, even though analogous instruments exist for .NET. Besides, C# does not have clear rules for naming classes and storing them on disk. This often creates additional confusion (which qualified programmers successfully overcome).

C# doesn't have checked exceptions, the reasons for which are explained here. This decision has its reasons, but if the compiler doesn't control handling checked exception, there needs to be more information on how to work with errors through other communication channels. Otherwise some programmers will not even know what exceptions are.

The tigers are charging forward

There are certain areas where Java is clearly dominating, for example cellular phone games and the JavaCard technology. However, the struggle for market share between C# and Java will go on for a long time to come. Both platforms will be improved. For example both Java 5 and .NET 2.0 will support generics.

It is obvious that the success of every individual project will depend not on the programming language used, but on the understanding of the task, knowing how to give understandable names to methods, ability to avoid repetitious code, and other universal virtues.

Acknowledgements

I really appreciate the help of Dmitry Jemerov, thanks to whom you didn't have to read any of the nonsense which I wrote at first. I also thank DataArt company, which gave me a chance to study C# on the job, my colleagues at DataArt, who gave me intellectual help and boosted my moral, and the JetBrains company for good timing in developing the ReSarper tool, which allows me to have almost as much fun with C# as I am used to having with IntelliJ IDEA. A special thanks to Alexey Pchelintsev for editing the Russian version and to Pavel Sokolov for the translation.

References

The C# Programming Language for Java Developers

http://msdn.microsoft.com/vstudio/java/gettingstarted/csharpforjava/

J2EE fundamentals for .NET developers

http://www-106.ibm.com/developerworks/java/library/j-roadmap1/ Yakov Sirotkin

Senior Developer, DataArt

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有