Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables Expressions and Operators Flow Control.

Similar presentations


Presentation on theme: "Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables Expressions and Operators Flow Control."— Presentation transcript:

1

2 Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables http://www.mari.odu.edu Expressions and Operators Flow Control Statements

3 Interpreter-based languages: are translated into machine code every time a script is executed (at run time). Compiler-based languages: are translated into machine code, then linked into an executable file. Can be executed afterwards (many times). Interpreter-based languages: - syntax check, check of logic at run time - translation into machine code at run time reduces speed Examples: - Linux/OS9 script (shell scripts) - PHP - Pearl - Javascript - Python Compiler-based languages: - syntax check by compiler; check of some logic by compiler - compilation only once - linking checks libraries and compatibility with operating system - executable much faster than scripting language Examples: - Fortran - C - C++ - Java Steps: - write code in an editor - compile -> object code (binary) - link -> executable (binary) - test/validate Steps: - write code in a shell/editor - execute (test/validate) See more examples at: http://en.wikipedia.org/wiki/Comparison_of_programming_languages See also: http://en.wikibooks.org/wiki/Computer_Programming/Hello_world

4 See more examples at: http://en.wikipedia.org/wiki/Comparison_of_programming_languages

5 Fortran (2000): originally based on ANSI Standards, now ISO standards: compilers are reliable very good for numerical processing also good for handling of text variables/strings clear program control structures subroutines and functions very good tools for testing, validation, error detection not good for interactions with the operating system or a GUI There is a lot of code available in Fortran; mainly Fortran77 but also increasingly Fortran90/95/2000

6 C/C++: based on ISO standards, latest is C++2014 very good for numerical processing not that good for handling of text variables/strings clear program control structures procedures reasonable tools for testing, validation, error detection good for interactions with the operating system, less for a GUI C++ very good for object-based programming

7 PHP: no standard, de fact standard set by the interpreter “hypertext preprocessor” very good for web applications, generation of html code can be used for stand-alone graphical applications using a command-line interpreter (CLI)

8 Python: no standard handles variable types dynamically no limit to range of numbers excellent file handling

9 How different is the syntax of languages? See: http://en.wikibooks.org/wiki/Computer_Programming/Hello_world

10 Data Types: Single-value: - Integer Numbers - Floating-point numbers - Logical/Booleans - Text/Strings Compound/collections: - Arrays - Objects Resources/Handles - links to external resources (e.g. files) NULL data type - has no value

11 Variables: depends on programming language Fortran: Variables need to be declared before being used; some implicit declarations integer, integer*2/*4/*8; same for complex real, real*4/*8/*16 logical, logical*1/*2/*4 character*n arrays: type name(n1:m1,..., nN,mN) Examples: integer nmax,nadd,nlines parameter (nmax=1000,nadd=100,nlines=10) real*8 y(0:nmax),x(0:nmax,5) complex*8 z(nmax) character addresses*80(0:nadd,nlines)

12 Variables: depends on programming language PHP: Variables are declared by usage (except for static variables) $a = 1; $b = “MARI”; $person[0] = “Jim”; $person[1] = “Smith”; $person[3] = “Norfolk”; $address[‘Name’] = “Jim Smith”; $address[‘City’] =”Norfolk”;

13 See more examples at: http://en.wikipedia.org/wiki/Comparison_of_programming_languages

14 Scope of Variables: depends on programming language Many languages have local and global variables, depending on the declaration Fortran has local variables and common blocks


Download ppt "Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables Expressions and Operators Flow Control."

Similar presentations


Ads by Google