Programming Languages and Software Engineering - PowerPoint PPT Presentation

About This Presentation
Title:

Programming Languages and Software Engineering

Description:

Programming Languages and Software Engineering Topics discuss some of the underlying commonalities and differences among programming languages explain what there is ... – PowerPoint PPT presentation

Number of Views:172
Avg rating:3.0/5.0
Slides: 17
Provided by: Thoma491
Category:

less

Transcript and Presenter's Notes

Title: Programming Languages and Software Engineering


1
Programming Languages and Software Engineering
2
Topics
  • discuss some of the underlying commonalities and
    differences among programming languages
  • explain what there is to learn about software
    engineering beyond programming

3
Learn Programming in Ten Years(Peter Norvig)
  • it takes time/practice/experience to learn to
    become a good programmer
  • you 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

4
  • 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.
  • Get involved in a language standardization
    effort.

5
  • 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?

6
  • Assembler
  • Fortran, Pascal, COBOL, Basic
  • Ada, Modula, PL/1, Simula, MatLAB
  • Haskell, LISP, Scheme
  • C, C, C, Objective-C
  • Smalltalk, Java, Javascript
  • PERL, PHP, TCL, Python, Ruby
  • csh, awk, sed
  • Prolog a logic-based language for making
    inferences from knowledge bases
  • Postscript a stack-based language for printers

7
source http//calvinx.com/tag/programming-languag
es/
8
Two Interesting Questions
  • Why are there such a bewildering array of
    languages?
  • historical artifact some languages evolved
    into, or inspired, other languages
  • some languages started out as experiments to test
    new ideas or features, like OO and
    message-passing in Smalltalk
  • some languages are more suited for certain
    applications, like Fortran for numerical
    computing, or PERL/Python for processing text
    files
  • there are special-purpose languages like
    Postscript (or MatLAB, Simula) that are
    custom-designed for certain tasks (printing,
    simulations...)

9
Two Interesting Questions
  • Isnt C overkill for writing low-level code
    like drivers/controllers/firmware? wouldnt C be
    much more efficient with less overhead?
  • this is a common misconception
  • by this reasoning, why not use assembler?
  • modern C compilers have many optimizations that
    make code fast/competitive
  • most 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
    microseconds
  • the original programmer might be long gone, and
    someone else has to find and fix a bug

10
Programming
  • The same algorithm can be implemented in many
    programming languages.

in C
in Python
in Java
import sys if __name____main__ a
int(sys.argv1) b int(sys.argv2) if
altb b,a a,b while bgt0 r ab
a,b b,r print GCD is,a
include ltstdio.hgt void main(int
argc,charargv) int a,b,temp
sscanf(argv1,d,a) sscanf(argv2,d,b)
if (altb) tempa ab btemp while
(bgt0) int rab ab br
printf(GCD is d\n,a)
public class GCD public static void
main(String args) int a,b,temp aInteger.pa
rseInt(args0) bInteger.parseInt(args1)
if (altb) tempa ab btemp while
(bgt0) int rab ab br
System.out.println( "GCD is "a)
  • Point 1 Once you understand the general
    principles (which you will learn in CSCE 314),
    you just have to learn the syntactic variations
    in each language
  • Point 2 There are some unique language
    differences/features including user-created
    types, polymorphism, list comprehension,
    exceptions, function objects...

11
  • In CSCE 314, you will learn the structure of
    languages and what unites them, so you can
    eventually learn to program in any of them
  • major classes of languages
  • imperative/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-programming
  • Prolog
  • (of course, some languages blur these
    distinctions)

12
  • I already showed examples of procedural
    programming
  • here is the functional version of factorial and
    GCD written in LISP
  • (this is an interactive command line I typed
    into)
  • gt(defun fact (n) (if (lt n 1) 1 ( n (fact (- n
    1)))))
  • FACT
  • gt(fact 10)
  • 3628800
  • gt(defun gcd (x y)
  • (if (lt x y) (gcd y x)
  • (if ( y 0) x (gcd y (mod x
    y)))))
  • GCD
  • gt(gcd 112 40) // running a program is done by
    evaluating an expression
  • 8

13
  • interpreted vs. compiled languages
  • interpreters read in lines and execute directly
  • compilers
  • convert source code to low-level language (.exe,
    assembly language, executable CPU instructions)
  • have to learn about regular expressions, parsing,
    syntax and semantics, optimization...
  • compare Python and C
  • block structure
  • think how the body of a for loop or if
    statement is marked in different languages (,
    endfor, change of indentation)
  • type systems
  • can users define new types and operations on
    them? like structs and classes, example Complex
    s
  • object-oriented languages
  • classes, inheritance, polymorphism...
  • extensions for concurrency, exception-handling,
    real-time applications...

14
  • Here is an example of an object-oriented
    definition of Rectangles in Java

public class Rectangle int height,width //
interval variables // initializer public
Rectangle(int a,int b) heighta widthb
int area() return heightwidth
static Rectangle BoundingBox( Rectangle
A,Rectangle B) int hmax(A.height,B.height)
int wmax(A.width,B.width) Rectangle Cnew
Rectangle(h,w) return C
public static void main(String args)
Rectangle Pnew Rectangle(3,2) Rectangle
Qnew Rectangle(1,4) Rectangle
RBoundingBox(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())
27 sungt java local/testRectangle p(3,2)
area6 q(1x4) area4 r(3x4) area12
P h3, w2
R h3, w4
Q h1, w4
15
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 principles
  • executables, flags, pipes, streams, sockets...
  • multitasking
  • many powerful tools for software development
  • editors like Emacs
  • compilers like g
  • make files (for multi-file projects)
  • debuggers like gdb
  • source-code control like CVS or SVN

16
Software Engineering (CSCE 431)
  • software engineering usually involves working in
    teams
  • requirements gathering/writing specifications
    (with customer)
  • UML (Unified Modeling Language)
  • diagram out how your modules work and interact
  • libraries reuse of code
  • e.g. APIs for image processing, network access,
    speech recog...
  • large projects have many dependencies
  • testing defining test cases as important as
    writing code
  • documentation
  • explain 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.12
  • critical so you can identify and undo mistakes
  • life-cycle models
  • waterfall, rapid prototyping, extreme programming
    (partners)...
  • metrics for tracking/estimating number of bugs
    over time
Write a Comment
User Comments (0)
About PowerShow.com