Cana40yearoldComputerLanguagedoWebApplications?UsingCommonLisptobuildWebApplications.NickyPeetersnicky.peeters@pandora.beJune19,2003AbstractToday’swebapplicationsareoftenbuiltusingJavatechnology.ProponentsofJavaadvocateitsmanyadvancedfeaturesandrepeatedlyclaimthereissomemagiclinkandinterdependencebetweenwebtechnologyandJavaasaprogramminglanguage.Thefabricofthewebhowever,theopenprotocolslikeTCP/IP,HTTPandstandardslikeHTMLandXML,isinfactlanguage-,operating-system-,andvendor-neutral.ItcanbearguedthatJavaisnothingnew,andonlyaclevercocktailoffeaturesofseveraloldertechnologies.ANSICommonLispprovidesnearlyalloftheadvantagesthatmakeJavaattractive,includingautomaticmemorymanagement,dynamicobject-orientedprogrammingandportability.SeveralotherfeaturesincludingitsinteractivityandfulldynamictypingmakeLispdevelopmentaverydifferentexperience.ItismythesisthatthevenerablecomputerlanguageCommonLispisatleastascapableasanimplementationtechnologyforwebapplicationseventhoughconceivedandrefinedlongbeforetheinternetrevolution.IwillshowhowsomeofLisp’sfeatures,manywhicharenot(yet)availableinJava,makeitagreatplatformtobuildwebapplicationson.1AcknowledgementsIthankSvenVanCaekenberghe1andHeinSarisfortheopportunitytodothisprojectatBetaNineSoftwareEngineering2.BetaNineismostofallaJava/J2EEshopbutareexperiencedinotherlanguagesandtechnolo-giesandassucharenotafraidtoexperimentwiththeunknownandofferemployeesandinternslearningopportunities.IexpressmygratitudetoSvenspecificallyforhisguidanceandsupportthroughouttheLisplearningprocessandthewholeproject.Ilearnedalotbyjustwatchinghimprogramandreadinghisbeautifulcode.TryingtoexplainwhatLispisandhowitworkswasnosinecureandhisadvicewasmostwelcome.IhavetomentionthediscussionsIhavehadwithIvanMelotte,RonaldJamaer,JochenPunie,MarcoHuygenandTimDegrandeatBetaNineaboutsoftwaredevelopment,the”holywars”weconductedinourdissem-inationofoperatingsystems,userinterfacesandgeneralcomputerscience.Theywerebothentertainingandanessentialpartofthelearningprocesslargelyassociatedwithcomputergeeksandhackers.Thanksguys!IalsothankmyfellowinternsBertHeymansandJurgenVanhex.WhenIsawthemsufferingwhileprogrammingaproxyserverinJava,IcouldonlysupportthembytellingthemhowcoolLispwas.ChristopheSchatsdeservesmythanks(andofhisBetaNinecolleages)forhandlingallthepaperworkassociatedwithinternshipsandotherbusi-nessrelatedissuesandlast,butnotleast,forkeepingthecoffeeflowingduringourdaysofwritingcode.Muchappreciated,Christophe!IthankFrancisVosandMarinaLuwelatDeHogeschoolLimburgfortheireffortsandhelpduringmyyearsatcollege.ToendthislistIthankDagWieers3,LinuxGuruandHackerExtraordi-naire,whointroducedmetoLinuxandOpenSourcesoftwareandwithoutwhomIwouldneverhaveendedupatBetaNineinthefirstplace.1://beta9.be/3:CommonLisp.........102.2LanguagedesignandFeatures..................122.2.1Designideas........................122.2.2Languagefeatures....................152.2.3AnexampleLispsession.................173KPAXWebApplicationFramework203.1WebApplications.........................203.1.1WhatareWebApplications?..............203.1.2KPAXWebApplications................213.2DesignandFeatures.......................213.2.1SessionManagementandSecurity...........223.2.2WebActions.......................233.2.3LispServerPages.....................233.2.4Webapplicationdefinition................233.3Examples.............................243.3.1HelloWorld........................253.3.2Factorial..........................264RSSSyndication304.1WhatisRSS?...........................304.2DesignandFeatures.......................313CONTENTSCONTENTS4.2.1Feedpersistancy.....................324.2.2XMLTechnology.....................335Psillog355.1TheWeblogphenomena.....................355.1.1Whatareweblogs?....................355.1.2ExistingWeblogImplementations............365.2DesignandFeatures.......................375.2.1Design...........................375.2.2Features..........................385.2.3ObjectDomainModel..................385.2.4Databasepersistency...................405.3PsillogWeblogSystem......................415.4Eyeswideshut,aPsillogpoweredWeblog............446Conclusions476.1Lisp................................476.1.1FirstContact.......................476.1.2LearningLispmakesyouabetterprogrammer....486.1.3Interactivedevelopmentenvironment..........496.2KPAXandWebApplications..................506.3EndConclusion..........................514Chapter1Introduction1.1WhyLisp?ThesedaysmostComputerSciencestudentslearntoprogramindifferentlanguagesthan10yearsago.Javaisthemainlanguageinmanycoursesandespeciallyintheworkplace.Ontopofthat,manyyoungprogrammerswillbecodinginJavaformanyyearstocome,thereseemstobeonlyonelanguagethatmatters.Javaprogrammersareusedtofeatureslikega