Programming Languages and Software Engineering

Download Programming Languages and Software Engineering

Post on 31-Dec-2015




4 download

Embed Size (px)


Programming Languages and Software Engineering. Topics. Discuss some of the underlying commonalities and differences among programming languages Explain what there is to learn about software engineering beyond programming. Learn Programming in Ten Years (Peter Norvig). - PowerPoint PPT Presentation


  • Programming Languages and Software Engineering

  • TopicsDiscuss some of the underlying commonalities and differences among programming languagesExplain what there is to learn about software engineering beyond programming

  • Learn Programming in Ten Years(Peter Norvig)It takes time/practice/experience to learn to become a good programmerYou can learn syntax in one semester (or from a book), but...Need to built up a repertoire of problems you have previously solved, so when you face a new problem, you can draw upon your prior experience, youve seen it before design patterns

  • Norvigs suggestions:Get interested in programming, and do some because it is fun..Program. The best kind of learning is learning by doing.Talk with other programmers; read other programs. Work on projects with other programmers. Work on projects after other programmers. Learn at least a half dozen programming languages. Remember that there is a "computer" in "computer science". Understand how it works.

  • In CSCE 121, we teach C++ because it is widely used for large industrial applications.Many additional computational concepts are introduced in this course, such as how compilers work, object-oriented design, etc.There are many other languages - do you need to learn them all?

  • AssemblerFortran, Pascal, COBOL, BasicAda, Modula, PL/1, Simula, MatLABHaskell, LISP, SchemeC, C++, C#, Objective-CSmalltalk, Java, JavascriptPERL, PHP, TCL, Python, Rubycsh, awk, sedProlog a logic-based language for making inferences from knowledge basesPostscript a stack-based language for printers

  • source:

  • Two Interesting QuestionsWhy are there such a bewildering array of languages? Historical artifact some languages evolved into, or inspired, other languagesSome languages started out as experiments to test new ideas or features, like OO and message-passing in SmalltalkSome languages are more suited for certain applications, like Fortran for numerical computing, or PERL/Python for processing text filesThere are special-purpose languages like Postscript (or MatLAB, Simula) that are custom-designed for certain tasks (printing, simulations...)

  • Two Interesting QuestionsIsnt C++ overkill for writing low-level code like drivers/controllers/firmware? wouldnt C be much more efficient with less overhead?This is a common misconceptionBy this reasoning, why not use assembler?Modern C++ compilers have many optimizations that make code fast/competitiveMost importantly, C++ allows code to be expressed in a more comprehensible (generic, factored) way that facilitates maintainability and long-term use of code over many years These issues often outweigh a few extra microsecondsThe original programmer might be long gone, and someone else has to find and fix a bug

  • import sysif __name__==__main__:

    a = int(sys.argv[1]) b = int(sys.argv[2])

    if a0:

    r = a%b a,b = b,r print GCD is,a

    #include void main(int argc,char*argv){ int a,b,temp; sscanf(argv[1],%d,&a); sscanf(argv[2],%d,&b);

    if (a0) { int r=a%b; a=b; b=r; } printf(GCD is %d\n,a);}public class GCD { public static void main(String[] args) { int a,b,temp;a=Integer.parseInt(args[0]);b=Integer.parseInt(args[1]);

    if (a0) { int r=a%b; a=b; b=r; } System.out.println( "GCD is "+a); } }ProgrammingThe same algorithm can be implemented in many programming languages.

    in Cin Pythonin JavaPoint #1: Once you understand the general principles (which you will learn in CSCE 314), you just have to learn the syntactic variations in each languagePoint #2: There are some unique language differences/features including: user-created types, polymorphism, list comprehension, exceptions, function objects...

  • In CSCE 314, you will learn the structure of languages and what unites them, so you can eventually learn to program in any of themMajor classes of languagesImperative/procedural languages (block-structured)Pascal, Fortran, C, Ada...Functional languages (expression evaluation)Scheme, LISP, Haskell...Object-oriented (encapsulation, message passing)Smalltalk, Java, Objective-C, C++Logic-programmingProlog(of course, some languages blur these distinctions)

  • I already showed examples of procedural programmingHere is the functional version of factorial and GCD written in LISP:(this is an interactive command line I typed into)

    >(defun fact (n) (if ((fact 10)3628800

    >(defun gcd (x y) (if (< x y) (gcd y x) (if (= y 0) x (gcd y (mod x y)))))GCD

    >(gcd 112 40) // running a program is done by evaluating an expression8

  • Interpreted vs. compiled languagesinterpreters read in lines and execute directlycompilersconvert source code to low-level language (.exe, assembly language, executable CPU instructions) have to learn about regular expressions, parsing, syntax and semantics, optimization...Block structurethink how the body of a for loop or if statement is marked in different languages (}, endfor, change of indentation)Type systemscan users define new types and operations on them? like structs and classes, example: Complex #sObject-oriented languagesclasses, inheritance, polymorphism...Extensions for: concurrency, exception-handling, real-time applications...

  • Here is an example of an object-oriented definition of Rectangles in Javapublic class Rectangle { int height,width; // interval variables

    // initializer public Rectangle(int a,int b) { height=a; width=b; }

    int area() { return height*width; }}

    static Rectangle BoundingBox( Rectangle A,Rectangle B){ int h=max(A.height,B.height); int w=max(A.width,B.width); Rectangle C=new Rectangle(h,w); return C;}public static void main(String[] args) { Rectangle P=new Rectangle(3,2); Rectangle Q=new Rectangle(1,4); Rectangle R=BoundingBox(p,q);

    System.out.println( P:(3,2) area="+P.area()); System.out.println( Q:(1x4) area="+Q.area()); System.out.println( R:(3x4) area="+R.area()); }> java local/testRectangleP:(3,2) area=6Q:(1x4) area=4R:(3x4) area=12

  • Learning Unix (part of CSCE 312/Systems)Why learn this? Is it necessary?Many command-line development tools(compared to IDEs like MS Visual Studio)Unix has well-defined concepts and principlesExecutables, flags, pipes, streams, sockets... MultitaskingMany powerful tools for software development:Editors like EmacsCompilers like g++make files (for multi-file projects)Debuggers like gdbSource-code control like CVS or SVN

  • Software Engineering (CSCE 431)Software engineering usually involves working in teamsRequirements gathering/writing specifications (with customer)UML (Unified Modeling Language)Diagram out how your modules work and interactLibraries reuse of codee.g. APIs for image processing, network access, speech recog...Large projects have many dependenciesTesting defining test cases as important as writing codeDocumentationExplain how things work, why it was designed that way, ASSUMPTIONS, alternatives, limitations...Version control Issue new number with each change to file, e.g. v3.0.12Critical so you can identify and undo mistakesLife-cycle modelsWaterfall, rapid prototyping, extreme programming (partners)...Metrics for tracking/estimating number of bugs over time


View more >