山那边是海 发表于 2015-1-18 11:41:58

JAVA教程之JAVA程序员眼里的C#

在1995年5月23日以“Java”的名称正式发布了。程序|程序员JavadevelopersviewofC#.
September03,2004
Therearetwowaystocompareprogramminglanguages:areligiouswaranda"wejustdontcare"typeofattitude.Iwilltrytofindthemiddlegroundandstartwithgeneralities.ThekeyfeatureofbothJavaandC#isautomatedmemorymanagement.Ofcoursethismakesbothlanguagesuselessforwritinganoperatingsystemkernel,butitmakesapplicationdevelopmentsignificantlyeasierbecause

Chancesofamemoryleakareminimized
Wedonthavetowritecodetofreeupmemory
Wecanwritef(g(x))andnotworryaboutfreeingupmemoryusedbythereturnvalueofg(x).
So,wehavetwopopularsoftwaredevelopmentplatforms.Eachofthetwoisusedbymillionsofsoftwaredevelopersandisbackedbyaworldfamoussoftwaregiant,butneitheronecarriesanyrevolutionaryadvantages.



InfluenceofMicrosoft
HistoricallyJavacameaboutearlierthan.NETandslowlycapturednotonlytheserver-sidesoftwaremarket,butalsothemarketofcorporateclientorientedGUIapplications.ThereasonswerethatC++istoocomplexformakingforms,VisualBasicdoesntfeellikeacooldeveloperslanguage,andBorlandinvestedmoreintoJavathanintoDelphi.

However,themoreJavaapplicationsthereare,thesmallerthedemandforWindows.SoMicrosoftdecidednottosupportJava,andtocreate.NETinordertostimulatethedevelopmentofsoftwaredesignedtorunonWindows.Ofcourse.NEThassomecross-platformcompatibility,butfromthepointofviewofWindows,.NETistryingtobecomeapartoftheoperatingsystemlikeInternetExplorer.Thecareerofa.NETdevelopersupposesaclosepartnershipwithMicrosoftincludingtheuseoftheVisualStudioDevelopmentEnvironment,MSSQLdatabase,andtheversioningcontrolsystemVisualSourceSafe.

MicrosoftmarketingdeservesalotofcreditforthefactthatmanysoftwaredevelopmentcompaniestendtothinkaboutsoftwareentirelywithintheMicrosoftframework.Becauseofthat,sometimeswehavetoputasidebelovedJava,andmakeuseofC#.Thegoodnewsis,theexperiencegainedwhileworkingwithJavaishelpfulwith.NET,anddevelopmentof.NETismotivatingprogressofJava.



CVSvs.VSS
ThemajorityofJavadevelopershavegottenusedtoCVS,afterwhichamovetoVisualSourceSafecombinedwithitsintegrationintoVisualStudioandthesolutions-projectsconceptisperceivedasquitepainful.TobefairwemustnotethattheuseofCVSinalargeprojectistheoreticallypossible,buttriggersanegativereactionofpeople,usedtoworkingwithVSS.

HereIcouldthrowsomepunchesonthesubjectof"whyisCVSbetterthanVSS",butIwillnotdothatbecauseCVSisntperfecteither.Thenthereisaprojectcalled"Subversion"whichisopenlypositionedasthereplacementforCVS.NeitherdoesMicrosoftconsiderVSSasitsflagshipproduct,andisworkingonareplacementforitintheformoftheVisualStudio2005TeamSystem.



TheinfluenceofVB.NET
ManylanguagescanbecompiledintobytecodeforJVM,butpracticallyallthesoftwarefortheJavaplatformiswritteninJavaitself.Aprojectfor.NETcanequallylikelybewrittenineitherC#orVB.NET,andquiteoftenbothlanguagesareused.

ClearlyC#andVB.NEThaveveryfewdifferences,exceptforthesyntax,butcreateadivideinthecommunityofdevelopers.EvenifyouwriteexclusivelyinC#,intheresultsofasupportdocumentationsearchyouwillalwaysfindmaterialrelatedtoVB.NET.InadesktopversionofMSDNonecanfilterthecontentbyprogramminglanguage,yetIstillfindtheJavadocumentationmuchmoreconvenientandhelpful.



GUIdevelopment
GUIdevelopmentinC#isatypicalexampleofRAD,likeDelphi.InJavatheGUIisusuallydonewithSwing.EventhoughSwingisquitelargeandcomplex,thefactthatthearchitectureiswellthoughtoutandscalablecombinedwiththeavailabilityofthesourcecodeallowsfordevelopmentofGUIofanycomplexity.



