Software Tools
Total Page:16
File Type:pdf, Size:1020Kb
Integrated Development Environments ! An IDE usually includes ! You should know how to use Software Tools " Source code editor (usually a debugger! with color highlighting) " Place breakpoints " Compiler or interpreter " Step through code " Tools for “build # Step over automation” (i.e., keeps # Step into track of what needs to be # Step out of… recompiled) " Examine current call-stack " Debugger " Examine values of active " Class browser (for variables languages with classes) Lecture 9 # Some debuggers allow you to change a variable value Top 20 Tools of All Time CS 212 – Fall 2007 (http://uk.gizmodo.com/) ! Examples: DrJava, Eclipse " In Eclipse: As you type, ! Debuggers are usually much gives you list of options + more effective than placing documentation print-statements Unix Programming Languages ! Original version by Ken Thompson ! Philosophy ! Some of the languages used in ! Some other languages (from a (Bell Labs) in 1969 " Almost everything is a text file Cornell’s CS Dept Yahoo list) " Little programs (utilities) to do " Java ABC, ActiveX, Ada, AMOS, APL, little tasks ! An interactive, multi-user # 100, 211, 212 AppleScript, Assembly, awk, BASIC, operating system (not the first " Connect programs with pipes & BETA, C and C++, C#, Cecil, Cilk, redirection " C, C++, C# such system, but an early one) CLU, COBOL, ColdC, cT, Curl, Delphi, # % who | sort | lpr # Many of the upper level Dylan, Dynace, Eiffel, Forth, # Print an alphabetical list of who is courses (networks, Fortran, Guile, Haskell, Icon, IDL, ! Unix is closely tied to the active on the system distributed computing) Infer, Intercal, J, Java, JavaScript, development of C ! Linux is an open software version " Matlab JCL, JOVIAL, Limbo, Lisp, Logo, M - " Unix was originally written in PDP- of Unix # 100M, numerical analysis MUMPS, Magma, ML, Modula-2, 7 Assembly Language " Since 1991 courses Modula-3, Oberon, Obliq, Occam, " Then in B # Linus Torvalds (the kernel) " ML OpenGL, Pascal, Perl, PL/I, Pop, # " Then in C Richard Stallman (GNU) # Functional programming PostScript, Prograph, Prolog, Python, " Widely used for high-performance Rexx, Ruby, SAS, Sather, Scheme, " B and C were basically created to # 312, logic-related courses ScriptEase, SDL, Self, SETL, write Unix computing " … Smalltalk, SQL, Tcl/Tk, TOM, Verilog, VHDL, VRML, Visual, Visual ! Mac OS X is built on Unix ! Fortran, C, C++ are used widely in Engineering Basic, Z Scripting Languages Regular Expressions ! A script is a sequence of ! Example scripting languages: ! Common goal: search/match/do ! Some of the rules for regular common commands made into a Unix shell, Python, Perl, stuff with strings expressions single program Tcl (Tool command language) " A regular character matches " Unix uses shell scripts ! Idea: use special strings to itself " The shell is the interactive ! Some Python code: match other strings " A . matches any character interface to Unix " * implies 0 or more " Some characters are meta- " occurrences (of preceding You can combine commands class Stack (object): characters item) from the Unix shell to create def __init__ (self): programs self.stack = [ ] " + implies 1 or more def put (self, item): ! Regular expressions are closely occurrences self.stack.append(item) related to finite state ! A scripting language is " \ implies following character is def get (self): automata (CS 381/481) treated as a regular character " Usually easy to learn return self.stack.pop() " [ … ] matches any one " Interpreted instead of def isEmpty (self): return len(self.stack) == 0 character from within the compiled brackets; - can be used to indicate a range ! A regular expression in Java "((\\.[0-9]+)|([0-9]+\\.[0-9]*))" 1 Makefiles Memory Management ! Used when ! Once you have a makefile ! Modern programs are ! Manual memory management compiling/recompiling a " You recompile whatever is " Long running bugs large system (several necessary by typing make " Make dynamic use of " Dangling pointers interdependent files) memory # Memory has been freed, but part of the code is " Checks which files have ! To create a makefile changed and only still trying to use it " Usual strategy is to find ! Garbage collector recompiles those that are " Memory leaks some examples and modify necessary " Some languages (e.g., Java, # Memory that is no longer them C#) use a garbage " Because of dependencies, used, but is not freed " There are automated tools collector to reclaim unused more than just the # Long running program ⇒ for building makefiles memory changed files can need to run out of memory be recompiled " Other languages (e.g., C, C++) require programmers " Of course, can always to manage their own ! There are tools to help recompile everything, but memory catch such bugs this can be too expensive " E.g., purify for C, C++ Garbage Collection Garbage Collector Schemes ! Want to keep any object ! Once “not-in-use” objects ! Mark and Sweep ! For either scheme that can be reached from are found " Mark every object as “not-in- " Can “stop the world” use” program’s variables " Can reclaim the memory " Can interleave (i.e., take turns) " Starting from the call stack, " Either directly or through for re-use " Can run concurrently visit every reachable object, other objects that can be " Can also compact memory marking it as “in-use” ! Java’s current garbage reached # I.e., move all the “in-use” " Everything still marked “not- " Program’s variables = objects to another in-use” can be reclaimed collector anything in the call stack memory block (without " A 2-tier scheme (old gaps between objects) generation; new generation) ! Reference Counting " A mark-and-sweep method " Every object keeps a count of " With compaction how many pointers reference it " When count is zero, memory ! Java’s garbage collection can be reclaimed scheme has changed as new " Problem: cycles! Java versions were released Use of Standard Data Structures Version Control ! Packages for widely-useful ! For example, Java provides ! Allows you to keep track of ! CVS (Concurrent Version data structures " Interfaces changes for a large project System) " Java Collections # List, Map, Set " Can back up to old version " Open source Framework " Classes if changes create problems " Widely used tool for " C++ STL (Standard # ArrayList, LinkedList, " Multiple contributors can version control Template Library) HashMap, TreeMap, work on the system " Maintains a history of all HashSet, TreeSet changes made " " Provide tools for Algorithms " Supports branching, # Arrays.sort, # Sorting & searching allowing several lines of Arrays.search,… # Iteration development # List " Provides mechanisms for # Set merging branches back # Map (or dictionary) together when desired # Stack ! SVN (Subversion) # Queue " An alternative to CVS # Priority Queue 2 Profiling More Advanced Profiling ! The goal is to make a program run faster ! Need additional profiling ! Example: " Rule of thumb: 80% of the time is spent in 20% of the code tools for applications that VTune Performance " No use improving the code that isn’t executed often " Are multithreaded Analyzer (from Intel) " How do you determine where your program is spending its time? " Use multiple cores " Can monitor ! People are notoriously bad at predicting the most computationally # Memory usage expensive parts of a program # Performance during file ! Part of the data produced by a profiler (Python) I/O 2649853 function calls (2319029 primitive calls) in 53.502 CPU seconds # Thread overhead and Ordered by: standard name synchronization ncalls tottime percall cumtime percall filename:lineno(function) # 2521 0.227 0.000 1.734 0.001 Drawing.py:102(update) Load balancing 7333 0.355 0.000 0.983 0.000 Drawing.py:244(transform) # Idle time 4347 0.324 0.000 4.176 0.001 Drawing.py:64(draw) # Communication 3649 0.212 0.000 1.570 0.000 Geometry.py:106(angles) bottlenecks 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) A List of Software Tools (from Wikipedia) ! No hammer? No screw or ! Revision control: Bazaar, Bitkeeper, ! Parser generators: Lex, Yacc, Parsec screwdriver? Bonsai, ClearCase, CVS, Git, GNU arch, ! Bug Databases: gnats, Bugzilla, Trac, Mercurial, Monotone, PVCS, RCS, SCM, Atlassian Jira, LibreSource ! Why the rifle and not the SCCS, SourceSafe, SVN, LibreSource ! Debuggers: gdb, GNU Binutils, valgrind Synchronizer cannon? Why the watch and ! Memory Leaks/Corruptions Detection: ! Interface generators: Swig dmalloc, Electric Fence, duma, Insure++ not the clock? ! Build Tools: Make, automake, Apache ! Memory use: Aard ! No electricity? Ant, SCons, Rake, Flowtracer ! Code coverage: GCT, CCover ! Compilation and linking tools: GNU ! toolchain, gcc, Microsoft Visual Studio, Source-Code Clones/Duplications CodeWarrior, Xcode, ICC Finding: CCFinderX ! ! Static code analysis: lint, Splint Refactoring Browser ! ! Search: grep, find Code Sharing Sites: Freshmeat, Krugle, Sourceforge, ByteMyCode, UCodit ! Text editors: emacs, vi ! Source code generation tools ! Scripting languages: Awk, Perl, Python, ! REXX, Ruby, Shell, Tcl Documentation generators: Doxygen, help2man, POD, Javadoc, Pydoc/Epydoc 3.