您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > Another Go at Language Design
AnotherGoatLanguageDesignRobPikegolang.orgApril28,2010 Notmuchtext;alotgetsdone.Oldprogramsreadlikequietconversationsbetweenawell-spokenresearchworkerandawell-studiedmechanicalcolleague,notasadebatewithacompiler. Who'dhaveguessedsophisticationboughtsuchnoise?-DickGabrielWednesday,April28,2010SophisticationIfmorethanonefunctionisselected,anyfunctiontemplatespecializationsinthesetareeliminatedifthesetalsocontainsanon-templatefunction,andanygivenfunctiontemplatespecializationF1iseliminatedifthesetcontainsasecondfunctiontemplatespecializationwhosefunctiontemplateismorespecializedthanthefunctiontemplateofF1accordingtothepartialorderingrulesof14.5.6.2.Aftersucheliminations,ifany,thereshallremainexactlyoneselectedfunction.(C++0x,§13.4[4])Wednesday,April28,2010SophisticationWhichBoosttemplatedpointertypeshouldIuse?-linked_ptr-scoped_ptr-shared_ptr-smart_ptr-weak_ptr-intrusive_ptr-exception_ptrWednesday,April28,2010NoisepublicstaticI,OListenableFutureOchain(ListenableFutureIinput,Function?superI,?extendsListenableFuture?extendsOfunction)deargodmakeitstop-arecentlyobservedchatstatusfoo::Foo*myFoo=newfoo::Foo(foo::FOO_INIT)-butintheoriginalFoowasalongerwordWednesday,April28,2010Howdidwegethere?Apersonalanalysis:1)CandUnixbecamedominantinresearch.2)Thedesireforahigher-levellanguageledtoC++,whichgraftedtheSimulastyleofobject-orientedprogrammingontoC.ItwasapoorfitbutsinceitcompiledtoCitbroughthigh-levelprogrammingtoUnix.3)C++becamethelanguageofchoiceinpartsofindustryandinmanyresearchuniversities.4)Javaaroseasaclearer,stripped-downC++.5)Bythelate1990s,ateachinglanguagewasneededthatseemedrelevant,andJavawaschosen.Wednesday,April28,2010ProgrammingbecametoohardTheselanguagesarehardtouse.Theyaresubtle,intricate,andverbose.Theirstandardmodelisoversold,andwerespondwithadd-onmodelssuchaspatterns.(Norvig:patternsareademonstrationofweaknessinalanguage.)Yettheselanguagesaresuccessfulandvital.Wednesday,April28,2010AreactionTheinherentclumsinessofthemainlanguageshascausedareaction.Anumberofsuccessfulsimplerlanguages(Python,Ruby,Lua,JavaScript,Erlang,...)havebecomepopular,inpartasarejectionofthestandardlanguages.Somebeautifulandrigorouslanguagesdesignedbydomainexperts(Scala,Haskell,...)havealsoarisen,althoughtheyarenotaswidelyadopted.Sodespitethestandardmodel,otherapproachesarepopularandtherearesignsofagrowthinoutsiderlanguages,arenaissanceoflanguageinvention.Wednesday,April28,2010AconfusionThestandardlanguages(Java,C++)arestaticallytyped.Mostoutsiderlanguages(Ruby,Python,JavaScript)areinterpretedanddynamicallytyped.Perhapsasaresult,non-expertprogrammershaveconfusedeaseofusewithinterpretationanddynamictyping.Thisconfusionarosebecauseofhowwegothere:graftinganorthodoxyontoalanguagethatcouldn'tsupportitcleanly.Wednesday,April28,2010Part21.History2.Aniche3.TourofGo4.StatusWednesday,April28,2010ThegoodThestandardlanguagesareverystrong:type-safe,effective,efficient.Inthehandsofexperts,theyaregreat.Hugesystemsandhugecompaniesarebuiltonthem.Inpracticetheyworkwellforlargescaleprogramming:bigprograms,manyprogrammers.Wednesday,April28,2010ThebadThestandardlanguagesarehardtouse.Compilersareslowandfussy.Binariesarehuge.Effectiveworkneedslanguage-awaretools,distributedcompilationfarms,...Manyprogrammersprefertoavoidthem.Thelanguagesareatleast10yearsoldandpoorlyadaptedtothecurrentcomputingenvironment:cloudsofnetworkedmulticoreCPUs.Wednesday,April28,2010FlighttothesuburbsThisispartlywhyPythonetal.havebecomesopopular:Theydon'thavemuchofthebad.-dynamicallytyped(fewernoisykeystrokes)-interpreted(nocompilertowaitfor)-goodtools(interpretersmakethingseasier)Buttheyalsodon'thavethegood:-slow-nottype-safe(staticerrorsoccuratruntime)-verypooratscaleAndthey'realsonotverymodern.Wednesday,April28,2010AnicheThereisanichetobefilled:alanguagethathasthegood,avoidsthebad,andissuitabletomoderncomputinginfrastructure:-comprehensible-staticallytyped-lightonthepage-fasttoworkin-scaleswell-doesn'trequiretools,butsupportsthemwell-goodatnetworkingandmultiprocessingWednesday,April28,2010Part31.History2.Aniche3.TourofGo4.StatusWednesday,April28,2010ThetargetGoaimstocombinethesafetyandperformanceofastaticallytypedcompiledlanguagewiththeexpressivenessandconvenienceofadynamicallytypedinterpretedlanguage.Italsoaimstobesuitableformodernsystemsprogramming.Wednesday,April28,2010Hello,world2.0Serving:packagemainimport(fmthttp)funchandler(c*http.Conn,r*http.Request){fmt.Fprintf(c,Hello,%s.,r.URL.Path[1:])}funcmain(){http.ListenAndServe(:8080,http.HandlerFunc(handler))}Wednesday,April28,2010HowdoesGofilltheniche?FastcompilationExp
本文标题:Another Go at Language Design
链接地址:https://www.777doc.com/doc-6297188 .html