studentsincomputerscienceattheUniversityofUp- psala.HavingcompletedaMastersdegreemanyof thesestudentswereemployedbyErlangSystems.MikeWilliamsmovedfromtheComputerScienceLab- oratorytomanageErlangSystemsandhadsoonbuilt upastrongteamofconsultantsandimpressivetrain- ingfacilities.In1996over500Ericssonprogrammers attendedcoursesatErlangSystems.Erlangconsultingisoneofthemostimportantfactors thathaveledtothespreadofErlangwithinEricsson.IntherstErlangprojectstherewasveryclosecontact betweenthedevelopersandtheusers.Weknewevery userandcouldprovideindividualhelpandtuition- thisdoesn'tscale.Now,whenwestartanewproject,wealwaystryto getatleasttwoErlangSystemsconsultantsworking ontheproject.Theyprovideavitallinkbetweenthe usersanddevelopersofErlang.Thisisasignicant factorinthesuccessofnewprojects.Itisalsointerestingtonotethattheskilllevelrequired foranentry-levelindustrialprogrammerhasincreased inrecentyears.Agooddegreeincomputerscienceis nowapre-conditionforworkingwithstateoftheart softwaretechnology.Thedaysoftheamateurhacker arefastdisappearing.
Thetools
ThecurrentErlangsystemcomeswithanextensive toolkit.Aswellastheobvioussoftwaretoolsyacc,lexlook-a-likesetc.thereisawiderangeoftools whichareusefulforbuildingtelecomsapplications.Theseincludethingslikecross-compilersforinterfac- ingErlangtoforeignlanguageapplications,anASN.1 interfacecompiler,anSNMPtool-kit,aHTTP-server etc.ManyofthenewusersofErlangarenotinitiallyat- tractedbythelanguagebutratherbythesetoftools whichcomeswiththelanguage.Forexample,itis extremelyeasytobuildanSNMPapplicationusing theErlangSNMPtoolkit.TheSNMPtoolkit,forex- ample,containsaMIBcompiler,andsetofdefault methodswhichallowsanon-expertusertobuildan SNMPagentinamatterofhours.Doingthisina conventionallanguageismuchmoredicult.Manyoftherstversionsofthetoolswerewrittenby studentsaspartoftheirMasterthesiswork.
Mnesia
Manyreal-timeapplicationsneedaccesstodataover longperiodsoftime.Forexample,inatelephone exchangesubscriberdatamustbestoredformany yearsandmustbeaccessiblewithinafewmillisec- onds.Chargingdatatelephonebillsmustbekept andneverlost.Mnesia9isareal-timedistributeddatabasedesigned forprogrammingtelecomsapplicationsinErlang.Am- nesiaiswrittenentirelyinErlang.
OTP
On1January1996anewEricssondivisionwascreated tosupportapplicationswritteninErlang.Ourusers wantalotmorethanjustaprogramminglanguage.Forexample,someuserswantnotonlythelanguage butalsotheoperatingsystemsandthehardwareplat- formtobedeliveredinonepackage.TheOTPOpenTelecomPlatformdivisioncanpro- videEricssonuserswithanythingfromasimpleErlang systemwhichrunsonaPCtoanembeddedsystem completewithhardware.Thedivisionhasthegoal ofprovidingprospectiveuserswithaturn-keysystem whichtheycanturnonandstartprogrammingfrom dayoneofaproject.StandardOTPsoftwarecomes withextensivelibrarieswhichsolvecommonapplica- tionproblems.AnothergoaloftheOTPdivisionwastotransferre- sponsibilityforthemaintenanceandsupportofthe ErlangsystemfromtheComputerScienceLaboratory toamainstreamEricssondivision.
3Erlangin14Examples
TheprevioussectionsdescribedthedevelopmentofErlang.ThefollowingsectionsdescribeErlangthroughanumberof smallexamples.
3.1SequentialErlang Example1-Factorial
Allfunctionsaredenedinmodules,forexample,factorial canbewritten:
-modulemath. -exportfac1. facNwhenN0-N*facN-1; fac0-1.
Theannotation
-exportfac1
meansthefunction
fac
withoneargumentisfromthemodule.Onlyexported functionscanbecalledfromoutsidethemodule.Onceamodulehasbeenloadedintothesystemthequery evaluatorcanbeusedforfunctionevaluation:
math:fac25. 15511210043330985984000000
Example2-BinaryTree
lookupKey,Key,Val,_,_- ok,Val; lookupKey,Key1,Val,S,BwhenKeyKey1- lookupKey,S; lookupKey,Key1,Val,S,B- lookupKey,B; lookupKey,nil- not_found.
Herethe
tuple
Key,Val,S,B
representsanodeofa binarytree.Tuplesstorexednumbersofarguments.
Example3-Append
appendH|T,L-H|appendT,L; append,L-L.
Leave a Comment