DOC PREVIEW
Berkeley COMPSCI 164 - Compilers in Real Life

This preview shows page 1-2-3-24-25-26-27-48-49-50 out of 50 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 50 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Compilers in Real LifeSoftware Development TimeSoftware MaintenanceLessons from Real LifeSolutions for Real LifeCelebrity EndorsementsCompilers are SoftwareCase Study 1: Search ResultsThe ProblemSolution 1: Spaghetti codeSolution 2: Write it over and overSolution 3: RecipesRecipesA Better WayRFL: Result Format LanguageReport Format LanguageRFL InterpreterSlide 18Running RFLRFL CompilerExpressivenessImplementation PerformanceUsabilityEvolution of RFLCase Study 2: Little ReportsCBL: Cash Balance LanguageError Checking in CBLError Avoidance in CBLCBL ImplementationCBL In PracticeCBL EvaluationBreakCase Study 3: UnrealScriptThe Unreal EngineCustomizing GamesSlide 36UnrealScriptSlide 38Actor StatesNetworkingErrors in UnrealScriptDynamic Error HandlingPerformanceImplementation QualitySlide 46Slide 47Slide 48Slide 49Creating Your Own LanguageGetting StartedCompilers in Real LifeDave Mandelin2 Dec 2004Software Development Time1/6Code1/2Test1/3DesignTest1/2Code1/6Design1/3From The Mythical Man-Month by Fred BrooksCan we do more error checking and less testing?Better yet, can we avoid writing bugs in the first place?Software MaintenanceMaintenance isFixing bugsEnhancing functionalityImproving performanceRefactoring60/60 Rule60% of project cost is maintenance60% of maintenance is enhancements30% of maintenance cost is reading existing codeFrom Facts and Fallacies of Software Engineering by Robert GlassLessons from Real LifeSoftware needs to beReliableMaintainableUnderstandable…especially if it’s any good.Solutions for Real LifeHow can we write reliable, maintainable, understandable software?Design a new language!A language specially designed to handle your problemProgram is short, focused on task“Junk” implementation details hiddenAnd maintainable in one placeError checkingError avoidanceCelebrity EndorsementsCompilers are SoftwareProgramming language tools need to be maintainable, understandable tooCompilers, code analyzers, debuggersWe could design special languages to help implement our languagesToo much for most projectsCan be done, though (PA3, yacc)Focus on simplicity insteadCase Study 1: Search ResultsProject SearchDepartment SearchThe ProblemMany search typesWant same look and feel for allEasy to learn, use, and understandNeed different result formatDifferent titles, linksSolution 1: Spaghetti codeif (type == PROJECT) {link1 = “project.asp?” + name;link2 = “grant.asp?” + id;} else {link1 = “dept.asp?” + id;link2 = null;}…System.out.println(link1);if (type == PROJECT) {System.out.println(link2);}Maybe it works, maybe you get firedUnmaintainableSolution 2: Write it over and overWrite each search page as a separate classMaybe Alice does departments, Bob does projects, …Hard to keep consistent look and feelSolution 3: RecipesWrite each search page as a separate classFollow a fixed recipe each timeExample: recursive descent parsingFollow a fixed recipe for each productionGood strategyBut not the best!RecipesWhat’s good about recipes?Figure out how to do it only onceAvoid bugs if the recipe is correctWhat’s wrong with recipes?Type it in many timesCan type in bugs each timeBoringA Better WayFactor out the repetitionDescribe the differences with a notationPA3: grammar fileSearch: describe result formatImplement the repeated parts with interpreters, compilers, and librariesPA3: parsing engine, table generatorSearch: interpreterRFL: Result Format LanguageColumntitle=“Dept”source_data=“dept”type=STRINGlink=“dept.asp?deptid={ID}”Columntitle=“Name”source_data=”description”type=STRINGReport Format LanguageA configuration language for reportsSyntactic sugar for the recipe codeRaises level of abstractionJava has abstraction features, toomethods, classesSometimes Java is not good enoughPA3: parsing table is unreadableNeed a new languageRFL InterpreterSearch results come from databaseRFL program is an ASTCreated programmatically – no front endRun RFL program on each result tuple340200,”Admin”340300,”Outreach”Columntitle=“Dept”source_data=“dept”type=STRINGlink=“dept.asp?deptid={ID}”Columntitle=“Name”source_data=”description”type=STRINGRFL Interpreter<tr><td><a href=…RFL InterpreterAllowed rapid development of many search pagesOne day, a user sends an email…Site is slow when displaying 5000 search resultsDon’t askWhat can we do?Running RFLInterpreterfor col in columns// Visit each columnObject data = row.getData(col.name);String s = col.format(data);if (col.hasLink()) {col.writeLink(row);}print(s);if (col.hasLink()) {print(“</a>”);}Hand-written// First columndata = row.getData(“name”);s = col.format(data);col.writeLink(row);print(s);print(“</a>”);// Second columndata = row.getData(“title”);s = col.format(data);print(s);RFL Compilera.k.a. code generatorCompile ASTs to HLL code (VBScript)Performs easy optimizationsLoop unrollingConstant propagationEasy because compiler knows which assignments it is generating10x speedupExpressivenessConfiguration languagesLittle languagesDomain-specific languages (DSLs)General-purpose languages (GPLs)Expressiveness,Maintenance EfortRFLVHDL, PostScript, UnrealScriptJava, Perl, Decafmake, PA2 lexer specImplementation PerformanceInterpreterBasic CompilerOptimizing CompilerFancy Optimizing CompilerExecution Speed,Development EfortRFL Interpreterjavac, RFL CompilerPA6, gccPA4UsabilityAuthorHackersProgrammersUsersUsability,Language Design Efortone-of code generatorsJava, Perl, DecafRFL, X configuration scriptsUnrealScriptEvolution of RFLConfig LanguageLittle LanguageDSLGPLInterpreter Compiler Fancy Compilerv0.001InterpreterCompilerCase Study 2: Little ReportsRevenue 60,000Deferred Revenue 14,000Expenses 70,000Profit 4,000CBL: Cash Balance Language‘Profit’=GROUP((REV + DEF) + EXP)‘title’=GROUP(…) is CBL syntaxREVLike a primitive zero-argument functionEvaluated using a database queryWhat happens if we need values from a web site?Need extensibilityCBL has an interface for implementing new primitives by writing a simple classError Checking in CBLDebits and credits are confusingWhich is right, REV – DEF or REV + DEF?“That’s like asking the square root of million. No one will


View Full Document

Berkeley COMPSCI 164 - Compilers in Real Life

Documents in this Course
Lecture 8

Lecture 8

40 pages

Load more
Download Compilers in Real Life
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Compilers in Real Life and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Compilers in Real Life 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?