Webapplicationdevelopment
IhavealotofexperienceinwebapplicationdevelopmentinJava,andneverhaveIworkedwithASP.NET.HoweverIreadilyacceptASP.NEThavingsomeminoradvantageswhenitcomestocreatingsmallscalewebsites.Howevertheseadvantagesseparateweb-applicationsintoadistinctsegmentofsoftware.ManydevelopersspecializeineitherwebdevelopmentorGUIdevelopment.InJavaweb-applicationscaneasilybecreatedwithouttheuseofspecialtechnologieslikeJSP,JSTLorStruts.AllyouhavetosayisextendsHttpServlet.

OfcourseJavawillnoteasilygiveupthemarketofwebdevelopment.WecanexpectmorenewsfromJavaServerFacesandFabrique.Inanycasewebpagedevelopmentisnotamongthemostcomplicatedproblemsforamodernprogramminglanguage.



Iseverythingobject?
InJavathereisapopularslogan"Everythingisobject",inC#thiswouldnotbetrue.ThefirstthingthatstandsoutistheexistenceofstructuresinC#.Obviouslywearemotivatedtousestructurestoincreaseproductivity,butIthinkmoderncomputersareproductiveenoughnottorequiretheadditionofanotherentityinaprogramminglanguage.

AlsoanonymousclassesarereplacedbydelegatesinC#.Thisistheideathatifamethodhasadefinitesetofargumentsandagivenreturntype,itisabsolutelyunimportantwhatitsnameisandwhetherornotitisstatic,oranyothernonsense.Youcanjustcallit.

Whileweareonthesubjectofdelegates,weshouldalsomentionevents.TheyreallydodecreasethecodevolumeinGUIdevelopment.HoweverthiscomesatapriceofgoingagainstOOPprinciples.

InadditionC#hassomeaddedabilities,whicharenotpresentinJava.Withoutgoingintomuchdetail,Iwillmentionoperatoroverloading,andkeywordssuchasvirtual,override,ref,outandparam.



Theinfluenceofthedevelopmentplatformontheprogrammersself-consciousness
Withoutadoubt,theonethingthatinfluencesthequalityofsoftwareisthequalityofsoftwaredevelopers,andnottheprogramminglanguage.Nevertheless,myexperiencetellsmethatinthemajorityofJavaprojectsAntisusedforbuildmanagement.Ontheotherhandin.NET,buildsareoftendonewithtoolsbuiltintoVisualStudio,eventhoughanalogousinstrumentsexistfor.NET.Besides,C#doesnothaveclearrulesfornamingclassesandstoringthemondisk.Thisoftencreatesadditionalconfusion(whichqualifiedprogrammerssuccessfullyovercome).

C#doesnthavecheckedexceptions,thereasonsforwhichareexplainedhere.Thisdecisionhasitsreasons,butifthecompilerdoesntcontrolhandlingcheckedexception,thereneedstobemoreinformationonhowtoworkwitherrorsthroughothercommunicationchannels.Otherwisesomeprogrammerswillnotevenknowwhatexceptionsare.



Thetigersarechargingforward
TherearecertainareaswhereJavaisclearlydominating,forexamplecellularphonegamesandtheJavaCardtechnology.However,thestruggleformarketsharebetweenC#andJavawillgoonforalongtimetocome.Bothplatformswillbeimproved.ForexamplebothJava5and.NET2.0willsupportgenerics.

Itisobviousthatthesuccessofeveryindividualprojectwilldependnotontheprogramminglanguageused,butontheunderstandingofthetask,knowinghowtogiveunderstandablenamestomethods,abilitytoavoidrepetitiouscode,andotheruniversalvirtues.



Acknowledgements
IreallyappreciatethehelpofDmitryJemerov,thankstowhomyoudidnthavetoreadanyofthenonsensewhichIwroteatfirst.IalsothankDataArtcompany,whichgavemeachancetostudyC#onthejob,mycolleaguesatDataArt,whogavemeintellectualhelpandboostedmymoral,andtheJetBrainscompanyforgoodtimingindevelopingtheReSarpertool,whichallowsmetohavealmostasmuchfunwithC#asIamusedtohavingwithIntelliJIDEA.AspecialthankstoAlexeyPchelintsevforeditingtheRussianversionandtoPavelSokolovforthetranslation.



References

