Announcements Week 12 „ Part 4 „ Paul Chew’s Office Hour for today (W 4:30 – 5:30) is z Will be due on last day of Software Engineering Tools cancelled due to special classes (Friday, May 7) computer graphics talk z Today’s talk

™ 4:30pm, Call Auditorium

™ Marc Levoy (Stanford)

™ The Digital Michelangelo „ No Sections today (or next Paul Chew Project week) CS 212 – Spring 2004 z Tomorrow’s talk ™ 4:15pm, Call Auditorium

™ George Joblove (Sony Picture Imageworks) and Douglas Kay (Mondo Media)

™ Digital Imagery in Entertainment

2

Unix Programming Languages

„ Original version by Ken „ Philosophy „ Some of the languages used „ Some other languages (from a Thompson (Bell Labs) in 1969 z Almost everything is a text file in CS Dept Yahoo list) ABC, ActiveX, Ada, AMOS, APL, z Little programs (utilities) to do z C, C++, C# „ An interactive, multi-user little tasks AppleScript, Assembly, awk, BASIC, ™ Many of the upper level (not the first BETA, C and C++, C#, Cecil, Cilk, z Connect programs with pipes courses (networks, CLU, COBOL, ColdC, cT, Curl, such system, but an early one) & redirection ) Delphi, Dylan, Dynace, Eiffel, Forth, ™ % who | sort | lpr Fortran, Guile, Haskell, Icon, IDL, z Java „ Unix is closely tied to the ™ Print an alphabetical list of Infer, Intercal, J, Java, JavaScript, ™ 100, 211, 212 development of C who is active on the system JCL, JOVIAL, Limbo, Lisp, Logo, M - z Matlab MUMPS, Magma, ML, -2, z Unix was originally written in „ Linux is an open software version Modula-3, Oberon, Obliq, Occam, PDP-7 Assembly Language of Unix ™ 100M, numerical analysis OpenGL, Pascal, Perl, PL/I, Pop, courses z Then in B z Since 1991 PostScript, Prograph, , Python, ™ Linus Torvalds (the kernel) z ML Rexx, Ruby, SAS, Sather, Scheme, z Then in C ScriptEase, SDL, Self, SETL, ™ Richard Stallman (GNU) z B and C were basically ™ , SQL, Tcl/Tk, TOM, Verilog, created to write Unix z Widely used for high- ™ 312, logic-related courses VHDL, VRML, Visual, Visual Basic, Z performance computing z …

3 4

Scripting Languages Regular Expressions

„ A script is a sequence of „ Example scripting languages: „ Common goal: „ Some of the rules for regular common commands made Unix shell, Python, Perl, search/match/do stuff with expressions into a single program Tcl (Tool command language) strings z A regular matches itself z Unix uses shell scripts z A . matches any character z The shell is the interactive „ Some Python code: „ Idea: use special strings to interface to Unix match other strings z * implies 0 or more occurrences (of preceding class Stack (object): z You can combine z Some characters are item) commands from the Unix def __init__ (self): meta-characters self.stack = [ ] z + implies 1 or more shell to create programs def put (self, item): occurrences self.stack.append(item) „ Regular expressions are z \ implies following character is def get (self): treated as a regular character „ A scripting language is return self.stack.pop() closely related to finite state z [ … ] matches any one z Usually easy to learn def isEmpty (self): automata (CS 381/481) return len(self.stack) == 0 character from within the z Interpreted instead of brackets; - can be used to compiled indicate a range „ ( [0-9]+\. | \. [0-9] ) [0-9]* 5 6

1 Makefiles Version Control

„ Used when „ Once you have a makefile „ Allows you to keep track of „ CVS (Concurrent Version compiling/recompiling a large z You recompile whatever is changes for a large project System) system (several necessary by typing make z Can back up to old version z Open source interdependent files) if changes create z Widely used tool for z Checks which files have problems „ To create a makefile version control changed and only z Multiple contributors can z Usual strategy is to find z Maintains a history of all recompiles those that are work on the system changes made necessary some examples and modify them z Supports branching, z Because of dependencies, z There are automated tools allowing several lines of more than just the development changed files can need to for building makefiles be recompiled z Provides mechanisms for merging branches back z Of course, can always together when desired recompile everything, but this can be too expensive

7 8

UML Profiling

„ UML „ The goal is to make a program run faster z = Unified Modeling Language z Rule of thumb: 80% of the time is spent in 20% of the code z No use improving the code that isn’t executed often z Design tool for object oriented programming z How do you determine where your program is spending its time? z System for showing the interaction of objects „ People are notoriously bad at predicting the most computationally expensive parts of a program „ Part of the data produced by a profiler (Python) 2649853 function calls (2319029 primitive calls) in 53.502 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 2521 0.227 0.000 1.734 0.001 Drawing.py:102(update) 7333 0.355 0.000 0.983 0.000 Drawing.py:244(transform) 4347 0.324 0.000 4.176 0.001 Drawing.py:64(draw) 3649 0.212 0.000 1.570 0.000 Geometry.py:106(angles) 56 0.001 0.000 0.001 0.000 Geometry.py:16(__init__) 343160/34316 9.818 0.000 12.759 0.000 Geometry.py:162(_determinant) 8579 0.816 0.000 13.928 0.002 Geometry.py:171(cross) 4279 0.132 0.000 0.447 0.000 Geometry.py:184(transpose) 9 10

Bali for Part 4 New Bali Syntax

„ Adds classes (and fields and int main ( ) class -> class name [ ( name ) ] { fieldDeclaration* } methods) with single {int n; Stack s;} { n = 0; { constructor* } inheritance while n < 10 do { { method* } „ Does not remove functions s.put(n); n = n + 1; } n = 0; fieldDeclaration -> modifier variableDeclaration z There is still a main- while n < 10 do { function, executed when print s.get(); constructor -> modifier name ( [ parameters ] ) functionBody program is run n = n + 1; } method -> modifier function class Stack } { private Node top; } {} modifier -> public | private { public void put (int i) {} class Node { top = Node(i, top); { public int data; public Node link; } return; } { public Node (data, line) {} public int get () { this.data = data; { Node n; } this.link = link; { n = top; } top = top.link; }{} return n.data; } } 11 12

2