Which Language is Better?

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Introducing Programming a general discussion. What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 11/05/07CS150 Introduction to Computer Science 1 Functions Chapter 6, page 303.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
CS150 Introduction to Computer Science 1
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Computer Science 1620 Programming & Problem Solving.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
6 Steps of the Programming Process
CH Programming An introduction to programming concepts.
FALL 2001ICOM Lecture 21 ICOM 4015 Advanced Programming Lecture 2 Procedural Abstraction Reading: LNN Chapter 4, 14 Prof. Bienvenido Velez.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
This set of notes is adapted from that provided by “Computer Science – A Structured Programming Approach Using C++”, B.A. Forouzan & R.F. Gilberg, Thomson.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
CPS120: Introduction to Computer Science Functions.
First steps Jordi Cortadella Department of Computer Science.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CPS120: Introduction to Computer Science Lecture 14 Functions.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
Sridhar Narayan Department of Computer Science
CHAPTER 10 ARRAYS AND FUNCTIONS Prepared by: Lec. Ghader Kurdi.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
Function Overloading Two different functions may have the same name as long as they differ in the number or types of arguments: int max(int x, int y) and.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
LOW vs. HIGH Level Languages
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Compilers and Interpreters
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Software Engineering Algorithms, Compilers, & Lifecycle.
CMSC 104, Version 8/061L16IncrementalProg.ppt Incremental Programming Topics Review of Incremental Programming Example of Incremental Programming Reading.
Basic concepts of C++ Presented by Prof. Satyajit De
Introduction to Computers and C++ Programming
Topic: Programming Languages and their Evolution + Intro to Scratch
Jie(Jay) Wang Week1 Sept. 30
Introduction to programming
Objectives Identify the built-in data types in C++
Chapter 1. Introduction to Computers and Programming
Teaching Computing to GCSE
Assembler, Compiler, Interpreter
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
Accomplishing Executables
CS150 Introduction to Computer Science 1
Assembler, Compiler, Interpreter
CS150 Introduction to Computer Science 1
Let’s all Repeat Together
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
Repetition Statements (Loops) - 2
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Compiler Structures 1. Overview Objective
CS150 Introduction to Computer Science 1
Dasar-Dasar Pemrograman 2: Java Basics
Presentation transcript:

Which Language is Better? A compiled language, C++, compared to an interpreted language, Matlab.

Interpreted vs. Compiled In computer science, interpret means to execute, while compile means to translate into the language of the computer (also known as, the “machine”). C++ is a compiled language. Matlab is an interpreted language (so is Java).

Compiled vs. Interpreted program compiler running on computer machine code Computer interprets output input Matlab program translator running on computer pcode Interpreter, which runs on computer, interprets output input

Declared Variables vs. Undeclared Variables C++ requires that every variable be “declared” before it is used (like Java). Declaration gives its name and “type”. Use before assignment gives random result. Matlab does not require declaration. Variable’s type is determined by its use. Use before assignment causes error.

Two example programs that do the same thing One program is written in C++. One is written in Matlab.

// C++ program to calculate // weighted average void main(void) { int N, i; float weights[3], sum_weights; float grades[3], sum, average; N = 3; cout << "Please input 3 grades: "; for (i = 0; i<N; i++){ cin >> grades[i]; } cout << "Please input 3 weights: "; cin >> weights[i]; sum = 0; sum_weights = 0; for (i = 0; i <N; i++){ sum += grades[i]*weights[i]; sum_weights += weights[i]; average = sum/sum_weights; cout << "Weighted average = " << average << endl; % Matlab program to calculate % weighted average grades = input('Please input 3 grades: '); weights = input('Please input 3 weights: '); average = sum(grades.*weights)/sum(weights); fprintf('Weighted average = %f\n', average);

Reasons for both approaches Compiling emphasizes program speed Declaring variables gives the compiler more information for optimization. The source code is translated into “native” machine code (i.e., language of the computer). Interpreting emphasizes programming speed Freedom from variable declaration simplifies programming. The interpreter can give detailed debugging information.

Reasons for both approaches SUMMARY: Compiled programs run faster. Interpreted programs are written faster. Another advantage to C++: For big programs (>10,000 lines), C++ makes it easier to employ disciplined programming techniques that reduce programming errors.

Which language is better? For large programs that will be run by people who do not understand programming—C++ is best. For small engineering programs that will be run by people who do understand programming—Matlab is best.

Which language is better? CONCLUSIONS: The language that best fits the task is the best language for that task. Until the task is specified, no language is better than any other.