TheC#ProgrammingLanguageforJavaDevelopers
http://msdn.microsoft.com/vstudio/java/gettingstarted/csharpforjava/

J2EEfundamentalsfor.NETdevelopers
http://www-106.ibm.com/developerworks/java/library/j-roadmap1/
YakovSirotkin
SeniorDeveloper,DataArt

大型的应用一般不会用这些框架(因为性能考虑);开发人员根据需要选择用一些框架,也可以不选用框架;不用框架并不代表要自己写框架;修改框架的可能性更小。

简单生活 发表于 2015-1-21 12:58:03

还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。

爱飞 发表于 2015-1-30 18:44:29

应用在电视机、电话、闹钟、烤面包机等家用电器的控制和通信。由于这些智能化家电的市场需求没有预期的高,Sun公司放弃了该项计划。随着1990年代互联网的发展

第二个灵魂 发表于 2015-2-6 08:18:03

如果要向java web方向发展也要吧看看《Java web从入门到精通》学完再到《Struts2.0入门到精通》这样你差不多就把代码给学完了。有兴趣可以看一些设计模块和框架的包等等。

谁可相欹 发表于 2015-2-6 12:47:26

当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?

若天明 发表于 2015-2-13 22:13:17

其实说这种话的人就如当年小日本号称“三个月拿下中国”一样大言不惭。不是Tomjava泼你冷水,你现在只是学到了Java的骨架,却还没有学到Java的精髓。接下来你得研究设计模式了。

深爱那片海 发表于 2015-2-16 08:48:10

如果要向java web方向发展也要吧看看《Java web从入门到精通》学完再到《Struts2.0入门到精通》这样你差不多就把代码给学完了。有兴趣可以看一些设计模块和框架的包等等。

兰色精灵 发表于 2015-3-5 02:20:41

当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?

透明 发表于 2015-3-5 16:27:04

还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。

变相怪杰 发表于 2015-3-7 05:48:13

Java自面世后就非常流行,发展迅速,对C++语言形成了有力冲击。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于个人PC、数据中心、游戏控制台

只想知道 发表于 2015-3-12 23:47:01

如果你学过HTML,那么事情要好办的多,如果没有,那你快去补一补HTML基础吧。其实JSP中的Java语法也不多,它更象一个脚本语言,有点象ASP。

活着的死人 发表于 2015-3-13 00:08:39

那么我书也看了,程序也做了,别人问我的问题我都能解决了,是不是就成为高手了呢?当然没那么简单,这只是万里长征走完了第一步。不信?那你出去接一个项目,你知道怎么下手吗,你知道怎么设计吗,你知道怎么组织人员进行开发吗?你现在脑子里除了一些散乱的代码之外,可能再没有别的东西了吧!

灵魂腐蚀 发表于 2015-3-13 23:07:29

是一种突破用户端机器环境和CPU

蒙在股里 发表于 2015-3-19 23:01:28

《JAVA语言程序设计》或《JAVA从入门到精通》这两本书开始学,等你编程有感觉的时候也可以回看一下。《JAVA读书笔记》这本书,因为讲的代码很多,也很容易看懂,涉及到面也到位。是你学习技术巩固的好书,学完后就看看《JAVA编程思想》这本书,找找一个自己写的代码跟书上的代码有什么不一样。

飘灵儿 发表于 2015-4-1 18:10:13

Java 编程语言的风格十分接近C、C++语言。

山那边是海 发表于 2015-4-5 01:41:55

关于设计模式的资料,还是向大家推荐banq的网站 http://www.jdon.com/,他把GOF的23种模式以通俗易懂的方式诠释出来,纯Java描述,真是经典中的经典。

再见西城 发表于 2015-4-8 04:37:42

你现在最缺的是实际的工作经验,而不是书本上那些凭空想出来的程序。

莫相离 发表于 2015-4-10 07:34:41

应用在电视机、电话、闹钟、烤面包机等家用电器的控制和通信。由于这些智能化家电的市场需求没有预期的高,Sun公司放弃了该项计划。随着1990年代互联网的发展

仓酷云 发表于 2015-4-11 01:13:22

一直感觉JAVA很大,很杂,找不到学习方向,前两天在网上找到了这篇文章,感觉不错,给没有方向的我指了一个方向,先不管对不对,做下来再说。

冷月葬花魂 发表于 2015-4-14 16:46:02

有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)
页: [1]
查看完整版本: JAVA教程之JAVA程序员眼里的C#