|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在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
大型的应用一般不会用这些框架(因为性能考虑);开发人员根据需要选择用一些框架,也可以不选用框架;不用框架并不代表要自己写框架;修改框架的可能性更小。 |
|