JAVA外文文献+翻译.docx
《JAVA外文文献+翻译.docx》由会员分享,可在线阅读,更多相关《JAVA外文文献+翻译.docx(16页珍藏版)》请在冰豆网上搜索。
JAVA外文文献+翻译
JavaandtheInternet
IfJavais,infact,yetanothercomputerprogramminglanguage,youmayquestionwhyitissoimportantandwhyitisbeingpromotedasarevolutionarystepincomputerprogramming、Theanswerisn’timmediatelyobviousifyou’recomingfromatraditionalprogrammingperspective、AlthoughJavaisveryusefulforsolvingtraditionalstand-aloneprogrammingproblems,itisalsoimportantbecauseitwillsolveprogrammingproblemsontheWorldWideWeb、
1.Client-sideprogramming
TheWeb’sinitialserver-browserdesignprovidedforinteractivecontent,buttheinteractivitywascompletelyprovidedbytheserver、Theserverproducedstaticpagesfortheclientbrowser,whichwouldsimplyinterpretanddisplaythem、BasicHTMLcontainssimplemechanismsfordatagathering:
text-entryboxes,checkboxes,radioboxes,listsanddrop-downlists,aswellasabuttonthatcanonlybeprogrammedtoresetthedataontheformor“submit”thedataontheformbacktotheserver、ThissubmissionpassesthroughtheCommonGatewayInterface(CGI)providedonallWebservers、ThetextwithinthesubmissiontellsCGIwhattodowithit、Themostcommonactionistorunaprogramlocatedontheserverinadirectorythat’stypicallycalled“cgi-bin、”(IfyouwatchtheaddresswindowatthetopofyourbrowserwhenyoupushabuttononaWebpage,youcansometimessee“cgi-bin”withinallthegobbledygookthere、)Theseprogramscanbewritteninmostlanguages、Perlisacommonchoicebecauseitisdesignedfortextmanipulationandisinterpreted,soitcanbeinstalledonanyserverregardlessofprocessororoperatingsystem、
ManypowerfulWebsitestodayarebuiltstrictlyonCGI,andyoucaninfactdonearlyanythingwithit、However,WebsitesbuiltonCGIprogramscanrapidlybecomeoverlycomplicatedtomaintain,andthereisalsotheproblemofresponsetime、TheresponseofaCGIprogramdependsonhowmuchdatamustbesent,aswellastheloadonboththeserverandtheInternet、(Ontopofthis,startingaCGIprogramtendstobeslow、)TheinitialdesignersoftheWebdidnotforeseehowrapidlythisbandwidthwouldbeexhaustedforthekindsofapplicationspeopledeveloped、Forexample,anysortofdynamicgraphingisnearlyimpossibletoperformwithconsistencybecauseaGIFbecreatedandmovedfromtheservertotheclientforeachversionofthegraph、Andyou’venodoubthaddirectexperiencewithsomethingassimpleasvalidatingthedataonaninputform、Youpressthesubmitbuttononapage;thedataisshippedbacktotheserver;theserverstartsaCGIprogramthatdiscoversanerror,formatsanHTMLpageinformingyouoftheerror,andthensendsthepagebacktoyou;youmustthenbackupapageandtryagain、Notonlyisthisslow,it’sinelegant、
Thesolutionisclient-sideprogramming、MostmachinesthatrunWebbrowsersarepowerfulenginescapableofdoingvastwork,andwiththeoriginalstaticHTMLapproachtheyaresittingthere,justidlywaitingfortheservertodishupthenextpage、Client-sideprogrammingmeansthattheWebbrowserisharnessedtodowhateverworkitcan,andtheresultfortheuserisamuchspeedierandmoreinteractiveexperienceatyourWebsite、
Theproblemwithdiscussionsofclient-sideprogrammingisthattheyaren’tverydifferentfromdiscussionsofprogrammingingeneral、Theparametersarealmostthesame,buttheplatformisdifferent:
aWebbrowserislikealimitedoperatingsystem、Intheend,youmuststillprogram,andthisaccountsforthedizzyingarrayofproblemsandsolutionsproducedbyclient-sideprogramming、Therestofthissectionprovidesanoverviewoftheissuesandapproachesinclient-sideprogramming、
2、Plug-ins
Oneofthemostsignificantstepsforwardinclient-sideprogrammingisthedevelopmentoftheplug-in、Thisisawayforaprogrammertoaddnewfunctionalitytothebrowserbydownloadingapieceofcodethatplugsitselfintotheappropriatespotinthebrowser、Ittellsthebrowser“fromnowonyoucanperformthisnewactivity、”(Youneedtodownloadtheplug-inonlyonce、)Somefastandpowerfulbehaviorisaddedtobrowsersviaplug-ins,butwritingaplug-inisnotatrivialtask,andisn’tsomethingyou’dwanttodoaspartoftheprocessofbuildingaparticularsite、Thevalueoftheplug-inforclient-sideprogrammingisthatitallowsanexpertprogrammertodevelopanewlanguageandaddthatlanguagetoabrowserwithoutthepermissionofthebrowsermanufacturer、Thus,plug-insprovidea“backdoor”thatallowsthecreationofnewclient-sideprogramminglanguages(althoughnotalllanguagesareimplementedasplug-ins)、
3、Scriptinglanguages
Plug-insresultedinanexplosionofscriptinglanguages、Withascriptinglanguageyouembedthesourcecodeforyourclient-sideprogramdirectlyintotheHTMLpage,andtheplug-inthatinterpretsthatlanguageisautomaticallyactivatedwhiletheHTMLpageisbeingdisplayed、Scriptinglanguagestendtobereasonablyeasytounderstandand,becausetheyaresimplytextthatispartofanHTMLpage,theyloadveryquicklyaspartofthesingleserverhitrequiredtoprocurethatpage、Thetrade-offisthatyourcodeisexposedforeveryonetosee(andsteal)、Generally,however,youaren’tdoingamazinglysophisticatedthingswithscriptinglanguagessothisisnottoomuchofahardship、
ThispointsoutthatthescriptinglanguagesusedinsideWebbrowsersarereallyintendedtosolvespecifictypesofproblems,primarilythecreationofricherandmoreinteractivegraphicaluserinterfaces(GUIs)、However,ascriptinglanguagemightsolve80percentoftheproblemsencounteredinclient-sideprogramming、Yourproblemsmightverywellfitcompletelywithinthat80percent,andsincescriptinglanguagescanalloweasierandfasterdevelopment,youshouldprobablyconsiderascriptinglanguagebeforelookingatamoreinvolvedsolutionsuchasJavaorActiveXprogramming、
ThemostcommonlydiscussedbrowserscriptinglanguagesareJavaScript(whichhasnothingtodowithJava;it’snamedthatwayjusttograbsomeofJava’smarketingmomentum),VBScript(whichlookslikeVisualBasic),andTcl/Tk,whichcomesfromthepopularcross-platformGUI-buildinglanguage、Thereareothersoutthere,andnodoubtmoreindevelopment、
JavaScriptisprobablythemostcommonlysupported、ItcomesbuiltintobothNetscapeNavigatorandtheMicrosoftInternetExplorer(IE)、Inaddition,thereareprobablymoreJavaScriptbooksavailablethantherearefortheotherbrowserlanguages,andsometoolsautomaticallycreatepagesusingJavaScript、However,ifyou’realreadyfluentinVisualBasicorTcl/Tk,you’llbemoreproductiveusingthosescriptinglanguagesratherthanlearninganewone、(You’llhaveyourhandsfulldealingwiththeWebissuesalready、)
4、Java
Ifascriptinglanguagecansolve80percentoftheclient-sideprogrammingproblems,whatabouttheother20percent—the“reallyhardstuff?
”ThemostpopularsolutiontodayisJava、Notonlyisitapowerfulprogramminglanguagebuilttobesecure,cross-platform,andinternational,butJavaisbeingcontinuallyextendedtoprovidelanguagefeaturesandlibrariesthatelegantlyhandleproblemsthataredifficultintraditionalprogramminglanguages,suchasmultithreading,databaseaccess,networkprogramming,anddistributedcomputing、Javaallowsclient-sideprogrammingviatheapplet、
Anappletisamini-programthatwillrunonlyunderaWebbrowser、TheappletisdownloadedautomaticallyaspartofaWebpage(justas,forexample,agraphicisautomaticallydownloaded)、Whentheappletisactivateditexecutesaprogram、Thisispartofitsbeauty—itprovidesyouwithawaytoautomaticallydistributetheclientsoftwarefromtheserveratthetimetheuserneedstheclientsoftware,andnosooner、Theusergetsthelatestversionoftheclientsoftwarewithoutfailandwithoutdifficultreinstallation、BecauseofthewayJavaisdesigned,theprogrammerneedstocreateonlyasingleprogram,andthatprogramautomaticallyworkswithallcomputersthathavebrowserswithbuilt-inJavainterpreters、(Thissafelyincludesthevastmajorityofmachines、)SinceJavaisafull-fledgedprogramminglanguage,youcandoasmuchworkaspossibleontheclientbeforeandaftermakingrequestsoftheserver、Forexample,youwon’tneedtosendarequestformacrosstheInternettodiscoverthatyou’vegottenadateorsomeotherparameterwrong,andyourclientcomputercanquicklydotheworkofplottingdatainsteadofwaitingfortheservertomakeaplotandshipagraphicimagebacktoyou、Notonlydoyougettheimmediatewinofspeedandresponsiveness,butthegeneralnetworktrafficandloadonserverscanbereduced,preventingtheentireInternetfromslowingdown、
OneadvantageaJavaapplethasoverascriptedprogramisthatit’sincompiledform,sothesourcecodeisn’tavailabletotheclient、Ontheotherhand,aJavaappletcanbedecompiledwithouttoomuchtrouble,buthidingyourcodeisoftennotanimportantissue、Twootherfactorscanbeimportant、Asyouwillseelaterinthisbook,acompiledJavaappletcancomprisemanymodulesandtakemultipleserver“hits”(accesses)todownload、(InJava1、1andhigherthisisminimizedbyJavaarchives,calledJARfiles,thatallowalltherequiredmodulestobepackagedtogetherandcompressedforasingledownload、)AscriptedprogramwilljustbeintegratedintotheWebpageaspartofitstext(andwillgenerallybesmallerandreduceserverhits)、ThiscouldbeimportanttotheresponsivenessofyourWebsite、Anotherfactoristheall-importantlearningcurve、Regardlessofwhatyou’veheard,Javaisnotatriviallanguagetolearn、Ifyou’reaVisualBasicprogrammer,movingtoVBScriptwillbeyourfa