Programming 01 PDF
Document Details
Tags
Summary
This document provides an overview of programming, focusing on the different types of programming languages and their applications. It covers the fundamental principles, stages in developing computer programming, and various programming paradigms.
Full Transcript
Programming 01 PRELIMINARIES GENERATIONS OF PROGRAMMING LANGUAGE 1ST GENERATION “MACHINE LANGUAGE”...
Programming 01 PRELIMINARIES GENERATIONS OF PROGRAMMING LANGUAGE 1ST GENERATION “MACHINE LANGUAGE” 6 STAGES OF IN DEVELOPING - uses binary codes that consist of string of COMPUTER PROGRAMMING only zeroes and ones Defining the problem - these are languages that a computer can Designing a solution to the program understand and execute directly Writing the program - machine dependent Compiling, debugging, and testing the - low-level language program 2ND GENERATION “ASSEMBLY LANGUAGE” Documenting the research program - uses mnemonics or very short words for Maintaining the program commands WHY DO WE PROGRAM? - program written in assembly language must To make life easier be converted by an ASSEMBLER Let’s take election for example. Back in - low-level language the day, it takes days to determine a victor in - TASM, MASM government elections. So, they posed a solution 3RD GENERATION “HIGH-LEVEL LANGUAGE” in which they would automate the elections for a - more or less independent of a particular type hassle free process. Now, it approximately takes of computer only one day to determine newly elected officials. - closer to human languages and they are TYPES OF PROGRAMMING ERRORS easier to read, write, and maintain - uses a COMPILER to translate the source SYNTAX ERRORS code into machine readable code errors due to the fact that the syntax of the - FORTRAN, BASIC, COBOL, PASCAL, C, C++, language is not respected ALGOL, ADA, JAVA SEMANTIC ERROR 4TH GENERATION “OBJECT-ORIENTED errors due to the improper use of program PROGRAMMING LANGUAGE” statements - organize coding around objects LOGICAL ERROR - event-driven event triggers the the outcome errors that occur when the specification is not of the program respected - JAVA, C+, C#, Visual Basic, VB.NET COMPILE TIME ERRORS 5TH GENERATION “LOGIC PROGRAMMING” errors that occur during the compilation phase - artificial language before the program is run; typically caused by - operates on concept of solving problems incorrect syntax or type-related errors based on constraints or rules that have been RUNTIME ERRORS declared in the program errors occur during the execution of the - the focus is on making the computer program, often due to unexpected conditions program solve the problem for you like dividing by zero or accessing invalid - uses knowledge bases and expert system memory - PROLOG, MERCURY, LISP WHAT IS PROGRAMMING well LANGUAGE? E -04 Artificial language used to communicate IT ew - 11 instructions to a machine (computer) Used to create programs that control the i Rev behavior of a machine and/or express algorithms precisely Software used to create another software PROGRAMMING PARADIGMS TYPES OF PROGRAMMING IMPERATIVE/PROCEDURAL PROGRAMMING LANGUAGES - expressing an essential order or MACHINE LANGUAGE command/procedural - binary language (proposed by Gottfried - describes computation in terms of a program Wilhelm Leibniz which was developed in 1689 state and actions that change the state and published in 1703 but the concept of - program consists of explicit commander using it for computer calculations was instructions to be executed, performing pioneered by Dr John Von Neumann ) operations on data and modifying values of - only language that computer understands program variables and the external - very fast in terms of program execution (not environment easy to write) FUNCTIONAL PROGRAMMING - instructions are directly executed by the CPU - computations are specified through - widely used in 1940s up to early 1950s mathematical functions that evaluate input expressions convert them into output values Central Processing - “what”-oriented Unit (CPU) Unique machine language - declarative programming paradigm where programs are created by applying sequential LOW-LEVEL OR ASSEMBLY LANGUAGE functions rather than statements - specific to a given microprocessor or CPU of LOGIC PROGRAMMING the computer - written in logical statements that describe - deals with a computer’s hardware the properties that solutions must have components and constraints - based on the concept of logical deduction in - way higher level language then machine symbolic logic, or the manipulation of symbols language so its faster, however, it is still hard to [e.g. && (and), || (or), > (greater than), = write and read (equal)] HIGH-LEVEL PROGRAMMING LANGUAGE OBJECT-ORIENTED PROGRAMMING - more or less independent of a particular type - data structures are seen as objects; of computer programmers create relationships between - closer to human language “objects” - easier to understand, modify, and debug - CLASS is a group of objects that have same - allow programmers to focus on solving the properties and behaviors problem CURRENT AND DISTRIBUTED PROGRAMMING COMPILER VS INTERPRETER - allows for execution of 2 or more operations translates a program written a program that directly at the same time in high-level language executes the instructions in a (source code) and translates high-level language, without - is concurrent (occurring at the same time), into machine language converting it into machine processes run in tandem using shared (object code) code The first compiler was Lisp interpreter was written resources written by Grace Hopper in in 1958 by John McCarthy's the early 1950s. She also student Steve Russell - parallel suggests that the processes run coined the term “compiler”. side-by-side yet operate independently; TWO TYPES OF PROGRAMMING parallel processing is a sub-set of concurrent PARADIGM processing STRUCTURED PROGRAMMING an do it! - enhance lucidity, caliber, and creation c efficiency of a computer program by leveraging a plethora of subroutines, block You structures, and looping constructs like for and while - procedural programming that uses Top Design Principle - Dr. Edsger W. Dijkstara is a Dutch computer scientist who developed the paradigm of structured programming for writing computer programs. CONTROL SEQUENCE SEQUENCE SELECTION/CONDITIONAL LOGIC INTERATION/ LOOPING MECHANISM OBJECT-ORIENTED PROGRAMMING - revolves around objects - the idea was first introduced by computer scientists Alan Kay and Adele Goldberg in the late 1960s - the first OOP language is called SIMULA which was created by Ole-Johan Dahl and Kristen Nygaard at the Norwegian Computing Center in Oslo, Norway in the 1960s MAJOR COMPONENTS OF OBJECT-ORIENTED PROGRAMMING OBJECT CLASS INHERITANCE POLYMORPHISM ABSTRACTION ENCAPSULATION On November 13, 2006, Sun Microsystems released most of its Java virtual machine (JVM) as free and open-source software under the terms of the GNU General Public License BRIEF HISTORY OF JAVA (GPL) One of the most popular and widely used On May 8, 2007, Sun Microsystems made all of programming languages its JVM’s core code available under free written and developed by Dr. James Gosling software/open-source distribution terms. and his colleagues in the 1990s at Sun Rich Green, executive vice president of Microsystems software at Sun Microsystems envisioned Sun it was released in 1995 as part of Sun Microsystems as a Java “evangelist” Microsystems’ Java platform Oracle acquired Sun Microsystems in 2009- based in terms of syntax and structure in C and 2010 and positioned itself as the “Steward of C++ Java Technology” open source freely available over the internet to James Gosling resigned from Oracle on April 2, download and use 2010 uses classes, methods, and object to create TYPES OF JAVA APPLICATIONS apps 1. JAVA APPLET - refer to Java programs apps written in Java can run on many different downloaded from the internet and executed operating systems with little or no modification inside your web browser by a JVM that is of the code HISTORY OF JAVA typically part of the browser spearheaded by James Gosling, Mike Sheridan, 2. APPLICATION - used to describe Java and Patrick Naughton; they initiated the Java programs running locally, standalone on a language project in June 1991 computer, much like programs on Windows purposed for interactive television (notepad for example) initially called OAK because of the oak tree 3. JAVA ARCHIVE (JAR) - a package file format visible from Gosling’s office window used to aggregate many Java class files and also called GREEN before JAVA (inspired by a associated metadata and resources into one coffee from Indonesia) file for distribution Gosling envisioned the language to resonate 4. SERVLET - run on a server and handle requests with both system and application programmers, and responses in web applications; key which is why he infused it with a syntax style component of Java web development that is familiar with C and C++ 5. SWING APPLICATION - Desktop applications In 1995, Sun Microsystems debuted the first that use the Swing toolkit for building graphical public version of Java 1.0 embracing a “Write user interfaces (GUIs) Once, Run Anywhere” (WORA) philosophy 6. ENTERPRISE JAVA BEANS (EJB) - A server- In 1998, Java evolved into Java , first known as side component that encapsulates business J2SE 1.2., it offered several configurations for logic of an application; used in large-scale different platforms enterprise applications to handle transactions, Java 2 Enterprise Edition (JEE) incorporated security, and scalability technologies and APIs tailored for server-side CHARACTERISTICS OF JAVA apps, while JAVA 2 Micro Edition (J2ME) was 1. Simple optimized for mobile apps 2. Object-oriented In 1997, Sun Microsystems sought 3. Distributed standardization of Java from the ISO/IEC JTC 1 4. Interpreted and Ecma International but eventually pulled 5. Robust back. Despite this, Java has remained a de 6. Secure facto standard, controlled through the Java 7. Architecture-neutral Community Process. 8. Portable 9. High Performance 10. Multithreaded 11. Dynamic BENEFITS OF JAVA 1. Serves as an introductory programming language for students; widely employed by seasoned professionals in the industry. 2. In Java, variables must be initialized before they are used, which is a key difference from C. This requirement helps prevent errors that can arise from using uninitialized variables. 3. In Java, every method that is not declared as void (methods that do not return value) must return a value of the specified type. This ensures that the method’s behavior is predictable and consistent. 4. One of Java’s primary assets is its comprehensive API (Application Programming Interface), providing an extensive selection of pre-built classes and methods. 5. Always maintain the same size in terms of bit count. 6. Java was considered slower than C due to its reliance on the Java Virtual Machine (JVM) for execution, which introduces some overhead compared to C’s direct compilation to machine code. However, this performance difference has become less significant over time. 7. Java handles error conditions, including input/output (I/O) errors, using a mechanism called exceptions. When an error occurs, Java throws an exception, which can be caught and handled to prevent the program from crashing. 8. Java’s “Write Once, Run Anywhere” (WORA) approach is its standout feature. This concept means that Java code can be written once and then run on any platform without needing modifications.