NewprogramminglanguageautomaticallycoordinatesinteractionsbetweenWebponents
23December2014,byLarryHardesty
InadditiontomakingWebapplicationseasiertowrite,Ur/Webalsomakesthemmoresecure."Let'ssayyouwanttohaveacalendarwidgetonyourWebpage,andyou'regoingtousealibrarythatprovidesthecalendarwidget,andonthesamepagethere'salsoanadvertisementboxthat'sbasedoncodethat'sprovidedbythework,"Chlipalasays."Whatyoudon'twantisfortheworktobeabletochangehowthecalendarworksortheauthorofthecalendarcodetobeabletointerferewithdeliveringtheads."Ur/Webautomaticallyprohibitsthatkindofunauthorizedessbetweenpageelements.
Credit:iStock/MIT
AWebpagetodayistheresultofanumberofponents—likecascadingstylesheets,XMLcode,adhocdatabasequeries,andJavaScriptfunctions.Forallbutthemostrudimentarysites,keepingtrackofhowthesedifferentelementsinteract,refertoeachother,andpassdatabackandforthcanbeatime-consumingchore.
InapaperbeingpresentedattheAssociationforComputingMachinery'sSymposiumonPrinciplesofProgrammingLanguages,AdamChlipala,theDouglasRossCareerDevelopmentProfessorofSoftwareTechnology,describesanewprogramminglanguage,calledUr/Web,thatletsdeveloperswriteWebapplicationsasselfcontainedprograms.Thelanguage'piler—theprogramthatturnshigh-levelinstructionsintomachine-executablecode—thenautomaticallygeneratesthecorrespondingXMLcodeandstylesheetspecificationsandembedstheJavaScriptanddatabasecodeintherightplaces.
Typing,scoping
Ur/Web'sabilitytobothprovidesecurityprotectionandcoordinatedisparateWebtechnologiesstemsfromtwopropertiesitshareswithmostfull-blownprogramminglanguages,likeC++orJava.Oneisthatitis"stronglytyped."ThatmeansthatanynewvariablethataprogrammerdefinesinUr/Webisconstrainedtoaparticulardatatype.Similarly,anyspecificationofanewfunctionhastoincludethetypeofdatathefunctionactsonandthetypeofdataitreturns.
putingthevaluetoreturn,thefunctionmayneedtocreatenewvariables.(Afunctionthatreturnedanaverageofvaluesinadatabase,forinstance,wouldfirstneedtocalculatetheirsum.)Butthosevariablesareessibletotherestoftheprogram.Thisisthesecondproperty,knownas"variablescoping,"becauseitlimitsthescope—thebreadthofessibility—ofvariablesdefinedwithinfunctions.
"Youmightwanttowritealibrarythathasinsideofitasprivatestatethedatabasetablethatrecordsusernamesandpasswords,"Chlipalasays."Youdon'twantanyotherpartofyourapplicationtobe
1/3
abletojustreadandoverwritepasswords.MostWebframeworksdon'tsupportthatstyle.Theyassumethateverypartofyourprogrampleteesstothedatabase."
Typinghelpswithsecurity,too.ManyWebdevelopmentframeworksgeneratedatabasequeriesinsuchawaythatsomeoneostensiblyloggingintoawebsitecantypecodeintotheusernamefieldthatinfactoverwritesdatainthedatabase.WithUr/Web,usernameswouldconstitutetheirowndatatype,whichwouldbehandledmuchdifferentlythandatabasequeries.
usedinapositionwheretablepropertieswouldhaveanymeaning,soyoudon'thavetobothersettingthose."
Moreinformation:Paper:"Ur/Web:AsimplemodelforprogrammingtheWeb"
ProvidedbyMassachusettsInstituteofTechnology
Meetingexpectations
TypingisalsowhatenablescoordinationacrossWebtechnologies.SupposethatabitofJavaScriptcodeissupposedtoactondatafetchedfromadatabaseandthattheresultissupposedtobedisplayedonaWebpageatalocationdeterminedbysomeXMLcode.IfanUr/WebprogrammerwroteadatabasequerythatextracteddataofatypetheJavaScriptwasn'texpecting,oriftheJavaScriptgeneratedanoutputofatypethattheXMLpagewasn'texpecting,pilerwouldregisterthediscrepancyandflagthecodeascontaininganerror.
Often,codethatisn'texplicitlytypedstillhasimplicitconsistencyrules.Forinstance,ifyouwriteaqueryintheSQLdatabaselanguagethatasksfortheaveragenumericalvalueofabunchoftextfields,thedatabaseserverwilltellyouthatitcan'tprocessyourrequest.ToenableUr/WebtocoordinatetheflowofdatabetweenWebtechnologies,ChlipalahadtocreatelibrariesofnewdatatypesforSQL,XML,andcascadingstylesheets(CSS)thatembodytheserules.
WhiletheUr/pilerdoesgenerateXML,JavaScript,andSQLcodeinitscurrentversion,itdoesn'tproducestylesheetsautomatically.But,Chlipalasays,"Onethingpilercandoisanalyzeyourfullprogramandsay,'HereisanexhaustivelistofalltheCSSclassesthatmightbementioned,andhereisadescriptionofthecontextinwhicheachclassmightbeused,whichtellsyouwhatpropertiesmightbeworthsetting.'So,forinstance,someparticularclassmightneverbe
2/3
APAcitation:NewprogramminglanguageautomaticallycoordinatesinteractionsbetweenWebponents(2014,December23)retrieved22May2022from/news/2014-12-languageautomatically-interactions-web-page.html
Thisdocumentissubjecttocopyright.Apartfromanyfairdealingforthepurposeofprivatestudyorresearch,nopartmaybereproducedwithoutthewrittenpermission.Thecontentisprovidedforinformationpurposesonly.
PoweredbyTCPDF()
3/3
声明:
该资讯来自于互联网网友发布,如有侵犯您的权益请联系我们。