Fundamental Principles of Programming - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Fundamental Principles of Programming

Description:

Example/Demo 2: Python. Background: Introduction. Programming Languages Share Common Principles ... All Programming Languages use variables to access data and ... – PowerPoint PPT presentation

Number of Views:286
Avg rating:3.0/5.0
Slides: 21
Provided by: Ped126
Category:

less

Transcript and Presenter's Notes

Title: Fundamental Principles of Programming


1
Fundamental Principles of Programming
  • Pedro Davalos
  • SEI Training
  • Mar 22, 2006

2
Outline
  • Background
  • Introduction to Programming, GL, Options
  • Basics
  • Scripts, Variables, Functions, Operators, Flow
  • Getting Started
  • Example/Demo 1 C
  • Example/Demo 2 Python

3
Background Introduction
  • Programming Languages Share Common Principles
  • Principles Include Structure, Flow, I/O
  • Programmers write Software
  • Software is everywhere!
  • data gather/storage, data process, analyze
    data/visualize, Robotics/AI, Controls, GUIs,
    Communication,

4
Background Programming Language Generations
New
  • 5th GL AI, neural net, Logic
  • Lisp, Prolog
  • 4th GL GUI, Databases
  • Matlab, Python, SQL
  • 3rd GL Human Readable
  • C, C, Java, Fortran, Cobol, Basic, Pascal
  • 2nd GL Low-Level, Assembly Language
  • 1st GL Low-Level, Machine Language

Old
5
Background Programming Language Generations
  • Newer GLs
  • PROS
  • More logic-oriented
  • More structure is built into the language built
    in functions
  • Easier implementation (Less typing, Quicker
    learning)
  • More graphical
  • CONS
  • Less control over bit manipulation
  • More limited you are by the built in functions
    Inefficient Algorithms
  • Not optimized for performance (timing and
    resources)

6
Programming Language Comparison Study
Source Lutz Prechelt ( http//page.mi.fu-berlin.d
e/prechelt )
7
Background Programming Options
  • Option to choose Environment and Language
  • Select based on requirements
  • Memory, performance, speed, size, libraries,
    hardware, power, resources, users/GUIs,
    development time, cost, maintenance, life, etc.

8
Basics Scripts
  • Source Code is always a clear ASCII text file,
    usually with file extensions that represent
    language
  • .m .c .cpp .py etc
  • Source Code needs to be compiled to be
    executable
  • 4GL Compilers seem
  • invisible
  • Matlab, python, etc

9
Basics C Compiler Flow
  • http//www.tenouk.com/ModuleW.html

10
Basics Variables (1)
  • All Programming Languages use variables to access
    data and handle parameters (after 2GL).
  • 4GL
  • Variable declarations or var. dimension not
    required in Matlab
  • Matlab Built-in Variables are overwriteable!
  • 3GL
  • C has 29 reserved keywords that can not be
    redefined
  • Variables must be declared at start of block
    before use in C

C Reserved keywords
11
Basics Variables (2)
  • Memory
  • float f
  • f3.14

12
Basics Variables (3)
  • Memory
  • int i, s4, t4, u0

13
Basics User Functions
  • Functions accept input arguments and return
    output arguments.
  • Sometimes referred to as procedures.
  • Most local variables are created when the
    function is called, and are destroyed on return
    from that function.
  • In other words Functions operate on variables
    within their own workspace.

Applies to most Languages!
14
Basics Operators
  • Arithmetic , -, , /, \, , , (),
  • Logical lt, gt, , , , ,

Syntax differences
Applies to most Languages!
15
Basics Flow Control
  • Loop constructs
  • if, else, and elseif
  • switch and case
  • for
  • while
  • Control Constructs
  • continue (next iteration in for and while)
  • break (exit for or while)
  • try catch (debug)
  • return (exit function)

Applies to most Languages!
16
Getting Started (for free!)
  • C Compiler 1 TAMU
  • oldschool.tamu.edu ? cisrequest.tamu.edu
  • Putty terminal to access unix account via SSH
  • Use unix gcc filename.c
  • C Compiler 2 Cygwin
  • Linux-like environment for Windows
  • C Compiler 3 DJGPP
  • GNU C compiler utilities for DOS
  • Python Compiler
  • python.ORG

17
Example Problem
  • Description
  • Write Program to log GPS data
  • GPS has serial interface (DB-9 connector, RS-232)

18
Example Approach
  • Open/configure Socket
  • While Running
  • Read Line from GPS
  • Write Line to file
  • Close Socket

19
Any Questions???
20
References
  • http//www.tenouk.com/ModuleW.html
  • http//www.its.strath.ac.uk/courses/c/
  • http//www.gnu.org/
  • http//computer.howstuffworks.com/c.htm
  • http//www.garmin.com/oem
  • http//java.sun.com/
  • http//cisrequest.tamu.edu
  • http//python.org
  • http//winscp.net
  • http//www.pololu.com/projects/prj0003/
  • Lutz Prechelt, An empirical comparison of C,
    C, Java, Perl, Python, Rexx, and Tcl,
    (http//page.mi.fu-berlin.de/prechelt)
  • http//www.cygwin.com/
Write a Comment
User Comments (0)
About PowerShow.com